var request = false;

try {
 request = new XMLHttpRequest();
} catch (trymicrosoft) {
 try {
 request = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (othermicrosoft) {
 try {
 request = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (failed) {
 request = false;
 }
 }
}
if (!request)alert("Error initializing XMLHttpRequest!");

 
//获取信息
function getInfo(id) {

 var url = "/ajax/room.asp?h="+id+"&db="+_$("date1").value+"&de="+_$("date2").value;
 request.open("GET", url, true);
 request.onreadystatechange = updatePage;
 request.send(null);
}
//更新页面
function updatePage() {
 if (request.readyState == 4) 
 {
 if (request.status == 200) {
 var response = request.responseText;
 document.getElementById("roomprice").innerHTML = response;
 } else
 alert(request.status + "错误");
 } else
 document.getElementById("roomprice").innerHTML = "价格加载中……";
}
function getCataInfo(parent){
	 var url = "/ajax/hotelArea.asp?parent="+parent;
     request.open("GET", url, true);
     request.onreadystatechange = showCata;
     request.send(null);
	}
	
function showCata(){
 if (request.readyState == 4) 
 {
 if (request.status == 200) {
 var response = request.responseText;
 document.getElementById("cataIdTD").innerHTML = response;
 } else
 alert(request.status + "错误");
 } else
 document.getElementById("cataIdTD").innerHTML = "加载中...";
}	

function DateDiff(sDate1, sDate2)
        {
            iDays = parseInt(Math.abs(sDate1 - sDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数
            return iDays 
        }
	//把字符串转化为日期	
		function formatDate(dateStr){
			aDate = dateStr.split("-") 
            oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式
            return oDate1
		}
		//把日期转化为输出用字符串 07月8日格式
		function print_date(sdate){
			return sdate.getMonth()+1+"月"+sdate.getDate()+"日"
		}
		//把日期转换为字符 2009-8-7格式
		function date2str(sdate){
			return sdate.getYear()+"-"+(sdate.getMonth()+1)+"-"+sdate.getDate()
		}
		//判断数组中是否存在指定元素 needle->指定元素 haystack->数组
		function in_array(needle, haystack) {
			var j=0	
		  for(var i in haystack) {
		   if(haystack[i] == needle) {
			 return j;		  
		  }
		  j++
		 }
		 return -1;
		} 
	function _$(id){
		return document.getElementById(id)
	}
	function gL(x){
	var l=0;
	while(x){
		l+=x.offsetLeft;
		x=x.offsetParent;
	}
	return l
	};
	function gT(x){
	var t=0;
	while(x){
		t+=x.offsetTop;
		x=x.offsetParent;
	}
	return t
	};
	function closeRoomAlert(){
		
		if(_$("alertDIV")){
		//	alert("aa")	
		document.body.removeChild(_$("alertDIV"))
		}
	}

function changeBanner(id){
		initShow();
		_$(id+"Button").className = "t9 showBanner_cur";
		_$(id+"Div").style.display = "";
	}
function initShow(){
		_$("showDiv").style.display = "none";
		_$("roomDiv").style.display = "none";
		_$("photoDiv").style.display = "none";
		_$("guestDiv").style.display = "none";
		_$("showButton").className= "t15 showBanner";
		_$("roomButton").className = "t15 showBanner";
		_$("photoButton").className = "t15 showBanner";
		_$("guestButton").className = "t15 showBanner";
		
	}
function loadShowInit(){
		initShow();
		var strHref = window.location.href;	
		if(strHref.indexOf("room")>0){
			_$("roomButton").className= "t9 showBanner_cur";
			_$("roomDiv").style.display = "";
		}else if(strHref.indexOf("photo")>0){
			_$("photoButton").className= "t9 showBanner_cur";
			_$("photoDiv").style.display = "";
		}else if(strHref.indexOf("guest")>0){
			_$("guestButton").className= "t9 showBanner_cur";
			_$("guestDiv").style.display = "";
		}else{
			_$("showButton").className= "t9 showBanner_cur";
			_$("showDiv").style.display = "";
		}	
	}	
	
	
