﻿/*
		--- 首页AJAX组件，异步读取页面并显示！ ---
		Author: 王龙,华北科技学院计算机B04-2
		Corp.: 微彩科技
		版权所有，未经需要不需用于其他用途
		Email: wanglong@ncist.edu.cn
		Website: www.yanjiao.org  www.longinsky.com
		
	*/
    
    var xmlHttp;
    /*if (window.ActiveXObject && !window.XMLHttpRequest) 
    {
	    window.XMLHttpRequest = function() 
	    {
		    var MSXML = ['Msxml2.XMLHTTP.5.0','Msxml2.XMLHTTP.4.0','Msxml2.XMLHTTP.3.0','Msxml2.XMLHTTP','Microsoft.XMLHTTP'];
		    for (var i = 0; i < MSXML.length; i++) 
		    {
			    try 
			    {
				    return new ActiveXObject(MSXML[i]);
			    } 
			    catch (e) {}
		    }
		    return null;
	    };
    }*/
    
    
    function createXmlHttpRequestObject()
    {
        var xmlHttpx;
        if(window.ActiveXObject)//如果在Internet Explorer下运行
        {
           try
           {
            xmlHttpx=new ActiveXObject("Microsoft.XMLHTTP");
           }
           catch(e)
           {
            xmlHttpx=false;
           }
        }
        else//如果在Mozilla或其它浏览器运行
        {
           try
           {
            xmlHttpx=new XMLHttpRequest();
           }
           catch(e)
           {
            xmlHttpx=false;
           }
        }
        if(!xmlHttpx)
        alert("没有创建XMLHttpRequest对象，可能你浏览器版本过低，推荐使用IE7.0");
        else
        return xmlHttpx;
    }


    xmlHttp=createXmlHttpRequestObject();
    
    //发送数据
    function postMsg(URL,strMsg,callBackFunction)
    {
	    xmlHttp.open("POST",URL , true);
	    xmlHttp.setRequestHeader ("CONTENT-TYPE","application/x-www-form-urlencoded")
	    xmlHttp.setRequestHeader("content-length",strMsg.length);
	    xmlHttp.onreadystatechange = callBackFunction;
	    xmlHttp.send(strMsg);
    }
    
    
    var roomname;
    var objname;
    function   getAbsolutePos(el)   {   
        var   r   =   {   x:   el.offsetLeft,   y:   el.offsetTop   };   
        if   (el.offsetParent)   {   
        var   tmp   =   getAbsolutePos(el.offsetParent);   
        r.x   +=   tmp.x;   
        r.y   +=   tmp.y;   
        }   
        return   r;   
    }
    
    function finishDoGetContent()
    {
        if (xmlHttp.readyState==4 && xmlHttp.status == 200)
	    {
	        ShowInfo(xmlHttp.responseText);
	    }
	    else
	    {
	        if(xmlHttp.readyState==4 && xmlHttp.status != 200)
	        {
	            ShowInfo(xmlHttp.responseText);
	        }
	        else
	        {
	        }
	    }
    }
    function CloseContent()
    {
        document.getElementById("DivShowPrice").style.display="none";
    }
    
    function ShowInfo(Info)
    {
        document.getElementById("DivShowPrice").innerHTML=Info;
        var rm=getAbsolutePos( document.getElementById(roomname));
        document.getElementById("DivShowPrice").style.display="";
        document.getElementById("DivShowPrice").style.left=rm.x;
        document.getElementById("DivShowPrice").style.top=rm.y+15;
    }
    


    function DoLoadRoomDetailData(id,begindate,enddate,roomName)
    {
        roomname=roomName;
        //ShowInfo(roomName+"的房价","正在读取房间价格日数据",cnstat_Style[1]);
        ShowInfo("正在读取房价数据，请等待..")
        postMsg("GetRoomPriceAPI.aspx","RoomID="+id.toString()+"&InDate="+begindate+"&OutDate="+enddate,finishDoGetContent);
        
    }