//Javascript //hotel index page script //create date:2011-03-30 //author :wst //copy right : chinahighlight //TrunMenu("citySwitch","active","li","dealHotels"); //各个函数区 //Obj 单击对像,calback回调函数 function TrunMenu2(Obj,callback){ $(Obj).siblings("li").removeClass("active").end().addClass("active"); var cmid = $(Obj).attr("mid"); var data = $(Obj).attr("data").split("|"); if($("#"+cmid).size()<1){ $("#waitingtable").siblings("div .dealBox").hide().end().show(); $.ajax({ type:"POST", url:'/api/api.asp', dataType:'json', data:"method=cht.hotel.monthpromotion&cityID="+data[0], success:function(data){ ListStr = ""; $.each(data.Hotel,function(i,n){ ListStr += "
\
"+n.HotelName+"
\
\

"+n.HotelName+" "+n.HotelStar+"

\
"+ (n.HotelLowPrice>0?"From $"+n.HotelLowPrice+"":"")+"
\
"+(n.HotelIntRate>0?"Customers' Rating: "+EGAP(n.HotelIntRate)+","+n.HotelIntRate:"")+"
\
\
\
\
" }); ListStr = '
'+ListStr+'
'; $("#waitingtable").hide(); $("#hotelDeals").append(ListStr); $("#"+cmid).siblings("table:visible,div .dealBox").hide().end().show(); $(".dealBox.roundCorner[id="+cmid+"]").find("a.jq_preview").preview(); if(typeof callback =="function"){ callback(Obj); } } }); } else { $("#"+cmid).siblings("table:visible,div .dealBox").hide().end().show(); if(typeof callback =="function"){ callback(Obj); } } } function GetLength(str) { var realLength = 0, len = str.length, charCode = -1; for (var i = 0; i < len; i++) { charCode = str.charCodeAt(i); if (charCode >= 0 && charCode <= 128) realLength += 1; else realLength += 2; } return realLength; }; function more_option(a) { //a=0关闭city,1打开city var obj = document.getElementById("showmoreOption"); switch(a){ case 0: obj.style.display="none"; obj=document.getElementById("show"); obj.style.display=""; obj=document.getElementById("hide"); obj.style.display="none"; break; case 1: document.getElementById("otherPromo").style.display = ""; obj.style.display=""; obj=document.getElementById("show"); obj.style.display="none"; break; } } function ds(){document.hotelsearchpanelform.submit();} //显示主推酒店 function getMaimHotel(city){ if(city=="Shanghai" || city=="Beijing" || city=="Guangzhou" || city=="Xian" || city=="Shenzhen" || city=="Guilin"){ $("#citySwitch li").filter(function(index){return $(this).text()==city}).trigger("click"); } else { $.ajax({ type: "GET", url: "/hotel/ajax-index.asp", dataType: "html", data: "city="+city, success: function(msg){ if(msg=="0"){return;} var kpNum = $("#citySwitch li").length; if(kpNum>6){ $("#citySwitch li").eq(0).text(city); $(".dealBox.roundCorner").eq(0).html(msg); }else{ var oldHTML = $("#citySwitch").html(); $("#citySwitch").prepend("
  • "+city+"
  • "); $('').insertBefore(".dealBox.roundCorner:first"); } $(".dealBox.roundCorner[id=de_"+city+"]").find("a.jq_preview").preview(); } }); } } $(function(){ var shcity= $("input[name='city']"); shcity.click(function(){ $("#hotelcities").fadeIn(200); }); $(".closeIt").click(function(){ $("#hotelcities").fadeOut(200); }); $("#hotelcities a").click(function(){ shcity.val($(this).text()); $("#hotelcities").hide(); getMaimHotel($(this).text()); }); $("#hotelstarttime").datepicker({ showAnim:"fadeIn", duration:0, minDate: 0, maxDate:"2y", numberOfMonths: 3, showButtonPanel: true }).bind('dateSelected', function(e, selectedDate, $td){ $("#hotelendtime").val(new Date(selectedDate).addDays(3).asString());$("#hotelendtime").focus();$.datepicker.dpDiv; } ); $("#hotelendtime").datepicker({ showAnim:"fadeIn", duration:0, minDate: 0, maxDate:"2y", numberOfMonths: 3, showButtonPanel: true, ortherDP:'hotelstarttime' }); //鼠标移动显示大图 if( typeof $.fn.preview == 'function' ){ $("a.jq_preview").preview();} //鼠标移到显示提示 $("img.newReview").hover( function () { $("#"+$(this).attr("cm")).show(); }, function () { $("#"+$(this).attr("cm")).hide(); } ); $("#citySwitch li").live('click',function(i){ TrunMenu2(this); }); $("#citySwitch li").filter(function(index){return $(this).text()==$("input[name=city]").val()}).trigger("click"); TrunMenu2($("#citySwitch li").eq(0)); });