function reservationCheck()
{

	if (document.getElementById('firstName').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('lastName').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('email').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('reemail').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('email').value != document.getElementById('reemail').value)
	{
		contactSubmitEmailMessage();
		return false;
	}

	if (document.getElementById('checkIn').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('checkOut').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}



	return true;
}



function departureFromHit(baseURL,value,dateMode)
{
	var url=baseURL + '&startDeparture=' + value + '&dateMode=' + dateMode;
	window.location=url;
}



function getCalEndValue(startID,endID)
{
var start;
var end;
	start =	document.getElementById(startID).value;
	end =	document.getElementById(endID).value;
	if (end == "")
	{
		return start;
	}
	else
	{
		return end;
	}
}

function contactSubmit()
{

	if (document.getElementById('firstName').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('lastName').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('email').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('reemail').value == "")
	{
		contactSubmitReqMessage();
		return false;
	}

	if (document.getElementById('email').value != document.getElementById('reemail').value)
	{
		contactSubmitEmailMessage();
		return false;
	}



	return true;
}

function contactSubmitReqMessage()
{
	alert("Please complete all required fields.");
}

function contactSubmitEmailMessage()
{
	alert("Please re-enter your e-mail, it does not match!");
}

function paneClickAjax(paneID,id,paneInfo)
{
//alert('paneID='+paneID+' id='+id+' paneInfo='+paneInfo);
	ajPaneContent(paneID,id,paneInfo);
}


function paneClick(url)
{
	window.location=url;
}



function pageLoad()
{
	//do search date widgets
}


function searchReset()
{
	document.getElementById('sLoc').value="";
	document.getElementById('sResType').value="";
	document.getElementById('sPrice').value="";
	document.getElementById('sRooms').value="";
	document.getElementById('sSleeps').value="";
	document.getElementById('sSpecial').checked="";
	document.getElementById('sStart').value="";
	document.getElementById('sEnd').value="";
	document.getElementById('sLoc').value="";
}


function setCursorPointer(id)
{
	document.getElementById(id).style.cursor="pointer";
}

function setCursorAuto(id)
{
	document.getElementById(id).style.cursor="auto";
}

function changeImage(id,image,cursor)
{
	document.getElementById(id).src=image;
	document.getElementById(id).style.cursor=cursor;
}


/*
function listingClick(id,propID)
{
	setCursorAuto(id);
	var url='page.php?menuMain=' + 'listing' + '&id=' + propID;
	window.location=url;
}

*/

function listingClick(id,url)
{
	setCursorAuto(id);
	window.location=url;
}


function listingHilite(id)
{
	setCursorPointer(id);
	document.getElementById(id).style.borderColor="#00e000 #00d800 #00d000 #00d800";
}
function listingUnhilite(id)
{
	setCursorAuto(id);
	document.getElementById(id).style.borderColor="#2840c0 #2840c0 #2840c0 #2840c0";
}

function featClick(id,propID)
{
	setCursorAuto(id);
	var url='page.php?menuMain=' + 'listing' + '&id=' + propID;
	window.location=url;
}

function gotoLink(url,id,image)
{
	document.getElementById(id).src=image;
	window.location=url;
}

function adminListItemHilite(id)
{
	setCursorPointer(id);
	document.getElementById(id).style.backgroundColor="#B4C8FA";
}
function adminListItemUnHilite(id)
{
	setCursorAuto(id);
	document.getElementById(id).style.backgroundColor="Transparent";
}


function adminChangeMenu(menuID,urlVals)
{
	var page=document.getElementById(menuID).value;
	var urlStr='page.php?menuMain=' + page + urlVals;
	window.location=urlStr;
}

function adminPageContentChangeMenu(menuID)
{
	var page=document.getElementById(menuID).value;
	var urlStr='page.php?menuMain=adminPageContent&page=' + page;
	window.location=urlStr;
}


function adminResCalClick(calID,refID,day,selStartDay,selEndDay,e)
{
	var shift=false;

	if (event.shiftKey == 1)
	{
		var shift=true;
	}


	urlStr='page.php?menuMain=adminReservations&id=' + refID + "&calID=" + calID + "&calClickDay=" + day+ "&selStartDay=" + selStartDay + "&selEndDay=" + selEndDay + "&shift=" + shift + "&jdDay=" + day;
	window.location=urlStr;
}

function adminRatesCalClick(calID,refID,day,selStartDay,selEndDay,e)
{
	var shift=false;

	if (event.shiftKey == 1)
	{
		var shift=true;
	}


	urlStr='page.php?menuMain=adminRates&id=' + refID + "&calID=" + calID + "&calClickDay=" + day+ "&selStartDay=" + selStartDay + "&selEndDay=" + selEndDay + "&shift=" + shift;
	window.location=urlStr;
}


function adminResChangeProperty(menuID)
//changes property id and redraws listing
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminReservations&id=' + id;
	window.location=urlStr;
}

function adminRatesChangeProperty(menuID)
//changes property id and redraws listing
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminRates&id=' + id;
	window.location=urlStr;
}

function adminRatesChangeType(menuID,propID)
//changes rateType id and redraws listing
{
	var rateType=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminRates&id=' + propID + "&rateType=" + rateType;
	window.location=urlStr;
}

function adminReorderThumChangeProperty(menuID)
//changes property id and redraws thumb reorder
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminImages&propID=' + id;
	window.location=urlStr;
}

function adminPropChangeProperty(menuID)
//changes property id
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminProperty&propID=' + id;
	window.location=urlStr;
}

function adminPropEditorChangePropType(menuID)
//adjusts fields according to property type
{
	var propType=document.getElementById(menuID).value;

	if (propType == 1)	//hotel
	{
		document.getElementById("room").disabled=true;
		document.getElementById("sleep").disabled=true;
		document.getElementById("bath").disabled=true;
		document.getElementById("typeMenuID").disabled=true;
		document.getElementById("shortTermMenuID").disabled=true;
		document.getElementById("longTermMenuID").disabled=true;
	}
	else	//other
	{
		document.getElementById("room").disabled=false;
		document.getElementById("sleep").disabled=false;
		document.getElementById("bath").disabled=false;
		document.getElementById("typeMenuID").disabled=false;
		document.getElementById("shortTermMenuID").disabled=false;
		document.getElementById("longTermMenuID").disabled=false;
	}
}



function adminPropEditorChangeProperty(menuID)
//changes property id
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminPropEditor&propID=' + id;
	window.location=urlStr;
}

function adminRevChangeProperty(menuID,revID)
//changes property id
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminReviews&propID=' + id + "&revID=" + revID;
	window.location=urlStr;
}

function adminRevChangeReviews(menuID,propID)
//changes review id
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminReviews&propID=' + propID + "&revID=" + id;
	window.location=urlStr;
}

function adminAmenChangeProperty(propID,amenID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminAmen&propID=' + propID + '&amenID=' + amenID;
	window.location=urlStr;
}




function adminAmenEditorChangeProperty(propID,amenID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminAmenEditor&propID=' + propID + '&amenID=' + amenID;
	window.location=urlStr;
}

function adminAmenEditorChangeAmen(amenID)
//changes property id
{
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminAmenEditor&amenID=' + amenID;
	window.location=urlStr;
}




function adminPropCustAmenChangeProperty(propID,amenID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminPropCustAmen&propID=' + propID + '&amenID=' + amenID;
	window.location=urlStr;
}

function adminPropCustAmenChangeAmen(propID,amenID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminPropCustAmen&propID=' + propID + '&amenID=' + amenID;
	window.location=urlStr;
}


function adminPropStdAmenChangeProperty(propID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	urlStr='page.php?menuMain=adminPropStdAmen&propID=' + propID;
	window.location=urlStr;
}

function adminAmenActAppChangeProperty(menuID)
//changes property id
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain= adminAmenActApp&propID=' + id;
	window.location=urlStr;
}

function adminAmenChangeAmen(propID,amenID)
//changes property id
{
	var propID=document.getElementById(propID).value;
	var amenID=document.getElementById(amenID).value;
	urlStr='page.php?menuMain=adminAmen&propID=' + propID + '&amenID=' + amenID;
	window.location=urlStr;
}

function adminContChange(menuID)
//changes content
{
	var contID=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminContent&contID=' + contID;
	window.location=urlStr;
}

function adminIslandChange(menuID)
//changes island content
{
	var islandID=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminIsland&islandID=' + islandID;
	window.location=urlStr;
}

function adminArticleChange(menuID,page)
//changes article content
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminPageContent&page=' + page + '&id=' + id;
	window.location=urlStr;
}

function adminMiscArticleChange(menuID)
//changes article content
{
	var name=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminArticles&name=' + name;
	window.location=urlStr;
}

function adminAboutChange(menuID)
//changes about content
{
	var aboutID=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminAbout&aboutID=' + aboutID;
	window.location=urlStr;
}

function adminGuestServicesChange(menuID)
//changes guest services content
{
	var guestServicesID=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminGuestServices&guestServicesID=' + guestServicesID;
	window.location=urlStr;
}

function adminCommunityChange(menuID)
//changes community
{
	var comID=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=adminCommunity&comID=' + comID;
	window.location=urlStr;
}

function adminPropCommunityChange(menuID)
//property community changed, dim if community
{
	var comID=document.getElementById(menuID).value;
	if (comID)
	{
		//dim coordinate elements
		document.getElementById('lat').style.visibility='hidden';
		document.getElementById('lng').style.visibility='hidden';
		document.getElementById('zoom').style.visibility='hidden';
		document.getElementById('mapLabelID').style.visibility='hidden';
	}
	else
	{
		document.getElementById('lat').style.visibility='visible';
		document.getElementById('lng').style.visibility='visible';
		document.getElementById('zoom').style.visibility='visible';
		document.getElementById('mapLabelID').style.visibility='visible';
	}
}


function adminResClick(id,rid,startDeparture,offset)
//changes property id and redraws listing
{
	urlStr='page.php?menuMain=adminReservations&id=' + id + '&rid=' + rid + '&startDeparture=' + startDeparture + '&offset=' + offset;
	window.location=urlStr;
}


function adminRateClick(id,rateID,rateType)
//changes property id and redraws listing
{
	urlStr='page.php?menuMain=adminRates&id=' + id + '&rateID=' + rateID + '&rateType=' + rateType;
	window.location=urlStr;
}


function changeProperty(menuID)
//changes property id and redraws listing
{
	var id=document.getElementById(menuID).value;
	urlStr='page.php?menuMain=listing&id=' + id;
	window.location=urlStr;
}

function createDateWidget(theFormName,theControlName)
{
	new tcal ({
		// form name
		'formname': theFormName,
		// input name
		'controlname': theControlName
	});
}








/*

function listUp(rowID,rowCount)
{
alert("up");
	var str="";
	var len=0;

	str="upID";
	var rowNum=rowID.substr(str.length);


	//get the uniqueID and item
var uniqueIDVal=listGetUniqueIDfromRowNum(rowNum*1);
var item=listGetItemfromRowNum(rowNum*1);

//get previous
var swapUniqueIDVal=listGetUniqueIDfromRowNum((rowNum*1)-1);
var swapItem=listGetItemfromRowNum((rowNum*1)-1);

//write out (do the swap)

listSetItemfromRowNum((rowNum*1)-1,item);
listSetUniqueIDfromRowNum((rowNum*1)-1,uniqueIDVal);

listSetItemfromRowNum((rowNum*1),swapItem);
listSetUniqueIDfromRowNum((rowNum*1),swapUniqueIDVal);

}


function listDown(rowID,rowCount)
{
	var str="";
	var len=0;

	str="downID";
	var rowNum=rowID.substr(str.length);


	//get the uniqueID and item
var uniqueIDVal=listGetUniqueIDfromRowNum(rowNum*1);
var item=listGetItemfromRowNum(rowNum*1);

//get after item
var swapUniqueIDVal=listGetUniqueIDfromRowNum((rowNum*1)+1);
var swapItem=listGetItemfromRowNum((rowNum*1)+1);

//write out (do the swap)

listSetItemfromRowNum((rowNum*1)+1,item);
listSetUniqueIDfromRowNum((rowNum*1)+1,uniqueIDVal);

listSetItemfromRowNum((rowNum*1),swapItem);
listSetUniqueIDfromRowNum((rowNum*1),swapUniqueIDVal);

}







function listGetUniqueIDfromRowNum(rowNum)
{
	var uniqueID="uniqueID" + rowNum;
	return document.getElementById(uniqueID).value;
}


function listGetItemfromRowNum(rowNum)
{
	var itemID="itemID" + rowNum;
	return document.getElementById(itemID).innerHTML;
}


function listSetUniqueIDfromRowNum(rowNum,uniqueID)
{
	var id="uniqueID" + rowNum;
	document.getElementById(id).value=uniqueID;
}

function listSetItemfromRowNum(rowNum,item)
{
	var id="itemID" + rowNum;
	document.getElementById(id).innerHTML=item;
}
*/



function listUp(rowID,rowCount)
{
	var str="";
	var len=0;

	str="upID";
	var rowNum=rowID.substr(str.length);


	//get the uniqueID and item
var uniqueIDVal=listGetUniqueIDfromRowNum(rowNum*1);
var item=listGetItemfromRowNum(rowNum*1);
var caption=listGetItemCaption(uniqueIDVal);
var captionAlt=listGetItemCaptionAlt(uniqueIDVal);

//get previous
var swapUniqueIDVal=listGetUniqueIDfromRowNum((rowNum*1)-1);
var swapItem=listGetItemfromRowNum((rowNum*1)-1);
var swapCaption=listGetItemCaption(swapUniqueIDVal);
var swapCaptionAlt=listGetItemCaptionAlt(swapUniqueIDVal);

//write out (do the swap)

listSetItemfromRowNum((rowNum*1)-1,item);
listSetUniqueIDfromRowNum((rowNum*1)-1,uniqueIDVal);
listSetItemCaption(uniqueIDVal,caption);
listSetItemCaptionAlt(uniqueIDVal,captionAlt);

listSetItemfromRowNum((rowNum*1),swapItem);
listSetUniqueIDfromRowNum((rowNum*1),swapUniqueIDVal);
listSetItemCaption(swapUniqueIDVal,swapCaption);
listSetItemCaptionAlt(swapUniqueIDVal,swapCaptionAlt);

}


function listDown(rowID,rowCount)
{
	var str="";
	var len=0;

	str="downID";
	var rowNum=rowID.substr(str.length);


	//get the uniqueID and item
var uniqueIDVal=listGetUniqueIDfromRowNum(rowNum*1);
var item=listGetItemfromRowNum(rowNum*1);
var caption=listGetItemCaption(uniqueIDVal);
var captionAlt=listGetItemCaptionAlt(uniqueIDVal);

//get after item
var swapUniqueIDVal=listGetUniqueIDfromRowNum((rowNum*1)+1);
var swapItem=listGetItemfromRowNum((rowNum*1)+1);
var swapCaption=listGetItemCaption(swapUniqueIDVal);
var swapCaptionAlt=listGetItemCaptionAlt(swapUniqueIDVal);

//write out (do the swap)

listSetItemfromRowNum((rowNum*1),swapItem);
listSetUniqueIDfromRowNum((rowNum*1),swapUniqueIDVal);
listSetItemCaption(swapUniqueIDVal,swapCaption);
listSetItemCaptionAlt(swapUniqueIDVal,swapCaptionAlt);

listSetItemfromRowNum((rowNum*1)+1,item);
listSetUniqueIDfromRowNum((rowNum*1)+1,uniqueIDVal);
listSetItemCaption(uniqueIDVal,caption);
listSetItemCaptionAlt(uniqueIDVal,captionAlt);

}




















function listGetUniqueIDfromRowNum(rowNum)
{
	var uniqueID="uniqueID" + rowNum;
	return document.getElementById(uniqueID).value;
}


function listGetItemfromRowNum(rowNum)
{
	var itemID="itemID" + rowNum;
	return document.getElementById(itemID).innerHTML;
}

function listGetItemCaption(uniqueID)
{
	var itemID="textID" + uniqueID;
	return document.getElementById(itemID).value;
}

function listGetItemCaptionAlt(uniqueID)
{
	var itemID="textIDAlt" + uniqueID;
	return document.getElementById(itemID).value;
}


function listSetUniqueIDfromRowNum(rowNum,uniqueID)
{
	var id="uniqueID" + rowNum;
	document.getElementById(id).value=uniqueID;
}

function listSetItemfromRowNum(rowNum,item)
{
	var id="itemID" + rowNum;
	document.getElementById(id).innerHTML=item;
}

function listSetItemCaption(uniqueID,caption)
{
	var itemID="textID" + uniqueID;
	return document.getElementById(itemID).value=caption;
}

function listSetItemCaptionAlt(uniqueID,caption)
{
	var itemID="textIDAlt" + uniqueID;
	return document.getElementById(itemID).value=caption;
}














function listGetUniqueIDfromValue(rowCount,value)
{
	var i;
	var id;
	var theValue;

	for (i=1;i<=rowCount;i++)
	{
		id="uniqueID" + i;
		theValue=document.getElementById(id).value;
		if (theValue == value)
		{
			return id;
		}
	}
}

function listGetDispIDfromValue(rowCount,value)
{
	var i;
	var id;
	var theValue;

	for (i=1;i<=rowCount;i++)
	{
		id="dispID" + i;
		theValue=document.getElementById(id).value;
		if (theValue == value)
		{
			return id;
		}
	}
}






function ajPaneTabs(paneID,id)
{
	var xmlHttp;

//	var ofTotalID = "ofTotal" + iid;

	//set up new request vars and call newRequest
	var url = "/ajax.php";		//the php routine
	var params = "selector=" + "paneTabs" + "&paneID=" + paneID + "&id=" + id;

	xmlHttp=ajaxuNewRequest(url,params);

	//save params for callbacks
	xmlHttp.paneID=paneID;
	xmlHttp.id=id;

	//define function
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4 && xmlHttp.status==200)
		{
			//do what needs to be done with responseText (the result from the php call)
			document.getElementById('paneTabs').innerHTML=xmlHttp.responseText;
		}
	}

	//ok, make request
	ajaxuDoRequest(xmlHttp);
}



function ajPaneContent(paneID,id,paneInfo)
{
	var xmlHttp;

//	var ofTotalID = "ofTotal" + iid;

	//set up new request vars and call newRequest
	var url = "/ajax.php";		//the php routine
	var params = "selector=" + "pane" + "&paneID=" + paneID + "&id=" + id + "&paneInfo=" + paneInfo;

	xmlHttp=ajaxuNewRequest(url,params);

	//save params for callbacks
	xmlHttp.paneID=paneID;
	xmlHttp.id=id;

	//define function
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4 && xmlHttp.status==200)
		{
			//do what needs to be done with responseText (the result from the php call)
			document.getElementById('paneContent').innerHTML=xmlHttp.responseText;
		}
	}

	//ok, make request
	ajaxuDoRequest(xmlHttp);
}









function ajaxuNewRequest(url,params)
{
var xmlHttp;

if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }

	xmlHttp.url=url;
	xmlHttp.params=params;

	return xmlHttp;

}

function ajaxuDoRequest(xmlHttp)
{
    xmlHttp.open("POST",xmlHttp.url,true); //async
		//Send the proper header information along with the request
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", xmlHttp.params.length);
		xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(xmlHttp.params);
}


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

