/* harmonynosara */
/* form validation messages - copied from /contact.base.php */
var vRequired={
	frontdesk:{
		en:{
			email:"Email Address"
		}
	},
	reservation:{
		en:{
			email:"Email Address",
			policies:"Harmony Hotel pre-payment and cancellations policies"
		}
	}
};

window.onload=function(){
	captureXImg();
	captureFormValidation();
}

function captureXImg(){
	if (document.getElementsByTagName){
		if (va=document.getElementsByTagName("a")){
			for (var i=0;i<va.length;i++){
				if (va[i].className.indexOf("ximg")!=-1){
					va[i].onmouseover=va[i].onfocus=function(){ximg(this,1);}
					va[i].onmouseout=va[i].onblur=function(){ximg(this,0);}
				}
			}
		}
		delete va;
	}
}

function ximg(a,s){
	if (img=a.firstChild){
		if (img.tagName.toLowerCase()=="img"){
			if (img.src.indexOf("_1.")==-1){
				img.src=img.src.replace(/(_(0|2)\.)/,"_"+(s?2:0)+".");
			}
		}
	}
}

function captureFormValidation(){
	if (document.getElementsByTagName){
		if (vForm=document.getElementsByTagName("form")){
			for (var i=0;i<vForm.length;i++){
				if (vForm[i]["validate"]){
					vForm[i].onsubmit=function(){
						return fvalidate(this);
					}
				}
			}
		}
	}	
}

function fvalidate(f){
	var fv, ep;
	if ((fv=f["validate"]) && document.getElementById){
		if (fv.value.length){
			var flang=f["lang"].value;
			var fform=f["form"].value;
			var vInput=fv.value.split(",");
			var vError=new Array();
			for (var i=0;i<vInput.length;i++){
				if (!validateInput(f,vInput[i],f["data["+vInput[i]+"]"].value)){
					vError[vError.length]=vRequired[fform][flang][vInput[i]];
				}
			}
			if (vError.length){
				if (ep=document.getElementById("ferrorlist")){
					var emsg=ep.innerHTML.toString().replace(/<br>/i,"\n\n").replace(/#fieldlist#/,vError.join("\n"));
					alert(emsg);
					return false;
				}
			}
		}
	}
	return true;
}

var isValidEmail=new RegExp("^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$");

function validateInput(f,key,val){
	switch (key){
		case "email":
			if (typeof(isValidEmail)!="undefined"){
				if (!isValidEmail.test(val)){
					return false;
				}
			}
			if (val=="" || val!=f["data[email_confirm]"].value){
				return false;
			}
			break;
		case "policies":
			if (!f["data[policies]"].checked){
				return false;
			}
			break;
	}
	return true;
}



<!--
window.onload=montre;
function montre(id) {
var d = document.getElementById(id);
	for (var i = 1; i<=13; i++) {
		if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
	}
if (d) {d.style.display='block';}
}
//-->
