//s
function isIE(){ //ie?
    if (window.navigator.userAgent.indexOf("MSIE")>=1)
        return true;
    else
        return false;
}

function $(id) {
 if (document.getElementById != null) {
 return document.getElementById(id);
 }
 else if (document.all != null) {
 return document.all[id];
 }
 else {
 return null;
 }
}

function create_xmlhttp() {
var req=null;
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
}else if(window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}

return req;
}

function ajax_post(url,data){

var xmlhttp = create_xmlhttp();
xmlhttp.open("POST", url, false);
xmlhttp.setrequestheader("cache-control","no-cache");
xmlhttp.setrequestheader("content-length",data.length);
xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded");
xmlhttp.send(data);
    if(xmlhttp.readyState == 4) {
        if(xmlhttp.status == 200){
            if(xmlhttp.responseText == "True") {
             return true;
            }
            else
            {
              return false;
            }
        }
    }
}


function hideElementAll(){
	HideElement("SELECT");
	HideElement("OBJECT");
}

function showElementAll(){
	ShowElement("SELECT");
	ShowElement("OBJECT");
}

function CreateDialog(content,subject,msgw,msgh)
{
var sWidth,sHeight;
sWidth  = document.body.scrollWidth;
//sHeight = document.body.scrollHeight;
var ch = document.body.clientHeight, sh = document.body.scrollHeight;
sHeight = (sh > ch ? sh : ch);
var bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.left="0";
bgObj.style.background="#999";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75);";
bgObj.style.opacity="0.3";
bgObj.style.width= sWidth + "px";
bgObj.style.height= sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);

var msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.style.position = "absolute";
//msgObj.className = "lightbox";
msgObj.className = "helpbox";
msgObj.style.left = "50%";
msgObj.style.top = "45%";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75 + document.documentElement.scrollTop +"px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.zIndex = "10001";

var title=document.createElement("div");
title.setAttribute("id","msgTitle");
title.className = "title";
title.innerHTML='<img src="" alt="Close this Dialog" onclick="RemoveDialog()"  style="cursor:pointer;" id="close" > ' + subject;
if(isIE()) hideElementAll();
document.body.appendChild(msgObj);
$("msgDiv").appendChild(title);
var txt = document.createElement("div");
txt.setAttribute("id","msgTxt");
txt.className ="content";
txt.style.height = msgh  - 65;
txt.innerHTML = content;
$("msgDiv").appendChild(txt);

}

function RemoveDialog()
{
if($("bgDiv")){
document.body.removeChild($("bgDiv"));
$("msgDiv").removeChild($("msgTitle"));
document.body.removeChild($("msgDiv"));
if(isIE()) showElementAll();
}
}

function test(){
var reg=/^[0-9]/.test(String.fromCharCode(event.keyCode));
if(!reg) event.keyCode=0;
}

function test2(){
var reg=/^[0-9.]/.test(String.fromCharCode(event.keyCode));
if(!reg) event.keyCode=0;
}

function test3(){
var reg=/^[0-9-]/.test(String.fromCharCode(event.keyCode));
if(!reg) event.keyCode=0;
}

//可折叠式滑动显示
var colContentHeight=0;
function displayIt(contentID,maxHeight){
	var h = $(contentID).offsetHeight;
	var max_h = maxHeight;
	var anim = function(){
		h += 15;
		if(h >= max_h){
			$(contentID).style.height = maxHeight + "px";
			if(tt){
				window.clearInterval(tt);
			}
		}else{
			$(contentID).style.display="block";
			$(contentID).style.overflow = "hidden";
			$(contentID).style.height = h + "px";

		}
	}
	var tt = window.setInterval(anim,2);
}

function hiddenIt(contentID,maxHeight){
	var h = $(contentID).offsetHeight;
	var anim = function(){
		h -= 15;
		if(h <= 5){
			$(contentID).style.display="none";
			if(tt){
				window.clearInterval(tt);
			}
		}else{
			$(contentID).style.height = h + "px";
			$(contentID).style.overflow = "hidden";
		}
	}
	var tt = window.setInterval(anim,2);
}

function collapseIt(contentID,colContentHeight){
	 //if(colContentHeight==0) colContentHeight = $(contentID).offsetHeight;
	 //alert($(contentID).offsetHeight);
	if($(contentID).style.display == "block"){
		hiddenIt(contentID,colContentHeight);
	}else{
		displayIt(contentID,colContentHeight);
	}
}

//不间断横向向左滚动
function initSlide(wrapper,content1,content2){
var slideSpeed=30;
var sct=$(wrapper);
var sct1=$(content1);
var sct2=$(content2);
if(sct1.offsetWidth > sct.offsetWidth ) {
sct2.innerHTML=sct1.innerHTML;
function Marquee(){
if(sct2.offsetWidth - sct.scrollLeft <= 0){
sct.scrollLeft -= sct1.offsetWidth;
}else{
sct.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,slideSpeed);
sct.onmouseover=function() {clearInterval(MyMar);};
sct.onmouseout=function() {MyMar=setInterval(Marquee,slideSpeed);};
}
}

function DisplayAndHiddenObj(arg,titleobj,bodyobj){
    if(arg == true){
      titleobj.style.display="none";
      bodyobj.style.display="block";
    }
    else{
      titleobj.style.display="block";
      bodyobj.style.display="none";
    }
        return false;
}

function HideElement(strElementTagName){

	try{

		for(i=0;i<window.document.all.tags(strElementTagName).length; i++){

			var objTemp = window.document.all.tags(strElementTagName)[i];

			objTemp.style.visibility = "hidden";

		}

	}catch(e){

		//alert(e.message);
	}

}


function ShowElement(strElementTagName){

	try{

		for(i=0;i<document.getElementsByTagName(strElementTagName).length; i++){

			var objTemp = document.getElementsByTagName(strElementTagName)[i];

			objTemp.style.visibility = "visible";

		}

	}catch(e){
		//alert(e.message);
	}
}

function getCookie(objName){
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
   var aCrumb = aCookie[i].split("=");
   if (objName == aCrumb[0])
   {
    if (aCrumb.length > 1 )
     return unescape(aCrumb[1]);
    else
     return "";
   }
}
return "";
}


function SetTravelers(Torder_adult,Torder_child)
{
   var persons =parseInt(Torder_adult.value) + parseInt(Torder_child.value);
}

function setPeople(id1, id2, max_num, bedid, show_beds){

var num1 = parseInt(id1.value);
var num2 = parseInt(id2.value);
var num3 = parseInt(show_beds.value);
var total_num = parseInt(max_num);

if (num1 + num2 > total_num)
{
	alert("The number of passengers cannot be greater than " + max_num + " for each room.");
	id1.selectedIndex = 0;
}
if (num3)
{
	if (num1 + num2 == 2)
	{
		bedid.style.display = "";
	    bedid.disabled = false;
	}
	else
	{
		bedid.style.display = "none";
	}
}
}

function setDate(clickdate){
var selectdate=document.getElementById("Date");
for(var i=0;i<selectdate.options.length;i++)
   {
   	 var tempdate=selectdate.options[i].text;
     if(tempdate.substring(0, 10) == clickdate)
       {
          selectdate.options[i].selected = true;
          break;
       }
   }
}