var MLeftOffset = 8; //follow style sheet
var MMouseoverClass = "menuMouseOver"; //mouse over class for main menu item
var MLastClass = "";
var MTimerId = 0;

function MenuReposition() {
	//screen size checking
	var browser = BrowserDetect.browser;
	var ch = 0;

	if (browser == "Explorer") {
		ch = document.body.clientWidth + 16;
	}
	else if (browser == "Firefox") {
		ch = window.innerWidth;
	}
	else if (browser == "Safari") {
		ch = window.innerWidth + 16;
	} else {
		ch = window.innerWidth;
	}

	if (ch <= 960)
	var leftspace = 0;
	else
	var leftspace = Math.ceil((ch - 960) / 2);
	leftspace += MLeftOffset;

	//check the number of menu items
	var MAX = 100;
	var accWidth = 0;
	for (i=1; i<=MAX; i++) {
		var mMenu = $("MainMenu_" + i);
		if (mMenu != undefined) {
			var sMenu = $("SubMenu_" + i);
			if (i==1 && sMenu != undefined) {
				sMenu.style.left = leftspace + "px";
				sMenu.style.display = "none";
			}
			else if (i > 1 && sMenu != undefined) {
				sMenu.style.left = (leftspace + accWidth) + "px";
				sMenu.style.display = "none";
			}
			accWidth += mMenu.offsetWidth;
		}
		else {
			break;
		}
	}
}
function ShowMenu(mId) {
	var sMenu = $("SubMenu_" + mId);
	var mMenu = $("MainMenu_" + mId);
	if (sMenu != undefined) {
		clearTimeout(MTimerId);
		sMenu.style.display = "";
		if($("cboHotel")) $("cboHotel").style.display="none";
		MLastClass = mMenu.className;
		if (MMouseoverClass != "") {
			if (MLastClass != "") {
				mMenu.className = MLastClass + " " + MMouseoverClass;
			}
			else {
				mMenu.className = MMouseoverClass;
			}
		}
	}
}
function HideMenu(mId) {
	MTimerId = setTimeout("GoHideMenu(" + mId + ")", 500);
}
function GoHideMenu(mId) {
	var sMenu = $("SubMenu_" + mId);
	var mMenu = $("MainMenu_" + mId);
	if (sMenu != undefined) {
		sMenu.style.display = "none";
		mMenu.className = "mn-lnk";
		if($("cboHotel")) $("cboHotel").style.display="";
	}
}
function HideAllMenu() {
	var MAX = 100;
	clearTimeout(MTimerId);
	for (i=1; i<=MAX; i++) {
		var mMenu = $("MainMenu_" + i);
		if (mMenu != undefined) {
			var sMenu = $("SubMenu_" + i);
			if (sMenu != undefined) {
				sMenu.style.display = "none";
				mMenu.className = "";
			}
		}
		else {
			break;
		}
	}
}

var shortRoomType = Array();
shortRoomType["Single"] = "SGL";
shortRoomType["Double"] = "TW";
shortRoomType["Triple"] = "TPL";
shortRoomType["TripleCh"] = "TPLC";
shortRoomType["Quad"] = "QUAD";
shortRoomType["Twin"] = "TW";
var termcondition=false;
var iSpan;
var Loop;
var ServiceCode;
var RoomType;
var RqBF;
var RqLunch;
var RqDinner;
var HotelCode;
var Allotment;
var SupplierCode_AV;
var aryRows = new Array();
var oSingle=0;
var oDouble=0;
var oTwin=0;
var oTriple=0;
var oQuad=0;
var ChkFindAV=0;
var ModeBooking="";
var numCot=1;
var PageSearch="";
function chkSearch(){
	if($("cboHotel")){
		if($("cboHotel").value=="NONE" || $("cboHotel").value=="" || $("cboHotel").value=="ALL"){
			alert("Please select hotel.");
		}else{
			//window.open("hotelcontent/hoteldesc.php?Code="+$("cboHotel").value+"&Name="+$("cboHotel").options[$("cboHotel").selectedIndex].text,"_self");
			var hotelname=$("cboHotel").options[$("cboHotel").selectedIndex].text;
			hotelname=hotelname.split(" ").join("_");
			if(Lang){
				window.open("/"+Lang+"/"+hotelname+"/description.html","_self");
			}else{
				window.open("/"+hotelname+"/description.html","_self");
			}
		}
	}
}
function AddCboRoom(obj,n){
	if(obj && n>0){
		for(i=1;i<=n;i++){
			try{
				obj.add(new Option(i, i), null);
			}
			catch(e){
				obj.add(new Option(i, i));
			}
		}
		lycboAdult = $("lycboAdult").innerHTML;
		$("cboRooms").value = totalRoom;
		FCboAdult();
	}
}
function FCboAdult(){
	var D = "";
	var n = $("cboRooms").value;
	for(i=1;i<=n;i++){
		D += lycboAdult;
		D = D.split("xxAdxx").join(i);
	}
	if($("lycboAdult")) $("lycboAdult").innerHTML = D;

	otxtSingle = txtSingle;
	otxtTwin = txtTwin;
	otxtDouble = txtDouble;
	otxtTriple = txtTriple;
	otxtQuad = txtQuad;
	for(i=1;i<=n;i++){
		if(otxtSingle>0){ otxtSingle-=1; val=1; }else
		if(otxtTwin>0){ otxtTwin-=1; val=2; }else
		if(otxtDouble>0){ otxtDouble-=1; val=2; }else
		if(otxtTriple>0){ otxtTriple-=1; val=3; }else
		if(otxtQuad>0){ otxtQuad-=1; val=4; }
		$("cboAdult-"+i).value=val;
	}
}
function setcboroom(cbo, n, k){cbo.length = 0;for (var i=k; i<=n; i++) cbo.options[cbo.length] = new Option(i, i);}
function setdisplayroom(){
	$("ly-rooms").innerHTML = "";
	if($("lytmp-rooms2")) $("ly-rooms2").innerHTML = "";
	for (var i=1; i<=parseFloat($("cboRooms").value); i++){
		if($("lytmp-rooms2")){
			var tmp = $("lytmp-rooms").innerHTML;
			tmp = tmp.split("xxixx").join(i);
			$("ly-rooms").innerHTML += tmp;
			var tmp2 = $("lytmp-rooms2").innerHTML;
			tmp2 = tmp2.split("xxixx").join(i);
			$("ly-rooms2").innerHTML += tmp2;
		}else{
			var tmp = $("lytmp-rooms").innerHTML;
			tmp = tmp.split("xxixx").join(i);
			tmp = tmp.split("xxixx").join(i);
			$("ly-rooms").innerHTML += tmp;
		}
	}
	for (var i=1; i<=parseFloat($("cboRooms").value); i++){
		if ($("cboRoomAdult-"+i))
		{
			$("cboRoomAdult-"+i).length = 0;
			$("cboRoomAdult-"+i).options[$("cboRoomAdult-"+i).length] = new Option("1", "1");
			$("cboRoomAdult-"+i).options[$("cboRoomAdult-"+i).length] = new Option("2 - Twin", "2-TW");
			$("cboRoomAdult-"+i).options[$("cboRoomAdult-"+i).length] = new Option("2 - Double", "2-DBL");
			$("cboRoomAdult-"+i).options[$("cboRoomAdult-"+i).length] = new Option("3", "3");
			$("cboRoomAdult-"+i).options[$("cboRoomAdult-"+i).length] = new Option("4", "4");
		}
//		setcboroom($("cboRoomAdult-"+i), 4 , 1);
		setcboroom($("cboRoomChild-"+i), 2, 0);
		setcboroom($("cboRoomAge1-"+i), 18, 0);
		setcboroom($("cboRoomAge2-"+i), 18, 0);
		if (hs.myDefault.sRoom[i-1]){
			var sRoom = hs.myDefault.sRoom[i-1];
			$("cboRoomAdult-"+i).value = sRoom[0];
			$("cboRoomChild-"+i).value = sRoom[1];
			$("cboRoomAge1-"+i).value = sRoom[2];
			$("cboRoomAge2-"+i).value = sRoom[3];
			$("chkRoomExbed-"+i).checked = sRoom[4];
		}
		changechild(i);
	}
}
function changechild(i){
	var displaych="none";
	for (var j=1; j<=parseFloat($("cboRooms").value); j++){
		if(parseFloat($("cboRoomChild-"+j).value)>0) displaych="";
	}
	if($("lySpecifyages")) $("lySpecifyages").style.display=displaych;
	$("cboRoomAge1-"+i).disabled = (parseFloat($("cboRoomChild-"+i).value)<1);
	$("cboRoomAge2-"+i).disabled = (parseFloat($("cboRoomChild-"+i).value)<2);
	$("cboRoomAge1-"+i).value = (parseFloat($("cboRoomChild-"+i).value)<1)? 0:$("cboRoomAge1-"+i).value;
	$("cboRoomAge2-"+i).value = (parseFloat($("cboRoomChild-"+i).value)<2)? 0:$("cboRoomAge2-"+i).value;
	exbedhandle(i);
}
function exbedhandle(i){
	$("chkRoomExbed-"+i).disabled = !((parseFloat($("cboRoomAdult-"+i).value)==2)&&(parseFloat($("cboRoomChild-"+i).value)>0));
	$("chkRoomExbed-"+i).checked = ($("chkRoomExbed-"+i).disabled)? false : $("chkRoomExbed-"+i).checked;
}
function loadResult(b2bMaxNights){
	if($("cboPaxPassport")) $("cboPaxPassport").value = hs.myDefault.sNationality;
	$("cboPaxPassport").selectedIndex = ($("cboPaxPassport").selectedIndex==-1)? 0 : $("cboPaxPassport").selectedIndex;
	if($("txtFromDate") && hs.myDefault.sFromDt3 !="--") $("txtFromDate").value = hs.myDefault.sFromDt3;
	if($("txtToDate") && hs.myDefault.sToDt3 !="--") $("txtToDate").value = hs.myDefault.sToDt3;
	/*
	Calendar.setup({inputField : "txtFromDate",ifFormat : "dd-mm-yy",button : "imgFromDate",singleClick : true });
	Calendar.setup({inputField : "txtToDate",ifFormat : "dd-mm-yy",button : "imgToDate",singleClick : true });
	changecalendar.bnight=1;
	changecalendar.setup("FromDt", "txtFromDate");
	changecalendar.setup("ToDt", "txtToDate");
	changecalendar.setup("Night", "txtNight");
	changecalendar.setup("maxNight", b2bMaxNights);
	*/
	calendar2.setup("txtFromDate", "imgFromDate", 2, "txtFromDate", "txtToDate", "txtNight", hs.myDefault.sMaxNights);
	calendar2.setup("txtToDate", "imgToDate", 2, "txtFromDate", "txtToDate", "txtNight", hs.myDefault.sMaxNights);
	setcboroom($("cboRooms"), hs.myDefault.sMaxRoom, 1);
	$("cboRooms").value = hs.myDefault.sRoom.length;
	setdisplayroom();
}
function getparamsearch(){
	var param = "";
	if ($("cboPaxPassport")) param += "Nationality=" + $("cboPaxPassport").value;
	if ($("cboCountry")) param += "&Country=" + $("cboCountry").value;
	if ($("cboCity")) param += "&City=" + $("cboCity").value;
	if ($("cboHotel")) param += "&Hotel=" + hs.myDefault.sHotel;
	param += "&FromDt=" + $("txtFromDate").value;
	param += "&ToDt=" + $("txtToDate").value;
	param += "&Rooms=" + $("cboRooms").value;
	for (var i=1; i<=parseFloat($("cboRooms").value); i++){
		param += "&RoomAdult-"+i+"=" + $("cboRoomAdult-"+i).value;
		param += "&RoomChild-"+i+"=" + $("cboRoomChild-"+i).value;
		param += "&RoomAge1-"+i+"=" + (($("cboRoomAge1-"+i).disabled)?"":$("cboRoomAge1-"+i).value);
		param += "&RoomAge2-"+i+"=" + (($("cboRoomAge2-"+i).disabled)?"":$("cboRoomAge2-"+i).value);
		param += "&RoomExbed-"+i+"=N";
		param += "&RoomExbed-"+i+"=" + (($("chkRoomExbed-"+i).checked)?"Y":"N");
	}
	return param;
}

function LoadSearch(FromSearch){
	var myurl = "/hotelcontent/reservation/search.php", http = new getXMLHTTPRequest();
	var PP = "";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText = http.responseText;
		if(myText != ""){
			if($("lyDetail"))$("lyDetail").innerHTML = myText;
			loadResult(b2bMaxNights);
//			AddCboRoom($("cboRooms"),b2bMaxRoom);
//			if(FromSearch) SearchResult();
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function DropHotel(){
	var http = new getXMLHTTPRequest();
	var myurl = "/hotelcontent/hotels/hotel.php";
	var datapath = "CityCode="+$("cboCityCode").value;
	datapath += "&Mode=reservation";
	datapath += "&"+new Date().getTime();
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		var hotelsearch = eval("("+http.responseText+")");
		loadselect(hotelsearch.MyLoad, $("cboHotelCode"),cboHotelCode);
	}
	http.open("POST", myurl, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(datapath);
}
function loadselect(obj, cbo, svalue){
	cbo.length = 0;
	var n = obj.length;
	for(var i=0; i<n; i++){
		var objOption = new Option(obj[i][1], obj[i][0]);
		cbo.options[cbo.length] = objOption;
	}
	cbo.value = svalue;
	cbo.selectedIndex = (cbo.selectedIndex==-1)? 0 : cbo.selectedIndex;
}
function DropCity(obj){
	var http = new getXMLHTTPRequest();
	var myurl = "/hotelcontent/hotels/hotel.php";
	var datapath = "Country="+obj.value;
	datapath += "&Mode=city";
	datapath += "&"+new Date().getTime();
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		var city = eval("("+http.responseText+")");
		loadselect(city.MyLoad, $("cboCity"), "");
	}
	http.open("POST", myurl, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(datapath);
}
function SetDatasearchbox(){
	var myurl = "/hotelcontent/php/SetDatasearchbox.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&cboPaxPassport="+$("cboPaxPassport").value;
	PP+="&txtFromDate="+$("txtFromDate").value;
	PP+="&txtToDate="+$("txtToDate").value;
	PP+="&txtSingle="+FindRoom("SGL");
	PP+="&txtTwin="+FindRoom("TW");
	PP+="&txtDouble="+FindRoom("DBL");
	PP+="&txtTriple="+FindRoom("TPL");
	PP+="&txtQuad="+FindRoom("QUAD");
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		HotelName=HotelName.split(" ").join("_");
		window.open("/"+HotelName+"/reservation.html","_self");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function SetDatasearch(){
	var myurl = "/hotelcontent/php/SetDatasearchbox.php", http = new getXMLHTTPRequest();
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		HotelName=HotelName.split(" ").join("_");
		window.open("/"+HotelName+"/reservation.html","_self");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send("&"+new Date().getTime());
}
function FindRoom(RT){
	var txtSingle = 0;
	var txtTwin = 0;
	var txtDouble = 0;
	var txtTriple = 0;
	var txtQuad = 0;
	var NR = 0;
	for(i=1;i<=$("cboRooms").value;i++){
		switch($("cboRoomAdult-"+i).value){
			case "1" : txtSingle++; break;
			case "2" : txtTwin++; break;
			case "3" : txtTriple++; break;
			case "4" : txtQuad++; break;
		}
	}
	switch(RT){
		case "SGL" : NR = txtSingle; break;
		case "TW" : NR = txtTwin; break;
		case "TPL" : NR = txtTriple; break;
		case "QUAD" : NR = txtQuad; break;
		default : NR = 0;
	}
	return(NR);
}
function Result(){
	if($("cboPaxPassport").value == ""){
		alert("Please select your passport. ");
	}else if($("cboCityCode").value == ""){
		alert("Please select destination city. ");
	}else if($("cboHotelCode").value == ""){
		alert("Please select hotel. ");
	}else{
		var myurl = "/hotelcontent/hotels/hotel.php", http = new getXMLHTTPRequest();
		var PP="cboPaxPassport="+$("cboPaxPassport").value;
		PP+="&cboCityCode="+$("cboCityCode").value;
		PP+="&cboHotelCode="+$("cboHotelCode").value;
		PP+="&txtFromDate="+$("txtFromDate").value;
		PP+="&txtToDate="+$("txtToDate").value;
		PP+="&txtNight="+$("txtNight").value;
		PP+="&txtSingle="+FindRoom("SGL");
		PP+="&txtTwin="+FindRoom("TW");
		PP+="&txtDouble="+FindRoom("DBL");
		PP+="&txtTriple="+FindRoom("TPL");
		PP+="&txtQuad="+FindRoom("QUAD");
		PP+="&Mode=resulthotel";
 		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			window.open("/"+mytext+"/reservation.php","_self");
		};
		http.open("POST", myurl, true);	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(PP+"&"+new Date().getTime());
	}
}
function checkerrorsearch(){
	if ($("cboPaxPassport")){
		if($("cboPaxPassport").value=="NONE" || $("cboPaxPassport").value==""){
			alert("Please insert Pax Passport"); $("cboPaxPassport").focus(); return false;
		}
	}
	if ($("txtNight")){
		if(($("txtNight").value=="")||(parseFloat($("txtNight").value)<=0)){
			alert("Please insert Night"); return false;
		}
	}
	if($("cboRooms").value > 0){
		i=0;
		while(i<$("cboRooms").value){
			i++;
			coutRoomChild=$('cboRoomChild-'+i).value;
			j=0;
			while(j < coutRoomChild){
				j++;
				objChildAge=$('cboRoomAge'+j+'-'+i);
				if(objChildAge.value < 1){
					alert('Please select child age !'); objChildAge.focus(); return false;
				}
			}
		}
	}
	return true;
}
function SetSession(){
	if (!checkerrorsearch()) return false;
	var myurl = "/hotelcontent/reservation/setsession.php", http = new getXMLHTTPRequest();
	http.onreadystatechange = function() {if (http.readyState != 4) {return; }
		window.open("/"+lang+"/reservation/search.php","_self");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(getparamsearch()+"&"+new Date().getTime());
}
function SearchResult(){
	cboPaxPassport = $("cboPaxPassport").value;
	if(cboPaxPassport == ""){
		alert("Please select your passport. ");
	}else{
		if(PageSearch!=""){
			if(cboPaxPassport == ""){
				alert("Please select your passport. ");
			}else{
				SetSession();
			}
		}else{
			if($("lyResult")){
				$("lyResult").innerHTML = "";
				if($("btnSearch")) $("btnSearch").disabled = true;
				var myurl = "/hotelcontent/reservation/result.php", http = new getXMLHTTPRequest();
				var PP = "";
				txtSingle = FindRoom("SGL");
				txtTwin = FindRoom("TW");
				txtDouble = FindRoom("DBL");
				txtTriple = FindRoom("TPL");
				txtQuad = FindRoom("QUAD");
				totalRoom = (txtSingle+txtTwin+txtDouble+txtTriple+txtQuad);
				PP+="&cboPaxPassport="+$("cboPaxPassport").value;
				PP+="&txtFromDate="+$("txtFromDate").value;
				PP+="&txtToDate="+$("txtToDate").value;
				PP+="&txtNight="+$("txtNight").value;
				PP+="&txtSingle="+txtSingle;
				PP+="&txtTwin="+txtTwin;
				PP+="&txtDouble="+txtDouble;
				PP+="&txtTriple="+txtTriple;
				PP+="&txtQuad="+txtQuad;
				http.onreadystatechange = function() {if (http.readyState != 4) { return; }
					var myText = http.responseText;
					if(myText !=""){
						$("lyResult").innerHTML = myText;
						if($("scboPaxPassport")) cboPaxPassport = $("scboPaxPassport").value;
						if($("stxtFromDate")) txtFromDate = $("stxtFromDate").value;
						if($("stxtToDate")) txtToDate = $("stxtToDate").value;
						if($("stxtNight")) txtNight = $("stxtNight").value;
						if($("btnSearch")) $("btnSearch").disabled=false;
					}
				};
				http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				http.send(PP+"&"+new Date().getTime());
			}
		}
	}
}
function showAvailable(AllotmentCode,HotelCode,SupplierCode){
	var objDate = new Date();
	strFile="/hotelcontent/php/showAvailable.php";
	strFile += "?AllotmentCode="+AllotmentCode +"&HotelCode="+HotelCode+"&SupplierCode="+SupplierCode+"&DateTime="+ new Date().getTime();
	window.open(strFile,"_blank","left=100,top=150;status=no,scrollbars=yes,resizable=yes,width=" + (800) + ",height=" + (400));
}
function ShowPriceRoom(Code,SupplierCode_AV,RoomCatg,RoomType,ABF,Lunch,Dinner,Rating,CheckIn,CheckOut,UseAllotment){
	strFile="/hotelcontent/php/Price/showpriceroom.php?";
	strFile+="Code="+Code;
	strFile+="&SupplierCode_AV="+SupplierCode_AV;
	strFile+="&RoomCatg="+RoomCatg;
	strFile+="&RoomType="+RoomType;
	strFile+="&ABF="+ABF;
	strFile+="&Lunch="+Lunch;
	strFile+="&Dinner="+Dinner;
	strFile+="&Rating="+Rating;
	strFile+="&CheckIn="+CheckIn;
	strFile+="&CheckOut="+CheckOut;
	strFile+="&UseAllotment="+UseAllotment;
	//alert(strFile);
	window.open(strFile,"_blank","left=150,top=150;status=no,scrollbars=yes,resizable=yes,width=" + (800) + ",height=" + (400));
}
function PaxDetail(){
	var myurl = "/hotelcontent/reservation/paxdetail.php", http = new getXMLHTTPRequest();
	var para = "";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText=http.responseText;
		if(myText !=""){
			if($("lyDetail"))$("lyDetail").innerHTML=myText;
			ModeBooking=$("ModeBooking").value;
			if(ModeBooking=="AMEND"){
				ReturnDataEdit();
				$("lytxtModify").style.display = "none";
				$("lyModifyDateRoom").style.display = "";
				$('btSearch').innerHTML = "Back to My Booking Detail";
			}else if(ModeBooking=="EDIT"){
				ReturnDataEdit();
				$('btSearch').innerHTML = "Back to Basket";
			}else{
				AddCboRoom($("cboRooms"),b2bMaxRoom);
				loadResult (b2bMaxNights);
				PaxDetailAllRoom(ModeBooking);
			}
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(para+new Date().getTime());
}
function PaxDetailAllRoom(Mode){
	if(Mode!="AMEND"){
		$("lyModifyDateRoom").style.display="none";
	}
	PaxDetailRoom("SGL");
	PaxDetailRoom("TW");
	PaxDetailRoom("TPL");
	PaxDetailRoom("QUAD");
	ChangePax(0);
	ChkFindAV=0;
	$("txtSingle").value=FindRoom("SGL");
	$("txtTwin").value=FindRoom("TW");
	$("txtDouble").value=FindRoom("DBL");
	$("txtTriple").value=FindRoom("TPL");
	$("txtQuad").value=FindRoom("QUAD");
}
function GuestInBasket(GuestRoomType,NumGuest,NumRoomGuest){
	strFile="/hotelcontent/php/GuestInBasket.php";
	window.open(strFile + "?GuestRoomType="+GuestRoomType+"&NumGuest="+NumGuest+"&NumRoomGuest="+NumRoomGuest,"_blank","left=250,top=150;status=no,scrollbars=yes,resizable=yes,width=" + (500) + ",height=" + (250));
}
function FindRoomDMember(){
	if($("txtSingle").value > 0){ DMember="SGL"; }else
	if($("txtTwin").value > 0){ DMember="TW"; }else
	if($("txtDouble").value > 0){ DMember="DBL"; }else
	if($("txtTriple").value > 0){ DMember="TPL"; }else
	if($("txtQuad").value > 0){ DMember="QUAD"; }
	return(DMember);
}
function ClearOld(){
	oSingle=0;
	oDouble=0;
	oTwin=0;
	oTriple=0;
	oQuad=0;
}
function cRow() {
	// property cost #############################
	this.Cat=""; 					this.Sex1=""; 					this.Name1="";					this.LastName1="";
	this.Sex2=""; 				this.Name2="";					this.LastName2="";			this.Nation2="";
	this.Sex3=""; 				this.Name3="";					this.LastName3="";			this.Nation3="";
	this.Sex4=""; 				this.Name4="";					this.LastName4="";			this.Nation4="";
	this.Nation1=""; 			this.BF=false;  					this.LN=false;  					this.DN=false;
	this.BFA=0;					this.BFC=0;						this.LNA=0;						this.LNC=0;
	this.DNA=0;					this.DNC=0;						this.BFdis="NONE";		this.OrgServiceNo="";
}
function ReturnDataEdit(){
	var httpReturnDataEdit = getXMLHTTPRequest();
	ClearOld();
	txtFromDate = sOldFromDt = $("sOldFromDt").value;
	txtToDate = sOldToDt = $("sOldToDt").value
	txtNight = sOldNight = $("sOldNight").value
	var myurl = "/hotelcontent/php/PaxDetailReturnDataEdit.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&FromDt="+sOldFromDt;
	PP+="&ToDt="+sOldToDt;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		var mytext = http.responseXML;
		var obj = mytext.getElementsByTagName("LoopRoom");
		for(i=0; i<obj.length; i+=1){
			objC = obj[i].childNodes;
			var objRow = new cRow();
			RoomTypeNode=objC[0].firstChild.nodeValue;
			CntLoopNode=objC[1].firstChild.nodeValue;
			aryRows[RoomTypeNode+CntLoopNode]=objRow;
			var eObj = aryRows[RoomTypeNode+CntLoopNode];
			for(ii=0; ii<objC.length; ii+=1){
				if(!((typeof eval("eObj."+objC[ii].nodeName)).toString().substr(0,2)=="un")){
					switch(objC[ii].nodeValue){
						case true:
						case false:
							eval("eObj."+objC[ii].nodeName+"="+objC[ii].firstChild.nodeValue);
							break;
						default:
							if(objC[ii].firstChild){
								if((objC[ii].firstChild)) eval("eObj."+objC[ii].nodeName+"='"+objC[ii].firstChild.nodeValue+"'");
							}
							break;
					}
				}
				if(objC[ii].nodeName=="HServiceNo"){
					$("HServiceNo").value=objC[ii].firstChild.nodeValue;
				}
				if(objC[ii].nodeName=="OrgDocID"){
					$("OrgDocID").value=objC[ii].firstChild.nodeValue;
				}
				if(objC[ii].nodeName=="WebNo"){
					if(objC[ii].firstChild.nodeValue!="0"){
						$("WebNo").value=objC[ii].firstChild.nodeValue;
					}
				}
			}
			switch(RoomTypeNode){
				case "Single" : oSingle=(oSingle+1);break;
				case "Double" : oDouble=(oDouble+1);break;
				case "Twin" : oTwin=(oTwin+1);break;
				case "Triple" : oTriple=(oTriple+1);break;
				case "Quad" : oQuad=(oQuad+1);break;
			}
		}
		txtSingle=oSingle;
		txtTwin=oTwin;
		txtDouble=oDouble;
		txtTriple=oTriple;
		txtQuad=oQuad;
		totalRoom=(txtSingle+txtTwin+txtDouble+txtTriple+txtQuad);
		AddCboRoom($("cboRooms"),b2bMaxRoom);
		loadResult (b2bMaxNights);
		PaxDetailAllRoom(ModeBooking);
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function AddTemp(RoomType){
	var oCheck=0;
	var PaxInclude="";
	if(ModeBooking=="AMEND"){
		txtSingle = $("txtSingle").value;
		txtTwin = $("txtTwin").value;
		txtDouble = $("txtDouble").value;
		txtTriple = $("txtTriple").value;
		txtQuad = $("txtQuad").value;
	}
	switch(RoomType){
		case "Single" : num=txtSingle; oCheck=oSingle; PaxInclude="Inc. for 3 PAX"; break;
		case "Twin" : num=txtTwin; oCheck=oTwin; PaxInclude="Inc. for 2 PAX"; break;
		case "Double" : num=txtDouble; oCheck=oDouble; PaxInclude="Inc. for 2 PAX"; break;
		case "Triple" : num=txtTriple; oCheck=oTriple; PaxInclude="Inc. for 3 PAX"; break;
		case "Quad" : num=txtQuad; oCheck=oQuad; PaxInclude="Inc. for 4 PAX"; break;
	}
	for(i=0;i<num;i+=1){
		if((i+1)<=oCheck){
			if(aryRows[RoomType+(i+1)].Cat!=""){
				$(RoomType+"Cat_"+(i+1)).value=aryRows[RoomType+(i+1)].Cat;
			}
			$(RoomType+"Name1_"+(i+1)).value=aryRows[RoomType+(i+1)].Name1;
			$(RoomType+"LastName1_"+(i+1)).value=aryRows[RoomType+(i+1)].LastName1;
			if(RoomType=="Double" || RoomType=="Twin" || RoomType=="Quad" || RoomType=="Triple"){
				$(RoomType+"Name2_"+(i+1)).value=aryRows[RoomType+(i+1)].Name2;
				$(RoomType+"LastName2_"+(i+1)).value=aryRows[RoomType+(i+1)].LastName2;
			}
			if(RoomType=="Quad" || RoomType=="Triple"){
				$(RoomType+"Name3_"+(i+1)).value=aryRows[RoomType+(i+1)].Name3;
				$(RoomType+"LastName3_"+(i+1)).value=aryRows[RoomType+(i+1)].LastName3;
			}
			if(RoomType=="Quad"){
				$(RoomType+"Name4_"+(i+1)).value=aryRows[RoomType+(i+1)].Name4;
				$(RoomType+"LastName4_"+(i+1)).value=aryRows[RoomType+(i+1)].LastName4;
			}

			if(aryRows[RoomType+(i+1)].Sex1!=""){
				$(RoomType+"Sex1_"+(i+1)).value=aryRows[RoomType+(i+1)].Sex1;
			}
			if(aryRows[RoomType+(i+1)].Sex2!=""){
				$(RoomType+"Sex2_"+(i+1)).value=aryRows[RoomType+(i+1)].Sex2;
			}
			if(aryRows[RoomType+(i+1)].Sex3!=""){
				$(RoomType+"Sex3_"+(i+1)).value=aryRows[RoomType+(i+1)].Sex3;
			}
			if(aryRows[RoomType+(i+1)].Sex4!=""){
				$(RoomType+"Sex4_"+(i+1)).value=aryRows[RoomType+(i+1)].Sex4;
			}
			if(aryRows[RoomType+(i+1)].BFdis=="true"){
				$(RoomType+"BF_"+(i+1)).disabled=true;
				$(RoomType+"BF_"+(i+1)).checked=true;
				$("ly"+RoomType+"BF_"+(i+1)).innerHTML=PaxInclude;
			}
			else
				if(aryRows[RoomType+(i+1)].BFdis=="false" ){
					$(RoomType+"BF_"+(i+1)).disabled=false;
					$(RoomType+"BF_"+(i+1)).checked=false;
				}
			if(aryRows[RoomType+(i+1)].BF=="true"){
				$(RoomType+"BF_"+(i+1)).checked=true;
				$(RoomType+"BF_"+(i+1)).disabled=false;
			}
			if(aryRows[RoomType+(i+1)].LN=="true"){
				$(RoomType+"LN_"+(i+1)).checked=true;
			}else{
				$(RoomType+"LN_"+(i+1)).checked=false;
			}
			if(aryRows[RoomType+(i+1)].DN=="true"){
				$(RoomType+"DN_"+(i+1)).checked=true;
			}else{
				$(RoomType+"DN_"+(i+1)).checked=false;
			}
			$(RoomType+"OrgServiceNo"+(i+1)).value=aryRows[RoomType+(i+1)].OrgServiceNo;
		}
	}
}
function ChangePax(Mo){
	if(Mo==0){
		$("btnSearch").style.display="none";
		$("btnBook").disabled=false;
	}else{
		$("btnSearch").style.display="";
		$("btnBook").disabled=true;
	}
}
function PaxDetailRoom(RoomType){
	var myurl = "/hotelcontent/reservation/paxdetailroom.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="strFile="+$('lyTmpRoom').value;
	PP+="&rType="+RoomType;
	PP+="&nRoom="+FindRoom(RoomType);
	PP+="&txtFromDate="+$('txtFromDate').value;
	PP+="&txtToDate="+$('txtToDate').value;
	PP+="&txtNight="+$('txtNight').value;
	PP+="&txtSingle="+FindRoom("SGL");
	PP+="&txtTwin="+FindRoom("TW");
	PP+="&txtDouble="+FindRoom("DBL");
	PP+="&txtTriple="+FindRoom("TPL");
	PP+="&txtQuad="+FindRoom("QUAD");
//	PP+="&SetDMember="+FindRoomDMember()
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText=http.responseText;
		if(myText !=""){
			ChkFindAV++;
			if(ChkFindAV==4){
				FindAV();
			}
			switch(RoomType){
				case "SGL" : IDinner="lyRoomSingle"; break;
				case "TW" : IDinner="lyRoomTwin"; break;
				case "DBL" : IDinner="lyRoomDouble"; break;
				case "TPL" : IDinner="lyRoomTriple"; break;
				case "QUAD" : IDinner="lyRoomQuad"; break;
			}
			if($(IDinner))$(IDinner).innerHTML=myText;

			/*
			if(ModeBooking=="AMEND" || ModeBooking=="EDIT"){
				switch(RoomType){
					case "SGL" : AddTemp("Single"); break;
					case "TW" : AddTemp("Twin"); break;
					case "DBL" : AddTemp("Double"); break;
					case "TPL" : AddTemp("Triple"); break;
					case "QUAD" : AddTemp("Quad"); break;
				}
			}
			*/
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function Payment(){
	var myurl = "/hotelcontent/reservation/payment.php", http = new getXMLHTTPRequest();
	var PP = "";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText=http.responseText;
		if(myText !=""){
			if($("lyDetail"))$("lyDetail").innerHTML=myText;
			ShowCancellationChargeInPayment();
			if($("txtFromDate")){
				Calendar.setup({inputField : "txtFromDate",ifFormat : "dd-mm-yy",button : "imgFromDate",singleClick : true });
				Calendar.setup({inputField : "txtToDate",ifFormat : "dd-mm-yy",button : "imgToDate",singleClick : true });
				changecalendar.setup("FromDt", "txtFromDate");
				changecalendar.setup("ToDt", "txtToDate");
				changecalendar.setup("Night", "txtNight");
				//changecalendar.setup("maxNight", b2bMaxNights);
			}
			if($("Logined")){
				Logined = ($("Logined")) ? $("Logined").value : 0;
				if(Logined == 1 && $("dLogin") && $("dNotLogin")){
					if(sModeMemAgent=="AGENT"){
						$("dLogin").style.display="none";
						$("dNotLogin").style.display="none";
						$("chkAccept").disabled = false;
					}else{
						$("dLogin").style.display="none";
						$("dNotLogin").style.display="";
						$("chkAccept").disabled = false;
					}
				}else{
					$("dLogin").style.display="";
					$("dNotLogin").style.display="none";
					$("chkAccept").disabled = false;
					$("Submit1").disabled = true;
				}
				if($("mMemberName")) $("mMemberName").innerHTML = $("MemberName").value;
				if($("mMemberPassport")) $("mMemberPassport").innerHTML = $("MemberPassport").value;
				if($("mMemberEmail")) $("mMemberEmail").innerHTML = $("MemberEmail").value;
			}
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function ForgetPassInPayment(){
	window.open("/member/forget-pass-rsvn.php","_blank","left=100,top=150,status=no,scrollbars=no,resizable=no,width=" + (605) + ",height=" + (195));
}
function ShowCancellationChargeInPayment(){
	LoadingPage=true;
	var httpCancellationChargeInPayment = getXMLHTTPRequest();
	var objDate = new Date();
	myurl = "/hotelcontent/php/Func/ShowCancellationChargeInPayment.php?DateTime="+ new Date().getTime();
	httpCancellationChargeInPayment.open("GET", myurl, true);
	httpCancellationChargeInPayment.onreadystatechange = function(){
	   if (httpCancellationChargeInPayment.readyState == 4) {
		if(httpCancellationChargeInPayment.status == 200) {
			var mytext = httpCancellationChargeInPayment.responseText;
			if($('lyCancelCharge')){
				$('lyCancelCharge').innerHTML = mytext;
			}
		}
	  }
	}
	httpCancellationChargeInPayment.send(null);
}
function HideResult(hide){
	if($(hide).style.display==""){
		$(hide).style.display="none";
	}else{
		$(hide).style.display="";
	}
}
function isEmail(string) {
	if(string.value!=""){
	chkMail=string.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) ;
		if(chkMail==-1){
			alert("You have entered an invalid email address. Please try again.");
			string.value="";
		}
	}
}
function isBlankF(string) {
	if(string.value!=""){
		chkBlank=string.value.substr(0,1);
		if(chkBlank==" "){
			alert("First charactor not allow to space. Please try again.");
			string.value="";
		}
	}
}
function checkUsername(){
	//find txtbox not blank#########################
	var txtSurname;
	var txtName;
	var cboPrefix;
	var txtSurnameFirst;
	var txtNameFirst;
	var cboPrefixFirst;
	var cntName=0;
	sMode=$("sMode").value;

	if((sMode=="")&&($("txtEmail").value=="" || $("txtUserName").value=="" || $("txtPassword").value=="")){
		alert("Please insert Member Login ");
	}else{
		obj =document.form1.elements;
		cntName=0;
		for(i=0;i<obj.length;i++){
			DataSingle=obj[i].name.substr(0,9);
			DataDouble=obj[i].name.substr(0,9);
			DataTwin=obj[i].name.substr(0,7);
			DataTriple=obj[i].name.substr(0,9);
			DataQuad=obj[i].name.substr(0,7);
			if(DataSingle=="SingleSex" || DataDouble=="DoubleSex" || DataTwin=="TwinSex" || DataTriple=="TripleSex" || DataQuad=="QuadSex" ){
				if((obj[i+1].value!="")&&(obj[i+2].value!="")&&(obj[i].value!="NONE")){
					cboPrefix=obj[i].value;
					txtSurname=obj[i+1].value;
					txtName=obj[i+2].value;
					cntName=1;
					break;
				}
			}
		}
		//end txtbox not blank#########################
		//find txtbox not blank first and insert #########################
		obj =document.form1.elements;
		for(i=0;i<obj.length;i++){
			//Room Double##########################################
			DataDouble=obj[i].name.substr(0,9);
			if(DataDouble=="DoubleCat"){
				cntNameFirst=0;
				if((obj[i+1].value!="NONE")&&(obj[i+2].value!="")&&(obj[i+3].value!="")){
					cboPrefixFirst=obj[i+1].value;
					txtSurnameFirst=obj[i+2].value;
					txtNameFirst=obj[i+3].value;
					cntNameFirst=1;
				}
				if(cntNameFirst==1){
					if(obj[i+4].value=="NONE" || obj[i+5].value=="" || obj[i+6].value==""){
						obj[i+4].value=cboPrefixFirst;
						obj[i+5].value=txtSurnameFirst;
						obj[i+6].value=txtNameFirst;
					}
				}
			}
			//Room Twin##########################################
			DataTwin=obj[i].name.substr(0,7);
			if(DataTwin=="TwinCat"){
				cntNameFirst=0;
				if((obj[i+1].value!="NONE")&&(obj[i+2].value!="")&&(obj[i+3].value!="")){
					cboPrefixFirst=obj[i+1].value;
					txtSurnameFirst=obj[i+2].value;
					txtNameFirst=obj[i+3].value;
					cntNameFirst=1;
				}
				if(cntNameFirst==1){
					if(obj[i+4].value=="NONE" || obj[i+5].value=="" || obj[i+6].value==""){
						obj[i+4].value=cboPrefixFirst;
						obj[i+5].value=txtSurnameFirst;
						obj[i+6].value=txtNameFirst;
					}
				}
			}
			//Room Triple##########################################
			DataTriple=obj[i].name.substr(0,9);
			if(DataTriple=="TripleCat"){
				cntNameFirst=0;
				if((obj[i+1].value!="NONE")&&(obj[i+2].value!="")&&(obj[i+3].value!="")){
					cboPrefixFirst=obj[i+1].value;
					txtSurnameFirst=obj[i+2].value;
					txtNameFirst=obj[i+3].value;
					cntNameFirst=1;
				}
				if(cntNameFirst==1){
					if(obj[i+4].value=="NONE" || obj[i+5].value=="" || obj[i+6].value==""){
						obj[i+4].value=cboPrefixFirst;
						obj[i+5].value=txtSurnameFirst;
						obj[i+6].value=txtNameFirst;
					}
					if(obj[i+7].value=="NONE" || obj[i+8].value=="" || obj[i+9].value==""){
						obj[i+7].value=cboPrefixFirst;
						obj[i+8].value=txtSurnameFirst;
						obj[i+9].value=txtNameFirst;
					}
				}
			}
			//Room Quad##########################################
			DataQuad=obj[i].name.substr(0,7);
			if(DataQuad=="QuadCat"){
				cntNameFirst=0;
				if((obj[i+1].value!="NONE")&&(obj[i+2].value!="")&&(obj[i+3].value!="")){
					cboPrefixFirst=obj[i+1].value;
					txtSurnameFirst=obj[i+2].value;
					txtNameFirst=obj[i+3].value;
					cntNameFirst=1;
				}
				if(cntNameFirst==1){
					if(obj[i+4].value=="NONE" || obj[i+5].value=="" || obj[i+6].value==""){
						obj[i+4].value=cboPrefixFirst;
						obj[i+5].value=txtSurnameFirst;
						obj[i+6].value=txtNameFirst;
					}
					if(obj[i+7].value=="NONE" || obj[i+8].value=="" || obj[i+9].value==""){
						obj[i+7].value=cboPrefixFirst;
						obj[i+8].value=txtSurnameFirst;
						obj[i+9].value=txtNameFirst;
					}
					if(obj[i+10].value=="NONE" || obj[i+11].value=="" || obj[i+12].value==""){
						obj[i+10].value=cboPrefixFirst;
						obj[i+11].value=txtSurnameFirst;
						obj[i+12].value=txtNameFirst;
					}
				}
			}
		}
		//end txtbox not blank first#########################
		//insert to txtbox blank#########################
		if(cntName==1){
			obj =document.form1.elements;
			for(i=0;i<obj.length;i++){
				DataSingle=obj[i].name.substr(0,9);
				DataDouble=obj[i].name.substr(0,9);
				DataTwin=obj[i].name.substr(0,7);
				DataTriple=obj[i].name.substr(0,9);
				DataQuad=obj[i].name.substr(0,7);
				if(DataSingle=="SingleSex" || DataDouble=="DoubleSex" || DataTwin=="TwinSex" || DataTriple=="TripleSex" || DataQuad=="QuadSex" ){
					if((obj[i].value=="NONE")||(obj[i+1].value=="")||(obj[i+2].value=="")){
						obj[i].value=cboPrefix;
						obj[i+1].value=txtSurname;
						obj[i+2].value=txtName;
					}
				}
			}
			if(sMode==""){
				CheckMember();
			}else{
				SubmitPax();
			}
		}else{
			alert("Please select Prefix, Guest name");
		}
		//insert to txtbox blank#########################
	}
}
function CheckMember(){
	var myurl = "/php/CheckMember.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&txtEmail="+$("txtEmail").value;
	PP+="&txtUserName="+$("txtUserName").value;
	PP+="&txtPassword="+$("txtPassword").value;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		var mytext = http.responseXML;
		var obj = mytext.getElementsByTagName('LOGIN');
		var Pass = mytext.getElementsByTagName('PASS')[0].firstChild.nodeValue;
		if(Pass==0){
			alert("This email and username duplicate. Please insert again.");
			$("btnBook").disabled=false;
		}else{
			SubmitPax();
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function SubmitPax(){
	var cntName=0;
	obj =document.form1.elements;
	cntName=0;
	for(i=0;i<obj.length;i++){
		DataSingle=obj[i].name.substr(0,9);
		DataDouble=obj[i].name.substr(0,9);
		DataTwin=obj[i].name.substr(0,7);
		DataTriple=obj[i].name.substr(0,9);
		DataQuad=obj[i].name.substr(0,7);
		if(DataSingle=="SingleSex" || DataDouble=="DoubleSex" || DataTwin=="TwinSex" || DataTriple=="TripleSex" || DataQuad=="QuadSex" ){
			if((obj[i+1].value!="")&&(obj[i+2].value!="")&&(obj[i].value!="NONE")){
				cboPrefix=obj[i].value;
				txtSurname=obj[i+1].value;
				txtName=obj[i+2].value;
				cntName=1;
				break;
			}
		}
	}
	if(cntName==1){
		ModeBooking=$("ModeBooking").value;
		if(ModeBooking=="ADD"){
			GenHtml="<Form method=\"POST\" name=\"form1\" ACTION=\"/hotelcontent/php/InsertDB.php\">\n";
		}else{
			GenHtml="<Form method=\"POST\" name=\"form1\" ACTION=\"/hotelcontent/php/InsertEditDB.php\">\n";
		}
		obj =document.form1.elements;
		for(i=0;i<obj.length;i++){
			Data=obj[i].type;
			if(Data=="checkbox"){
				if(obj[i].checked){
					if(obj[i].disabled){
						if(obj[i].type=="checkbox"){
							GenHtml+="<input type='text' name='"+obj[i].name+"' value='N'>"+obj[i].name+"<br>";
						}else{
						GenHtml+="<input type='text' name='"+obj[i].name+"' value='N'>"+obj[i].name+"<br>";
						}
					}else{
						if(obj[i].name.substr(0,12)=="chkBreakfast"){
							GenHtml+="<input type='text' name='"+obj[i].name+"' value='N'>"+obj[i].name+"<br>";
						}else
							if(obj[i].name.substr(0,9)=="chkRemark"){
								GenHtml+="<input type='text' name='"+obj[i].name+"' value='"+obj[i].value+"'>"+obj[i].name+"<br>";
							}else{
							GenHtml+="<input type='text' name='"+obj[i].name+"' value='Y'>"+obj[i].name+"<br>";
							}
					}
				}else{
					if(obj[i].name.substr(0,12)=="chkBreakfast"){
						GenHtml+="<input type='text' name='"+obj[i].name+"' value='N'>"+obj[i].name+"<br>";
					}else
						if(obj[i].name.substr(0,9)!="chkRemark"){
							GenHtml+="<input type='text' name='"+obj[i].name+"' value='N'>"+obj[i].name+"<br>";
						}
				}
			}else
				if(obj[i].name=="txtRemark"){
					GenHtml+="<textarea name='"+obj[i].name+"' id='"+obj[i].name+"'>"+obj[i].value+"</textarea>"+obj[i].name+"<br>";
				}else{
					GenHtml+="<input type='text' name='"+obj[i].id+"' value='"+obj[i].value+"'>"+obj[i].id+"<br>";
				}
		}
		GenHtml = GenHtml + "<input type=submit value=submit>\n";
		GenHtml = GenHtml + "</Form>\n";
		//var o = window.open();
		//o.document.write(GenHtml);
		var objWindow = eval("window.lySubmitPax");
		objWindow.open("","_self");
		objWindow.document.write(GenHtml);
		objWindow.document.close();
		objWindow.document.form1.submit();
		$("btnBook").disabled=true;
	}else{
		alert("Please select Prefix, Guest name");
	}
}
function FindAV(){
	FAV=0;
	var HAvailable=$("HaveAllotment").value;
	var HotelCode = $("HotelCode").value;
	var AgentCode = $("AgentCode").value;
	var AMEND = $("AMEND").value;
	var strRoomCatgName = Array();
	var strRoomCatgValue = Array();
	$("HaveAllotment").value = "N";
	$("AllotmentCode").value = "";
	obj = document.form1;
	var RSingle = obj.txtSingle.value;
	var RTwin = obj.txtTwin.value;
	var RDouble = obj.txtDouble.value;
	var RTriple = obj.txtTriple.value;
	var RTripleCh =0;
	var RQuad = obj.txtQuad.value;
	var GenHtml = "<Form method=\"POST\" name=\"form1\" id=\"form1\" action=\"/hotelcontent/php/FindAV.php\">\n";
	GenHtml = GenHtml + "<input name=\"HotelCode\" type=\"hidden\" value=\""+HotelCode+"\">\n";
	GenHtml = GenHtml + "<input name=\"CompanyCode\" type=\"hidden\" value=\""+AgentCode+"\">\n";
	GenHtml = GenHtml + "<input name=\"RSingle\" type=\"hidden\" value=\"" + RSingle + "\">\n";
	GenHtml = GenHtml + "<input name=\"RTwin\" type=\"hidden\" value=\"" + RTwin + "\">\n";
	GenHtml = GenHtml + "<input name=\"RDouble\" type=\"hidden\" value=\"" + RDouble + "\">\n";
	GenHtml = GenHtml + "<input name=\"RTriple\" type=\"hidden\" value=\"" + RTriple + "\">\n";
	GenHtml = GenHtml + "<input name=\"RTripleCh\" type=\"hidden\" value=\"" + RTripleCh + "\">\n";
	GenHtml = GenHtml + "<input name=\"RQuad\" type=\"hidde\" value=\"" + RQuad + "\">\n";
	GenHtml = GenHtml + "<input name=\"AMEND\" type=\"hidde\" value=\"" + AMEND + "\">\n";
	GenHtml = GenHtml + "</Form>\n";
	var objWindow = window.wAllotment.open("","_self");
	objWindow.document.write(GenHtml);
	objWindow.document.close();
//	alert(HAvailable);
//    if(HAvailable=="Y"){
		$('lyAllotment').innerHTML = "";
		objWindow.document.form1.submit();
//	}
	return(HAvailable);
}//function FindAV #############
function GenNumberRoom(){
	var objDate = new Date();
	obj =document.form1.elements;
	nSingle=0;
	nDouble=0;
	nTwin=0;
	nTriple=0;
	nQuad=0;
	cnt=0;
	$("btnBook").disabled = false;
	for(i=0;i<obj.length;i++){
		rName=obj[i].name.substr(0,5);
		if(rName=="nRoom"){
			cnt=cnt+1;
			obj[i].value=cnt;
			sHowRate(obj,i);
			$("lyScriptABF").innerHTML="";
			ServiceCode=obj[i+1].value;
			nLoop=obj[i-2].value;
			RType=obj[i-1].value;
			AV=$("HaveAllotment").value;
			myurl = "/hotelcontent/php/PaxDetailBFLNDN.php?ServiceCode="+ServiceCode+"&nLoop="+nLoop+"&RType="+RType+"&AV="+AV+"&DateTime="+ new Date().getTime();
			if(ServiceCode =="" || nLoop =="" || RType =="" || AV =="" ){
				window.location.reload();
			}
			switch(RType){
				case "Single" : nSingle=(nSingle+1);(nSingle>=oSingle)?ShowsABF(myurl,i):"";break;
				case "Double" : nDouble=(nDouble+1);(nDouble>=oDouble)?ShowsABF(myurl,i):"";break;
				case "Twin" : nTwin=(nTwin+1);(nTwin>=oTwin)?ShowsABF(myurl,i):"";break;
				case "Triple" : nTriple=(nTriple+1);(nTriple>=oTriple)?ShowsABF(myurl,i):"";break;
				case "Quad" : nQuad=(nQuad+1);(nQuad>=oQuad)?ShowsABF(myurl,i):"";break;
			}
		}
	}
}
function ShowsABF(myurl,Loop){
	var s = document.createElement("script");
	var str = "";
	str += "function ShowsABF"+Loop+"(){\n";
	str += "var objDate = new Date();\n";
	str += "var httpsABF"+Loop+" = getXMLHTTPRequest();\n";
	str += "myurl = '"+myurl+"'\n";
	str += "httpsABF"+Loop+".open('GET', myurl, true);\n";
	str += "httpsABF"+Loop+".onreadystatechange = function(){\n";
	str += "   if (httpsABF"+Loop+".readyState == 4) {\n";
	str += "	if(httpsABF"+Loop+".status == 200) {\n";
	str += "		var mytext = httpsABF"+Loop+".responseXML;\n";
	str += "		var obj = mytext.getElementsByTagName('BFLNDN');\n";
	str += "		var BFName = mytext.getElementsByTagName('BFName')[0].firstChild.nodeValue;\n";
	str += "		var BFChecked = mytext.getElementsByTagName('BFChecked')[0].firstChild.nodeValue;\n";
	str += "		var BFDisabled = mytext.getElementsByTagName('BFDisabled')[0].firstChild.nodeValue;\n";
	str += "		var BFTitle = mytext.getElementsByTagName('BFTitle')[0].firstChild.nodeValue;\n";
	str += "		var BFIncName = mytext.getElementsByTagName('BFIncName')[0].firstChild.nodeValue;\n";
	str += "		var BFIncText = mytext.getElementsByTagName('BFIncText')[0].firstChild.nodeValue;\n";
	str += "		var LNName = mytext.getElementsByTagName('LNName')[0].firstChild.nodeValue;\n";
	str += "		var LNDisabled = mytext.getElementsByTagName('LNDisabled')[0].firstChild.nodeValue;\n";
	str += "		var LNTitle = mytext.getElementsByTagName('LNTitle')[0].firstChild.nodeValue;\n";
	str += "		var DNName = mytext.getElementsByTagName('DNName')[0].firstChild.nodeValue;\n";
	str += "		var DNDisabled = mytext.getElementsByTagName('DNDisabled')[0].firstChild.nodeValue;\n";
	str += "		var DNTitle = mytext.getElementsByTagName('DNTitle')[0].firstChild.nodeValue;\n";
	str += "		(BFChecked=='true')?BFChecked=true:BFChecked=false;\n";
	str += "		(BFDisabled=='true')?BFDisabled=true:BFDisabled=false;\n";
	str += "		(BFTitle=='NONE')?BFTitle='':'';\n";
	str += "		(BFIncText=='NONE')?BFIncText='':'';\n";
	str += "		(LNDisabled=='true')?LNDisabled=true:LNDisabled=false;\n";
	str += "		(LNTitle=='NONE')?LNTitle='':'';\n";
	str += "		(DNDisabled=='true')?DNDisabled=true:DNDisabled=false;\n";
	str += "		(DNTitle=='NONE')?DNTitle='':'';\n";
	str += "		$(BFName).checked = BFChecked;\n";
	str += "		$(BFName).disabled = BFDisabled;\n";
	str += "		$(BFName).title = BFTitle;\n";
	str += "		$(BFIncName).innerHTML = BFIncText;\n";
	str += "		(BFIncText=='')?$(BFIncName).style.display='NONE':$(BFIncName).style.display='';\n";
	str += "		$(LNName).disabled = LNDisabled;\n";
	str += "		(LNDisabled==true)?$(LNName).checked=false:'';\n";
	str += "		$(LNName).title = LNTitle;\n";
	str += "		$(DNName).disabled = DNDisabled;\n";
	str += "		(DNDisabled==true)?$(DNName).checked=false:'';\n";
	str += "		$(DNName).title = DNTitle;\n";
//	str += "		GenNumberRoom();\n";
	str += "	}\n";
	str += "  }\n";
	str += "}\n";
	str += "httpsABF"+Loop+".send(null);\n";
	str += "}\n";
	str += "ShowsABF"+Loop+"();\n";
	s.text = str ;
	$("lyScriptABF").appendChild(s);
}
function sHowRate(obj,i){
	var objDate = new Date();
	//sHowRate#################################
	iSpan=obj[i-2].value;
	Loop=cnt;
	ServiceCode =obj[i+1].value;
	RoomType=obj[i-1].value;
	//shortRoomType[RoomType] =
	switch(RoomType){
		case "Single":
			if(obj[i+5].disabled){
				RqBF="N";
			}else{
				(obj[i+5].checked)?RqBF="Y":RqBF="N";
			}
			(obj[i+6].checked)?RqLunch="Y":RqLunch="N";
			(obj[i+7].checked)?RqDinner="Y":RqDinner="N";
			break;
		case "Twin":
			if(obj[i+8].disabled){
				RqBF="N";
			}else{
				(obj[i+8].checked)?RqBF="Y":RqBF="N";
			}
			(obj[i+9].checked)?RqLunch="Y":RqLunch="N";
			(obj[i+10].checked)?RqDinner="Y":RqDinner="N";
			break;
		case "Double":
			if(obj[i+8].disabled){
				RqBF="N";
			}else{
				(obj[i+8].checked)?RqBF="Y":RqBF="N";
			}
			(obj[i+9].checked)?RqLunch="Y":RqLunch="N";
			(obj[i+10].checked)?RqDinner="Y":RqDinner="N";
			break;
		case "Triple":
			if(obj[i+11].disabled){
				RqBF="N";
			}else{
				(obj[i+11].checked)?RqBF="Y":RqBF="N";
			}
			(obj[i+12].checked)?RqLunch="Y":RqLunch="N";
			(obj[i+13].checked)?RqDinner="Y":RqDinner="N";
			break;
		case "Quad":
			if(obj[i+14].disabled){
				RqBF="N";
			}else{
				(obj[i+14].checked)?RqBF="Y":RqBF="N";
			}
			(obj[i+15].checked)?RqLunch="Y":RqLunch="N";
			(obj[i+16].checked)?RqDinner="Y":RqDinner="N";
			break;
	}
	HotelCode=$("HotelCode").value;
	Allotment=$("AllotmentCode").value;
	SupplierCode_AV=$("SupplierCode").value;
	//sHowRate#################################

	(RoomType=="Double")?shortRoomType[RoomType]="DBL":"";
	RiSpan=shortRoomType[RoomType];
	DivShow="lyPaxRoomRate"+RiSpan+iSpan;
	DivShowNoRT="lyNoRoomType"+RiSpan+iSpan;
	RateUrl = "/hotelcontent/php/Reserv_Show_Rate.php?";
	RateUrl +="&iSpan="+ iSpan;
	RateUrl +="&HotelCode="+HotelCode;
	RateUrl +="&bNameRoom="+RoomType;
	RateUrl +="&ServiceCode="+ ServiceCode;
	RateUrl +="&RqBF="+ RqBF;
	RateUrl +="&RqLunch="+RqLunch;
	RateUrl +="&RqDinner="+RqDinner;
	RateUrl +="&RoomType="+shortRoomType[RoomType];
	RateUrl +="&AllotmentCode="+Allotment;
	RateUrl +="&SupplierCode_AV="+SupplierCode_AV;
	RateUrl +="&DivShow="+DivShow;
	RateUrl +="&txtFromDate="+$("txtFromDate").value;
	RateUrl +="&txtToDate="+$("txtToDate").value;
	RateUrl +="&sCurrencyName="+sCurrencyName;
	RateUrl +="&DateTime="+ new Date().getTime();
	RateUrl +="&txtSingle="+$('txtSingle').value;
	RateUrl +="&txtTwin="+$('txtTwin').value;
	RateUrl +="&txtDouble="+$('txtDouble').value;
	RateUrl +="&txtTriple="+$('txtTriple').value;
	RateUrl +="&txtQuad="+$('txtQuad').value;
	$("lyScript").innerHTML="";
	if($(RoomType+"Cat_"+iSpan).length>0){
		WriteFunction(DivShowNoRT,DivShow,RateUrl,Loop);
	}else{
		var thObj = $(RoomType+"Cat_"+iSpan), pObj = thObj.parentNode;
		pObj.innerHTML = "Not Available.";$("btnBook").disabled = true;
	}
}
function WriteFunction(DivShowNoRT,DivShow,RateUrl,Loop){
	var s = document.createElement("script");
	var str = "";
	str += "function ShowsHowRate"+Loop+"(){\n";
	str += "	var myurl = '"+RateUrl+"'\n";
	str += "	var DivShow = '"+DivShow+"'\n";
	str += "	var DivShowNoRT = '"+DivShowNoRT+"'\n";
	str += "	var httpsHowRate"+Loop+" = getXMLHTTPRequest();\n";
	str += "	httpsHowRate"+Loop+".open('GET', myurl, true);\n";
	str += "	httpsHowRate"+Loop+".onreadystatechange = function(){\n";
	str += "		if (httpsHowRate"+Loop+".readyState == 4) {\n";
	str += "			if(httpsHowRate"+Loop+".status == 200) {\n";
	str += "				var mytext = httpsHowRate"+Loop+".responseText;\n";
	str += "					if(Loop!='Y'){\n";
	str += "				$(DivShowNoRT).innerHTML = "+Loop+"+\") \";}\n";
	str += "				$(DivShow).innerHTML = mytext;\n";
	str += "				FindPricePaxDetail();\n";
	str += "			}\n";
	str += "		}\n";
	str += "	}\n";
	str += "	httpsHowRate"+Loop+".send(null);\n";
	str += "}\n";
	str += "ShowsHowRate"+Loop+"();\n";
	s.text = str ;
	$("lyScript").appendChild(s);
}
function FindPricePaxDetail(){
	this.getbyroomtype = function (RoomType){
		var elm = $("lyRoom"+RoomType).getElementsByTagName("font");
		var elmcur = $("lyRoom"+RoomType).getElementsByTagName("div");
		for (var i=0; i<elm.length; i++){
			spPaxDetail += parseFloat(elm[i].innerHTML.replace(",",""));
			curPaxDetail = elmcur[i].innerHTML;
		}
	}
	var spPaxDetail = 0;
	var curPaxDetail = "";
	this.getbyroomtype("Single");
	this.getbyroomtype("Double");
	this.getbyroomtype("Twin");
	this.getbyroomtype("Triple");
	this.getbyroomtype("Quad");
	var txtPrice = jNumberFormat(spPaxDetail,2)+" "+curPaxDetail;
	$("lyGrandTotal").innerHTML = txtPrice;
}
function FindsHowRate(Name){
	obj =document.form1.elements;
	for(i=0;i<obj.length;i++){
		rName=obj[i].name;
		if(rName==Name){
			cnt='Y';
			sHowRate(obj,i);
		}
	}
}
function FindsHowRateRoomcatg(Name){
	obj =document.form1.elements;
	var objDate = new Date();
	for(i=0;i<obj.length;i++){
		rName=obj[i].name;
		if(rName==Name){
			cnt='Y';
			sHowRate(obj,i);
			$("lyScriptABF").innerHTML="";
			ServiceCode=obj[i+1].value;
			nLoop=obj[i-2].value;
			RType=obj[i-1].value;
			AV=$("HaveAllotment").value;
			myurl = "/hotelcontent/php/PaxDetailBFLNDN.php?ServiceCode="+ServiceCode+"&nLoop="+nLoop+"&RType="+RType+"&AV="+AV+"&DateTime="+ new Date().getTime();
			ShowsABF(myurl,i);
		}
	}
}
function PopupShowPrice(){
	strFile="/hotelcontent/php/PopupShowPrice.php";
	var URL="";
	URL+="Code="+$('HotelCode').value;
	URL+="&Available="+$('HaveAllotment').value;
	URL+="&SupplierCode="+$('SupplierCode').value;
	URL+="&AllotmentCode="+$('AllotmentCode').value;
	URL+="&txtFromDate="+$('txtFromDate').value;
	URL+="&txtToDate="+$('txtToDate').value;
	URL+="&RSG="+$('txtSingle').value;
	URL+="&RTW="+$('txtTwin').value;
	URL+="&RDO="+$('txtDouble').value;
	URL+="&RTA="+$('txtTriple').value;
	URL+="&RTC="+0;
	URL+="&RQU="+$('txtQuad').value;
	URL+="&sAgentCode="+sAgentCode;
	URL+="&cboPaxPassport="+cboPaxPassport;
	URL+="&sCurrencyShow="+sCurrencyShow;
	URL+="&SupplierCode="+$("SupplierCode").value;
	window.open(strFile + "?"+URL,"_blank","left=50,top=50;status=no,scrollbars=yes,resizable=yes,width=" + (800) + ",height=" + (400));
}//PopupShowPrice############################
function DelBasketHotel(Code,FromDt,ToDt){
	var myurl = "/hotelcontent/php/DelBasketHotel.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&Code="+Code;
	PP+="&FromDt="+FromDt;
	PP+="&ToDt="+ToDt;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		Payment();
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function Terms(){
	if($("termandcondition")){
		termcondition=!termcondition;
		if(termcondition){
			window.termandcondition.open("/hotelcontent/php/TermConditions.php","_self");
			$("termandcondition").style.display="";
		}else{
			$("termandcondition").style.display="none";
		}
	}
}
function BottonAccept(){
	$("Submit1").disabled=($("chkAccept").checked)?false:true;
}
function CheckTime(Data){
	if((Data.indexOf(':')==2)||(Data.indexOf('.')==2)){
		Data1=Data.substr(0,2);
		Data2=Data.substr(3,2);
		Data=Data1+Data2;
		if(Data>2359 || Data2>59 || Data1>23){
			Data=0;
		}
	}else
		if((Data.indexOf(':')==1)||(Data.indexOf('.')==1)){
		Data='0'+Data;
		Data1=Data.substr(0,2);
		Data2=Data.substr(3,2);
		Data=Data1+Data2;
		if(Data>2359 || Data2>59 || Data1>23){
			Data=0;
		}
	}else{
		Data=Data.substr(0,4);
		Data1=Data.substr(0,2);
		Data2=Data.substr(2,2);
		//Data=parseInt(Data);
		if(Data>2359 || Data2>59 || Data1>23){
				Data=0;
		}
	}
	Data = Data.toString();
	h1=Data.substr(0,1);
	if(h1=='.'){h1=0;}
	h2=Data.substr(1,1);
	if(h2=='.'){h2=0;}
	m1=Data.substr(2,1);
	if(m1=='.'){m1=0;}
	m2=Data.substr(3,1);
	if(m2=='.'){m2=0;}
	c_h1 = parseInt(h1).toString();
	c_h2 = parseInt(h2).toString();
	c_m1 = parseInt(m1).toString();
	c_m2 = parseInt(m2).toString();
	if(Data.length<4 || c_h1=="NaN" || c_h1>2 || c_h1<0 || c_h2=="NaN" || c_h2>9 || c_h2<0 || c_m1=="NaN" || c_m1>6 || c_m1<0 || c_m2=="NaN" || c_m2>9 || c_m2<0){
		Data = "00:00";
	}else{
		Data = h1+h2+':'+m1+m2;
	}
	return(Data);
}
function ClickTime(obj){
	Data=CheckTime(obj.value);
	obj.value=Data;
}
function ClickRemark(obj){
	if(obj.checked==true){
		$('txtCot').value=numCot;
	}else{
		$('txtCot').value=0;
	}
}
function CheckCot(obj){
	if((obj.value!=1)&&(obj.value!=2)&&(obj.value!=3)&&(obj.value!=4)&&(obj.value!=5)&&(obj.value!=6)&&(obj.value!=7)&&(obj.value!=8)&&(obj.value!=9)){
		numCot=1;
		obj.value=numCot;
	}else{
		numCot=obj.value;
	}
}
function EditPay(Code,FromDt,ToDt,sFromDt,sToDt,sNight){
	var myurl = "/hotelcontent/php/EditPay.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&Code="+Code;
	PP+="&FromDt="+FromDt;
	PP+="&ToDt="+ToDt;
	if(sFromDt!=""){
		txtFromDate=sFromDt;
		txtToDate=sToDt;
		txtNight=sNight;
	}
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		PaxDetail();
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function CancelWB(){
	var myurl = "/hotelcontent/php/DelBooking.php", http = new getXMLHTTPRequest();
	var PP = "";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		if(ModeBooking == "AMEND"){
			MyBooking("MYAE");
		}else{
			LoadSearch();
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function SubmitForm(){
	if($("txtgroupname").value==""){
		alert("Please insert Guest & Group's Name");
	}else{
		var objDate = new Date();
		var GenHTML="<form name='formPay' action='/hotelcontent/php/SaveFlightDetail.php' method='POST'>";
		GenHTML+="<INPUT TYPE='text' name='txtgroupname' value='"+$("txtgroupname").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtOSRef' value='"+$("txtOSRef").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtFromDt' value='"+$("txtFromDate").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtFromTm' value='"+$("txtFromTm").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtFromFlight' value='"+$("txtFromFlight").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtVoyageFrom' value='"+$("txtVoyageFrom").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtToDt' value='"+$("txtToDate").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtToTm' value='"+$("txtToTm").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtToFlight' value='"+$("txtToFlight").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='txtVoyageTo' value='"+$("txtVoyageTo").value+"'>";

		GenHTML+="<INPUT TYPE='text' name='PayURL' value='"+$("PayURL").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='MERCHANTNUMBER' value='"+$("MERCHANTNUMBER").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='ORDERNUMBER' value='"+$("ORDERNUMBER").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='PAYMENTTYPE' value='"+$("PAYMENTTYPE").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='AMOUNT' value='"+$("AMOUNT").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='GTOTAL' value='"+$("GTOTAL").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='CURRENCY' value='"+$("CURRENCY").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='NAMECURRENCY' value='"+$("NAMECURRENCY").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='AMOUNTEXP10' value='"+$("AMOUNTEXP10").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='LANGUAGE' value='"+$("LANGUAGE").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='REF1' value='"+$("REF1").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='REF2' value='"+$("REF2").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='REF3' value='"+$("REF3").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='REF4' value='"+$("REF4").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='REF5' value='"+$("REF5").value+"'>";

		GenHTML+="<INPUT TYPE='text' name='RESPCODE' value='"+$("RESPCODE").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='STATUS' value='"+$("STATUS").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='AUTHCODE' value='"+$("AUTHCODE").value+"'>";
		GenHTML+="<INPUT TYPE='text' name='Credit' value='"+$("Credit").value+"'>";
		GenHTML+="</form>";
		var obj = window.wSubmit.open("","_self");
		obj.document.write(GenHTML);
		obj.document.formPay.submit();
		obj.document.close();
	}
}
function ChangePage(Page){
	var myurl = "/hotelcontent/php/EditPay.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&Page="+Page;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		window.open("/reservation/reservation.php","_self");
	};
	http.open("POST", myurl, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function MyBooking(Page,Data){
	var myurl = "/hotelcontent/reservation/mybookingae.php";
	var http = new getXMLHTTPRequest();
	var PP = "";
	switch(Page){
		case "AGENTLOGIN" :
			myurl = "/hotelcontent/HTML/AgentLogin.html";
		break;
		case "MYAE" :
			myurl = "/hotelcontent/reservation/mybookingae.php";
			if(Data!=""){ PP=Data; }
		break;
		case "MYSEARCH" :
			myurl = "/hotelcontent/reservation/mybooking.php";
		break;
		case "MYVIEWLIST" :
			myurl = "/hotelcontent/reservation/mybookingviewlist.php";
			if($("txtWebNo")){
				PP +="&txtRef="+$("txtRef").value;
				PP +="&txtWebNo="+$("txtWebNo").value;
				PP +="&txtGroupName="+$("txtGroupName").value;
				PP +="&txtGuestList="+$("txtGuestList").value;
				PP +="&cboStatus="+$("cboStatus").value;
				PP +="&OS="+$("OS").value;
				PP +="&OP="+$("OP").value;
				PP +="&Mode="+$("ModeSearch").value;
			}else{
				PP +="&Page="+Data;
			}
		break;
		case "REPORT" :
			myurl = "/hotelcontent/reservation/reportmenu.php";
		break;
	}
	if($("lyDetail"))$("lyDetail").innerHTML="";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText=http.responseText;
		if(myText !=""){
			if($("lyDetail"))$("lyDetail").innerHTML=myText;
			if(sModeMemAgent=="AGENT" && Page=="MYAE"){
				ShowCreditLimit();
			}
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function Cancel(ConfirmNo,HBDocID,FlagCancel){
	if(FlagCancel=="Y"){
		Cvalue= confirm("Are you sure cancel this booking !!!!");
		if(Cvalue){
			if($("lyDetail"))$("lyDetail").innerHTML="";
			var myurl = "/hotelcontent/php/CancelBooking.php", http = new getXMLHTTPRequest();
			var PP="";
			PP+="&ConfirmNo="+ConfirmNo;
			PP+="&HBDocID="+HBDocID;
			http.onreadystatechange = function() {if (http.readyState != 4) { return; }
				MyBooking("MYAE");
			};
			http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			http.send(PP+"&"+new Date().getTime());
		}
	}else{
		alert("Please contact reservation.");
	}
}
function CancelViewList(ConfirmNo,HBDocID,FlagCancel,Key){
	if(FlagCancel=="Y"){
		Cvalue= confirm("Are you sure cancel this booking !!!!");
		if(Cvalue){
			if($("lyDetail"))$("lyDetail").innerHTML="";
			var myurl = "/hotelcontent/php/CancelBooking.php", http = new getXMLHTTPRequest();
			var PP="";
			PP+="&ConfirmNo="+ConfirmNo;
			PP+="&HBDocID="+HBDocID;
			http.onreadystatechange = function() {if (http.readyState != 4) { return; }
				ShowMyBookingAE(ConfirmNo,Key);
			};
			http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			http.send(PP+"&"+new Date().getTime());
		}
	}else{
		alert("Please contact reservation.");
	}
}
function Reject(ConfirmNo,HBDocID,FlagCancel){
	if(FlagCancel=="Y"){
		Cvalue= confirm("Are you sure reject this booking !!!!");
		if(Cvalue){
			if($("lyDetail"))$("lyDetail").innerHTML="";
			var myurl = "/hotelcontent/php/RejectBooking.php", http = new getXMLHTTPRequest();
			var PP="";
			PP+="&ConfirmNo="+ConfirmNo;
			PP+="&HBDocID="+HBDocID;
			http.onreadystatechange = function() {if (http.readyState != 4) { return; }
				MyBooking("MYAE");
			};
			http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			http.send(PP+"&"+new Date().getTime());
		}
	}else{
		alert("Please contact reservation.");
	}
}
function Accept(ConfirmNo){
	if($("lyDetail"))$("lyDetail").innerHTML="";
	var myurl = "/hotelcontent/php/AcceptBooking.php", http = new getXMLHTTPRequest();
	var PP="";
	PP+="&ConfirmNo="+ConfirmNo;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		MyBooking("MYAE");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function AmendMY(ConfirmNo,FlagCancel,Code,FromDt,ToDt){
	if(FlagCancel=="Y"){
		if($("lyDetail"))$("lyDetail").innerHTML="";
		var myurl = "/hotelcontent/php/AmendToBasket.php", http = new getXMLHTTPRequest();
		var PP="";
		PP+="&ConfirmNo="+ConfirmNo;
		PP+="&Code="+Code;
		PP+="&FromDt="+FromDt;
		PP+="&ToDt="+ToDt;
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
//			Payment();
			PaxDetail();
		};
		http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(PP+"&"+new Date().getTime());
	}else{
		alert("Please contact reservation.");
	}
}
function AgentLogin(){
	var http = new getXMLHTTPRequest();
	var PP="";
	var txtAgentID=($("txtAgentID"))?$("txtAgentID").value:"";
	var txtUserName=($("txtUserName"))?$("txtUserName").value:"";
	var txtPassword=($("txtPassword"))?$("txtPassword").value:"";
	var txtEmail=($("txtEmail"))?$("txtEmail").value:"";

	PP+="txtUserName="+txtUserName;
	PP+="&txtPassword="+txtPassword;
	PP+="&txtAgentID="+txtAgentID;
	PP+="&txtEmail="+txtEmail;
	var myurl ="";
	if($("txtEmail")){
		myurl = "/hotelcontent/php/MemberLoginConnect.php";
	}else{
		myurl = "/hotelcontent/php/AgentLoginConnect.php";
	}
	http.onreadystatechange = function() {
		if (http.readyState == 4)	{
			var mytext = http.responseXML;
			var obj = mytext.getElementsByTagName('LOGIN');
			var Pass = mytext.getElementsByTagName('PASS')[0].firstChild.nodeValue;
			if(Pass==1){
				ChangePage("MYBOOKINGSEARCH");
			}else{
				if($("dPassword")) $("dPassword").style.color="#FF0000";
				if($("dUserName")) $("dUserName").style.color="#FF0000";
				if($("dAgentID")) $("dAgentID").style.color="#FF0000";
			}
		}
	};

	http.open("POST", myurl, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function MemberLogin(Mode){
	if(Mode==0){
		if(($("txtUserNameMem").value=="")||($("txtUserNameMem").value.length < 4)){ alert("Please Insert Username 4-8 characters"); return;}else
		if(($("txtPasswordMem").value=="")||($("txtPasswordMem").value.length < 4) || ($("txtPasswordMem").value.toLowerCase()==strDup)){ alert("Please Insert Password 4-8 Characters"); return;}
	}
	var myurl = "/hotelcontent/php/MemberLoginConnect.php", http = new getXMLHTTPRequest();
	var txtUserName = ($("txtUserNameMem")?$("txtUserNameMem").value:$("txtUserName").value);
	var txtPassword = ($("txtPasswordMem")?$("txtPasswordMem").value:$("txtPassword").value);
	var PP="";
	PP+="&txtUserName="+txtUserName;
	PP+="&txtPassword="+txtPassword;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		var mytext = http.responseXML;
		var obj = mytext.getElementsByTagName('LOGIN');
		var Pass = mytext.getElementsByTagName('PASS')[0].firstChild.nodeValue;
			if(Pass==1){
				if(Mode==0){
					window.open(window.location.href.replace("#",""),"_self");
				}else{
					SubmitForm();
				}
			}else{
				alert("Username or Password invalid");
				$("dUserName").style.color="#FF0000";
				$("dPassword").style.color="#FF0000";
			}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
var strDup="unknown";
function opRegister(){
	if($("lyRegister").style.display=="none"){
		$('lyRegister').style.display = "";
//		$("Submit1").disabled = false;
	}else{
		$('lyRegister').style.display = "none";
//		$("Submit1").disabled = true;
	}
}
function SubmitPaymentNewMember(){
	$("lyRegister").style.display='';
	$("lytxtUserNameNew").style.display='none';
	$("lytxtPasswordNew").style.display='none';
	$("lytxtPasswordNewConfirm").style.display='none';
	$("lytxtEmail").style.display='none';
	$("lycboPrefix").style.display='none';
	$("lytxtFirstName").style.display='none';
	$("lytxtLastName").style.display='none';
	$("lycboPassport").style.display='none';
	$("lytxtAddress1").style.display='none';
	$("lycboCountry").style.display='none';
	$("lycboCity").style.display='none';
	$("lytxtZipCode").style.display='none';
	$("lytxtPhone").style.display='none';
	$("lytxtMobile").style.display='none';

	if(($("txtUserNameNew").value=="")||($("txtUserNameNew").value.length < 4)){ chktxtUserNameNew(); }else
	if(($("txtPasswordNew").value=="")||($("txtPasswordNew").value.length < 4) || ($("txtPasswordNew").value.toLowerCase()==strDup)){ chktxtPasswordNew(); }else
	if($("txtPasswordNewConfirm").value!=$("txtPasswordNew").value){ chktxtPasswordNewConfirm(); }else
	if($("cboPrefix").value==""){ chkcboPrefix(); }else
	if($("txtFirstName").value==""){ chktxtFirstName(); }else
	if($("txtLastName").value==""){ chktxtLastName(); }else
	if($("txtEmail").value==""){ chktxtEmail(); }else
	if($("cboPassport").value==""){ chkcboPassport(); }else
	if($("txtAddress1").value==""){ chktxtAddress1(); }else
	if($("cboCountry").value==""){ chkcboCountry(); }else
	if($("cboCity").value==""){ chkcboCity(); }else
	if($("txtZipCode").value==""){ chktxtZipCode(); }else
	if($("txtPhone").value==""){ chktxtPhone(); }else
	if($("txtMobile").value==""){ chktxtMobile(); }else
	if(($("txtPasswordNew").value!=$("txtPasswordNewConfirm").value)){ chktxtPasswordNewSame(); }else{
		var Path="Username="+$("txtUserNameNew").value+"&";
		Path+="Password="+$("txtPasswordNew").value+"&";
		Path+="Prefix="+$("cboPrefix").value+"&";
		Path+="FirstName="+$("txtFirstName").value+"&";
		Path+="LastName="+$("txtLastName").value+"&";
		Path+="Email="+$("txtEmail").value+"&";
		Path+="Nationality="+$("cboPassport").value+"&";
		Path+="Address1="+$("txtAddress1").value+"&";
		Path+="Address2="+$("txtAddress2").value+"&";
		Path+="Address3="+$("txtAddress3").value+"&";
		Path+="Country="+$("cboCountry").value+"&";
		Path+="City="+$("cboCity").value+"&";
		Path+="State="+$("txtState").value+"&";
		Path+="HotelCode="+$("HotelCode").value+"&";
		Path+="ZipCode="+$("txtZipCode").value+"&";
		Path+="Phone="+$("txtPhone").value+"&";
		Path+="Mobile="+$("txtMobile").value+"&";
		Path+="FAX="+$("txtFax").value+"&";
		Path+="Mode=register";
		var myurl = "/hotelcontent/hotels/hotel.php", http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			if(mytext == "PASS"){
				$("txtUserNameMem").value=$("txtUserNameNew").value;
				$("txtPasswordMem").value=$("txtPasswordNew").value;
				MemberLogin(1);
			}else{
				alert("You username or email is dupicate. Please try again.");
			}
		}
		http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(Path+"&"+new Date().getTime());
	}
}
function chktxtPasswordNew(){
	$("txtPasswordNew").select();
	$("txtPasswordNew").focus();
	$("lytxtPasswordNew").style.display='';
	if($("txtPasswordNew").value.toLowerCase()==strDup){
		$("lytxtPasswordNew").innerHTML='Sorry but this password are not accepted.';
	}
	else {
		$("lytxtPasswordNew").innerHTML='Please Insert Password 4-8 Characters';
	}
}
function chktxtPasswordNewConfirm(){
	$("txtPasswordNewConfirm").select();
	$("txtPasswordNewConfirm").focus();
	$("lytxtPasswordNewConfirm").style.display='';
}
function chktxtPasswordNewSame(){
	$("txtPasswordNew").select();
	$("lytxtPasswordNew").style.display='';
	$("lytxtPasswordNewConfirm").style.display='';
}
function chkcboPrefix(){
	$("lycboPrefix").style.display='';
}
function chktxtFirstName(){
	$("txtFirstName").select();
	$("txtFirstName").focus();
	$("lytxtFirstName").style.display='';
}
function chktxtLastName(){
	$("txtLastName").select();
	$("txtLastName").focus();
	$("lytxtLastName").style.display='';
}
function chktxtPhone(){
	$("txtPhone").select();
	$("txtPhone").focus();
	$("lytxtPhone").style.display='';
}
function chktxtMobile(){
	$("txtMobile").select();
	$("txtMobile").focus();
	$("lytxtMobile").style.display='';
}
function chkcboCountry(){
	$("lycboCountry").style.display='';
}
function chkcboPassport(){
	$("lycboPassport").style.display='';
}
function chktxtAddress1(){
	$("txtAddress1").select();
	$("lytxtAddress1").style.display='';
}
function chkcboCity(){
	$("lycboCity").style.display='';
}
function chktxtZipCode(){
	$("txtZipCode").select();
	$("lytxtZipCode").style.display='';
}
function chktxtEmail(){
	$("txtEmail").select();
	$("lytxtEmail").style.display='';
}
function chkVarchkMemberC(){
	$("lychkMember").style.display='';
}
function chktxtUserNameNew(){
	$("txtUserNameNew").select();
	$("txtUserNameNew").focus();
	$("lytxtUserNameNew").style.display='';
}
function ShowMyBookingAE(ConfirmNo,i_key){
	var Data="&ConfirmNo="+ConfirmNo;
	Data+="&i_key="+i_key;
	MyBooking("MYAE",Data)
}
function ShowRoom(HBDocID){
	strFile="/hotelcontent/php/ShowRoomHistory.php";
	window.open(strFile + "?HBDocID="+HBDocID,"_blank","left=100,top=100;status=no,scrollbars=auto,resizable=yes,width=" + (760) + ",height=" + (400));
}
function FDetail(){
	$("FlightOpen").style.display=($("FlightOpen").style.display=="none")?"":"none";
	$("evArrow").innerHTML=($("FlightOpen").style.display=="none")?"<img src=\'images/uparrow.gif\'>":"<img src=\'images/downarrow.gif\'>";
}
function ShowHis(CntShow){
	$("HisDetail"+CntShow).style.display=($("HisDetail"+CntShow).style.display=="none")?"":"none";
}
function MM_ChangeFLT(ConfirmNo){
	strFile="/hotelcontent/php/ChangeFLT.php";
	window.open(strFile + "?Code="+ConfirmNo,"_blank","left=150,top=150;status=no,scrollbars=auto,resizable=no,width=" + (630) + ",height=" + (300));
}
function openVoucher(VoucherNo,IDMem){
	var objDate = new Date();
	window.open("/hotelcontent/Mail/VoucherSQL.php?VoucherNo="+VoucherNo+"&IDMem="+IDMem+"&time="+objDate.getTime(),"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + (screen.width-10) + ",height=" + (screen.height-50));
}
function openInvoice(DocID){
	var objDate = new Date();
	window.open("/hotelcontent/Report/RSVN/InvoiceReport.php?DocID="+DocID+"&time="+objDate.getTime(),"_blank","left=0,top=0;status=no,scrollbars=yes,resizable=yes,width=" + (screen.width-10) + ",height=" + (screen.height-50));
}
function Logout(){
	window.open("logout.php","_self");
}
function mRoomcatg(mRoomcatg){
	var myurl = "php/EditPay.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&mRoomcatg="+mRoomcatg;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		HotelName=HotelName.split(" ").join("_");
		window.open("/"+HotelName+"/accom.html","_self");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function ChangeLang(Lang){
//		alert(HotelName);
//		alert(dcuri);
		var myurl = "/"+Lang+"/";
		if(Lang=='en'){
			myurl = "/";
		}
		var link = window.location;
		link = link.toString();

///////////////--INDEX--///////////////
		if(link == "http://"+dcroot+"/"){
			link=link.split(dcroot+"/").join(dcroot+myurl);
			window.open(link,"_self");
		}else if(link == "http://"+dcroot+"/th/" || link == "http://"+dcroot+"/jp/" || link == "http://"+dcroot+"/cn/" || link == "http://"+dcroot+"/en/" ){
			link=link.split("/th/").join(myurl);
			link=link.split("/jp/").join(myurl);
			link=link.split("/cn/").join(myurl);
			window.open(link,"_self");
		}
//////////////--NO INDEX--////////////
		else{
			dcuri=dcuri.split("/th/").join("/");
			dcuri=dcuri.split("/jp/").join("/");
			dcuri=dcuri.split("/cn/").join("/");
			myurl = "/"+Lang;
				if(Lang=='en'){
					myurl = "";
				}
				link="http://"+dcroot+myurl+dcuri
				window.open(link,"_self");
		}
}
function eFixCode(fCode){
	var myurl = "php/EditPay.php", http = new getXMLHTTPRequest();
	var PP = "";
	PP+="&fCode="+fCode;
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
//		HotelName=HotelName.split(" ").join("_");
//		window.open("/"+HotelName+"/accom.html","_self");
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
function ShowCreditLimit(){
	var myurl = "/hotelcontent/php/ShowCreditLimit.php", http = new getXMLHTTPRequest();
	var PP = "";
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		myText=http.responseText;
		if($("lyAgentDetail"))$("lyAgentDetail").innerHTML=myText;
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&"+new Date().getTime());
}
/*-=-=-=-=-=-=-=-=-=-=-=-= Reccommended =-=-=-=-=-=-=-=-=-=-=-=-=*/
function LoadCity(){
	var CountryCode = $("ListCountry").value

	if(CountryCode == ""){
		var ly = '';

		ly = '<select class="rec-txtbox" id="ListCity" onchange="LoadListHotel(page);">\n';
		ly = ly + '	<option value="" selected>-------- Select City --------</option>\n';
		ly = ly + '</select>\n';

		$("lyCity").innerHTML = ly;
		LoadListHotel("1");
	}else{
		var http = new getXMLHTTPRequest();
		var myurl = "php/LoadCitys.php"
		var para = "CountryCode=" + CountryCode;
		var cbo;
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			result = http.responseText;
			if(result !=""){
				$("lyCity").innerHTML = result;
				LoadListHotel("1");
			}else{
				var ly = '';

				ly = '<select class="rec-txtbox" id="ListCity" onchange="LoadListHotel(page);">\n';
				ly = ly + '	<option value="" selected>-------- Select City --------</option>\n';
				ly = ly + '</select>\n';

				$("lyCity").innerHTML = ly;
				LoadListHotel("1");
			}
		};
		http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(para+"&"+new Date().getTime());
	}
}
function LoadListHotel(page){
	if(page == ""){
		page = "1";
	}
	var para = "";
	var CountryCode = $("ListCountry").value;
	var CityCode = $("ListCity").value;
	para += "page="+page+"&";
	para += "CountryCode=" + CountryCode + "&";
	para += "CityCode=" + CityCode + "&";
	LoadListHotelCboCountryCity(para);
	LoadListHotelPage(para);
}
function LoadListHotelCboCountryCity(para){
	var http = new getXMLHTTPRequest();
	var myurl = "php/ListAllHotel.php"
	http.onreadystatechange = function() {
		if (http.readyState != 4) {
			$("listallhotel").innerHTML = '<div align="center" style="font-weight:bold; margin-top:10px;">Loading...</div>';
		}else{
			$("listallhotel").innerHTML = http.responseText;
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(para+new Date().getTime());
}
function LoadListHotelPage(para){
	var http = new getXMLHTTPRequest();
	var myurl = "php/ListAllHotelPage.php"
	http.onreadystatechange = function() {if (http.readyState != 4) { return; }
		result = http.responseText;
		if(result !=""){
			$("hotelpage").innerHTML = result;
		}
	};
	http.open("POST", myurl, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(para+new Date().getTime());
}

function LoginCheck(){
	$("errUsername").style.display= "none";
	$("errPassword").style.display = "none";
	if($("txtUsername").value.length > 8 || $("txtUsername").value.length < 4 || $("txtUsername").value == ""){
		$("errUsername").style.display = "";
	}else if($("txtPassword").value.length > 8 || $("txtPassword").value.length < 4 ||$("txtPassword").value == ""){
		$("errPassword").style.display = "";
	}
	else {
		var http = getXMLHTTPRequest();
		var myurl = "/hotelcontent/hotels/hotel.php";
		http.onreadystatechange = function(){
			if(http.readyState==4){
				var data = http.responseText;
				if(data=="PASS"){
					ChangePage("MYBOOKINGVIEWLIST");
				}else{
					alert("Please login again !!");
				}
			}
		}
		http.open("POST",myurl,true);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("Username="+$("txtUsername").value+"&Password="+$("txtPassword").value+"&Mode=member"+"&"+new Date().getTime());
	}
}
/*-=-=-=-=-=-=-=-=-=-=-=-= End Reccommended =-=-=-=-=-=-=-=-=-=-=-=-=*/
function OpenRpt(act,HICCode,AgentCode){
	switch(act){
//		case "ContractRate" : window.open("/ReportWebOffice/Production/ContractRateReport.php?HICCode="+HICCode+"&AgentCode="+AgentCode,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width="+(screen.width-10)+",height="+(screen.width-10)); break;
		case "ContractRate" : myurl="/hotelcontent/Report/ContractRateSearch.php";ShowContractRate(myurl); break;
		case "DepartureDate" : myurl="/hotelcontent/Report/DepartureDateSearch.php";ShowDepartureDateSearch(myurl,1,act); break;
		case "BookingSummary" : myurl="/hotelcontent/Report/BookingSummarySearch.php";ShowDepartureDateSearch(myurl,1,act); break;
		case "Cancellation" : myurl="/hotelcontent/Report/CancellationSearch.php";ShowDepartureDateSearch(myurl,1,act); break;
		case "InvoiceSummary" : myurl="/hotelcontent/Report/InvoiceSummarySearch.php";ShowDepartureDateSearch(myurl,1,act); break;
		case "Statement" : myurl="/hotelcontent/Report/StatementSearch.php";ShowDepartureDateSearch(myurl,0,act); break;
		case "AcitivityAccom" : myurl="/hotelcontent/Report/ActivityAccomSearch.php";ShowDepartureDateSearch(myurl,1,act); break;
	}
}
function LoadDefaultReport(nc){
	with (document.form1) {
		cld = new Date();
		nDate=cld.getDate().toString();
		nDate=(nDate.length==1)?"0"+nDate:nDate;
		nMonth=(cld.getMonth()+1).toString();
		nMonth=(nMonth.length==1)?"0"+nMonth:nMonth;
		nYear=cld.getYear().toString().substr(2,2);
		qsfromdate=nDate+"-"+nMonth+"-"+nYear;
		txtqsfromdate.value=qsfromdate;
		txtqstodate.value=qsfromdate;
		(nc==1)?cboqOpenReport.value="ALL":"";
	}
}
function ShowContractRate(myurl){
	var http = getXMLHTTPRequest();
	var PP = "";
	http.onreadystatechange = function(){
		if(http.readyState == 4 && http.status == 200) {
			var mytext = http.responseText;
			if($('lyDetail')){
				$('lyDetail').innerHTML = mytext;
			}
		}
	}
	http.open("POST", myurl, true);
	http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	http.send(PP+"&DateTime="+new Date().getTime());
}
function OpenContractRate(){
	if($("HICCode").value == ""){
		alert("Please select hotel");
	}else{
		window.open("/ReportWebOffice/Production/ContractRateReport.php?HICCode="+$("HICCode").value +"&AgentCode="+$("AgentCode").value ,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width="+(screen.width-10)+",height="+(screen.width-10));
	}
}
function ShowDepartureDateSearch(myurl,nc,act){
	var httpDepartureDateSearch = getXMLHTTPRequest();
	var PP = "";
	httpDepartureDateSearch.onreadystatechange = function(){
		if(httpDepartureDateSearch.readyState == 4 && httpDepartureDateSearch.status == 200) {
			var mytext = httpDepartureDateSearch.responseText;
			if($('lyDetail')){
				$('lyDetail').innerHTML = mytext;
				Calendar.setup({inputField : "txtqsfromdate",ifFormat : "dd-mm-yy",button : "imgFromDate",singleClick : true });
				Calendar.setup({inputField : "txtqstodate",ifFormat : "dd-mm-yy",button : "imgToDate",singleClick : true });
				changecalendar.bnight=1;
				changecalendar.setup("FromDt", "txtFromDate");
				changecalendar.setup("ToDt", "txtToDate");
				changecalendar.setup("Night", "txtNight");
				changecalendar.setup("maxNight", b2bMaxNights);
				if(act!="DepartureDate") LoadDefaultReport(nc);
			}
		}
	}
	httpDepartureDateSearch.open("POST", myurl, true);
	httpDepartureDateSearch.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	httpDepartureDateSearch.send(PP+"&DateTime="+new Date().getTime());
}
function SubmitReport(ReportURL){
	GenHtml="<Form method=\"POST\" name=\"form1\" ACTION=\""+ReportURL+"\" target='_blank'>\n";
	obj =document.form1.elements;
	for(i=0;i<obj.length;i++){
		if(!(obj[i].disabled)){
			GenHtml+="<input type='text' name='"+obj[i].id+"' value='"+obj[i].value+"'>"+obj[i].id+"<br>";
		}
	}
	GenHtml = GenHtml + "</Form>\n";
	var objWindow = eval("window.lySearchReport");
	objWindow.open("","_self");
	objWindow.document.write(GenHtml);
	objWindow.document.close();
	objWindow.document.form1.submit();
}

function ResetData(){
	$("txtqsfromdate").disabled=true;
	$("txtqstodate").disabled=true;
	$("pfromCalendar").style.display="none";
	$("ptoCalendar").style.display="none";
	document.form1.reset();
	with (document.form1) {
		cld = new Date();
		nDate=cld.getDate().toString();
		nDate=(nDate.length==1)?"0"+nDate:nDate;
		nMonth=(cld.getMonth()+1).toString();
		nMonth=(nMonth.length==1)?"0"+nMonth:nMonth;
		nYear=cld.getYear().toString().substr(2,2);
		qsfromdate=nDate+"-"+nMonth+"-"+nYear;
		txtqsfromdate.value=qsfromdate;
		txtqstodate.value=qsfromdate;
		cboqOpenReport.value="ALL";
	}
}
function ResetData2(){
	$("txtqsfromdate").disabled=true;
	$("txtqstodate").disabled=true;
	$("pfromCalendar").style.display="none";
	$("ptoCalendar").style.display="none";
	document.form1.reset();
	with (document.form1) {
		cld = new Date();
		nDate=cld.getDate().toString();
		nDate=(nDate.length==1)?"0"+nDate:nDate;
		nMonth=(cld.getMonth()+1).toString();
		nMonth=(nMonth.length==1)?"0"+nMonth:nMonth;
		nYear=cld.getYear().toString().substr(2,2);
		qsfromdate=nDate+"-"+nMonth+"-"+nYear;
		txtqsfromdate.value=qsfromdate;
		txtqstodate.value=qsfromdate;
	}
}
function DateSearch(obj){
	$("txtqsfromdate").disabled=!obj.checked;
	$("txtqsfromdate").disabled=(obj.checked) ? true : false;

	$("txtqstodate").disabled=!obj.checked;
	$("txtqstodate").disabled=(obj.checked) ? true : false;

	if(obj.checked==true){
		$("pfromCalendar").style.display="none";
		$("ptoCalendar").style.display="none";
	}else{
		$("pfromCalendar").style.display="";
		$("ptoCalendar").style.display="";
	}
}
function rptBy(act){
	$("mnuRpt").className=act;
	for(i=1;i<=3;i++){$("mnu"+i).className="m-nact";}
	$("mnu4").className="m-nact4";

	$("lyByDate").className="nbox";
	$("lyByMonth").className="nbox";
	$("lyByQuarter").className="nbox";
	$("lyByYear").className="nbox";

	switch(act){
		case "rpt1":
			$("mnu1").className="m-act";
			$("lyByDate").className="box";
			activeTab = "ByDate";
		break
		case "rpt2":
			$("mnu2").className="m-act";
			$("lyByMonth").className="box";
			activeTab = "ByMonth";
		break
		case "rpt3":
			$("mnu3").className="m-act";
			$("lyByQuarter").className="box";
			activeTab = "ByQuarter";
		break
		case "rpt4":
			$("mnu4").className="m-act4";
			$("lyByYear").className="box";
			activeTab = "ByYear";
		break
	}
	$("txtActiveTab").value=activeTab;
}
function changePropertyReport(obj){
	objChild = window.wSetProperty.form1;
	objChild.objName.value = obj.name;
	objChild.objValue.value = obj.value;
	objChild.submit();
}
function agentlogin(){
	if($("txtagentid") && $("txtagentid").value!="" && $("txtagentusername").value!="" && $("txtagentpassword").value!=""){
		var txtagentid = $("txtagentid").value;
		var txtagentusername = $("txtagentusername").value;
		var txtagentpassword = $("txtagentpassword").value;
		var url="member/agentloginconnect.php";
		var hotelcode = ($("txthotelcode")&&$("txthotelcode").value!="") ? $("txthotelcode").value : hs.myDefault.sHotel;
		var param="txtagentid="+$("txtagentid").value;
		param+="&txtagentusername="+$("txtagentusername").value;
		param+="&txtagentpassword="+$("txtagentpassword").value;
		param+="&txthotelcode="+hotelcode;
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var myText=http.responseText;
			if(myText==1){
				window.open("/"+lang+"/reservation/search.php", "_self");
			}else{
				alert("Please login again");
			}
		};
		http.open("POST", url, true); http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(param+"&"+new Date().getTime());
	}else{
		alert("Please insert agentid, username & password");
	}
}
