function GetRatePlan()
{
	var a = eval("document.thisForm.bSelectSpecial");
	if (a.selectedIndex==0)
	{ alert("View Special Rate Detail Information\n\nPlease Select Special Rate First.");}
	else
	{
		OpenIt("/Cafes/Reservation/Available/RatePage.asp?RC="+a.options[a.selectedIndex].value);
	}
	return;
}

function GetRoomType()
{
	var a = eval("document.thisForm.SelectType");
	if (a.selectedIndex==0)
	{ alert("View Bed Type Detail Information\n\nPlease Select Bed Type First.");}
	else
	{
		OpenIt("/Cafes/Reservation/Available/RoomPage.asp?AC="+a.options[a.selectedIndex].value);
	}
	return;
}

function GetAlert()
{
	alert("Please Login First");
	return;
}
function ChkAvail(ServeHTTPS)
{
	ProcReq();
	strParam = GetParam();
	OpenWindow(ServeHTTPS+"/Cafes/Reservation/Available/CheckAll.asp?"+strParam,0);
}

function GetAccount(ServeHTTPS)
{
	strParam = GetParam();
	OpenWindow(ServeHTTPS+"/Cafes/Reservation/Available/ManageAccountEdit.asp?"+strParam,0);
}

function GetReservation(ServeHTTPS)
{
	strParam = GetParam();
	OpenWindow(ServeHTTPS+"/Cafes/Reservation/Available/ManageReservation.asp?"+strParam,0);
}

function GetParam()
{
	var strRateId = "T";
	var strRateCd = "";
	var strPackCd = "";
	var strPromoCd = "";
	var strCorpCd = "";
	var strAAA = "";
	
	strStartDate = document.thisForm.btextStartDate.value;
	strEndDate = document.thisForm.btextEndDate.value;

	var a = eval("document.thisForm.SelectAdult");
	var c = eval("document.thisForm.SelectChild");
	var r = eval("document.thisForm.SelectRoom");
	
	strAdult = a.options[a.selectedIndex].value;
	strChild = c.options[c.selectedIndex].value;
	strRoom = r.options[r.selectedIndex].value;
	
	var y = eval("document.thisForm.SelectType");
	strType = y.options[y.selectedIndex].value;

	strPromoCd = document.thisForm.textPackCd.value;
	if (strPromoCd!="" && strPromoCd!=null)
	{
		strRateId = "T";
		strRateCd = strPromoCd;
	}

	if (document.thisForm.textSide.value==1)
	{
		strCorpCd = document.thisForm.textCorpCd.value;
		if (strCorpCd!="" && strCorpCd!=null)
		{
			strRateId = "C";
			strRateCd = strCorpCd;
		}
		var x = eval("document.thisForm.bSelectSpecial");
		strAAA = x.options[x.selectedIndex].value;
		if (strAAA!="" && strAAA!=null)
		{
			strRateId = "T";
			strRateCd = strAAA;
		}
	}
	else
	{
		var x = eval("document.thisForm.bSelectPackage");
		strPackCd = x.options[x.selectedIndex].value;
		if (x.selectedIndex>0)
		{
			strRateId = "T";
			strRateCd = strPackCd;
		}
		
	}
	strSide = document.thisForm.textSide.value;
	
	strMsg = "xSD="+strStartDate+"&xED="+strEndDate+"&xAT="+strAdult+"&xCD="+strChild+"&xRM="+strRoom+"&xRI="+strRateId+"&xRC="+strRateCd+"&SIDE="+strSide;
	strMsg = strMsg +"&xPO="+strPromoCd+"&xCP="+strCorpCd+"&xAA="+strAAA+"&xPA="+strPackCd+"&xRT="+strType;
	return strMsg;
}

function ClickCheck()
{
	if (document.thisForm.textHeight.value==9)
	{return;}
	document.thisForm.textSide.value = 1;
	setElementProperty('CheckOn', 'display', 'block');
	setElementProperty('CheckOff', 'display', 'none');

	setElementProperty('PackOn', 'display', 'none');
	setElementProperty('PackOff', 'display', 'block');
	//setElementProperty('MyPromo', 'display', 'block');
	
	setElementProperty('List1', 'display', 'none');

	if (document.thisForm.textHeight.value==0)
	{
		setElementProperty('Book', 'display', 'block');
		setElementProperty('Short1', 'display', 'block');
		setElementProperty('MidSect', 'display', 'none');
		setElementProperty('long1', 'display', 'none');
		setElementProperty('long2', 'display', 'none');
	}
	else
	{
		setElementProperty('Book', 'display', 'none');
		setElementProperty('LList1', 'display', 'block');
		setElementProperty('Short1', 'display', 'none');
		setElementProperty('MidSect', 'display', 'block');
		setElementProperty('long1', 'display', 'block');
		setElementProperty('long2', 'display', 'none');
	}
}

function ClickPack()
{
	if (document.thisForm.textHeight.value==9)
	{return;}
	document.thisForm.textSide.value = 2;
	setElementProperty('PackOn', 'display', 'block');
	setElementProperty('PackOff', 'display', 'none');

	setElementProperty('CheckOn', 'display', 'none');
	setElementProperty('CheckOff', 'display', 'block');
	
	setElementProperty('List1', 'display', 'block');
	setElementProperty('Book', 'display', 'none');
	//setElementProperty('MyPromo', 'display', 'none');

	if (document.thisForm.textHeight.value==0)
	{
		setElementProperty('Short1', 'display', 'block');
		setElementProperty('MidSect', 'display', 'none');
		setElementProperty('long1', 'display', 'none');
		setElementProperty('long2', 'display', 'none');
	}
	else
	{
		setElementProperty('LList1', 'display', 'block');
		setElementProperty('Short1', 'display', 'none');
		setElementProperty('MidSect', 'display', 'block');
		setElementProperty('long1', 'display', 'none');
		setElementProperty('long2', 'display', 'block');
	}
}

function ExpandBook(strSide)
{
	FocusExt();
	if (strSide==2)
	{ClickPack();}
}

function FocusExt()
{
	if (document.thisForm.textHeight.value==9)
	{return;}
	if (document.thisForm.textHeight.value==0)
	{
		setElementProperty('MidSect', 'display', 'block');
		if (document.thisForm.textSide.value==1)
		{
			setElementProperty('Book', 'display', 'none');
			setElementProperty('LList1', 'display', 'block');
			setElementProperty('Short1', 'display', 'none');
			setElementProperty('MidSect', 'display', 'block');
			setElementProperty('long2', 'display', 'none');
			setElementProperty('long1', 'display', 'block');
		}
		else
		{
			setElementProperty('Book', 'display', 'none');
			setElementProperty('Short1', 'display', 'none');
			setElementProperty('MidSect', 'display', 'block');
			setElementProperty('long1', 'display', 'none');
			setElementProperty('long2', 'display', 'block');
		}
		setElementProperty('long3', 'display', 'block');
	}
	document.thisForm.textHeight.value=1;
}

function setElementProperty(p_elm, p_property, p_value){
	var elm = null;
	if(typeof(p_elm) == "object"){
		elm = p_elm;
	} else {
		elm = document.getElementById(p_elm);
	}
	if((elm != null) && (elm.style != null)){
		elm = elm.style;
		elm[ p_property ] = p_value;
	}
}
function ChkbtextStartDate()
{ 
	if (!isValidDate(document.thisForm.btextStartDate,document.thisForm.btextStartDate.value))
		return;
	if (!Chk2Date(document.thisForm.btextstart.value,document.thisForm.btextStartDate.value))
	{
		alert("Date should be greater or equal to "+document.thisForm.btextstart.value);
		document.thisForm.btextStartDate.value = document.thisForm.btextend.value;
		document.thisForm.btextStartDate.focus();
		return;
	}

    objDate = new Date(document.thisForm.btextStartDate.value);
    strYear = objDate.getYear();
    if (parseInt(strYear)<99)
    { strYear = 2000 + parseInt(strYear);}
    if (parseInt(strYear)<1000)
    { strYear = 1900 + parseInt(strYear);}
	
	document.thisForm.btextStartDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;

    objDate = new Date(document.thisForm.btextEndDate.value);
    strYear = objDate.getYear();
    if (parseInt(strYear)<99)
    { strYear = 2000 + parseInt(strYear);}
    if (parseInt(strYear)<1000)
    { strYear = 1900 + parseInt(strYear);}
	document.thisForm.btextEndDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;

	if (!ChkEDate(document.thisForm.btextStartDate.value,document.thisForm.btextEndDate.value))
	{
	    objDate = new Date(document.thisForm.btextStartDate.value);
        objDate.setDate(objDate.getDate()+1);
        strYear = objDate.getYear();
        if (parseInt(strYear)<99)
        { strYear = 2000 + parseInt(strYear);}
		if (parseInt(strYear)<1000)
	    { strYear = 1900 + parseInt(strYear);}
		document.thisForm.btextEndDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;
		document.thisForm.btextEndDate.focus();
		return;
	}
}

function ChkbtextEndDate()
{
	if (!isValidDate(document.thisForm.btextEndDate,document.thisForm.btextEndDate.value))
		return;
	if (!Chk2Date(document.thisForm.btextend.value,document.thisForm.btextEndDate.value))
	{
		alert("Date should be greater or equal to "+document.thisForm.btextend.value);
		document.thisForm.btextEndDate.value = document.thisForm.btextend.value;
		document.thisForm.btextEndDate.focus();
		return;
	}
	
    objDate = new Date(document.thisForm.btextStartDate.value);
    strYear = objDate.getYear();
    if (parseInt(strYear)<99)
    { strYear = 2000 + parseInt(strYear);}
    if (parseInt(strYear)<1000)
    { strYear = 1900 + parseInt(strYear);}
	document.thisForm.btextStartDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;

    objDate = new Date(document.thisForm.btextEndDate.value);
    strYear = objDate.getYear();
    if (parseInt(strYear)<99)
    { strYear = 2000 + parseInt(strYear);}
    if (parseInt(strYear)<1000)
    { strYear = 1900 + parseInt(strYear);}
	document.thisForm.btextEndDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;

	if (!ChkEDate(document.thisForm.btextStartDate.value,document.thisForm.btextEndDate.value))
	{
	    objDate = new Date(document.thisForm.btextEndDate.value);
        objDate.setDate(objDate.getDate()-1);
        strYear = objDate.getYear();
        if (parseInt(strYear)<99)
        { strYear = 2000 + parseInt(strYear);}
		if (parseInt(strYear)<1000)
	    { strYear = 1900 + parseInt(strYear);}
		document.thisForm.btextStartDate.value = (objDate.getMonth()+1)+"/"+objDate.getDate()+"/"+strYear;
		document.thisForm.btextStartDate.focus();
		return;
	}
}
function GetCode()
{
	if (document.thisForm.textSide.value==1)
	{
		objPackCd	= eval("document.thisForm.textPackCd");
		objCorpCd	= eval("document.thisForm.textCorpCd");

		if (objPackCd.value!="" && objPackCd.value!= null)
		{ return objPackCd.value; }
		if (objCorpCd.value!="" && objCorpCd.value!= null)
		{ return objCorpCd.value; }
	}
	else
	{
		objPackage	= eval("document.thisForm.bSelectPackage");
		objPackCd	= eval("document.thisForm.textPackCd");

		strPackage	= objPackage.options[objPackage.selectedIndex].value;
		if (strPackage!="" && strPackage!= null)
		{ return strPackage; }
		if (objPackCd.value!="" && objPackCd.value!= null)
		{ return objPackCd.value; }
	}
	return "0";
}

function GetCalStart()
{
	FocusExt();
	if (document.thisForm.textSide.value==1)
	{
		strVal = GetCode();
		if (strVal=="0") 
		{
			OpenIt("/Cafes/Reservation/Available/AllCalendar.asp?F=btextStartDate&Date="+document.thisForm.btextStartDate.value+"&MIN="+document.thisForm.btextstart.value+"&Desc=Check-in");
		}
		else
		{
			OpenIt("/Cafes/Reservation/Available/PackCalendar.asp?F=btextStartDate&Date="+document.thisForm.btextStartDate.value+"&MIN="+document.thisForm.btextstart.value+"&Desc=Check-in&GAL="+strVal);
		}
		
	}
	else
	{
		strVal = GetCode();
		if (strVal=="0") 
		{
			alert("Select a Package or Enter a Promo Code");
			return;
		}
		
		OpenIt("/Cafes/Reservation/Available/PackCalendar.asp?F=btextStartDate&Date="+document.thisForm.btextStartDate.value+"&MIN="+document.thisForm.btextstart.value+"&Desc=Check-in&GAL="+strVal);
	}
}

function GetCalEnd()
{
	FocusExt();
	if (document.thisForm.textSide.value==1)
	{
		strVal = GetCode();
		if (strVal=="0") 
		{
			OpenIt("/Cafes/Reservation/Available/AllCalendar.asp?F=btextEndDate&Date="+document.thisForm.btextEndDate.value+"&MIN="+document.thisForm.btextStartDate.value+"&Desc=Check-out");
		}
		else
		{
			OpenIt("/Cafes/Reservation/Available/PackCalendar.asp?F=btextEndDate&Date="+document.thisForm.btextEndDate.value+"&MIN="+document.thisForm.btextStartDate.value+"&Desc=Check-out&GAL="+strVal);
		}
		
	}
	else
	{
		strVal = GetCode();
		if (strVal=="0") 
		{
			alert("Select a Package or Enter a Promo Code");
			return;
		}
		
		OpenIt("/Cafes/Reservation/Available/PackCalendar.asp?F=btextEndDate&Date="+document.thisForm.btextEndDate.value+"&MIN="+document.thisForm.btextStartDate.value+"&Desc=Check-out&GAL="+strVal);
	}
}

function Login() 
{
	if (document.thisForm.textHeight.value==0)
	{
		objLogin = eval("document.thisForm.textLogin0");
		objPass = eval("document.thisForm.textPassword0");
	}
	else
	{
		objLogin = eval("document.thisForm.textLogin"+document.thisForm.textSide.value);
		objPass = eval("document.thisForm.textPassword"+document.thisForm.textSide.value);
	}

	if (!ValidDesc(objLogin,"Login"))
		return;
		
	if (!ValidDesc(objPass,"Password"))
		return;
	
	if (!ValidSize(objPass,"Password",6))
		return;

	OpenIt("/Cafes/Home/Login/LoginPage.asp?LOG="+objLogin.value+"&PASS="+objPass.value);
}

function SendMail()
{
	if (document.thisForm.textHeight.value==0)
		{objLogin = eval("document.thisForm.textLogin0");}
	else
		{objLogin = eval("document.thisForm.textLogin"+document.thisForm.textSide.value);}
	if (!ValidDesc(objLogin,"Login"))
		return;

	OpenIt("/Cafes/Reservation/Account/EmailPage.asp?LID="+objLogin.value);
}

function ChktextCorpCd()
{
	if (document.thisForm.textCorpCd.value == "" || document.thisForm.textCorpCd.value == null)
	{
		if (document.thisForm.textPackCd.value == "" || document.thisForm.textPackCd.value == null)
		{
			var xIndex = 0;
			var x = document.thisForm.bSelectSpecial;
			if (x.selectedIndex==0)
			{
				document.thisForm.textRateCd.value = "";
				document.thisForm.textRateId.value = "T";
			}
		}
		return;
	}
	
	document.thisForm.textPackCd.value = "";

	document.thisForm.textCorpCd.value = document.thisForm.textCorpCd.value.toUpperCase();

    co = RSExecute("/Cafes/Reservation/Available/CheckLogin.asp","chkcft",document.thisForm.textCorpCd.value);
	if (co.return_value == 0)
    {
		alert("Invalid Corporate ID\nPlease Re-Enter");
		document.thisForm.textCorpCd.value = "";
		document.thisForm.textCorpCd.focus();
		return;
	}

//	document.thisForm.textCorpId.value = co.return_value;

//	document.thisForm.textRateCd.value = document.thisForm.textCorpCd.value;
//	document.thisForm.textRateId.value = "C";
}

function ChktextPackCd()
{
	objPackCd	= eval("document.thisForm.textPackCd");
	if (objPackCd.value=="" || objPackCd.value==null)
	{
	/*
		if (document.thisForm.textSide.value==1)
		{
			if (document.thisForm.textCorpCd.value == "" || document.thisForm.textCorpCd.value == null)
			{
				var xIndex = 0;
				var x = document.thisForm.bSelectSpecial;
				if (x.selectedIndex==0)
				{
					document.thisForm.textRateCd.value = objPackCd.value;
					document.thisForm.textRateId.value = "T";
				}
			}
		}
		else
		{
			var xIndex = 0;
			var x = document.thisForm.bSelectPackage;
			if (x.selectedIndex==0)
			{
				document.thisForm.textRateCd.value = objPackCd.value;
				document.thisForm.textRateId.value = "T";
			}
		}
	*/
		return;
	}
	else
	{
		objPackCd.value = objPackCd.value.toUpperCase();
		strPackCd = objPackCd.value;
		
		co = RSExecute("/Cafes/Reservation/Available/CheckLogin.asp","chkrate",strPackCd);
		if (co.return_value == 0)
		{
			alert("Invalid Promotional Code: "+strPackCd+"\nPlease Re-Enter");
			objPackCd.value = "";
			objPackCd.focus();
			return;
		}
	}
	if (document.thisForm.textSide.value==1)
	{
		document.thisForm.textCorpCd.value = "";
		var x = document.thisForm.bSelectSpecial;
		x.selectedIndex = 0;
	}
	else
	{
		var xIndex = 0;
		var x = document.thisForm.bSelectPackage;

		for (i=0; i < x.length; i++)
		{
			strVal  = x.options[i].value;
			if (strVal == strPackCd)
			{ xIndex = i;}

		}
		x.selectedIndex = xIndex;
		document.thisForm.textRateCd.value = strPackCd;
	}
//	document.thisForm.textRateCd.value = objPackCd.value;
//	document.thisForm.textRateId.value = "T";
}

function ChgPack()
{
	objPackage	= eval("document.thisForm.bSelectPackage");
	objPackCd	= eval("document.thisForm.textPackCd"+document.thisForm.textSide.value);

	var x = document.thisForm.bSelectPackage;
	if (x.selectedIndex>0)
	{document.thisForm.textPackCd.value="";}

//	strPackage	= objPackage.options[objPackage.selectedIndex].value;
//	document.thisForm.textRateCd.value = strPackage;
//	document.thisForm.textRateId.value = "T";
}

function ProcReq()
{
	setElementProperty('ChkRateOn', 'display', 'none');
	setElementProperty('ChkRateOff', 'display', 'block');

	setElementProperty('SearchOn1', 'display', 'none');
	setElementProperty('SearchOff1', 'display', 'block');
	setElementProperty('SearchOn2', 'display', 'none');
	setElementProperty('SearchOff2', 'display', 'block');
	
	document.thisForm.textHeight.value=9;
}

function ChangeList(objChanged,objToChange,objRoom)
{
	objListRoom		= eval("document.thisForm."+objRoom);
	objListChanged	= eval("document.thisForm."+objChanged);
	objListToChange = eval("document.thisForm."+objToChange);

	strRoom = objListRoom.options[objListRoom.selectedIndex].value;
	strChanged = objListChanged.options[objListChanged.selectedIndex].value;
	strToChange = objListToChange.options[objListToChange.selectedIndex].value;
	strLoc = objListToChange.selectedIndex;
	
	objListToChange.length = 0;
	//objListToChange.options[objListToChange.length] = new Option(0, 0, false, false);
	
	strCount = Math.floor((strRoom*4)-parseInt(strChanged));
	
	for (i=1; i<=strCount; i++)
	{
		if (i==strToChange)
			objListToChange.options[objListToChange.length] = new Option(i, i, false, true);
		else
			objListToChange.options[objListToChange.length] = new Option(i, i, false, false);
		
	}
	objListToChange.selectedIndex = strLoc;
}

function ChangeLista(objChanged,objToChange,objRoom)
{
	objListRoom		= eval("document.thisForm."+objRoom);
	objListChanged	= eval("document.thisForm."+objChanged);
	objListToChange = eval("document.thisForm."+objToChange);

	strRoom = objListRoom.options[objListRoom.selectedIndex].value;
	strChanged = objListChanged.options[objListChanged.selectedIndex].value;
	strToChange = objListToChange.options[objListToChange.selectedIndex].value;
	strLoc = objListToChange.selectedIndex;
	
	objListToChange.length = 0;
	objListToChange.options[objListToChange.length] = new Option(0, 0, false, false);
	
	strCount = Math.floor((strRoom*4)-parseInt(strChanged));
	
	for (i=1; i<=strCount; i++)
	{
		if (i==strToChange)
			objListToChange.options[objListToChange.length] = new Option(i, i, false, true);
		else
			objListToChange.options[objListToChange.length] = new Option(i, i, false, false);
		
	}
	objListToChange.selectedIndex = strLoc;
}

function ChangeRoom(objAdult,objChild,objRoom)
{
	objListRoom	 = eval("document.thisForm."+objRoom);
	objListAdult = eval("document.thisForm."+objAdult);
	objListChild = eval("document.thisForm."+objChild);

	strRoom			= objListRoom.options[objListRoom.selectedIndex].value;
	strAdult		= objListAdult.options[objListAdult.selectedIndex].value;
	strChild		= objListChild.options[objListChild.selectedIndex].value;
	
	strALoc			= objListAdult.selectedIndex;
	strCLoc			= objListChild.selectedIndex;
	
	if (parseInt(strAdult) >= (strRoom*4))
	{
		strAdult = (strRoom*4)/2;
		strALoc = strAdult - 1;
	}
	
	if (parseInt(strChild) >= (strRoom*4))
	{
		strChild = (strRoom*4)/2;
		strCLoc = strChild - 1;
	}

	objListAdult.length = 0;
	strCount = Math.floor((strRoom*4)-parseInt(strChild));

	for (i=1; i<=strCount; i++)
	{
		if (i==strAdult)
			objListAdult.options[objListAdult.length] = new Option(i, i, false, true);
		else
			objListAdult.options[objListAdult.length] = new Option(i, i, false, false);
		
	}

	objListAdult.selectedIndex = strALoc;
	objListChild.length = 0;
	
	strCount = Math.floor((strRoom*4)-parseInt(strAdult));
	
	for (i=0; i<=strCount; i++)
	{
		if (i==strChild)
			objListChild.options[objListChild.length] = new Option(i, i, false, true);
		else
			objListChild.options[objListChild.length] = new Option(i, i, false, false);
	}
	
	objListChild.selectedIndex = strCLoc;
}

function ChangeListII(objChanged,objToChange)
{
	objListChanged	= eval("document.thisForm."+objChanged);
	objListToChange = eval("document.thisForm."+objToChange);

	strChanged = objListChanged.options[objListChanged.selectedIndex].value;
	strToChange = objListToChange.options[objListToChange.selectedIndex].value;
	strLoc = objListToChange.selectedIndex;
	
	objListToChange.length = 0;
	//objListToChange.options[objListToChange.length] = new Option(0, 0, false, false);
	
	strCount = Math.floor(4-parseInt(strChanged));
	for (i=1; i<=strCount; i++)
	{
		if (i==strToChange)
			objListToChange.options[objListToChange.length] = new Option(i, i, false, true);
		else
			objListToChange.options[objListToChange.length] = new Option(i, i, false, false);
		
	}
	objListToChange.selectedIndex = strLoc;
}

function ChangeListaII(objChanged,objToChange)
{
	objListChanged	= eval("document.thisForm."+objChanged);
	objListToChange = eval("document.thisForm."+objToChange);

	strChanged = objListChanged.options[objListChanged.selectedIndex].value;
	strToChange = objListToChange.options[objListToChange.selectedIndex].value;
	strLoc = objListToChange.selectedIndex;
	
	objListToChange.length = 0;
	objListToChange.options[objListToChange.length] = new Option(0, 0, false, false);
	
	strCount = Math.floor(4-parseInt(strChanged));
	
	for (i=1; i<=strCount; i++)
	{
		if (i==strToChange)
			objListToChange.options[objListToChange.length] = new Option(i, i, false, true);
		else
			objListToChange.options[objListToChange.length] = new Option(i, i, false, false);
		
	}
	objListToChange.selectedIndex = strLoc;
}
