function hideWaitScreen() {
	var oWait = null, elemWait = null;
	if (document.getElementById) { // IE 5+/NS6
		elemWait = document.getElementById('waitScreen');
		if (elemWait != null) {
			oWait = elemWait.style;
		}
	} else if (document.layers) {
		oWait = document.layers['waitScreen'];
	} else if (document.all) {
		elemWait = document.all['waitScreen'];
		if (elemWait != null) {
			oWait = elemWait.style;
		}
	}
	if (oWait != null) {
		oWait.visibility = 'hidden';
	}
}


function popupBook(url) {
	var w=window.open(url, "myWindow", 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=503,height=250');
	w.focus();
}


function popUp(url) {
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=500,height=450');
	self.name = "mainWin";
}

function openNewWindow(fileName,windowName,theWidth,theHeight) {
	if (windowName == "newWindow") {
		 windowName = new String(Math.round(Math.random() * 100000));
	}
	window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

function openMapWindow(mapUrl,windowName,width,height) {
	window.open(mapUrl,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height)
}
function openMapWithPropInfo(mapUrl,propInfo,propInfoString,windowName,width,height) {
	var newUrl;
	if (isNN3 || isNN4 || isNN6) {
		newUrl = mapUrl + propInfo + propInfoString;
	} else {
		newUrl = mapUrl + propInfo + escape(propInfoString);
	}	
	window.open(newUrl,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+width+",height="+height)	
}

function openNewWindowEscape(fileName,windowName,theWidth,theHeight,to) {
	if (windowName == "newWindow") {
		 windowName = new String(Math.round(Math.random() * 100000));
	}
	var encoded = escape(to);
	encoded = fileName + encoded;
	window.open(encoded,windowName,"toolbar=1,location=1,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

function openNewWindowReturnFalse(fileName,windowName,theWidth,theHeight) {
	if (windowName == "newWindow") {
		 windowName = new String(Math.round(Math.random() * 100000));
	}
	var w = window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight);
	return false;
}

function openPopup(url, to, windowName, theWidth, theHeight) {
	var newURL;
	if (isNN3 || isNN4) {
		newURL = url + to;
	} else {
		newURL = url + escape(to);
	}
	window.open(newURL,windowName,"toolbar=1,location=1,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight)
}

function openPopup3(url, name1, param1, name2, param2, name3, param3, windowName, theWidth, theHeight) {
	var wSettings = 'toolbar=1,location=1,directories=0,status=0,menubar=1,scrollbars=1,resizable=1';
	openPopupWin(url, name1, param1, name2, param2, name3, param3, windowName, wSettings, theWidth, theHeight);
}

function openMapNetscape(url, name1, param1, name2, param2, name3, param3, windowName, theWidth, theHeight) {
	var wSettings = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1';
	openPopupWin(url, name1, param1, name2, param2, name3, param3, windowName, wSettings, theWidth, theHeight);
}

function openPopupWin(url, name1, param1, name2, param2, name3, param3, windowName, windowSettings, theWidth, theHeight) {
	var newURL;
	windowSettings += ',width='+theWidth+',height='+theHeight;
	if (isNN3 || isNN4) {
		newURL = url + name1 + param1 + name2 + param2 + name3 + param3;
	} else {
		newURL = url + name1 + escape(param1) + name2 + escape(param2) + name3 + escape(param3);
	}
	window.open(newURL,windowName,windowSettings);
}

function open_calendar(strType) {
	document.myform.inout.value = strType;
	new_window=window.open("calendar.htm","","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=yes,width=300,height=200");
}

function popup(url, name, width, height) {
	settings="toolbar=yes,location=yes,directories=yes,"+"status=no,menubar=no,scrollbars=yes,"+"resizable=yes,width="+width+",height="+height;
	MyNewWindow=window.open("http://"+url,name,settings);
}

function getMousePos(capEvent) {
	if (document.layers) {
		xPos=capEvent.screenX +30
		yPos=capEvent.screenY +10
	} else if (window.event) {
		xPos=window.event.clientX +30
		yPos=window.event.clientY +10
	} else {
		xPos=0
		yPos=0
	}
}
function openPopWindow(pageLocation,winName, pgW, pgH) {
	winStats='toolbar=no,location=no,directories=no,menubar=no,';
	winStats+='scrollbars=no,width=' + pgW + ',height=' + pgH ;

	if (navigator.appName.indexOf("Microsoft")>=0) {
		winStats+=',left=' + (xPos) + ',top=' + (-200 + yPos);
	} else {
		winStats+=',screenX='+ (xPos) + ',screenY=' + (yPos - 300);
	}

	floater=window.open(pageLocation,winName,winStats);
	if (floater!=null) { if (floater.focus) { floater.focus() } };
}

function openCalWindow(thisPage, strType, CalLocation) {
	document.myform.inout.value = strType;

	// Switch to JSP, this is a catch-all for old code.  Should be removed eventually
	if (thisPage=='popcal.html') { thisPage = 'popcal.html'; }

	if ( strType == 'out') {
		thisPage = thisPage + '?' + new String(document.myform.COMonth.value -1) + ',' + document.myform.COYear.value
	} else {
		thisPage = thisPage + '?' + new String(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value -1) + ',' + document.myform.CIYear.value
	}

	winStats='toolbar=no,location=no,directories=no,menubar=no,'

	//IE/NS
	if (navigator.appName.indexOf("Microsoft")>=0) {winStats+='scrollbars=no,width=160,height=180'}
	else {winStats+='scrollbars=no,width=160,height=170'}

	//IE leftnav area
	if (navigator.appName.indexOf("Microsoft")>=0) {
			if(CalLocation == 'leftNavArea')
				{winStats+=',left=' + (xPos) + ',top=' + (yPos)
				 }//IE content area
			else if (CalLocation == 'contentArea')
				{winStats+=',left=' + (-200 + xPos) + ',top=' + (-160 + yPos)
				}
    } else {
		//Netscape leftnav area
		if(CalLocation == 'leftNavArea')
				{winStats+=',screenX='+ (xPos) + ',screenY=' + (yPos)
				 }//Netscape content area
			else if (CalLocation == 'contentArea')
				{winStats+=',screenX='+ (-150 + xPos) + ',screenY=' + (-230 + yPos)
				}
    }
	floater=window.open(thisPage,"myform",winStats)
	if (floater!=null) { if (floater.focus) { floater.focus() } };
}

function openWindow(thisPage, strType) {
	document.myform.inout.value = strType;
	thisPage = thisPage + '?' + new String(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value -1) + ',' + document.myform.CIYear.value

	if ( strType == 'out') {
		thisPage = thisPage + '?' + new String(document.myform.COMonth.value -1) + ',' + document.myform.COYear.value
	}
	winStats='toolbar=no,location=no,directories=no,menubar=no,'
	winStats+='scrollbars=no,width=160,height=140'
	if (navigator.appName.indexOf("Microsoft")>=0) {
     	  winStats+=',left=' + (xPos) + ',top=' + (yPos)
	} else {
	winStats+=',screenX='+ (xPos) + ',screenY=' + (yPos)
	}
	floater=window.open(thisPage,"myform",winStats)
	if (floater!=null) { if (floater.focus) { floater.focus() } };

}
function initializeDates()
{
	var thisdate = new Date();
	var thismonth = thisdate.getMonth();
	var thisday = thisdate.getDate();
	var thisyear = thisdate.getFullYear();

	document.myform.CIMonth.value = thismonth+1;
	document.myform.CIYear.value = thisyear;
	document.myform.CIDay.value = thisday+7;

	document.myform.COMonth.value = thismonth+1
	document.myform.COYear.value = thisyear;
	document.myform.CODay.value = thisday+7+1;
}

function doSelectOptions(theValue,theField) {

	var objForm = document.myform;
	for (i=0; i< objForm[theField].options.length; i++)
		if (objForm[theField].options[i].value == theValue) {
			objForm[theField].options[i].selected = true;
		}
}

function updateBothDates(theForm)
{
	var worker	= new Date();
	calcBothDates(theForm, (worker.getYear()%1900+1900), worker.getMonth()+1, worker.getDate());
}
function calcBothDates(theForm, ty, tm, td)
{
	calcBothDates2(theForm, ty, tm, td, 2);
}

function calcBothDates2(theForm, ty, tm, td, daysInAdvance)
{
	var today	= new Date((ty%1900+1900), tm-1, td, 0,0,0);
	var inDate	= new Date((ty%1900+1900), parseInt(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value)-1, document.myform.CIDay[document.myform.CIDay.selectedIndex].value, 0,0,0);
	
	//When calculating inDate value for next year months, the value 'ty' is not representing the 
	//forth coming year but the current year.
	//Since in our site we will show only current month and the months after.. 	
	if(inDate.getMonth() < today.getMonth()){
		ty = ty+1;
		inDate = new Date((ty%1900+1900), parseInt(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value)-1, document.myform.CIDay[document.myform.CIDay.selectedIndex].value, 0,0,0);
	}
	
	var outDate	= new Date((ty%1900+1900), parseInt(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value)-1, parseInt(document.myform.CIDay[document.myform.CIDay.selectedIndex].value)+daysInAdvance, 0,0,0);

	if (inDate.getTime()  < today.getTime()) { // Crossed the newyear boundary
		inDate.setYear((today.getYear()%1900+1900)+1);
		outDate.setYear((today.getYear()%1900+1900)+1);
	}

	theForm.CIYear.value	= (inDate.getYear()%1900) + 1900;
	doSelectOptions(inDate.getMonth()+1, 'CIMonth');
	doSelectOptions(inDate.getDate(), 'CIDay');

	theForm.COYear.value	= (outDate.getYear()%1900) + 1900;
	doSelectOptions(outDate.getMonth()+1, 'COMonth');
	doSelectOptions(outDate.getDate(), 'CODay');
}

function updateCIDate(theForm)
{
	var worker	= new Date();
	calcCIDate(theForm, (worker.getYear()%1900+1900), worker.getMonth()+1, worker.getDate());
}
function calcCIDate(theForm, ty, tm, td)
{
	var today	= new Date((ty%1900+1900), tm-1, td, 0,0,0);
	var inDate	= new Date((ty%1900+1900), parseInt(document.myform.CIMonth[document.myform.CIMonth.selectedIndex].value)-1, document.myform.CIDay[document.myform.CIDay.selectedIndex].value, 0,0,0);

	if (inDate.getTime()  < today.getTime()) { // Crossed the newyear boundary
		inDate. setYear((today.getYear()%1900+1900)+1);
	}

	theForm.CIYear.value	= (inDate.getYear()%1900) + 1900;
	doSelectOptions(inDate.getMonth()+1, 'CIMonth');
	doSelectOptions(inDate.getDate(), 'CIDay');
}

function updateCODate(theForm)
{
	var worker	= new Date();
	calcCODate(theForm, (worker.getYear()%1900+1900), worker.getMonth()+1, worker.getDate());
}
function calcCODate(theForm, ty, tm, td)
{
	var today	= new Date((ty%1900+1900), tm-1, td, 0,0,0);
	var outDate	= new Date((ty%1900+1900), parseInt(document.myform.COMonth[document.myform.COMonth.selectedIndex].value)-1, parseInt(document.myform.CODay[document.myform.CODay.selectedIndex].value), 0,0,0);

	if( (parseInt(theForm.CIYear.value)%1900) >(today.getYear()%1900) || (outDate.getTime() < today.getTime()) ){
		outDate	= new Date((ty%1900+1900)+1, parseInt(document.myform.COMonth[document.myform.COMonth.selectedIndex].value)-1, parseInt(document.myform.CODay[document.myform.CODay.selectedIndex].value), 0,0,0);
	}

	theForm.COYear.value	= (outDate.getYear()%1900) + 1900;
	doSelectOptions(outDate.getMonth()+1, 'COMonth');
	doSelectOptions(outDate.getDate(), 'CODay');
}

function searchDebug() { alert('CIYear='+myform.CIYear.value+', COYear='+myform.COYear.value); }
function changeRezDebug() { alert('CIYear='+myform.CIYear.value+', COYear='+myform.COYear.value); }
function debugRefineLeftnav() { alert('CIYear='+myform.CIYear.value+', COYear='+myform.COYear.value); }

/* function focusOnSecTwo(destNum) {
    if (isIE) {
	if (document.forms.myform.usertypedcity.value != "") {
	    document.forms.myform.destination[0].checked = true;
	} else {
	    if (destNum > 1) {
		destNumAry = new Array(
		    2, 5, 8, 11, 14, 
		    3, 6, 9, 12, 15, 
		    4, 7, 10, 13, 16);
		eval('document.forms.myform.destination[' + destNumAry[destNum] + '].checked = true;');
	    }
	}
	window.setTimeout('document.forms.myform.CIMonth.focus()', 200);
    } else {
	document.forms.myform.CIMonth.focus();
    }
}


function selectUserTyped() {
    if (isIE) {
	if (document.forms.myform.usertypedcity.value != "") {
	    document.forms.myform.destination[0].checked = true;
	}
    }
}
*/