
function addToFavourites(NotSupported,LinkText,SiteName) {if (document.all) {window.external.AddFavorite(LinkText,SiteName)} else {alertNotSupported()}}

function showPanel(PanelID) {
	if (document.getElementById) {
		if (document.getElementById("jmap")) {document.getElementById("jmap").style.display=(PanelID=="jmap" ? "" : "none")}
		if (document.getElementById("jvid")) {document.getElementById("jvid").style.display=(PanelID=="jvid" ? "" : "none")}
		if (document.getElementById("JPla")) {document.getElementById("JPla").style.display=(PanelID=="JPla" ? "" : "none")}
		if (document.getElementById("jloc")) {document.getElementById("jloc").style.display=(PanelID=="jloc" ? "" : "none")}
		if (document.getElementById("JAvail")) {document.getElementById("JAvail").style.display=(PanelID=="JAvail" ? "" : "none")}
		if (document.getElementById("TabJMap")) {document.getElementById('TabJMap').className=(PanelID=="JMap" ? "Active" : "")}
		if (document.getElementById("TabJVid")) {document.getElementById('TabJVid').className=(PanelID=="JVid" ? "Active" : "")}
		if (document.getElementById("TabJPla")) {document.getElementById('TabJPla').className=(PanelID=="JPla" ? "Active" : "")}
		if (document.getElementById("TabJLoc")) {document.getElementById('TabJLoc').className=(PanelID=="JLoc" ? "Active" : "")}
		if (document.getElementById("TabJAvail")) {document.getElementById('TabJAvail').className=(PanelID=="JAvail" ? "Active" : "")}
		}
	}

function addToPortfolio(PID,Message,SiteRoot) {
	var strPIDlist=FSfncReadCookie("Portfolio");
	var dtExpires= new Date();
	dtExpires.setFullYear(dtExpires.getFullYear() + 1)
	if (("," + strPIDlist).indexOf("," + PID + ",")==-1) {FSfncSetCookie("Portfolio",strPIDlist + PID + ",",dtExpires,SiteRoot)}
	document.getElementById("PortfolioButton").disabled=true;
	alert(Message);
	}

function removeFromPortfolio(PID,Message,SiteRoot) {
	var strPIDlist=FSfncReadCookie("Portfolio");
	var dtExpires= new Date();
	dtExpires.setFullYear(dtExpires.getFullYear() + 1)
	if (("," + strPIDlist).indexOf("," + PID + ",")>-1) {
		strPIDlist=("," + strPIDlist).replace("," + PID + ",",",");
		if (strPIDlist.substring(0,1)==",") {strPIDlist=strPIDlist.substring(1,strPIDlist.length)}
		FSfncSetCookie("Portfolio",strPIDlist,dtExpires,SiteRoot);
		}
	document.getElementById("PortfolioButton").disabled=true;
	alert(Message);
	}

function FSfncReadCookie(key) {
	var cookie_string='' + document.cookie;
	var cookie_array=cookie_string.split('; ');
	for (var i=0; i<cookie_array.length; i++) {
		var single_cookie=cookie_array[i].split('=');
		if (single_cookie.length!=2) {continue}
		if (key==unescape(single_cookie[0])) {return unescape(single_cookie[1])}
		}
	return "";
	}

function FSfncSetCookie(name,value,expires,path,domain,secure) {
	document.cookie=name + '=' + escape(value) + ((expires == null) ? '' : ('; expires=' + expires.toGMTString())) + ((path == null) ? '' : ('; path=' + path)) + ((domain == null) ? '' : ('; domain=' + domain)) + ((secure == true) ? '; secure' : '');
	}

function removeOptions(SelectRef,Length) {SelectRef.options.length=Length}

function addOption(SelectRef,TheText,TheValue) {SelectRef.options[SelectRef.options.length] = new Option(TheText,TheValue)}

function getXmlNodes(objXML,NodeName) {if (window.ActiveXObject) {return objXML.selectNodes("//" + NodeName)} else {return objXML.getElementsByTagName(NodeName)}}

function setMinPrice(fieldRef) {
	switch (fieldRef[fieldRef.selectedIndex].value) {
		case "1" : // Rentals
			var minArray = new Array(200,300,400,500,750,1000,1500,2000);
			var maxArray = new Array(300,400,500,750,1000,1500,2000);
			break;
		case "2" : // Holidays
			var minArray = new Array(100,150,200,250,500,750,1000,1500,2000);
			var maxArray = new Array(150,200,250,500,750,1000,1500,2000);
			break;
		default : // Sales
			var minArray = new Array(30000,50000,100000,150000,200000,250000,300000,350000,400000,450000,500000,1000000,2000000,3000000,4000000,5000000);
			var maxArray = new Array(50000,100000,150000,200000,250000,300000,350000,400000,450000,500000,1000000,2000000,3000000,4000000,5000000,10000000);
			break;
		}
	removeOptions(fieldRef.form.PriceMin,1);
	for (var i=0; i<minArray.length; i++) {addOption(fieldRef.form.PriceMin,'â‚¬' + minArray[i],minArray[i]);}
	removeOptions(fieldRef.form.PriceMax,1);
	for (var i=0; i<maxArray.length; i++) {addOption(fieldRef.form.PriceMax,'â‚¬' + maxArray[i],maxArray[i])}
	}

function checkContactForm(FormRef,Message,Message2) {
	if (FSfncCheckString(FormRef.FullName,Message + FormRef.FullName.title,false)==false) {return false}
	if (FSfncCheckString(FormRef.Country,Message + FormRef.Country.title,false)==false) {return false}
	if (FSfncCheckString(FormRef.Message,Message + FormRef.Message.title,false)==false) {return false}
	if (FormRef.Email.value!="") {return FSfncValidateEmailAddress(FormRef.Email,Message + FormRef.Email.title,false)}
	else if (FormRef.Telephone.value!="") {return true}
	else {alert(Message2); return false}
	}

function FSfncCheckString(FormField,TheMessage,AllowBlank,MaxLength) {
	// MaxLength is optional, when not provided the string is only checked for being blank.
	if ((AllowBlank==false) && (FormField.value=="")) {alert(TheMessage); FormField.focus(); return false}
	if ((MaxLength!="") && (FormField.value.length>MaxLength)) {alert(TheMessage); FormField.focus(); return false}
	return true;
	}

function checkSearchForMeForm(FormRef,Message,Message2) {
	if (FSfncCheckString(FormRef.FirstName,Message + FormRef.FirstName.title,false)==false) {return false}
	if (FSfncCheckString(FormRef.Surname,Message + FormRef.Surname.title,false)==false) {return false}
	if (FSfncCheckString(FormRef.Telephone,Message + FormRef.Telephone.title,false)==false) {return false}
	if (FSfncValidateEmailAddress(FormRef.Email,Message + FormRef.Email.title,false)==false) {return false}
	if (FSfncCheckString(FormRef.Postcode,Message + FormRef.Postcode.title,false)==false) {return false}
	if (FormRef.Terms.checked==false) {alert(Message2); return false}
	else {return true}
	}

function MapInitialize() {
    if (document.getElementById(GoogleMap) && GBrowserIsCompatible()) {
        // Define map
        map = new GMap2(document.getElementById(GoogleMap));
		map.addControl(new GSmallZoomControl3D()); //GLargeMapControl3D
        map.addControl(new GScaleControl());
		//map.enableContinuousZoom();
		//map.disableDragging();
        //map.enableScrollWheelZoom();
        // Set location from geocoder and set center
        var geocoder = new GClientGeocoder();
        geocoder.setBaseCountryCode("es");
        geocoder.getLatLng(GooglePostcode + ", SPAIN", setLocationCenter);
        }
    }

function setLocationCenter(point) {
    if (point) {map.setCenter(point, parseInt(GoogleZoom)) }
    else { document.getElementById(GoogleMap).style.display='none'}
    }

function MapInitialize3() {
	// GeoLookup property (hide map if no match)
	var geocoder = new google.maps.Geocoder();
	geocoder.geocode(
		{address: GooglePostcode + ', SPAIN', region:'es'},
		function(results,status) {
			if (status==google.maps.GeocoderStatus.OK) {setupMap(results[0].geometry.location,GoogleZoom)}
			else {
				// alert('Google Map not found');
				document.getElementById(GoogleMap).style.display='none'}
			}
		);
    }

function setupMap(centerPoint,zoomLevel) {
	 // ROADMAP, SATELLITE, HYBRID, TERRAIN
	var myOptions = {zoom:zoomLevel, center:centerPoint, mapTypeControl:false, scaleControl:true, mapTypeId:google.maps.MapTypeId.HYBRID}
	var map = new google.maps.Map(document.getElementById(GoogleMap), myOptions);
	var marker=new google.maps.Marker({map:map, position:centerPoint})
	}

function setTown(fieldRef,townArray) {
	var objTown=fieldRef.form.Town;
	removeOptions(objTown,1)
	if (fieldRef[fieldRef.selectedIndex].text.substring(0,2)=="- ") {
		objTown.disabled=false
		for (var i=0; i<townArray.length; i++) {
			//alert(townArray[i][0] + "==" + fieldRef[fieldRef.selectedIndex].value);
			if ("RegionID=" + townArray[i][0]==fieldRef[fieldRef.selectedIndex].value) {
				for (var j=0; j<townArray[i][1].length; j++) {addOption(objTown,townArray[i][1][j][1],townArray[i][1][j][0])}
				break;
				}
			}
		}
	else {objTown.disabled=true}
	}

function removeOptions(SelectRef,NewSize) {SelectRef.options.length=(NewSize ? NewSize : 0)}

function addOption(SelectRef,TheText,TheValue) {
	SelectRef.options[SelectRef.options.length] = new Option(TheText,TheValue);
	SelectRef.options[SelectRef.options.length - 1].title=TheText;
}





