var MINUTE = 60 * 1000;
var HOUR = MINUTE * 60;
var DAY = HOUR * 24;
var WEEK = DAY * 7;

function openWindow(theUrl,theHeight,theWidth,title,theTop,theLeft,scroll,status,resizable) {
	if (!theLeft)
		theLeft = parseInt((window.screen.width - theWidth)/2);
	if (!theTop)
		theTop = parseInt((window.screen.height - theHeight)/2);
	if (!title)
		title = "popUp";
	scrollBar = (scroll) ? ",scrollbars=yes" : "";
	statusBar = (status) ? ",statusbar=yes" : "";
	resizable = (resizable) ? ",resizable=yes" : "";
	theParams = "height="+theHeight+",width="+theWidth+",left="+theLeft+",top="+theTop + scrollBar +statusBar +resizable;
	newWin = window.open(theUrl,title,theParams);
	newWin.focus();
}
function openRates(rateID,roomID,roomName) {
	openWindow("rates.php?rateID="+rateID+"&roomID="+roomID+"&roomName="+roomName,500,600,"rates",false,false,true,false,false)
}
function openRoomDetail(url) {
	openWindow(url,500,600,"room",false,false,true,false,false)
}
function closeWindow() {
	if (window.opener)
		window.opener.focus();
	window.close();
}
function hideLayer(theLayer) {
	document.getElementById(theLayer).style.display = "none";
}
function showLayer(theLayer) {
	document.getElementById(theLayer).style.display = "";
}
function trim(theString,trimEnd) {
	if (trimEnd != "end") {
		while (theString.substr(0,1) == " ")
			theString = theString.substring(1,theString.length)
	}
	if (trimEnd != "start")	{
		while (theString.substr(theString.length-1,1) == " ")
			theString = theString.substring(0,theString.length-1)
	}
	return theString;
}
function stripImg(imgObj) {
	if (imgObj.src.indexOf("_") != -1 && imgObj.src.indexOf("_sel") == -1)
		imgObj.src = imgObj.src.substring(0,imgObj.src.indexOf("_")) + ".gif";
}
function addImg(imgObj,tag) {
	if (imgObj.src.indexOf("_sel") == -1) {
		stripImg(imgObj)
		imgObj.src = imgObj.src.substring(0,imgObj.src.indexOf(".gif")) + tag + ".gif";
	}
}
function stripClass(obj,clearSel) {
	if (obj.className.indexOf("_") != -1 && obj.className.indexOf("_so") == -1) {
		if (obj.className.indexOf("_sel") == -1 || clearSel)
			obj.className = obj.className.substring(0,obj.className.indexOf("_"));
	}
}
function addClass(obj,tag) {
	if (obj.className.indexOf("_sel") == -1 && obj.className.indexOf("_so") == -1) {
		stripClass(obj)
		obj.className += tag;
	}
}
function menuOver(obj) {
	addImg(obj.firstChild,"_high");
}
function menuOut(obj) {
	stripImg(obj.firstChild);
}
function doMenu(page) {
	document.location = page;
}
function setSelected(obj,val) {
	for (i=0;i<obj.options.length;i++) {
		if (obj.options[i].value == val)
			obj.options[i].selected = true;
	}
}
function showInfo(msg,error) {
	document.getElementById("infoLayer").innerHTML = msg;
}