function departureFromHit(baseURL,value)
{
	var url=baseURL + '&startDeparture=' + value;
	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)
{
	ajPaneTabs(paneID,id);
	ajPaneContent(paneID,id,paneInfo);
}

function paneClick(paneID,id,paneInfo)
{
	ajPaneTabs(paneID,id);
	ajPaneContent(paneID,id,paneInfo);
	var url='page.php?menuMain=' + 'listing' + '&id=' + id + '&paneID=' + paneID;
	window.location=url;
}

function pageLoad()
{
	//do search date widgets
//	createDateWidget('searchWidget','sEnd');

//	createDateWidget('testform','testinput');
}


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 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 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 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 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 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 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)
//changes property id and redraws listing
{
	urlStr='page.php?menuMain=adminRates&id=' + id + '&rateID=' + rateID;
	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)
{
	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 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);
}

