function checkwhere(e) {
  // returns the mouse x and y coodinates to position the calendar
    var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	return (posx+':'+posy);
}
/* OLD function is below - the above version was rewitten by Shad, commented out by Nick 5/22/08
/*
function checkwhere(e) {
	// returns the mouse x and y coodinates to position the calendar
	if (document.layers){
		xCoord = e.x;
		yCoord = e.y;
	}
	else if (document.all){
		xCoord = event.clientX;
		yCoord = event.clientY;
	}
	else if (document.getElementById){
		xCoord = e.clientX;
		yCoord = e.clientY;
	}
	return (xCoord+':'+yCoord);
}
*/
function rePositionCal () {
  var theCoodinates=checkwhere();
  var coodinateArray=theCoodinates.split(":");
  var Xcoodinate=parseInt(coodinateArray[0])-parseInt(document.formHO.offsetX.value);
  var Ycoodinate=parseInt(coodinateArray[1])+parseInt(document.formHO.offsetY.value);
  var ifr = 
    document.all ? document.all['iframeCal'] : 
      document.getElementById('iframeCal');
  ifr.style.top=Ycoodinate+'px';
  ifr.style.left=Xcoodinate+'px';
}

function rePositionCalLeft () {
  var theCoodinates=checkwhere();
  var coodinateArray=theCoodinates.split(":");
  var Xcoodinate=parseInt(coodinateArray[0])-parseInt(document.formHO.offsetX.value);
  var Ycoodinate=parseInt(coodinateArray[1])+parseInt(document.formHO.offsetY.value);
  var ifr = 
    document.all ? document.all['iframeCal'] : 
      document.getElementById('iframeCal');
  ifr.style.top=Ycoodinate-30+'px';
  ifr.style.left=Xcoodinate-290+'px';
}
	
function rePositionCalRight () {
  var theCoodinates=checkwhere();
  var coodinateArray=theCoodinates.split(":");
  var Xcoodinate=parseInt(coodinateArray[0])-parseInt(document.formHO.offsetX.value);
  var Ycoodinate=parseInt(coodinateArray[1])+parseInt(document.formHO.offsetY.value);
  var ifr = 
    document.all ? document.all['iframeCal'] : 
      document.getElementById('iframeCal');
  ifr.style.top=Ycoodinate+20+'px';
  ifr.style.left=Xcoodinate-80+'px';
}

function checkfields() {
	 var error=0;
     var curYear = parseInt(document.formHO.currYear.value);
     var curMonth = parseInt(document.formHO.currMonth.value);
     if (document.formHO.dateLeavingMonth.value < curMonth)
        {theyear = curYear+1;}
     else if (document.formHO.dateLeavingMonth.value >= curMonth)
        {theyear = curYear;}
     if (document.formHO.dateReturningMonth.value < curMonth)
        {thedepyear = curYear+1;}
     else if (document.formHO.dateReturningMonth.value >= curMonth)
        {thedepyear = curYear;}

	 document.formHO.checkin.value=document.formHO.dateLeavingMonth.value+'/'+document.formHO.dateLeavingDay.value+'/'+theyear;
	 document.formHO.checkout.value=document.formHO.dateReturningMonth.value+'/'+document.formHO.dateReturningDay.value+'/'+thedepyear;

	 // find the site ID in the URL and set up URL params for a user bookmark
	 var siteIDstring='';
	 if (location.search != "")
	 {
		var x = location.search.substr(1).split("&")
		for (var i=0; i<x.length; i++)
		{
			var y = x[i].split("=");
			casechanged=y[0].toLowerCase();
			if (casechanged == 'siteid')
				{siteIDstring=y[1];}
		}
	 }	

	// uses its own URL, redirect accordingly
	var subDirLoc='';
	if (location.hostname=='www.travel-journeypod.com' || location.hostname=='www.travel-gocorporateaccess.com' || location.hostname=='travel-journeypod.com' || location.hostname=='travel-gocorporateaccess.com') {
		//var currLoc=left(location.href,43);
		//var currLoc2=left(location.href,39);
		var str=location.href
		var currLoc=str.substring(0,43);
		var currLoc2=str.substring(0,39);
		var currLoc3=str.substring(0,51);
		var currLoc4=str.substring(0,47);
		if (currLoc == 'http://www.travel-journeypod.com/?siteID=40' || currLoc2 == 'http://travel-journeypod.com/?siteID=40' || currLoc3 == 'http://www.travel-gocorporateaccess.com/?siteID=139' || currLoc4 == 'http://travel-gocorporateaccess.com/?siteID=139')
			{subDirLoc='hotelsearch/';}
	}
 
 	if (location.hostname=='www.corporateaccessllc.com' || location.hostname=='corporateaccessllc.com' || location.hostname=='www.gocorporateaccess.com' || location.hostname=='gocorporateaccess.com') {
		siteIDstring=139;
		subDirLoc='http://www.travel-gocorporateaccess.com/hotelsearch/';
	}

	if (siteIDstring != '41') {
		 document.formHO.action=subDirLoc+'processing.cfm?siteID='+siteIDstring+'&checkin='+document.formHO.checkin.value+'&checkout='+document.formHO.checkout.value+'&adults='+document.formHO.adults.value+'&children='+document.formHO.children.value+'&rooms='+document.formHO.rooms.value;
	}
	document.formHO.submit();
}

function show(divID) {
		if (document.layers) {
			window.document[divID].visibility = 'show';
			window.document[divID].display = 'inline';
		}
		else if (document.all) {
			document.all[divID].style.visibility = 'visible';
			document.all[divID].style.display = 'inline';
		}
		else if (document.getElementById) {
			document.getElementById(divID).style.visibility = 'visible';
			document.getElementById(divID).style.display = 'inline';
		}
}

function hide(divID) {
		if (document.layers) {
			window.document[divID].visibility = 'hide';
			window.document[divID].display = 'none';
		}
		else if (document.all) {
			document.all[divID].style.visibility = 'hidden';
			document.all[divID].style.display = 'none';
		}
		else if (document.getElementById) {
			document.getElementById(divID).style.visibility = 'hidden';
			document.getElementById(divID).style.display = 'none';
		}
}