﻿function SetSearchStartDay(){var str = $("#SearchHotel_hiddSetStartDay").attr("value");var endDay = $("#SearchHotel_txtEndDay");WdatePicker({minDate:str,doubleCalendar:true,onpicked:function(){endDay.focus();}});}
function SetSearchEndDay(){WdatePicker({minDate:'#F{$dp.$D(\'SearchHotel_txtStartDay\',{d:1});}',maxDate:'#F{$dp.$D(\'SearchHotel_txtStartDay\',{d:14});}',doubleCalendar:true});}
function funcPomptListInfo(arrList,strTextID,width,height,type){this.arrList = arrList;this.strTextID = strTextID;this.width = width;this.height = height;this.type = type;}
funcPomptListInfo.prototype.Show = function(objPompt){var arrList = objPompt.arrList;var objInputId = objPompt.strTextID;
document.write("<div id='div"+objInputId+"' style='overflow: auto; width: 290px; height: 350px;position:absolute;display:none;z-index: 999;'></div>");}
funcPomptListInfo.prototype.Load = function(objPompt){var arrList = objPompt.arrList;var objInputId = objPompt.strTextID;var type = objPompt.type;var outerID = "#div"+objInputId;var objouter = $("#div"+objInputId);var objInput = $("#"+objInputId);var selectedIndex=-1; var intTmp; var blnIsShowDiv = false;
if (objInput == null) {alert('初始化失败:没有找到"'+objInputId+'"文本框');return ;} 
objInput.blur(function(){blnIsShowDiv = true;objouter.hide();});objouter.blur(function(){if(blnIsShowDiv){blnIsShowDiv = false;objouter.focus();return;}objouter.hide();});objouter.focus(function(){objouter.show();});objInput.keyup(checkKeyCode);
objInput.keydown(function(){var evt = GetEvent();var keyCodes = evt.keyCode;if (keyCodes == 13 || keyCodes == 108){return false;}});objInput.focus(funcOnmouseShow);
function checkKeyCode(){var evt = GetEvent();var keyCodes = evt.keyCode;if (keyCodes == 40 || keyCodes == 38){var isUp=false;if(keyCodes == 40){isUp=true;}chageSelection(isUp);}else if(keyCodes == 39 || keyCodes == 13 || keyCodes == 108){outSelection(selectedIndex);}else{checkAndShow();}divPosition();}
function funcOnmouseShow(){
if(objInputId.indexOf("txtSearchAreaKeyWord") > -1){
divPosition();
objouter.html("");
var strHTML = "<style>body{margin:0px;padding:0px;color:#0055AA;background:#FFF;text-align:left;border:1px solid #ccc;line-height:175%;filter: alpha(opacity=80);font-size:12px;}.sman_selectedStyle{background-Color:#C8E3FC;}";
strHTML += "#divHotCity ul {margin: 0;padding: 0;}";
strHTML += "#divHotCity li {width:65px;cursor:pointer;display:block;float:left;font-size:12px;height:25px;line-height:25px;margin:0;overflow:hidden;padding:2px 0 0;text-align:center;vertical-align:middle;}";
strHTML += "</style>";
strHTML += "<div style='height:25px;border-bottom:1px dashed #ccc;color:#000'>&nbsp;&nbsp;输入中文/拼音</div>";
strHTML += "<div id=\"divHotCity\" style=\"width: 285px; display: block;\">";    
strHTML += "<ul style=\"overflow: auto; max-height: 260px;\" class=\"popcitylist\">";
strHTML += "<li title=\"北京\">北京</li>";
strHTML += "<li title=\"上海\">上海</li>";
strHTML += "<li title=\"广州\">广州</li>";
strHTML += "<li title=\"深圳\">深圳</li>";
strHTML += "<li title=\"杭州\">杭州</li>";
strHTML += "<li title=\"苏州\">苏州</li>";
strHTML += "<li title=\"宁波\">宁波</li>";
strHTML += "<li title=\"南京\">南京</li>";
strHTML += "<li title=\"三亚\">三亚</li>";
strHTML += "<li title=\"厦门\">厦门</li>";
strHTML += "<li title=\"珠海\">珠海</li>";
strHTML += "<li title=\"武汉\">武汉</li>";
strHTML += "<li title=\"成都\">成都</li>";
strHTML += "<li title=\"重庆\">重庆</li>";
strHTML += "<li title=\"西安\">西安</li>";
strHTML += "<li title=\"昆明\">昆明</li>";
strHTML += "<li title=\"青岛\">青岛</li>";
strHTML += "<li title=\"海口\">海口</li>";
strHTML += "<li title=\"沈阳\">沈阳</li>";
strHTML += "<li title=\"天津\">天津</li>";
strHTML += "</ul>";
strHTML += "</div>";
strHTML += "<script type=\"text/javascript\">";
strHTML += "var obj1 = document.getElementById('divHotCity').getElementsByTagName('li');";
strHTML += "for(var i=0;i<obj1.length;i++){";
strHTML += "(function(){";
strHTML += "var temp = obj1[i];";
strHTML += "temp.onmouseover = function(){temp.className='sman_selectedStyle';}})();";
strHTML += "(function(){";
strHTML += "var temp = obj1[i];";
strHTML += "temp.onmouseout = function(){temp.className='';}})();";
strHTML += "(function(){";
strHTML += "var x = i;";
strHTML += "obj1[x].onmousedown = function(){funcShowHotCity(obj1[x].innerHTML)}})();}";
strHTML += "function funcShowHotCity(str){window.parent.document.getElementById('"+objInputId+"').value=str;}"
strHTML += "</script>";
funcInIframe(outerID,strHTML,objouter.width(),objouter.height());
objouter.show();}else{checkAndShow();}}
function checkAndShow(){var strInput = encodeURI(objInput.attr("value"));var iCurrentText = "";if (strInput!=""){divPosition();selectedIndex = -1;objouter.html("");if(type == "Hotel"){funcAjax();}if(type == "Area"){
for (intTmp = 0;intTmp < arrList.length; intTmp++){iCurrentText = arrList[intTmp].toUpperCase();if (iCurrentText.indexOf(strInput.toUpperCase()) > -1){ var keyWords=new Array();keyWords = arrList[intTmp].split("#");addOption(decodeURI(keyWords[0]),decodeURI(keyWords[1])); continue;}}}
if(objouter.html()!=""){var strHTML = "<style>body{margin:0px;padding:0px;color:#0055AA;background:#FFF;text-align:left;border:1px solid #ccc;line-height:175%;filter: alpha(opacity=80);font-size:12px;}.sman_selectedStyle{background-Color:#C8E3FC;}</style><div style='height:25px;border-bottom:1px dashed #ccc;color:#000'>&nbsp;&nbsp;输入中文/拼音</div>" + objouter.html();
objouter.html("");funcInIframe(outerID,strHTML,objouter.width(),objouter.height());objouter.show();}else{objouter.hide();}}else{objouter.hide();}
function addOption(value,value1){var listName,listPinyin;listName=value;listPinyin=value1;
if (listPinyin.indexOf("hotel") > 0 || listPinyin == "undefined"){listPinyin = listName;listName = "";}
objouter.append("<div style='padding:0 5px;' onmouseover=\"this.className='sman_selectedStyle'\" onmouseout=\"this.className=''\" onmousedown=\"window.parent.document.getElementById('"+objInputId+"').value='" + value + "';window.parent.document.getElementById('div"+objInputId+"').style.display='none';\"> <span style='float:right;'>" +listName +"</span>"+ listPinyin+"</div>");}
function funcAjax(){var strCity = $("#txtSearchAreaKeyWord").attr("value");if(strCity==undefined || strCity==""){strCity = $("#SearchHotel_txtSearchAreaKeyWord").attr("value");}
if(strCity!=undefined && strCity!=""){
$.ajax({
    type: "get",
    data: "keyCode=" + escape(objInput.attr("value")) + "&txtCity=" + escape(strCity),
    url : "/UserControl/GetHotelName.ashx",
    datatype : "json",
    success : function(data){	
        ObjouterAdd(data);
    },
    async: false
});}}
function ObjouterAdd(str){if(str!=""){var arrList=new Array();arrList = str.split("|");  
for (intTmp = 0;intTmp < arrList.length; intTmp++){objouter.append("<div style='padding:0 5px;' onmouseover=\"this.className='sman_selectedStyle'\" onmouseout=\"this.className=''\" onmousedown=\"window.parent.document.getElementById('"+objInputId+"').value='" + arrList[intTmp].toString() + "';window.parent.document.getElementById('div"+objInputId+"').style.display='none';\"> <span>" +arrList[intTmp].toString() +"</span></div>");}}}}
function chageSelection(isUp){ 
if (objouter.css("display") == "none"){objouter.show();}
else{if(isUp){selectedIndex++;}else{selectedIndex--;}}
var iObj = document.getElementById("ifrm"+outerID).contentWindow; 
var maxIndex = iObj.document.getElementsByTagName('div').length - 1;
if (selectedIndex<0){selectedIndex=0} 
if (selectedIndex>maxIndex) {selectedIndex=maxIndex} 
for (intTmp=1;intTmp<=maxIndex;intTmp++){
    if (intTmp==selectedIndex+1){iObj.document.getElementsByTagName('div')[intTmp].className="sman_selectedStyle";}
    else if(maxIndex<selectedIndex+1){iObj.document.getElementsByTagName('div')[maxIndex].className="sman_selectedStyle";}
    else{iObj.document.getElementsByTagName('div')[intTmp].className="";}
}}
function outSelection(Index){ 
var iObj = document.getElementById("ifrm"+outerID).contentWindow;
var maxIndex = iObj.document.getElementsByTagName('span').length - 1;
if(Index<0||Index>maxIndex+1){return;}
var selcity="";
if(Index>maxIndex){selcity=iObj.document.getElementsByTagName('span')[maxIndex].firstChild.data;}
else{selcity=iObj.document.getElementsByTagName('span')[Index].firstChild.data;}
objInput.attr("value",selcity);
objouter.hide();}
function divPosition(){ 
objouter.css("top",objInput.height() + objInput.offset().top + 8);
objouter.css("left",objInput.offset().left);
var width = objPompt.width
if(!width){width = objInput.width();}
objouter.css("width",width);
var height = objPompt.height
if(!height){height = "160px";}objouter.css("height",height);}}
function funcInIframe(strID,objHTML,iWidth,iHeight){
$(document).ready(function(){      
var strIFrmID = "ifrm"+strID;
var iframe = $("<iframe />",{id:strIFrmID,width:iWidth,height:iHeight,frameborder:"0",scrolling:"no",src:"" });
$(strID).html("");
iframe.appendTo($(strID));
var iObj = document.getElementById(strIFrmID).contentWindow; 
iObj.document.open(); 
iObj.document.writeln(objHTML); 
iObj.document.close();});}
function GetEvent(){
if(document.all){return window.event; } 
func = GetEvent.caller;
while(func != null){
var arg0 = func.arguments[0]; 
if(arg0){if((arg0.constructor == Event || arg0.constructor == MouseEvent) ||(typeof(arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)){return arg0;}}
func = func.caller;}return null;}
function SetStartDay(){var str = $("#hiddSetStartDay").attr("value");var endDay = $("#txtEndDay");WdatePicker({minDate:str,doubleCalendar:true,onpicked:function(){endDay.focus();}})}
function SetEndDay(){WdatePicker({minDate:'#F{$dp.$D(\'txtStartDay\',{d:1});}',maxDate:'#F{$dp.$D(\'txtStartDay\',{d:14});}',doubleCalendar:true});}
function funcShowHotelDetail(strHotelID,strHotelName){
$.get("/Hotel/GET/GetHotelIntroduction.ashx?HID="+strHotelID,function(data){
if(data != ""){
    var strinfo = "<div id='divHotelIntroduction'>" + data + "</div>"
    var wBoxs = $("#btnshowBox").wBox({title: strHotelName  + "--酒店介绍",html: strinfo});
    $("#btnshowBox").click();
}});}
function funcShowMap(ev,strHotelName,strLatitude,strLongitude,strInfoHTML){
var wBoxs = $(ev).wBox({
    title:strHotelName,
    requestType:"iframe",
    iframeWH:{width:780,height:370},
    target:"/Public/GoogleMaps.aspx?Latitude=" + strLatitude + "&Longitude=" + strLongitude + "&InfoHTML=" + strInfoHTML + "&mapWidth=780&mapHeight=370"
});
$("#btnshowBox").click();}
function funcShowPic(ev,strHotelId,strHotelName){
var wBoxs = $(ev).wBox({
    title:strHotelName + " 图库浏览",
    requestType:"iframe",
    iframeWH:{width:850,height:500},
    target:"/Hotel/HotelPhotoBrowse.aspx?hid="+strHotelId
});
$("#btnshowBox").click();}
function funcShowDaysPrice(ev,strHotelID,strRoomType,strMode,strName){
var strStarDay = $("#hiddStarDay").attr("value");
var strEndDay = $("#hiddEndDay").attr("value");
if(strStarDay==null||strStarDay==""){strStarDay = GetDateStr(0);}
if(strEndDay==null||strEndDay==""){strEndDay = GetDateStr(1);}
var strTitle = strName + " 每日价格";
var wBoxs = $(ev).wBox({
    title:strTitle,
    requestType:"iframe",
    iframeWH:{width:850},
    target:"/Hotel/GET/GetDaysPrice.aspx?HID=" +strHotelID+ "&Type=" + strRoomType + "&Sday=" +strStarDay+ "&Eday=" +strEndDay+ "&Mode=" +strMode+"&tmp=tmp"
});
$("#btnshowBox").click();}
function funcShowRoomTypeInfo(ev,roomTypeId,roomTypeName,roomTypeRemark){
$.ajax({
type: "get",
data: "RoomId=" + roomTypeId + "&RoomName=" + roomTypeName + "&RoomRemark=" + roomTypeRemark,
url : "/Hotel/GET/GetRoomTypeInfo.ashx",
datatype : "json",
success: function(data){
    $("#divRoomTypeInfo").html(data);
    $("#divRoomTypeInfo").css("top",$(ev).height() + $(ev).offset().top + 8);
    $("#divRoomTypeInfo").css("left",$(ev).offset().left);
    $("#divRoomTypeInfo").show();
}});}
function funcHideRoomTypeInfo(){$("#divRoomTypeInfo").hide();}
function GetDateStr(AddDayCount){var dd = new Date();dd.setDate(dd.getDate()+AddDayCount);var y = dd.getFullYear();var m = dd.getMonth()+1;var d = dd.getDate(); return y + "-" + m + "-" + d;}
function funcShowRoomTypePriceAll(ev,strHotelID,strMode){
var strStarDay = $("#hiddStarDay").attr("value");
var strEndDay = $("#hiddEndDay").attr("value");
if(strStarDay==null||strStarDay==""){strStarDay = GetDateStr(0);}
if(strEndDay==null||strEndDay==""){strEndDay = GetDateStr(1);}
var $div = $("#divPriceList_"+strHotelID);
var $a = $(ev);
var type = $a.attr("class");
var divH = $div.height();
var tTa = $("#divPriceList_"+strHotelID + " table");
var tmp = ($("#divPriceList_"+strHotelID+ " tr").outerHeight()) * 4;
var ts = tTa.height();
var aH;
var strshowAllRoom = "<img src=\"/Images/pus.gif\" />更多房型/价格 ▼";
var strhideAllRoom = "隐藏房型/价格 ▲";
switch (type){
case "showAllRoom":
    if ($div.attr("noGet") == undefined || $div.attr("noGet") == ""){getHtml();return false;}setOpen();
    break;
case "hideAllRoom":
    var getH = $div.attr("dHeight");
    $div.animate({height: getH + "px"});
    $div.removeAttr("dHeight");
    $a.removeClass();
    $a.addClass("showAllRoom");
    $a.html(strshowAllRoom);
    break;
default:}
function getHtml(){$div.css("overflow", "hidden");
$.ajax({
type: "get",
data: "HID=" + strHotelID + "&Count=All" + "&Sday=" + strStarDay + "&Eday=" + strEndDay + "&Mode=" + strMode,
url : "/Hotel/GET/GetRoomTypeList.ashx",
datatype : "json",
success: function(html){$div.css({height: tmp + "px"});
$div.html(html);
aH = $div.find("table").height();
setOpen(aH);setOpen();
$div.attr("noGet", "yes");}})};
function setOpen(s){
if (s) {ts = s;}
$div.animate({height: ts + "px"});
$div.attr("dHeight", tmp);
$a.removeClass();
$a.addClass("hideAllRoom");
$a.html(strhideAllRoom);};}
function funcSetHiddSeacrchHotel(){
var strAreaKey = $("#SearchHotel_txtSearchAreaKeyWord").attr("value");
var strHotelKey = $("#SearchHotel_txtSearchHotelKeyWord").attr("value");
var strStartDay = $("#SearchHotel_txtStartDay").attr("value");
var strEndDay = $("#SearchHotel_txtEndDay").attr("value");
var strType = $("#SearchHotel_ddlSearchHotelType").attr("value");
var strStars = $("#SearchHotel_ddlSearchHotelStars").attr("value");
var strPriceRange = $("#SearchHotel_ddlSearchPriceRange").attr("value");
var strInfo = strAreaKey + "|" + strHotelKey + "|" + strStartDay + "|" + strEndDay + "|" + strType + "|" + strStars + "|" + strPriceRange;
$("#SearchHotel_hiddSearchInfo").attr("value",strInfo)}
$(document).ready(function(){
var type = $("#hiddHotelType").attr("value");
var stars = $("#hiddHotelStars").attr("value");
var price = $("#hiddHotelPrice").attr("value");
var sort = $("#hiddHotelSort").attr("value");
$("#aType_"+type).css({ color: "#ff2200", "font-weight": "bolder" });
$("#aStars_"+stars).css({ color: "#ff2200", "font-weight": "bolder" });
$("#aPrice_"+price).css({ color: "#ff2200", "font-weight": "bolder" });
var liSort = $("#liSort_"+sort);var strClass = liSort.attr("class");if(strClass!=undefined && strClass!=""){strClass = strClass.replace('Normal','Act');liSort.attr("class",strClass);}});
function funcHotelSearch(model, id){$("#"+model).attr("value",id);$("#hiddPage").attr("value","1");$("#btnSubmit").click();}
function funcSort(ths,val){
$.each($(ths).siblings(),function(index,item){$(item).attr('class',$(item).attr('class').replace('Act','Normal'));});
$(ths).attr('class',$(ths).attr('class').replace('Normal','Act'));
$("#hiddHotelSort").attr("value",val);$("#btnSubmit").click();}
var strUrl = "";
function funcCheckLogin(ev,hotelID,type,Sday,Eday){var IsLogin = $("#hiddIsLogin").attr("value");if(IsLogin == "0"){
strUrl = "/Hotel/HotelOrder.aspx?HID=" + hotelID + "&Type=" + type + "&Sday=" + Sday + "&Eday=" + Eday;
userLogin(ev); 
}else{
window.location.href = "/Hotel/HotelOrder.aspx?HID=" + hotelID + "&Type=" + type + "&Sday=" + Sday + "&Eday=" + Eday;}}
function wReload(){if(strUrl != null && strUrl != ""){window.location.href = window.location.href;}else{window.location.href = "/Hotel/Hotellist.aspx";}}
var wBoxs;
function userLogin(ev){wBoxs = $(ev).wBox({title:"会员登陆",requestType:"iframe",iframeWH:{width:780,height:355},target:"/Ajax/Login_in_2.aspx?Function=wReload()&tem="+ Math.random()});$("#btnshowBox").click();}
function tab(tabId, tabC){for(i=1;i<=4;i++){if ("tabId"+i==tabId){$("#tabId"+i).attr("class","current");}else{$("#tabId"+i).attr("class","");}if ("tabC"+i==tabC){$("#tabC"+i).attr("class","show");}else{$("#tabC"+i).attr("class","hidden");}}}
function setTab(name,cursel,n){for(i=1;i<=n;i++){var menu=document.getElementById(name+i);var con=document.getElementById("con_"+name+"_"+i);menu.className=i==cursel?"hover":"";con.style.display=i==cursel?"block":"none";}}
function funcShowHotelMap(strX,strY,strInfo){$("#frmTraffic").attr("src","/Public/GoogleMaps.aspx?Latitude="+strX+"&Longitude=" +strY+ "&mapWidth=590&mapHeight=320&InfoHTML="+strInfo);}
function funcShowHotelMeeting(strHotelID,strHotelName){$.get("/Hotel/GET/GetHotelIntroduction.ashx?Type=HotelMeeting&HID="+strHotelID,function(data){if(data != ""){var strinfo = "<div id='divHotelIntroduction'>" + data + "</div>";var wBoxs = $("#btnshowBox").wBox({title: strHotelName + "--会议介绍",html: strinfo});$("#btnshowBox").click();}else{}});}
function SetStartDay2(){var str = $("#hiddSetStartDay").attr("value");var endDay = $("#txtOutDay");WdatePicker({minDate:str,doubleCalendar:true,onpicked:function(){endDay.focus();}});}
function SetEndDay2(){WdatePicker({minDate:'#F{$dp.$D(\'txtInDay\',{d:1});}',maxDate:'#F{$dp.$D(\'txtInDay\',{d:14});}',doubleCalendar:true});}
