var bgActiveColor="#FFFDD7";
var bgNormalColor="#FFFFFF";
var objActive;
var BURL = window.location.href;
function Zaehlen () {
	// 1 sec = 1000
	//window.open(BURL,"_self");
	window.location.reload ();
	aktiv = window.setTimeout("Zaehlen()", 300000);
}
function ClearTime () {
	window.clearTimeout(aktiv);
	aktiv = window.setTimeout("Zaehlen()", 300000); 
}
aktiv = window.setTimeout("Zaehlen()", 300000);
window.ClearTime();
function setSelectSearch(obj) { if (obj.type!="select-one") { obj.select(); } obj.style.background=bgActiveColor;}
function setBgNormal(obj) { obj.style.background=bgNormalColor; } 
function SetFocus(){   document.form1.txtqDocID.focus();  }
function LoadObj(str){return(document.getElementById(str));}
function showSearch(){
	imS = LoadObj('imgSearch');
	if(imS.src.indexOf('ico_search_act')!=-1){
		imS.src="images/ico_search.gif";
		LoadObj('TbSearch').style.display="none";
	}else{
		imS.src="images/ico_search_act.gif";
		LoadObj('TbSearch').style.display="";
	}
}
function setCboCompareDate() {
        var objCompare = document.form1.cboqDatecd;
        //disable text ###############################
        document.getElementById("lyDateSearch1").style.display="none";
        document.getElementById("lyDateSearch2").style.display="none";	
        switch (objCompare.value) {
        //user only value1 ###################################
        case "ATDATE" :
        case "LESS" :
        case "LESSEQUAL" :
        case "MORE" :
        case "MOREEQUAL" : 
                document.getElementById("lyDateSearch1").style.display="";
        break;
        //user both value1 and value2 ########################
        case "BETWEEN" : 
                document.getElementById("lyDateSearch1").style.display="";
                document.getElementById("lyDateSearch2").style.display="";
        break;
        }
}
function setCboCompareNumber() {
	var objCompare = document.form1.cboqNumcd;
	//disable text ###############################
	document.getElementById("lyNumberSearch1").style.display="none";
	document.getElementById("lyNumberSearch2").style.display="none";	

	switch (objCompare.value) {
		//user only value1 ###################################
		case "EQUAL" :
		case "LESS" :
		case "LESSEQUAL" :
		case "MORE" :
		case "MOREEQUAL" : 
			document.getElementById("lyNumberSearch1").style.display="";
			break;
		case "BETWEEN" : 
			document.getElementById("lyNumberSearch1").style.display="";
			document.getElementById("lyNumberSearch2").style.display="";
			break;
	}
}
function ChangeStatus(Status,DocID,ConfirmNo,Mode,fixStatus,Search){
        if(Status=="RSVN"){ Status="RESERVED";}
		switch(fixStatus){
			case"CONF":
			case"AMENDCONF":
				window.open("UpdateStatusHB.php?status="+Status+"&mode="+Mode+"&DocID="+DocID+"&file="+ConfirmNo+"&fStatus="+fixStatus+"&s="+Search,"wStatus");
				//OpendDetail (DocID, fixStatus);
				break;
			default:
				window.open("UpdateStatusHB.php?status="+Status+"&mode="+Mode+"&DocID="+DocID+"&file="+ConfirmNo+"&fStatus="+fixStatus+"&s="+Search,"wStatus");
				break;
		}
}
function waiting(DocID,status){
   objDate = new Date();
	window.open("waiting.php?DateTime=" + objDate.getTime()+"&docid="+DocID+"&status="+status,"wWaiting");	
}
function JumpToVoucher(DocID){     
         window.open("rptVoucher.php?DocID="+DocID,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); 
}
function JumpToDetail(DocID,Status,doctype){      
    if(doctype=="HB"){              
        window.open("rptHBooking.php?DocID="+DocID+"&Status="+Status,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); }
    else if(doctype=="AHB"){   
        window.open("rptAHBooking.php?DocID="+DocID+"&Status="+Status,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800);   }
    else {     
        window.open("rptCHBooking.php?DocID="+DocID+"&Status="+Status,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800);  }
    }
function Msg(DocID){   
    window.open("MsgMercury.php?DocID="+DocID,"_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800);  
    window.location.reload();}
function Allotment(ServiceNo,Status){ 
    window.WAllotment.open("AcceptAllotment.php?ServiceNo="+ServiceNo+"&s="+Status,"_self"); }
function LoadCbo(obj){
        DocType=document.form1.cboqDocType.value;
        window.open("LoadcboStatus.php?DocType="+DocType,"LoadStatus");
}
function OpendReport(){   window.open("rptHBsmy.php","_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); }
function OpendReport1(){   window.open("rptArrivaldate.php","_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); }
function OpendReport2(){   window.open("rMakeToDay.php","_blank","left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); }
function SendEmailConfirm(Status,DocID,ConfirmNo,Mode,fixStatus){
    objDate = new Date();
    if(Status=="CONF"){           window.open("HBookingSendmail.php?Status="+Status+"&DocID="+DocID,"wSpecial");        }
    else if(Status=="AMENDCONF"){             window.open("AHBookingSendmail.php?Status="+Status+"&DocID="+DocID,"wSpecial");         }
    else{    window.open("CHBookingSendmail.php?Status="+Status+"&DocID="+DocID,"wSpecial");   }
}//SendEmailConfirm


function getXMLHTTPRequest() {
	try {req = new XMLHttpRequest();} 
		catch(err1) {  try {req = new ActiveXObject("Msxml2.XMLHTTP");} 
		catch (err2) { try {req = new ActiveXObject("Microsoft.XMLHTTP");} 
		catch (err3) {req = false;}
	  }
	}
	return req;
}

function $ (str){return document.getElementById(str);}
function Neptune () {
	this.LoadListStatus = function (){
		var myurl = "Func/LoadListStatus.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("lyListStatus").innerHTML = mytext;
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("Code="+this.Code+"&"+new Date().getTime());
	};
	
	this.LoadStatus = function (StatusValue, Mode){
		var myurl = "Func/LoadStatus.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("lyLoadStatus").innerHTML = mytext;
			//prompt("",mytext);
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("Code="+this.Code+"&Mode="+Mode+"&StatusValue="+StatusValue+"&"+new Date().getTime());
	};
	
	this.Search = function (){
		param = "pSupplierCode="+this.Code;
		param += "&Mode=Search";
		param += "&pDocID=" + $("txtqDocID").value;
		param += "&pVoucherNo=" + $("txtqVoucherNo").value;
		param += "&pDocType=" + $("cboqDocType").value;
		param += "&pStatus=" + $("cboqStatus").value;
		param += "&pCode=" + $("cboqCode").value;
		param += "&pGuestName=" + $("txtqGuestName").value;
		param += "&pSearchDate=" + $("cboqSearchDate").value;
		param += "&pFromDate=" + $("txtqsfromdate").value;
		param += "&pDatecd=" + $("cboqDatecd").value;
		param += "&pToDate=" + $("txtqstodate").value;
		param += "&pSearchNum=" + $("cboqSearchnum").value;
		param += "&pFromPrice=" + $("txtqfromprice").value;
		param += "&pNumcd=" + $("cboqNumcd").value;
		param += "&pToPrice=" + $("txtqtoprice").value;
		
		var myurl = "Func/LoadSearch.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("lyLoadStatus").innerHTML = mytext;
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(param+"&"+new Date().getTime());
	};

	this.getDocumentDetail = function (myurl, DocID, Status){
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("lyDetail").innerHTML = mytext;
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send("DocID="+DocID+"&Status="+Status+"&"+new Date().getTime());
	};

	this.Login = function (){
		if (!this.LoginMode)this.LoginMode = 1;
		
		var param = "Mode="+this.LoginMode;
		param += "&SupplierID="+$("txtSupplierID").value;
		param += "&UserName="+$("txtUserName").value;
		param += "&Password="+$("txtPassword").value;
		var myurl = "Func/Login/Login.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("result-login").innerHTML = mytext;
			if ($("txt-result-login") && $("txt-result-login").value!="") {
				if($("txt-result-login").value=="Y"){
					window.open("Master.php", "_self"); 
				} else {
					window.open("Neptune.php", "_self"); 
				}
			}
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(param+"&"+new Date().getTime());		
	};

	this.MasterLoadList = function (){
		var param = "Mode=MasterLoadList";
		var myurl = "Func/Master/Master.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			$("lyMaster").innerHTML = mytext;
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(param+"&"+new Date().getTime());		
	};

	this.MastergetProfile = function (Code){
		var param = "Mode=MastergetProfile";
		param += "&Code="+Code;
		var myurl = "Func/Master/Master.php";
		var http = new getXMLHTTPRequest();
		http.onreadystatechange = function() {if (http.readyState != 4) { return; }
			var mytext = http.responseText;
			window.open ("Neptune.php?"+new Date().getTime(), "wDetail");
		};
		http.open("POST", myurl, true); 
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(param+"&"+new Date().getTime());		
	};

}
var JB = new Neptune () ;

function OpendDetail (DocID, Status){
	var strFileName = "Func/ChangeRate/index.php?DocID="+DocID+"&Status="+Status+"&"+new Date().getTime();
	window.open(strFileName, "_blank", "left=0,top=0,status=no,scrollbars=yes,resizable=yes,width=" + 900 + ",height=" + 800); 
}
