﻿// JScript 文件
        window.status=" ";
function $ID(id)
{
    return document.getElementById(id);
}

function $TN(xmlHttp,obj)
{
    return xmlHttp.responseXML.getElementsByTagName(obj);
}

function getNodeValue(obj)
{
	if (window.navigator.userAgent.indexOf("MSIE")>=1)
    //如果浏览器为IE
    {
		return obj.text;
    }
    else //如果浏览器为Firefox
    {
        if (window.navigator.userAgent.indexOf("Firefox")>=1)
        {
			return obj.textContent;
        }
    }
	return "浏览器不兼容!";
}

function loadXMLDoc(dname) 
{
try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e) {alert(e.message)}
  }
try 
  {
  xmlDoc.async=false;
  xmlDoc.load(dname);
  return(xmlDoc);
  }
catch(e) {alert(e.message)}
return(null);
}

function createXMLHttpRequest(xmlHttp) 
{ 
    if(window.XMLHttpRequest) 
    { 
        xmlHttp=new XMLHttpRequest();//mozilla浏览器 
    } 
    else if(window.ActiveXObject) 
    { 
        try 
        { 
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");//IE旧版本 
        } 
        catch(e) 
        { 
        } 
        try 
        { 
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");//IE新版本 
        } 
        catch(e) 
        { 
        } 
        if(!xmlHttp) 
        { 
            window.alert("不能创建XMLHTTPREQUEST对象!"); 
            return false; 
        } 
    }
    return xmlHttp;
}
function xmlRequestCode(url,requestChange)
{
    var xmlHttp=null;
    xmlHttp = createXMLHttpRequest(xmlHttp,xmlHttp);
    xmlHttp.open("Post",url,true);
    xmlHttp.onreadystatechange=function(){return requestChange.call(xmlHttp,xmlHttp)}; 
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    xmlHttp.send(null);
}

function getRoomDatePriceDS(RoomID,startTime,endTime)//
{
	$ID("PreviewBox").style.display = "none";
    if(startTime=="")
    {
        alert("请输入起始时间");
        return;
    }
    if(endTime=="")
    {
        alert("请输入结束时间");
        return;
    }
    var url = "http://www.hnsss.com/aspx/RoomPriceDetail.aspx?RoomID="+RoomID+"&startTime="+startTime+"&endTime="+endTime;
    xmlRequestCode(url,roomDatePrice);
    void(0);
}
function roomDatePrice(xmlHttp)
{
    if(xmlHttp.readyState==4)
　　{
　　　　if(xmlHttp.status==200)
　　　　{
　　　　    if(xmlHttp.responseText != "酒店未提供该时间段房价信息")
　　　　    {
                var tempTable = $TN(xmlHttp,"tempTable");
                var i = 0;
                var tempHtml = "";
                var tabl=$ID("datePriceTable");
                tabl.parentNode.removeChild(tabl);
                var tabl = document.createElement("table");
                tabl.setAttribute("id", "datePriceTable");
                tabl.setAttribute("name", "datePriceTable");
                tabl.setAttribute("class", "hotel_room_price_date2");
                tabl.setAttribute("className", "hotel_room_price_date2");
                var tr = tabl.insertRow(-1);
                var td0= tr.insertCell(-1);
                var td1= tr.insertCell(-1);
                var td2= tr.insertCell(-1);
                var td3= tr.insertCell(-1);
                var td4= tr.insertCell(-1);
                var td5= tr.insertCell(-1);
                var td6= tr.insertCell(-1);
                $ID("Room_Price_Cal").appendChild(tabl);
                for(i=0;i<tempTable.length;i++)
                {
                    var CurrentDate = getNodeValue($TN(xmlHttp,"lrsj")[i]);
                    var date = new Date(CurrentDate.substring(0,4),CurrentDate.substring(5,7)*1-1,CurrentDate.substring(8,10));
                    var psjg = getNodeValue($TN(xmlHttp,"psjg")[i]);
                    var zmjg = getNodeValue($TN(xmlHttp,"zmjg")[i]);
                    var Introduction = getNodeValue($TN(xmlHttp,"sm")[i]);
					var sfzc = getNodeValue($TN(xmlHttp,"bz")[i]);
					var nID = getNodeValue($TN(xmlHttp,"nID")[i]);
					sfzc = (sfzc!="")?sfzc:"无";
                    Introduction = (Introduction!="")?Introduction:"无";
                    CurrentDate = CurrentDate.substring(5,10);
                    var day = CurrentDate.substring(0,2)+CurrentDate.substring(3,5);
                    day = "a"+day;
                    var datePriceHTML = "<em>"+CurrentDate+"</em><i>"+psjg+"<s>"+sfzc+"</s><small id='"+day+"'>详细说明:<br />"+Introduction+"</small></i>";
                    var zmjgHTML = "<em style='color:blue'>"+CurrentDate+"</em><i>"+zmjg+"<s>"+sfzc+"</s><small id='"+day+"'>详细说明:<br />"+Introduction+"</small></i>";
                    if(date.getDay()==0)
                    {
                        var tr = tabl.insertRow(-1);
                        var td0= tr.insertCell(-1);
                        var td1= tr.insertCell(-1);
                        var td2= tr.insertCell(-1);
                        var td3= tr.insertCell(-1);
                        var td4= tr.insertCell(-1);
                        var td5= tr.insertCell(-1);
                        var td6= tr.insertCell(-1);
                    }
                    switch(date.getDay())
                    {
                        case 0:
                            setTDAttribute(td0,day,datePriceHTML);
                            break;
                        case 1:
                            setTDAttribute(td1,day,datePriceHTML);
                            break;
                        case 2:
                            setTDAttribute(td2,day,datePriceHTML);
                            break;
                        case 3:
                            setTDAttribute(td3,day,(nID==297)?zmjgHTML:datePriceHTML);
                            break;
                        case 4:
                            setTDAttribute(td4,day,(nID==5 || nID==28 || nID==30 || nID==140 || nID==172 || nID==250 || nID==277 || nID==297 || nID==356)?zmjgHTML:datePriceHTML);
                            break;
                        case 5:
                            setTDAttribute(td5,day,zmjgHTML);
                            break;
                        case 6:
                            setTDAttribute(td6,day,zmjgHTML);
                            break;
                    }
                    if(date.getDay()==6)
                    {
                        var tr = tabl.insertRow(-1);
                        var td0= tr.insertCell(-1);
                        var td1= tr.insertCell(-1);
                        var td2= tr.insertCell(-1);
                        var td3= tr.insertCell(-1);
                        var td4= tr.insertCell(-1);
                        var td5= tr.insertCell(-1);
                        var td6= tr.insertCell(-1);
                    }
                }
                $ID("PreviewBox").style.display = "block";
            }
            else
            {
				ymPrompt.alert({title:'特惠酒店',message:'<div style="padding-top:15px;text-align:center;">特惠酒店,详细价格请咨询客服!咨询热线：<span style="color:Red;font-size:14px;">400-7258-666</span></div>',icoCls:'',width:395,height:102,increment:0.3,interval:50});
                $ID("PreviewBox").style.display = "none";
            }
　　　　}
　　　　else if(xmlHttp.status==404)
　　　　{			
			$ID("PreviewBox").style.display = "none";
　　　　    	alert("找不到请求的服务器资源！");
　　　　}
　　　　else
　　　　{			
			$ID("PreviewBox").style.display = "none";
			alert("Internal Server Error "+xmlHttp.status);
　　　　}
　　}
}

function setTDAttribute(obj,day,datePriceHTML)
{
    obj.setAttribute("class","day");
    obj.setAttribute("id","td_"+day);
    obj.innerHTML = datePriceHTML;
    setMyEvent(obj,day);
}
function setMyEvent(obj,day)
{
    if (window.navigator.userAgent.indexOf("MSIE")>=1)
    //如果浏览器为IE
    {
        obj.setAttribute("onmouseover",function() {show_Breakfast1(day);});
        obj.setAttribute("onmouseout",function() {hiddshow_Breakfast1(day);});
    }
    else //如果浏览器为Firefox
    {
        if (window.navigator.userAgent.indexOf("Firefox")>=1)
        {
            obj.setAttribute("onmouseover", "show_Breakfast1('"+day+"');");
            obj.setAttribute("onmouseout", "hiddshow_Breakfast1('"+day+"');");
        }
    }
}
function show_Breakfast1(day){
	try
	{
	var Td_ID_s;
	Td_ID_s = document.getElementById('td_'+day);
	Td_ID_s.style.background = '#DCEEF4';

	var Td_ID;
	Td_ID = document.getElementById(day);
	Td_ID.style.position = 'absolute';
	Td_ID.style.display = 'block';
	Td_ID.style.width='160px';
	Td_ID.style.height='auto';
	Td_ID.style.border = '1px solid #ccc';
	Td_ID.style.textAlign='left';
	Td_ID.style.padding='6px'
	}
	catch (e)
	{
	}
}
function hiddshow_Breakfast1(day){

	try
	{
		var Td_ID_s = 'td_'+day;
		Td_ID_s = document.getElementById(Td_ID_s);
		Td_ID_s.style.background = '#ffffff';

		var Td_ID = document.getElementById(day);
		Td_ID.style.position = 'absolute';
		Td_ID.style.display = 'none';
		
	}
	catch (e)
	{
		
	}

}

function showPreviewBox(PreviewBox)
{
    $ID("PreviewBox").style.display = "block";
}
function closePreviewBox(PreviewBox)
{
    $ID("PreviewBox").style.display = "none";
}
function rePostDatePrice()
{
    var RoomID = getRoomID();
    var startTime = $ID("d4311").value;
    var endTime = $ID("d4312").value;
    //alert(RoomID+ ":" +startTime+ "-----" +endTime);
    getRoomDatePriceDS(RoomID,startTime,endTime);
    void(0);
}
function setRoomID(RoomID)
{
    $ID("hidRoomID").value = RoomID;
}
function getRoomID()
{
    return $ID("hidRoomID").value;
}
function aaa(RoomID)
{
    alert(RoomID);
}




function xmlRequestCodeHotelPrice(url,requestChange)
{
    var xmlHttp=null;
    xmlHttp = createXMLHttpRequest(xmlHttp,xmlHttp);
    xmlHttp.open("Post",url,true);
    xmlHttp.onreadystatechange=function(){return requestChange.call(xmlHttp)}; 
    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
    xmlHttp.send(null);
}
function getHotelPrice(HotelID,startTime)
{
    var url = "http://www.hnsss.com/aspx/HotelPrice.aspx?HotelID="+RoomID+"&startTime="+startTime;
    xmlRequestCodeChristmas(url,HotelPrice(xmlHttp,xmlHttp));
    void(0);
}
function HotelPrice(xmlHttp)
{
	alert(objTable);
	alert(objDIV);
    if(xmlHttp.readyState==4)
　　{
　　　　if(xmlHttp.status==200)
　　　　{
　　　　    if(xmlHttp.responseText != "noMessage")
　　　　    {
                var tempTable = $TN(xmlHttp,"tempTable");
                var i = 0;
                var tempHtml = "";
                for(i=0;i<tempTable.length;i++)
                {                    
                    var psjg = getNodeValue($TN(xmlHttp,"psjg")[i]);
                    //var zmjg = getNodeValue($TN(xmlHttp,"zmjg")[i]);
                }
                $ID("PreviewBox").style.display = "block";
            }
            else
            {
				
            }
　　　　}
　　　　else if(xmlHttp.status==404)
　　　　{			
			//$ID("PreviewBox").style.display = "none";
　　　　    	alert("找不到请求的服务器资源！");
　　　　}
　　　　else
　　　　{			
			//$ID("PreviewBox").style.display = "none";
			alert("Internal Server Error "+xmlHttp.status);
　　　　}
　　}
}