function ButtonModeON(imgName)
{		
	imgNum = "imgsrc1"	
	document.images[imgNum].src= imgName;		
}
function ButtonModeOFF(imgName)
{
	imgNum = "imgsrc1"	
	document.images[imgNum].src= imgName;		
}
function writestatusbar(strText) 
{
	window.status = strText;
}
function statusSetter(strDefaultStatusText,strStatusText) 
{   
	window.defaultStatus = strDefaultStatusText;
	window.status = strStatusText;
}
function WindowSubmit(lsHTMLFile,iWidth,iHeight) 
{
	windowName = new String(Math.round(Math.random() * 10000));
	winobj =  window.open(lsHTMLFile,windowName,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,top=0,left=0,resizable=1,width="+iWidth+",height="+iHeight);
	FormSubmit(winobj);
}
function openNewWindow(lsHTMLFile,iWidth,iHeight,strText) 
{
	window.status = strText;
	windowName = new String(Math.round(Math.random() * 100000));
	winobj =  window.open(lsHTMLFile,windowName,"toolbar=0,location=0,directories=0,status=0,scrollbars=0,top=0,left=0,resizable=0,width="+iWidth+",height="+iHeight);
}
function openThisWindow(lsHTMLFile,iWidth,iHeight,strText) 
{
	window.status = strText;
	windowName = new String(Math.round(Math.random() * 100000));
	winobj =  window.open(lsHTMLFile,windowName,"toolbar=0,location=0,directories=0,status=1,scrollbars=1,top=0,left=0,resizable=1,width="+iWidth+",height="+iHeight);	
}
function openScrollWindow(lsHTMLFile,iWidth,iHeight) 
{	
	windowName = new String(Math.round(Math.random() * 10000));
	winobj =  window.open(lsHTMLFile,windowName,"toolbar=0,location=0,directories=0,status=0,scrollbars=1,top=0,left=0,resizable=1,width="+iWidth+",height="+iHeight);
	window.status = "Transportation page ...  select any button above to navigate through our site";
}

lstMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
lstLengths = new Array(31,28,31,30,31,30,31,31,30,31,30,31);

function ChangeDateLengthArr(objMonth,objValue,objYear)
{

var x;

	for (var i in lstMonths)
	{	

		if (lstMonths[i] == objValue)			
		{	
			if (lstMonths[i] == "February" && objYear % 4 == 0)			
			{
				var theLength = lstLengths[i]+1;
				lstList = new Array(lstLengths[i]+1);	
			}
			else
			{
				var theLength = lstLengths[i];
				lstList = new Array(lstLengths[i]);			
				//alert(lstLengths[i]);			
			}	
		}		
	}

	for (x = 1; x <= theLength; x++)
	{		
		lstList[x] = String(x);
	}

var lstObj = document.Form.ArrivalDay;
lstObj.options.length = 1; 

	for (x =1; x <= theLength; x++)
	{	
		lstObj.options[x-1] = new Option(lstList[x]); 						
	}

document.Form.DepartureMonth.value = objValue;
ChangeDateLengthDep(objMonth,objValue,objYear)

}
function ChangeDateLengthDep(objMonth,objValue,objYear)
{

var x;

	for (var i in lstMonths)
	{	
		if (lstMonths[i] == objValue)			
		{	
			if (lstMonths[i] == "February" && objYear % 4 == 0)			
			{
				var theLength = lstLengths[i]+1;
				lstList = new Array(lstLengths[i]+1);	
			}
			else
			{
				var theLength = lstLengths[i];
				lstList = new Array(lstLengths[i]);							
			}	
		}		
	}

	for (x = 1; x <= theLength; x++)
	{		
		lstList[x] = String(x);
	}

var lstObj = document.Form.DepartureDay;
lstObj.options.length = 1; 

	for (x =1; x <= theLength; x++)
	{		
	lstObj.options[x-1] = new Option(lstList[x]); 						
	}
}
function GotoHREF(lsRoomType)
{
	//location.href="JavaScript:openNewWindow('ReserveForm.asp?RoomType=" + lsRoomType + "',360,570,'Registration Information ...')";
	FormSubmit("ReserveForm.asp");
}

//dates passed in will be server side dates and dates created here will be client dates
function ValidDate(lsDay,lsMonth,lsYear,lsAsp)  
{
var lsArrDate = document.Form.ArrivalDay.value;
var lsArrMonth = document.Form.ArrivalMonth.value;
var lsArrYear = document.Form.ArrivalYear.value;
var lsDepDate = document.Form.DepartureDay.value;
var lsDepMonth = document.Form.DepartureMonth.value;
var lsDepYear = document.Form.DepartureYear.value;
var form = document.forms[0];
var dicFormValues;	
var Today = new Date();
var bProbs = false;

dicFormValues	= new ActiveXObject("Scripting.Dictionary");

	//place all entry fields into a Scripting.Dictionary 
		for(i=0;i<form.elements.length;i++)
			{	
				//if (!dicFormValues.Exists (form.elements[i].name)) 
					//{
						//dicFormValues.Add (form.elements[i].name, escape(form.elements[i].value));																							
						alert(form.elements[i].name + ": " + form.elements[i].value);
					//}						
			}

//alert(lsMonth + " " + lsDay + " " + lsYear);
//alert(lsDepDate + lsDepMonth + lsDepYear);

	//month and year are before todays date
	if (GetTheMonthNumber(lsArrMonth) < Today.getMonth() && lsArrYear < Today.getYear())
		{					
			alert("last year and month -- Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}
	//month is same as todays date - but day is before today
	if (GetTheMonthNumber(lsArrMonth) == Today.getMonth() && lsArrDate < Today.getDate()+ 2)
		{					
			alert("a few days ago - Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}	
	//year is before todays year
	if (lsArrYear < Today.getYear())
		{					
			alert("last year -- Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}	
	//month is before todays month
	if (GetTheMonthNumber(lsArrMonth) < Today.getMonth())
		{					
			alert("Months before -- Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}	
	//both dates are the same 
	if (GetTheMonthNumber(lsArrMonth) == GetTheMonthNumber(lsDepMonth) && lsArrDate == lsDepDate && lsArrYear == lsDepYear)
		{					
			alert("Both dates are the same -- Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}		
	//Dep date is before Arr Date
	if (GetTheMonthNumber(lsArrMonth) <= GetTheMonthNumber(lsDepMonth) && (lsArrYear > lsDepYear))
		{					
			alert("Departure Date is before Arrival date -- Room reservation must be made 2 days in advance ... ");				
			bProbs = true;			
		}			
	if (bProbs == false)
		{					
			FormSubmit(lsAsp);		
			return true;
		}
	else
		{					
			FormSubmit("CorrectInfo.asp");					
		}	
}
function GetTheMonthNumber(theMonth) 
{
	for (var i in lstMonths)
		{
		if (lstMonths[i] == theMonth)	
			{
				return i;
			}
		}			
}
function FormSubmit(lsHTML)
{
	var form = document.forms[0];
	//alert(lsHTML);	
	form.submit();		
	location.href=lsHTML;	
}
function ReCalculateKing(value)
{		
	var FieldTotal = document.Form.availKingTotal.value;		
	document.Form.KingTotal.value = getCurrencyNumber(value,FieldTotal);				
}
function ReCalculateDbl(value)
{	
	var FieldTotal = document.Form.availDoubleTotal.value;					
	document.Form.DoubleTotal.value = getCurrencyNumber(value,FieldTotal);				
}
function ReCalculateKit(value)
{		
	var FieldTotal = document.Form.availKitchenTotal.value;					
	document.Form.KitchenTotal.value = getCurrencyNumber(value,FieldTotal);
}
function ReCalculateJac(value)
{			
	var FieldTotal = document.Form.availJacuzziTotal.value;		
	document.Form.JacuzziTotal.value = getCurrencyNumber(value,FieldTotal);
}
function getCurrencyNumber(value,FieldTotal)
{
	var currencyVal = String(value * FieldTotal);	
	var offset = currencyVal.indexOf(".");		
	
	var llNumber = currencyVal.substring(0,offset+3);
	
		switch (offset)
			{
			case -1:
				currencyVal = "$" + currencyVal + ".00";				
				break						
			default:				
					if (llNumber.length-offset == 2)
						{
							currencyVal = "$" + llNumber + "0";
						}
					else
						{
							currencyVal = "$" + llNumber; 			
								
								if (currencyVal.substring(currencyVal.length-1,currencyVal.length) == 4) 
									{
										currencyVal = currencyVal.substring(0,currencyVal.length-1) + "5"
									}						
								if (currencyVal.substring(currencyVal.length-1,currencyVal.length) == 9) 
									{
										theNumber = parseInt(currencyVal.substring(currencyVal.length-2,currencyVal.length-1)) + 1										
										currencyVal = currencyVal.substring(0,currencyVal.length-2) + theNumber + "0"										
									}	
						}									
				break
			}
	
	return currencyVal;

}			
function ValidEmail(item) 
{
var objRegExp = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{2,4}\.[0-9]{2,4}\.[0-9]{2,4}\.[0-9]{2,4}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,4}))$/;
  if(objRegExp.test(item))
	{
		return true;
	}
	else
	{
		alert("Please enter a Valid Email Address");
		return false;
	}					
}  
function checkReserveForm()
{
		var ErrMsg;
		var bRequiredInfo;
		var lsAddress;		
		var dicFormValues;			
		var theMsg;
		var form = document.forms[0];
		var expdate;
		var expMon;
		var expYr;
		var todayDate;
		var today = new Date();
				
		ValidEmail(document.Form.EMail.value);			
		dicFormValues	= new ActiveXObject("Scripting.Dictionary");
		
		/* place all entry fields into a Scripting.Dictionary */		
		for(i=0;i<form.elements.length;i++)
			{	
					if (!dicFormValues.Exists (form.elements[i].name)) 
						{
							dicFormValues.Add (form.elements[i].name, escape(form.elements[i].value));																							
						}						
			}												
		expMon = dicFormValues.item("ExpdateMon");
		expYr =  dicFormValues.item("ExpdateYr");								
		todayMon = today.getMonth();
		todayMon = 1 + todayMon;
		todayYr = today.getYear();				
		//alert(todayMon+"/"+todayYr+" : "+expMon+"/"+expYr);
			if (expYr < todayYr)
				{
					theMsg = "--Credit card is expired...";																											
					alert(theMsg);					
					return false;
				}
			if (expYr <= todayYr && expMon < todayMon)
				{
					theMsg = "--Credit card is expired...";																											
					alert(theMsg);					
					return false;
				}	
		ErrMsg = "";									
			if (dicFormValues.item("Name") == "")
				{
					ErrMsg += " --First & Last Name \n"
					bRequiredInfo = true;
				}				
			if (dicFormValues.item("PhoneNumber") == "")
				{
					ErrMsg += " --Phone Number \n";
					bRequiredInfo = true;
				}		
			if (dicFormValues.item("Address1") == "")			
				{
					ErrMsg += " --Address 1 \n";
					bRequiredInfo = true;
				}		
			if (dicFormValues.item("City") == "")			
				{
					ErrMsg += " --City \n";
					bRequiredInfo = true;
				}					
			if (dicFormValues.item("State") == "")			
				{
					ErrMsg += " --State/Providence \n";
					bRequiredInfo = true;
				}		
			if (dicFormValues.item("Country") == "")			
				{
					ErrMsg += " --Country \n";
					bRequiredInfo = true;
				}		
			if (dicFormValues.item("CreditNum") == "")			
				{
					ErrMsg += " --Credit Card Number \n";
					bRequiredInfo = true;
				}							
			if (bRequiredInfo == true)
				{	
					theMsg = "Please input the following information: " + "\n" + ErrMsg + "\nClick OK to complete form ...";																											
					alert(theMsg);					
					return false;
				}
			else
				{								
					return true;											
				}					
}
