function NewWindow(mypage) {
		window.open(mypage,'avalon','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=680,height=550,top=60,left=200');
		return false;
	}
function toggleview(item) {
	if (document.getElementById(item+"content").style.display == "none") {
		document.getElementById(item+"content").style.display="block";
		document.getElementById(item+"status").innerHTML="-";
	} else {
		document.getElementById(item+"content").style.display="none";
		document.getElementById(item+"status").innerHTML="+";
	}
}

function getCities(aForm, anArray) {
   var selIndex = aForm.country.value;

   if (selIndex != 0) {
      aForm.cityname.options.length = 0;
      aForm.property.options.length = 0;
      if(!anArray[selIndex]) {
         return;
      }
      for(var i = 0, n = 0; i < anArray[selIndex].length; i++) {
         aForm.cityname.options[n++] = new Option(anArray[selIndex][i][1], anArray[selIndex][i][0]);
      }
      aForm.cityname.selectedIndex = 0;
   }
}

function getProperties(aForm, anArray) {
   var selIndex = aForm.cityname.value;
   if (selIndex != 0) {
      aForm.property.options.length = 0;
      if(!anArray[selIndex]) {
         return;
      }
      for (var i = 0, n = 0; i < anArray[selIndex].length; i++) {
         aForm.property.options[n++] = new Option(anArray[selIndex][i][1], anArray[selIndex][i][0]);
      }
      aForm.property.selectedIndex = 0;
   }
}

function visitURL(aForm) {
   var hotelURL = aForm.property.value;
   //alert(hotelURL);
   window.open(hotelURL);
}

function getsubcategories(aForm, anArray) {
   var selIndex = aForm.country.selectedIndex;
   aForm.Hotelnames.options.length = 0;

   if (!anArray[selIndex]) {
      return;
   }
   for (var i = 0, n = 0; i < anArray[selIndex].length; i++) {
      aForm.Hotelnames.options[n++] = new Option(anArray[selIndex][i][1], anArray[selIndex][i][0]
      );
   }
   aForm.Hotelnames.selectedIndex = 0;
}

function checkSelections() {
   if (document.idForm.country.value.length == 0) {
      alert('Please select a country.');
      return false;
   } else {
      return true;
   }
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function validateEnquiry(f) {
   //declare some variables here first
   var strErrMsg = "";
   var regExp1 = /[^a-zA-Z0-9 ]/
   var regstr1 = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
   var regstr2 = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
   var regEmail1 = new RegExp(regstr1);
   var regEmail2 = new RegExp(regstr2);
   var regEmail3 = /[^a-zA-Z0-9\-_.@]/;

   //reset all the fields to #FFFFFF
   f.txtFirstName.style.backgroundColor = '#FFFFFF';
   f.txtLastName.style.backgroundColor = '#FFFFFF';
   f.txtEmailAddress.style.backgroundColor = '#FFFFFF';
   f.captcha.style.backgroundColor = '#FFFFFF';
   f.numPhoneCountryCode.style.backgroundColor = '#FFFFFF';
   f.txtAddress.style.backgroundColor = '#FFFFFF';
   f.txtEnquiryContents.style.backgroundColor = '#FFFFFF';

   if(!f.txtFirstName.value) {
      strErrMsg = strErrMsg + "- First Name/Given Name is required\n";
      f.txtFirstName.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.txtFirstName.value)) {
            strErrMsg = strErrMsg + "- Family Name is invalid\n";
            f.txtFirstName.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.txtLastName.value) {
      strErrMsg = strErrMsg + "- Last Name/Family Name is required\n";
      f.txtLastName.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.txtLastName.value)) {
            strErrMsg = strErrMsg + "- Given Name is invalid\n";
            f.txtLastName.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.txtEmailAddress.value) {  //for the Email Address field
      strErrMsg = strErrMsg + "- Email Address is required\n";
      f.txtEmailAddress.style.backgroundColor = "#FF0000";
   } else {
      if(window.RegExp) {
         if(!(!regEmail1.test(f.txtEmailAddress.value) && regEmail2.test(f.txtEmailAddress.value) && !regEmail3.test(f.txtEmailAddress.value)) || !(f.txtEmailAddress.value.indexOf("@")>=0)) {
            strErrMsg = strErrMsg + "- Invalid Email Address\n";
            f.txtEmailAddress.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.numPhoneCountryCode.value){
      strErrMsg = strErrMsg +"- Country Code is required\n";
      f.numPhoneCountryCode.style.backgroundColor = '#FF0000';
   }

   if(!f.numPhoneNumber.value){
      strErrMsg = strErrMsg +"- Phone Number is required\n";
      f.numPhoneNumber.style.backgroundColor = '#FF0000';
   }

   if(!f.txtAddress.value){
      strErrMsg = strErrMsg +"- Address is required\n";
      f.txtAddress.style.backgroundColor = '#FF0000';
   }

   if(!f.txtEnquiryContents.value){
      strErrMsg = strErrMsg +"- Enquiry / Feedback is required\n";
      f.txtEnquiryContents.style.backgroundColor = '#FF0000';
   }

   if(!f.captcha.value) {
      strErrMsg = strErrMsg + "- Anti Spam Code is required\n";
      f.captcha.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.captcha.value)) {
            strErrMsg = strErrMsg + "- Please enter the Anti Spam Code shown in the image shown on the left \n";
            f.captcha.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(strErrMsg != "") {
      alert(strErrMsg);
      return false;
   } else {
      return true;
   }
}

function validateFeedback(f) {
   var strErrMsg = "";
   var regExp1 = /[^a-zA-Z0-9 ]/
   var regstr1 = "(@.*@)|(\\.\\.)|(@\\.)|(\\.@)|(^\\.)";
   var regstr2 = "^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$";
   var regEmail1 = new RegExp(regstr1);
   var regEmail2 = new RegExp(regstr2);
   var regEmail3 = /[^a-zA-Z0-9\-_.@]/;

   //reset all the fields to #FFFFFF
   f.txtFirstName.style.backgroundColor = '#FFFFFF';
   f.txtLastName.style.backgroundColor = '#FFFFFF';
   f.txtEmailAddress.style.backgroundColor = '#FFFFFF';
   f.txtComments.style.backgroundColor = '#FFFFFF';
   f.captcha.style.backgroundColor = '#FFFFFF';

   if(!f.txtFirstName.value) {
      strErrMsg = strErrMsg + "- First Name is required\n";
      f.txtFirstName.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.txtFirstName.value)) {
            strErrMsg = strErrMsg + "- First Name is invalid\n";
            f.txtFirstName.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.txtLastName.value) {
      strErrMsg = strErrMsg + "- Last Name is required\n";
      f.txtLastName.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.txtLastName.value)) {
            strErrMsg = strErrMsg + "- Last Name is invalid\n";
            f.txtLastName.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.txtEmailAddress.value) {  //for the Email Address field
      strErrMsg = strErrMsg + "- Email Address is required\n";
      f.txtEmailAddress.style.backgroundColor = "#FF0000";
   } else {
      if(window.RegExp) {
         if(!(!regEmail1.test(f.txtEmailAddress.value) && regEmail2.test(f.txtEmailAddress.value) && !regEmail3.test(f.txtEmailAddress.value)) || !(f.txtEmailAddress.value.indexOf("@")>=0)) {
            strErrMsg = strErrMsg + "- Invalid Email Address\n";
            f.txtEmailAddress.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(!f.txtComments.value) {
      strErrMsg = strErrMsg + "- Comments is required\n";
      f.txtComments.style.backgroundColor = '#FF0000';
   }

   if(!f.captcha.value) {
      strErrMsg = strErrMsg + "- Anti Spam Code is required\n";
      f.captcha.style.backgroundColor = '#FF0000';
   } else {
      if(window.RegExp) {
         if(regExp1.test(f.captcha.value)) {
            strErrMsg = strErrMsg + "- Please enter the Anti Spam Code shown in the image shown on the left \n";
            f.captcha.style.backgroundColor = '#FF0000';
         }
      }
   }

   if(strErrMsg != "") {
      alert(strErrMsg);
      return false;
   } else {
      return true;
   }
}

function isNumberKey(evt) {
   var charCode = (evt.which) ? evt.which : event.keyCode
   if (charCode > 31 && (charCode < 48 || charCode > 57)) {
      return false;
   }
   return true;
}

//function to automatically populate the form fields in the booking engine with the current date
function todayDate(f) {
   var now = new Date();
   //f.txtArrivalDate.value = now.getDate() + "/" + (now.getMonth() + 1) + "/" + now.getFullYear();
	var dteArrivalDate = new Date(now.getTime() + (7*24*60*60*1000));
	f.txtArrivalDate.value = dteArrivalDate.getDate() + "/" + (dteArrivalDate.getMonth() + 1) + "/" + dteArrivalDate.getFullYear();
   f.fromday.value = dteArrivalDate.getDate();
   f.frommonth.value = dteArrivalDate.getMonth() + 1;
   f.fromyear.value = dteArrivalDate.getFullYear();

   //var txtDaysForward = f.nbdays.options[f.nbdays.selectedIndex].value;

   var dteDepartureDate = new Date(now.getTime() + (8*24*60*60*1000));
   f.txtDepartureDate.value = dteDepartureDate.getDate() + "/" + (dteDepartureDate.getMonth() + 1) + "/" + dteDepartureDate.getFullYear();
	f.endday.value = dteDepartureDate.getDate();
   f.endmonth.value = dteDepartureDate.getMonth() + 1;
   f.endyear.value = dteDepartureDate.getFullYear();
}

function GoogleLocationMapPopUp() {
	window.open("location_map_google.php", "", "width=670, height=520, resizable=no");	
}

function NormalLocationMapPopup() {
	window.open("location_map_normal.php", "", "width=650, height=650, resizable=1, scrollbars=1");	
}
//added by Darryl on 17th December 2008
function popupECards() {
	window.open('ecard_popup.php', '', 'width=800, height=620, scrollbars=no, resizable=no');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}













/***********************************************
* AnyLink Drop Down Menu- c Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
	var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	var parentEl=what.offsetParent;
	
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth) {
	if (ie4||ns6) {
		dropmenuobj.style.left=dropmenuobj.style.top="-500px"
	}
	
	if (menuwidth!="") {
		dropmenuobj.widthobj=dropmenuobj.style
		dropmenuobj.widthobj.width=menuwidth
	}
	
	if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
		obj.visibility=visible
	} else if (e.type=="click") {
		obj.visibility=hidden
	}
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
	var edgeoffset=0
	
	//if (whichedge=="rightedge") {
		var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
		dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
		if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
		edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
	/*
	}
	else{
		var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
		var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
		dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
		if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure) //move up?
		edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
		if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
		edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
		alert(dropmenuobj.contentmeasure);
		edgeoffset = dropmenuobj.contentmeasure+obj.offsetHeight-topedge;
	}
	*/
	return edgeoffset
}

function populatemenu(what){
	if (ie4||ns6) {
		dropmenuobj.innerHTML=what.join("")
	}
}


function dropdownmenu(obj, e, menucontents, menuwidth){
	if (window.event) {
		event.cancelBubble=true
	} else if (e.stopPropagation) {
		e.stopPropagation()
	}
	clearhidemenu()
	dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
	populatemenu(menucontents)
	
	if (ie4||ns6){
		showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
		dropmenuobj.x=getposOffset(obj, "left")
		dropmenuobj.y=getposOffset(obj, "top")
		dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
		dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
	}
	return clickreturnvalue()
}

function clickreturnvalue(){
	if(ie4||ns6) {
		return false;
	} else {
		return true;
	}
}

function contains_ns6(a, b) {
	while (b.parentNode) {
		if ((b = b.parentNode) == a) {
			return true;
			return false;
		}
	}
}

function dynamichide(e){
	if (ie4&&!dropmenuobj.contains(e.toElement)) {
		delayhidemenu()
	} else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) {
		delayhidemenu()
	}
}

function hidemenu(e){
	if (typeof dropmenuobj!="undefined"){
		if (ie4||ns6) {
			dropmenuobj.style.visibility="hidden"
		}
	}
}

function delayhidemenu(){
	if (ie4||ns6) {
		delayhide=setTimeout("hidemenu()",disappeardelay)
	}
}

function clearhidemenu(){
	if (typeof delayhide!="undefined") {
		clearTimeout(delayhide)
	}
}

if (hidemenu_onclick=="yes") {
	document.onclick=hidemenu
}