// JavaScript Document
<!-- Begin
//<![CDATA[
    var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
        geocoder = new GClientGeocoder();
      }
	  showAddress(document.getElementById("address").value);
    }

	function showAddress(address) {
	  geocoder.getLatLng(
		address,
		function(point) {
		  if (!point) {
			alert(address + " address not found with google map.");
		  } else {
			map.setCenter(point, 15);
			var marker = new GMarker(point);
			map.addOverlay(marker);
			marker.openInfoWindowHtml(address);
		  }
		}
	  );
	}
    //>
	
	function PrintThisPage(id)
	{
	  var disp_setting="toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=no,";
	  disp_setting+="scrollbars=yes,width=900, height=600, left=100, top=25";
	  
	  window.open("WEB-INF/modules/site/print.php?id="+id,"ArlingtonEstates",disp_setting);
	}
	
function detailsCheckrequired(form) {
	if(document.getElementById("first").value == ""){
		alert("Please fill the first name field.");
		document.getElementById("first").focus();
		return false;
	}else if(document.getElementById("last").value == ""){
		alert("Please fill the last name field.");
		document.getElementById("last").focus();
		return false;
	}else if(document.getElementById("phone").value == ""){
		alert("Please fill the phone field.");
		document.getElementById("phone").focus();
		return false;
	}else if(document.getElementById("email").value == ""){
		alert("Please fill the email field.");
		document.getElementById("email").focus();
		return false;
	}else if ( (form.interest[0].checked == false ) && ( form.interest[1].checked == false ) ) {
		alert("Please select either sales or lettings radio button.");
		return false;
	}else if(document.getElementById("from").value == ""){
		alert("Please fill the 'Price from' field.");
		document.getElementById("from").focus();
		return false;
	}else if(document.getElementById("to").value == ""){
		alert("Please fill the 'Price to' field.");
		document.getElementById("to").focus();
		return false;
	}
	
	//check if valid email
	return checkbae(form);
}

function propertiesCheckrequired(form) {
	if(document.getElementById("address").value == ""){
		alert("Please fill the address field.");
		document.getElementById("address").focus();
		return false;
	}else if(document.getElementById("postcode").value == ""){
		alert("Please fill the postcode field.");
		document.getElementById("postcode").focus();
		return false;
	}else if(document.getElementById("firstname").value == ""){
		alert("Please fill the firstname  field.");
		document.getElementById("firstname").focus();
		return false;
	}else if(document.getElementById("surname").value == ""){
		alert("Please fill the Surname field.");
		document.getElementById("surname").focus();
		return false;
	}else if(document.getElementById("email").value == ""){
		alert("Please fill the email field.");
		document.getElementById("email").focus();
		return false;
	}
	
	//check if valid email
	return checkbae(form);
}

function mailfriendCheckrequired(form) {
	if(document.getElementById("yourname").value == ""){
		alert("Please fill your name field.");
		document.getElementById("yourname").focus();
		return false;
	}else if(document.getElementById("youremail").value == ""){
		alert("Please fill your email field.");
		document.getElementById("youremail").focus();
		return false;
	}else if(document.getElementById("friendsname").value == ""){
		alert("Please fill friends name field.");
		document.getElementById("friendsname").focus();
		return false;
	}else if(document.getElementById("friendsemail").value == ""){
		alert("Please fill friends email field.");
		document.getElementById("friendsemail").focus();
		return false;
	}
	
	//check if valid email
	return friendscheckemail(form);
}

function friendscheckemail(form){
	var testresults;
	var str=document.getElementById("youremail").value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		testresults=true;
	else{
		alert("Please input a valid email address!");
		document.getElementById("youremail").focus();
		testresults=false;
		return testresults;
	}
	
	str=document.getElementById("friendsemail").value;
	if (filter.test(str))
		testresults=true;
	else{
		alert("Please input a valid email address!");
		document.getElementById("friendsemail").focus();
		testresults=false;
	}
	return testresults;
}

function checkbae(form){
		if (document.layers||document.getElementById||document.all)
			return checkemail(form);
		else
			return true;
}

function checkemail(form){
	var testresults;
	var str=document.getElementById("email").value;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
		testresults=true;
	else{
		alert("Please input a valid email address!");
		document.getElementById("email").focus();
		testresults=false;
	}
	return testresults;
}
//  End -->
