
//酒店详细页JS

//Ajax异步调用
function loadAjaxRequest()
{
	var hotelid = jQuery("#hotelid").val();
	var cityid = jQuery("#CityID").val();
	var star = jQuery("#Star").val();
	var price = jQuery("#Price").val();
    var pp = Math.random();

    jQuery.get("AjaxRequestProxy.aspx", { RequestType: "otherhotel", ShowDetail: true, hotelID: hotelid, cityid: cityid, Lat: jQuery("#Latitude").val(), Lng: jQuery("#Longitude").val(), star: star, price: price ,p:pp},
		function(data) {
		
			jQuery("#divotherhotel").html(data);
			
		});
//    //取城市类似的酒店
//    var ajax = new Ajax();
//    ajax.doRequest("AjaxRequestProxy.aspx?RequestType=samehotel" + strThisHotel,OnGetSameHotels);
}

//取城市类似的酒店
function OnGetSameHotels(state)
{
    if (state)
    {
        document.getElementById("div_sameHotel_title").style.display = 'block';
        
        var obj=document.getElementById("div_sameHotel");
        obj.style.display = 'block';
        obj.innerHTML = state;
    }
}

//取周边其他酒店
function OnGetOtherHotels(state)
{
    if (state)
    {
        document.getElementById("div_otherHotel_title").style.display = 'block';
        
        var obj=document.getElementById("div_otherHotel");
        obj.style.display = 'block';
        obj.innerHTML = state;
    }
}

//地图页Ajax异步调用
function loadMapRequest()
{   
    var hotelid = document.getElementById("hotelid").value;
    var cityid = document.getElementById("CityID").value;
    var star = document.getElementById("Star").value;
    var price = document.getElementById("Price").value;
    var pp = Math.random();
    var strThisHotel = "&hotelid=" + hotelid + "&cityid=" + cityid + "&star=" + star + "&price=" + price + "&x="+pp;
    
    //取周边其他酒店
    var lat = document.getElementById("Latitude").value;
    var lng = document.getElementById("Longitude").value;
    var strLatLng = "Lat=" + lat + "&Lng=" + lng;
  
    var ajax = new Ajax();
    ajax.doRequest("AjaxRequestProxy.aspx?RequestType=otherhotel&ShowDetail=true&Zoom=3&" + strLatLng + strThisHotel, OnGetMapOtherHotels);
} 

//酒店点评详细页Ajax异步调用
function loadCommentRequest(Commentpage,Commentable,displaydiv)
{   
    
    var hotelid = document.getElementById("hotelid").value;
    
    var strThisHotel = "hotelid=" + hotelid + "&commentable=" + Commentable + "&Commentpage=" + Commentpage;
    
    aj_load('AjaxRequestProxy.aspx?RequestType=hotelcommentdetail&' + strThisHotel, displaydiv);
 }
 
 //更多点评按钮，附带城市
function gotoComment()
{  
    
    var CityName = document.getElementById("CityName").value;
    var cityid = document.getElementById("CityID").value;
    
    
    window.top.location = 'http://dianping.elong.com/listcomment_'+ cityid +'_'+ CityName +'.html';
 } 

//地图页取周边其他酒店
function OnGetMapOtherHotels(state)
{
    var obj=document.getElementById("div_otherHotel");
    obj.style.display = 'block';
    
    if (state)
    {
        var hList = state;
        var mKey = "hotelset:";
        var hPos = state.lastIndexOf(mKey);
        if (hPos > -1)
        {
          hList = state.substr(0,hPos);
          //接收后台生成的JSON对象
          hotelSet = eval("(" + state.substr(hPos + mKey.length) + ")");
        }
        
        obj.innerHTML = hList;
        
        //后台生成的JSON对象添加标注
        addMarkers();
        
    }else{
        obj.innerHTML = HOTEL_DETAILS_TRAFFIC_NOOTHERHOTEL;
    }
    
    var hotelname = document.getElementById("HotelName").value;
    var lat = document.getElementById("Latitude").value;
    var lng = document.getElementById("Longitude").value;
    
    if (lat == "" || lat == "0" || lng == "" || lng == "0")
    {
        var cityName = document.getElementById("CityName").value;
        //定位到城市
        moveToCity(cityName);
    }
    else
    {
        //将该酒店标注到地图
        addHotelMarker(lat,lng,hotelname);
    }
}

        
function linkmoddate_onclick(obj)
{
	var obj=document.getElementById(obj);
	if(obj.style.display == 'none')
	{
		obj.style.display = 'block';
	}
	else
	{
		obj.style.display = 'none';
	}
}
	

function RePickDate(obj,serverDate,objCheckInDate,objCheckOutDate,hid,Theme,index)
{
	var formName = obj.form;
	var returnValue = false;
	var Page_HotelId_Validators;
	
	Page_HotelId_Validators = eval('Page_HotelID_Validators'+index);
	
	returnValue = Page_ClientValidate(Page_HotelId_Validators);	
	
	if(returnValue)
	{
	
	/*
	if (!CheckInOutDate(objCheckInDate,objCheckOutDate,serverDate,Theme))
	{ 
	   return false;
	}		
	*/

	//document.HotSrch.CheckInDate.value = objCheckInDate.value;
	//document.HotSrch.CheckOutDate.value = objCheckOutDate.value;
	document.getElementById("CheckInDate").value = objCheckInDate.value;
	document.getElementById("CheckOutDate").value = objCheckOutDate.value;
	document.getElementById("HotSrch").action="details.aspx?hotelid="+ hid;
	document.getElementById("HotSrch").submit();
	}

}

function CheckRePickDate(serverDate,Theme)
{		
	if (!CheckInOutDate(document.HotSrch.CheckInDate,document.HotSrch.CheckOutDate,serverDate,Theme))
		{ 
		   return false;
		}		
	
	return true;	
	
}

function BackSearch(isGAT)
{
	if (window.top != window.self) 
	{
        document.HotSrch.target = "_top"; //"_blank"
    }
    if (isGAT == "GAT") {
        document.getElementById("HotSrch").action = "searchGAT.aspx";
    } else {
        document.getElementById("HotSrch").action = "search.aspx";
    }
    document.getElementById("__VIEWSTATE").value="";
	document.getElementById("HotSrch").submit();
}

function PostItem(obj)
{
	if (window.top != window.self) 
	{
        document.HotSrch.target = "_top"; //"_blank"
    }
	document.getElementById("HotSrch").action="details.aspx?c=add";	
	document.getElementById("HotSrch").submit();
}



function SubmitRePickDate(obj,serverDate,preNameControl,Theme)
{
	var formName = obj.form;
	
	if (preNameControl==null)
	{
	   preNameControl = "";
	}
		
	//var returnValue = false;
	
	//returnValue = Page_ClientValidate(Page_DatePicker_Validators);	
	
	
	
		
	if (!CheckInOutDate(eval('document.HotSrch.'+ preNameControl + 'CheckInDate'),eval('document.HotSrch.' + preNameControl +'CheckOutDate'),serverDate,Theme))
	{ 
	   return false;
	}
	
			
	document.HotSrch.CheckInDate.value = eval('document.HotSrch.'+ preNameControl + 'CheckInDate').value;
	document.HotSrch.CheckOutDate.value = eval('document.HotSrch.' + preNameControl +'CheckOutDate').value;
	//document.HotSrch.RoomNum.value = eval('document.HotSrch.' + preNameControl +'RoomNum').value;
	
	var hotelid = document.HotSrch.hotelid.value;
	document.HotSrch.action="details.aspx?hotelid="+hotelid;
	document.HotSrch.submit();
	
	
	
}

function showDatePicker()
{	
	if(document.getElementById("DatePickerTable").style.display == 'none')
	{
		document.getElementById("DatePickerTable").style.display = 'block'
	}
	else
	{
		document.getElementById("DatePickerTable").style.display = 'none'
	}			
}

//接机
function GoToAirPortReception()
{
	var frm = document.forms[0];
	var oldAction = frm.action;
	var oldTarget = frm.target;
	var oldMethod = frm.method;

	frm.action = "AirPortReception.aspx";
	frm.target="_blank";
	frm.method="post";
	frm.submit();
	
	frm.action = oldAction;
	frm.target=oldTarget;
	frm.method=oldMethod;
}

//在地图页发送邮件
function sendMapToMail(obj)
{
  var email = document.getElementById(obj).value;
  
  if (!CheckEmail(email)){
    alert(HOTEL_REQUEST_GUESTINFO_EMAIL);
    return false;
  }
  
  var frm = document.getElementById("HotSrch");
  var oldAction = frm.action;
  var oldTarget = frm.target;
  var oldMethod = frm.method;
  
  frm.target="sendframe";
  frm.method="post";
  frm.action="emailAndPrint.aspx?RequestType=sendmap";
  frm.submit();
  
  frm.action = oldAction;
  frm.target=oldTarget;
  frm.method=oldMethod;
  
  return true;
}
//地埋位置信息
//add by minjiang 09-9-15
function Load_SurroundingTrafic(_sTitle,sType) {

    var sTitle = "";
    //alert(sTitle);
    //jQuery("#msgBoxDivInfo").dialog('option', "title", "aa");
    
    var sContent = "";
    switch (sType) {
        case 1:
        //酒店介绍
            sContent = jQuery("#hidHotelSimpleIntro").val();
            sTitle = jQuery("#hidHotelSimpleIntroTitle").val();
            break;
        case 2:
        //酒店交通位置
            sContent = jQuery("#hidSurroundingTrafic").val();
            sTitle = jQuery("#hidSurroundingTraficTitle").val();
            var top = $("#imgMore").offset().top + 10;
            var left = $("#imgMore").offset().left;
            $("#msgBoxDivInfo").dialog("option", "position", [left, top]);

            break;
    }
    //alert(sTitle);  
   
    //alert(sContent);
    //jQuery("#msgBoxDivInfo").html(sContent).dialog('open');
    jQuery("#msgBoxDivInfo").html(sContent);
    jQuery("#msgBoxDivInfo").dialog('option', 'width', 400);
    jQuery("#msgBoxDivInfo").dialog('option', 'height', 'auto');
    jQuery("#msgBoxDivInfo").dialog('option', 'title', sTitle);
    jQuery("#msgBoxDivInfo").dialog('open');    
    //jQuery("#msgBoxDivInfo").dialog('open');


}
function Load_ImgInfo(RoomTypeID,stitle, type, Theme) {
    //jQuery("#msgBoxDivInfo").dialog({ title: "aaa", bgiframe: true, width: 523 });
    //jQuery("#msgBoxDivInfo").dialog('option', 'maxWidth', 500);
    //jQuery("#msgBoxDivInfo").dialog('option', 'bgiframe', true );
    jQuery("#msgBoxDivInfo").dialog('option', 'title', "");
   
    var cH = 0;
    var cW = 0;

    cfsrc = "";

   if (type == "image") {
        if (Theme == "eLongEn") {
            cfsrc = "./Themes/eLongEn/DisplayImage.aspx?name=" + escape(stitle);
        }
        else if (Theme == "OnLine") {
        cfsrc = "./Themes/OnLine/DisplayImage.aspx?name=" + escape(stitle);
        }
        else if (Theme == "OnLineEn") {
        cfsrc = "./Themes/OnLineEn/DisplayImage.aspx?name=" + escape(stitle);
        }
        else {
            cfsrc = "./Themes/eLongCn/DisplayImage.aspx?name=" + escape(stitle);
        }
        cH = 445;
        cW = 415;
    }

    else if (type == "virtual") {
        if (Theme == "eLongEn") {
            cfsrc = "./Themes/eLongEn/DisplayVirtual.aspx?name=" + escape(stitle);
        }
        else if (Theme == "OnLine") {
        cfsrc = "./Themes/OnLine/DisplayVirtual.aspx?name=" + escape(stitle);
        }
        else if (Theme == "OnLineEn") {
        cfsrc = "./Themes/OnLineEn/DisplayVirtual.aspx?name=" + escape(stitle);
        }
        else {
            cfsrc = "./Themes/eLongCn/DisplayVirtual.aspx?name=" + escape(stitle)
        }
//        cH = 520;
        //        cW = 650;
        cH = 420;
        cW = 590;
    }

    //var sContent = "<iframe  id='MsgBoxFrame2' name='MsgBoxFrame2' width='"+cW +"' height='"+cH +"' frameborder='0' scrolling='no'  style='z-index:10000;overflow:hidden;' allowtransparency='true' src='" + cfsrc + "'></iframe>";
    var sContent = "<iframe  id='MsgBoxFrame2' name='MsgBoxFrame2' frameborder='0' scrolling='no'  style='z-index:10000; width:" + cW + "px;height:" + cH + "px;' allowtransparency='true' src='" + cfsrc + "'></iframe>"
    jQuery("#msgBoxDivInfo").dialog('option', 'width', cW+50);
    jQuery("#msgBoxDivInfo").dialog('option', 'height', cH + 70);
    //jQuery("#msgBoxDivInfo").dialog('option', 'bgiframe', true);
    jQuery("#msgBoxDivInfo").html(sContent).dialog('open');
//    jQuery("#msgBoxDivInfo").dialog('option', 'width', cW);
    //    jQuery("#msgBoxDivInfo").dialog('option', 'height', cH);
    
}
