function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
startList = function() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("menu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];			
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function isValidEmail(str)
{   
	var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/;
    if (!str.match(re)) {
        return false;
    } else {
        return true;
    }

}
function alphanumeric(thestring) {
	for(var j=0; j<thestring.length; j++) {
		var string = thestring.charAt(j);
		var hh = string.charCodeAt(0);
		if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123)) {
		} else {
			return false;
		}
	}
	return true;
}
checkForm = function(theForm) {
	var strMsg = "You have not filled in all the required fields:\n";
	fOK = true;
	if (theForm.fullname.value.length == 0) {
		strMsg += "\n- Please enter your full name.";
		fOK = false;
	}
	if (theForm.email.value.length == 0 || (theForm.email.value.length != 0 && !isValidEmail(theForm.email.value))) {
		strMsg += "\n- Please enter a valid email address.";
		fOK = false;
	}
	if (theForm.enquiry != null && theForm.enquiry.value.length == 0) {
		strMsg += "\n- Please enter your enquiry.";
		fOK = false;
	}
	if (theForm.comments != null && theForm.comments.value.length == 0) {
		strMsg += "\n- Please enter your comments.";
		fOK = false;
	}
	if (!fOK) {
		alert(strMsg);
	} else {
		document.forms[0].submit();
	}	
}
checkSearch = function(theForm) {
	var strMsg = "You have not filled in all the required fields:\n";
	fOK = true;
	if (theForm.maxprice.value != 0 && theForm.minprice.value != 0 && (theForm.maxprice.value != "7k+" && parseInt(theForm.minprice.value) > parseInt(theForm.maxprice.value))) {
		strMsg += "\n- Minimum price must be below maximum price";
		fOK = false;
	}
	if (!fOK) {
		alert(strMsg);
	} 
	return fOK;
}
checkPAForm = function(theForm) {
	var strMsg = "You have not filled in all the required fields:\n";
	fOK = true;
	if (theForm.name.value.length == 0) {
		strMsg += "\n- Please enter your name.";
		fOK = false;
	}
	if (theForm.email.value.length == 0 || (theForm.email.value.length != 0 && !isValidEmail(theForm.email.value))) {
		strMsg += "\n- Please enter a valid email address.";
		fOK = false;
	}
	if (theForm.password.value.length == 0 || (theForm.password.value.length < 4 || theForm.password.value.length > 16) || (theForm.password.value.length != 0 && !alphanumeric(theForm.password.value))) {
		strMsg += "\n- Please enter an alpanumeric password between 4-16 characters.";
		fOK = false;
	}
	if (theForm.minprice.value == 0) {
		strMsg += "\n- Select minimum price.";
		fOK = false;
	}
	if (theForm.maxprice.value == 0) {
		strMsg += "\n- Select maximum price.";
		fOK = false;
	}
	if (parseInt(theForm.minprice.value) > parseInt(theForm.maxprice.value)) {
		strMsg += "\n- Minimum price must be below maximum price";
		fOK = false;
	}
	if (theForm.bedrooms.value == 0) {
		strMsg += "\n- Select minimum bedrooms.";
		fOK = false;
	}
	if (!fOK) {
		alert(strMsg);
	} 
	return fOK;
}
function checkQuotation(theForm)
{
	var strMsg = "You have not filled in all the required fields:\n";
	fOK = true;
	if (theForm.surname.value.length == 0) {
		strMsg += "\n- Please enter your surname.";
		fOK = false;
	}
	if (theForm.firstname.value.length == 0) {
		strMsg += "\n- Please enter your firstname.";
		fOK = false;
	}
	if (theForm.email.value.length == 0 || (theForm.email.value.length != 0 && !isValidEmail(theForm.email.value))) {
		strMsg += "\n- Please enter a valid email address.";
		fOK = false;
	}
	if (theForm.tel.value.length == 0) {
		strMsg += "\n- Please enter your telephone number.";
		fOK = false;
	}
	if (!fOK) {
		alert(strMsg);
	} 
	return fOK;
}
deleteAlert = function() {
	if (confirm("Do you want to cancel your property alert?")) {
		document.getElementById('propertyalertaction').value='delete';
		document.propertyalertform.submit();
	}
}