You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.2 KiB
JavaScript

//Javascript
//hotel index page script
//create date:2011-03-30
//author :wst
//copy right : chinahighlight
TrunMenu("citySwitch","active","li","dealHotels");
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").html("<li>"+city+"</li>" + oldHTML);
$('<div class="dealBox roundCorner" style="display: none;" name="dealHotels">'+msg+'</div>').insertBefore(".dealBox.roundCorner:first");
}
$(".dealBox.roundCorner").eq(0).find("a.jq_preview").preview();
TrunMenu("citySwitch","active","li","dealHotels");
}
});
}
}
$(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'
});
//鼠标移动显示大图
$("a.jq_preview").preview();
//鼠标移到显示提示
$("img.newReview").hover(
function () {
$("#"+$(this).attr("cm")).show();
},
function () {
$("#"+$(this).attr("cm")).hide();
}
);
$("#citySwitch li").filter(function(index){return $(this).text()==$("input[name=city]").val()}).trigger("click");
});