function ShowMenu(x)
	{
		document.getElementById(x).style.color='#000000';
		document.getElementById(x).style.background='#D1F1A0';
		if(document.getElementById('Sub'+x))
		document.getElementById('Sub'+x).style.visibility='visible';
	}
	
function HideMenu(x)
	{
		document.getElementById(x).style.color='#FFFFFF';
		document.getElementById(x).style.background='url(images/navbg.gif)'
		if(document.getElementById('Sub'+x))
		document.getElementById('Sub'+x).style.visibility='hidden';
	}
	
function SubItemOver(x)
	{x.style.background='#D1F1A0'}
	
function SubItemOut(x)
	{x.style.background='#EEFFDD'}

function openCal(c)
	{
		var mcheight = 130;
		var mcwidth = 180;
		var thetop = ((screen.height/2)-(mcheight/2));
		var theleft = ((screen.width/2)-(mcwidth/2));
		var miniCal = window.open('minical.cfm?c='+c,'miniCal','toolbars=0,resizable=yes,height='+mcheight+',width='+mcwidth+',top='+thetop+',left='+theleft+'');
		miniCal.focus();
	}

//function openRateCal(c,rid)
//	{
//		var mcheight = 130;
//		var mcwidth = 180;
//		var thetop = ((screen.height/2)-(mcheight/2));
//		var theleft = ((screen.width/2)-(mcwidth/2));
//		var miniCal = window.open('miniratecal.cfm?c='+c+'&rid='+rid,'miniCal','toolbars=0,resizable=yes,height='+mcheight+',width='+mcwidth+',top='+thetop+',left='+theleft+'');
//		miniCal.focus();
//	}

function setDate(c,y,m,d)
	{
		var Y = c+'y';
		var M = c+'m';
		var D = c+'d';
		opener.document.getElementById(Y).selectedIndex=(y-1);
		opener.document.getElementById(M).selectedIndex=(m-1);
		opener.document.getElementById(D).selectedIndex=(d-1);
		opener.document.getElementById(D).focus();
		self.close();
	}

//function OpenCalendar_OLD(c)
//	{
//		document.getElementById('MiniCal_'+c).style.height='140px';
//		document.getElementById('MiniCal_'+c).style.width='180px';
//		document.getElementById('MiniCal_'+c).style.visibility='visible';
//		document.getElementById('MiniCal_'+c).focus();
//	}

function OpenCalendar(c)
	{
		document.getElementById('MiniCal_a').style.height='0px';
		document.getElementById('MiniCal_d').style.height='0px';
		
		document.getElementById('MiniCal_'+c).style.width='180px';
		document.getElementById('MiniCal_'+c).style.visibility='visible';
		grow(c,0);
	}

function grow(c,i)
	{
		document.getElementById('MiniCal_'+c).style.height=i+'px';
		i = i + 20
		if(i<=140)
			setTimeout("grow('"+c+"',"+i+")",1);
	}

function CloseCalendar(c)
	{
		shrink(c,140);
		//parent.document.getElementById('MiniCal_'+c).style.height='0px';
		//parent.document.getElementById('MiniCal_'+c).style.width='0px';
	}

function shrink(c,i)
	{
		parent.document.getElementById('MiniCal_'+c).style.height=i+'px';
		i = i - 20
		if(i>=0)
			setTimeout("shrink('"+c+"',"+i+")",1);
		else
			parent.document.getElementById('MiniCal_'+c).style.visibility='hidden';
	}

function setDate2(c,y,m,d)
	{
		var Y = c+'y';
		var M = c+'m';
		var D = c+'d';
		parent.document.getElementById(Y).selectedIndex=(y-1);
		parent.document.getElementById(M).selectedIndex=(m-1);
		parent.document.getElementById(D).selectedIndex=(d-1);
		parent.document.getElementById(D).focus();
		CloseCalendar(c);
	}

//function setRateDate(rid,c,y,m,d)
//	{
//		var Y = c+'y'+rid;
//		var M = c+'m'+rid;
//		var D = c+'d'+rid;
//		opener.document.getElementById(Y).selectedIndex=(y-1);
//		opener.document.getElementById(M).selectedIndex=(m-1);
//		opener.document.getElementById(D).selectedIndex=(d-1);
//		self.close();
//	}

function showhelp(x,msg)
	{
		document.getElementById(x).innerHTML=msg;
		document.getElementById(x).style.visibility='visible';
	}
	
function closehelp(x)
	{document.getElementById(x).style.visibility='hidden';}
	
function textCounter( field, countfield, maxlimit )
	{
	if ( field.value.length > maxlimit )
		{
	    	field.value = field.value.substring( 0, maxlimit );
	    	alert( 'Textarea value can only be '+maxlimit+' characters in length.' );
	    	return false;
	 	}
	else
		{
			countfield.innerHTML = field.value.length;
		}
	}

function openprintpage(pid)
	{
		var mcheight = 500;
		var mcwidth = 650;
		var thetop = ((screen.height/2)-(mcheight/2));
		var theleft = ((screen.width/2)-(mcwidth/2));
		var displaydate = document.getElementById('displaydate').value;
		var propertyprint = window.open('propertyprint.cfm?pid='+pid+'&displaydate='+displaydate,'propertyprint','toolbars=0,resizable=yes,height='+mcheight+',width='+mcwidth+',top='+thetop+',left='+theleft+'');
		propertyprint.focus();
	}
	
function printbooking(bookingid)
	{
		var mcheight = 500;
		var mcwidth = 670;
		var thetop = ((screen.height/2)-(mcheight/2));
		var theleft = ((screen.width/2)-(mcwidth/2));
		var ownerspropertybookingsprint = window.open('ownerspropertybookingsprint.cfm?bookingid='+bookingid,'ownerspropertybookingsprint','toolbars=0,resizable=yes,height='+mcheight+',width='+mcwidth+',top='+thetop+',left='+theleft+'');
		ownerspropertybookingsprint.focus();
	}
	
function showhits(x,y,z)
	{
		document.getElementById(x).innerHTML=y+' visitors on '+ z;
		document.getElementById(x).style.visibility='visible';
	}
	
function closehits(x)
	{document.getElementById(x).style.visibility='hidden';}

function CheckReservationForm()
	{
		var problem = '';
		var arrivaldate = document.forms[0].ay.value+document.forms[0].am.value+document.forms[0].ad.value;
		var departuredate = document.forms[0].dy.value+document.forms[0].dm.value+document.forms[0].dd.value;
		if(document.forms[0].Name.value == '')
			problem = problem+'\n * Please enter your Name';
		
		if(document.forms[0].Email.value == '' && document.forms[0].Phone.value == '')
			problem = problem+'\n * Please enter your Email Address or your Phone Number';
		
		if(arrivaldate > departuredate)
			problem = problem+'\n * Your Arrival Date can not occur after your Departure Date';
		
		if(problem != '')
		   {alert(problem);return false;}
	}

function CalculateNumberOfNights(x)
	{
		var aTheYear = document.getElementById("a"+x+"y").options[document.getElementById("a"+x+"y").selectedIndex].value;
		var aTheMonth = document.getElementById("a"+x+"m").options[document.getElementById("a"+x+"m").selectedIndex].value;
		var aTheDay = document.getElementById("a"+x+"d").options[document.getElementById("a"+x+"d").selectedIndex].value;

		var dTheYear = document.getElementById("d"+x+"y").options[document.getElementById("d"+x+"y").selectedIndex].value;
		var dTheMonth = document.getElementById("d"+x+"m").options[document.getElementById("d"+x+"m").selectedIndex].value;
		var dTheDay = document.getElementById("d"+x+"d").options[document.getElementById("d"+x+"d").selectedIndex].value;


		var days = 0;
		var difference = 0;
		Arrival = new Date(aTheMonth+"/"+aTheDay+"/"+aTheYear);
		Departure = new Date(dTheMonth+"/"+dTheDay+"/"+dTheYear);
		difference = Departure - Arrival;
		days = difference/(1000*60*60*24);
		days = days.toFixed(0);
		var nightstext = 'Night'
		if(days != 1)
			nightstext = 'Nights'
		document.getElementById("NumberOfNights"+x).innerHTML = days+" "+nightstext
	}