function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
function openWin(theURL,winName,wWidth,wHeigt) 
{
	sWidth = wWidth;
	sHeight = wHeigt;
	pTop = (screen.Height-sHeight)/2;
	pLeft = (screen.Width-sWidth)/2;
	window.open(theURL,winName,"toolbar=0,location=0,status=0,menubar=0,scrollbars=2,resizable=0,width="+sWidth+"px,height="+sHeight+"px,top="+pTop+",left="+pLeft+"");
}
var hellotext="Done"
var thetext=""
var started=false
var step=0
var times=1
function welcometext()
{
times--
if (times==0)
{
if (started==false)
{
started = true;
window.status = hellotext;
setTimeout("anim()",1);
}
thetext = hellotext;
}
}
function showstatustext(txt)
{
thetext = txt;
setTimeout("welcometext()",4000)
times++
}
function anim()
{
step++
if (step==7) {step=1}
if (step==1) {window.status=thetext}
if (step==2) {window.status=thetext}
if (step==3) {window.status=thetext}
if (step==4) {window.status=thetext}
if (step==5) {window.status=thetext}
if (step==6) {window.status=thetext}
setTimeout("anim()",200);
}
function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}
function limitText(limitField, limitCount, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	} else {
		limitCount.value = limitNum - limitField.value.length;
	}
}
function isEmail(str) 
{
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	return false
	}
	if (str.indexOf(at,(lat+1))!=-1){
	return false
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	return false
	}
	if (str.indexOf(dot,(lat+2))==-1){
	return false
	}
	if (str.indexOf(" ")!=-1){
	return false
	}
	return true
}
function cekContact(theForm) 
{
	if(trim(theForm.name.value) == "" || trim(theForm.name.value) == "-") 
	{
		alert("Please enter your name!");
		theForm.name.focus();
		return(false);
	}
	if(!isEmail(trim(theForm.email.value))) 
	{
		alert("Please enter a valid email address!");
		theForm.email.focus();
		return(false);
	}	
	if(trim(theForm.message.value) == "" || trim(theForm.message.value) == "-") 
	{
		alert("Please enter your message/comment!");
		theForm.message.focus();
		return(false);
	}
	if(trim(theForm.sccode.value) == "" || trim(theForm.sccode.value) == "-") 
	{
		alert("Please enter string code!");
		theForm.sccode.focus();
		return(false);
	}
	return (true);
	}
function cekGuestbook(theForm) 
{
	if(trim(theForm.txtName.value) == "" || trim(theForm.txtName.value) == "-") 
	{
		alert('Please enter your name');
		theForm.txtName.focus();
		return(false);
	}
	else if(trim(theForm.txtLocation.value) == '')
	{
		alert('Please enter your location');
		theForm.txtLocation.focus();
		return false;
	}
	else if(trim(theForm.txtEmail.value) != '' && !isEmail(trim(theForm.txtEmail.value)))
	{
		alert('Please enter a valid email address or leave it blank');
		theForm.txtEmail.focus();
		return false;
	}
	else if(trim(theForm.txtMessage.value) == '')
	{
		alert('Please enter your message');
		theForm.txtMessage.focus();
		return false;
	}
	else if(trim(theForm.sccode.value) == "" || trim(theForm.sccode.value) == "-") 
	{
		alert("Please enter string code!");
		theForm.sccode.focus();
		return(false);
	}
	else
	{
		return true;
	}
}
function setNightsDropDown()
{
	var f = document.form_booking;
	var ChkInDate;
	var ChkOutDate;
	var thisDate = new Date();
	var thisMonth = thisDate.getMonth() + 1; // need to increment arrivalMonth and arrivaldate b/c they are arrays
	var thisYear = thisDate.getFullYear();
	var thisDay = thisDate.getDate();
	DateNow = thisMonth + "/" + thisDay + "/" + thisYear;
	ChkInDate = f.month1.value + "/" + f.day1.value + "/" + f.year1.value;
	ChkOutDate = f.month2.value + "/" + f.day2.value + "/" + f.year2.value;

	var dateArrival = new Date(ChkInDate);
	var dateDepart = new Date(ChkOutDate);
	var daysBetween = getDateDifference(dateArrival, dateDepart);

	f.numnights.selectedIndex = daysBetween - 1
}
function getDateDifference(startDate, endDate)
{
	var dateDif;

	dateDif = endDate.getTime() - startDate.getTime();
	dateDif = Math.round(dateDif/(1000 * 60 * 60 * 24));
	return dateDif;
}
function cekBooking(theForm) 
{
	var ChkInDate;
	var ChkOutDate;
	var thisDate = new Date();
	var thisMonth = thisDate.getMonth() + 1; // need to increment arrivalMonth and arrivaldate b/c they are arrays
	var thisYear = thisDate.getFullYear();
	var thisDay = thisDate.getDate();
	DateNow = thisMonth + "/" + thisDay + "/" + thisYear;
	ChkInDate = theForm.month1.value + "/" + theForm.day1.value + "/" + theForm.year1.value;
	ChkOutDate = theForm.month2.value + "/" + theForm.day2.value + "/" + theForm.year2.value;
	if(trim(theForm.guestname.value) == "" || trim(theForm.guestname.value) == "-") 
	{
		alert("Please enter your full name!");
		theForm.guestname.focus();
		return(false);
	}
	if(trim(theForm.address.value) == "" || trim(theForm.address.value) == "-") 
	{
		alert("Please enter your address!");
		theForm.address.focus();
		return(false);
	}
	if(trim(theForm.phone.value) == "" || trim(theForm.phone.value) == "-") 
	{
		alert("Please enter your phone!");
		theForm.phone.focus();
		return(false);
	}
	if(!isEmail(trim(theForm.email.value))) 
	{
		alert("Please enter a valid email address!");
		theForm.email.focus();
		return(false);
	}	
	if (trim(theForm.email.value)!="") 
	{
		if (isEmail(theForm.email.value)==false)
		{
			theForm.email.focus()
			return(false)
		}
	}	
	if (Date.parse(ChkInDate) >= Date.parse(ChkOutDate))
	{
		alert ("The Check Out Date needs to be after the Check In Date.");
		theForm.day1.focus();
		return (false);
	}
	if (Date.parse(ChkInDate) < Date.parse(theForm.hiddenDate.value))
	{
		alert ("You are not allowed to book any days earlier than 2");
		theForm.day1.focus();
		return (false);
	}
	if(trim(theForm.numnights.value) == "") 
	{
		alert("Please select Number of nights");
		theForm.numnights.focus();
		return(false);
	}
	if(trim(theForm.sccode.value) == "" || trim(theForm.sccode.value) == "-") 
	{
		alert("Please enter string code!");
		theForm.sccode.focus();
		return(false);
	}
	return (true);
	}