﻿var roomTypeNameList="Twin|Twin+1 Child|Double|Double+1 Child|Single|Triple|Twin For Sole Use|Quard";
var roomTypeCodeList="TB|TBC|DB|DBC|SB|TR|TS|Q"

var gCurrCatOpt="|HKD|EUR|USD|GBP|SGD|YEN|AUD";
var gCurrCatVal="|HKD|EUR|USD|GBP|SGD|YEN|AUD";

function promptIncorrectDateMessage(){
    alert("Incorrect Date Formatting!\nFor Instance:2008-08-08");
}

function validateDate(oDate){
    var strDate=oDate.value;
    var reg=/^(\d{4})([-])(\d{2})([-])(\d{2})/;
    if(strDate.length!=10){
        oDate.focus();
        promptIncorrectDateMessage();
        return false;
    }
    if(!reg.test(strDate)){
        oDate.focus();
        promptIncorrectDateMessage();
        return false;
    }
    return true;
}

function compareDate(oDate1,oDate2){
    
    var s1 = oDate1.value;
    var s2 = oDate2.value;
    s1 = s1.replace(/-/g, "/"); 
    s2 = s2.replace(/-/g, "/"); 
    s1 = new Date(s1);
    s2 = new Date(s2);
    
    var times= s2.getTime() - s1.getTime(); 
    var days = parseInt(times / (1000 * 60 * 60 * 24));
    if(days<1){
        oDate2.focus();
        alert("Check out not earlier than check in!");
        return false;
    }
    if(days>90){
        oDate2.focus();
        alert("Maximum Stay Period is 90!");
        return false;
    }
    return true;
}

function diffDays(date1,date2){
        s1 = date1.replace(/-/g, "/"); 
        s2 = date2.replace(/-/g, "/"); 
        s1 = new Date(s1);
        s2 = new Date(s2);
        var times= s2.getTime() - s1.getTime(); 
        var days = parseInt(times / (1000 * 60 * 60 * 24));    
	    return days;
}
    
function loadXML(src) {
var xmlDoc;
if(document.implementation && document.implementation.createDocument)
{        
xmlDoc = document.implementation.createDocument("", "", null);    
xmlDoc.async = false;
xmlDoc.load(src);
}
else if (typeof window.ActiveXObject != 'undefined')
{        
xmlDoc = new ActiveXObject('Microsoft.XMLDOM');
xmlDoc.async = false;
xmlDoc.load(src);
}	
else { xmlDoc=null; }
return xmlDoc;
}



function GetCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
//var expires = (argc > 2) ? argv[2] : null;
var expires="no";
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + (24 * 60 * 60 * 1000));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GetCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

String.prototype.trim = function()
{
   return this.replace(/(^\s+)|\s+$/g,"");
}


function $(obj){
	return (document.getElementById(obj))
}
function turn(n,m,x){
	for(i=1;i<=m;i++){
		if(i==n){
			$('lm'+x+'_'+i).className="now"
			$('content'+x+'_'+i).style.display=""
		}else{
			$('lm'+x+'_'+i).className=""
			$('content'+x+'_'+i).style.display="none"
		}
	}
	/*
	var oTabItem=document.getElementById('oTabId');
	if(n==1)
		oTabItem.value="air";
	else if(n==2)
		oTabItem.value="hotel";
	*/
}
