//函数定义 var Daytrip = {Data:{},Fun:{}}; function changingOverTab(o) { var a_current = o; var a_parent = a_current.parent(); var a_current_name = a_current.attr("class"); a_parent.siblings().each(function(){ var sibling = $(this).find("a"); var sibling_name = sibling.attr("class"); if(testReg(/active/, sibling_name)){ sibling.removeClass('active'); } }); if(testReg(/active/, a_current_name)){ }else{ a_current.addClass("active"); } } //正则测试 function testReg(reg,str){ return reg.test(str); } //滚动条移动 var currentPosition,timer; function GoTop(){ timer=setInterval("runToTop()",1); } function runToTop(){ currentPosition=document.documentElement.scrollTop || document.body.scrollTop; currentPosition-=(10+Math.pow(currentPosition/200,3)) if(currentPosition>0) { window.scrollTo(0,currentPosition); } else { window.scrollTo(0,0); clearInterval(timer); } } //翻页函数 //page 页码 //$search['city'] //.$search['code2'] 扩展类型 //.$search['order'] 排序 function goToPage(page,city,code2,code3,order){ code2=code2.replace(/(^\s*)|(\s*$)/g, '').replace(/[&]/g, '%26').replace(/\s+/g,'-'); code3=code3.replace(/(^\s*)|(\s*$)/g, '').replace(/[&]/g, '%26').replace(/\s+/g,'-'); $.ajax({ type: "GET", url: "/daytrip/search_" + city +'_'+ code2 +'_'+ code3 +'_'+ order +'_'+ page, success: function(msg){ $("#dataGrid").html(msg); GoTop(); } }); } function geginSearch(){ if($('#city').val().length<2){ alert('Please Select a city from the drop-down.'); return; } code2 = $('#code2').val().replace(/(^\s*)|(\s*$)/g, '').replace(/[&]/g, '%26').replace(/\s+/g,'-'); code2 = (code2!='')?'?code2='+code2:''; window.location='/daytrip/list_'+$('#city').val().toLowerCase().replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g,'-')+'/' + code2; } function setTourPrice(data,date){ var ExRate = data.ExRate; var toUsd = function(rmb){rmb = Number(rmb);if(isNaN(rmb)){return 0;}return Math.ceil( rmb*1.025 / ExRate);} var toUsdU= function(rmb,Ext){return Ext + toUsd(rmb);} var toDateObj = function(str){ var result = str.split("-"); return (result.length==3)?new Date(result[0],result[1],result[2]):new Date();} var echoPrice = function(priceD,i){ //输出人等价格,如果有锯齿状 lastKey = 0; for(var key in priceD){if(priceD[key]=='0')break;lastKey = key;} } $(data.data).each(function(i){ var Item = this; var T1 = toDateObj(Item.date_start); var T2 = toDateObj(Item.date_end); var Tnow = new Date(); if( T2.getTime() > Tnow.getTime() && Tnow.getTime() > T1.getTime()){ window.tripPrice = jQuery.parseJSON(Item.price); if(Item.person_type == 0){ $("#priceTable tr:eq(0)").html("1 Person2-3 Persons\ 4-5 Persons6-9 Persons> 10 Persons"); $("#priceTable tr:eq(1)").html( '' + (tripPrice[0]?toUsdU(tripPrice[0],'$'):'--') + ''+ '' + (tripPrice[1]?toUsdU(tripPrice[1],'$'):'--') + ''+ '' + (tripPrice[2]?toUsdU(tripPrice[2],'$'):'--') + ''+ '' + (tripPrice[3]?toUsdU(tripPrice[3],'$'):'--') + '' + '' + (tripPrice[4]?toUsdU(tripPrice[4],'$'):'--') + ''); $(".bestPrice").text(toUsd(tripPrice[2])); }else if(Item.person_type == 1){ $("#priceTable tr:eq(0)").html("1 - 2 Person3 - 5 Persons\ 6 - 9 Persons> 10 Persons"); $("#priceTable tr:eq(1)").html( '' + (tripPrice[0]?toUsdU(tripPrice[0],'$'):'--') + ''+ '' + (tripPrice[1]?toUsdU(tripPrice[1],'$'):'--') + ''+ '' + (tripPrice[2]?toUsdU(tripPrice[2],'$'):'--') + ''+ '' + (tripPrice[3]?toUsdU(tripPrice[3],'$'):'--') + ''); $(".bestPrice").text(toUsd(tripPrice[2])); }else if(Item.person_type == 2){ $("#priceTable tr:eq(0)").html("Per Person"); $("#priceTable tr:eq(1)").html('' + toUsdU(tripPrice[0],'$') + ''); $(".bestPrice").text(toUsd(tripPrice[0])); } } }) } //上述函数替代 function iniPriceTable(D){ TB = $("#priceTable"); if(D.statu==1){ TB.find('tr:eq(0)').empty(); TB.find('tr:eq(1)').append('On Request'); } if(D.data.length==0){ TB.find('tr:eq(0)').empty(); TB.find('tr:eq(1)').append('On Request'); } var ExRate = D.ExRate; var toUsd = function(rmb){rmb = Number(rmb);if(isNaN(rmb)){return 0;}return Math.ceil( rmb*1.03 / ExRate);} var toUsdU = function(rmb,Ext){return Ext + toUsd(rmb);} var pershow= function(p1,p2){if(p1==p2){return p1;}else if(p1==1 && p2>20){ return 'Per'; }else if(p2>20){return ">"+p1;}else{return p1+' - '+p2;}} for(i=0;i'+ pershow(D.data[i].PKP_PersonStart, D.data[i].PKP_PersonStop) +' Person'); TB.find('tr:eq(1)').append(''+ toUsdU(p,'$') +''); } } //js formate date string function formateDT(date,formate){ var yyyy = date.getFullYear(); var mm = date.getUTCMonth()+1; var dd = date.getUTCDate(); var hh = date.getHours(); var ii = date.getMinutes(); var ss = date.getSeconds(); mm = ("00"+mm).slice(-2); dd = ("00"+dd).slice(-2); hh = ("00"+hh).slice(-2); ii = ("00"+ii).slice(-2); ss = ("00"+ss).slice(-2); if(formate == 1){ return mm +'/'+ dd + '/'+ yyyy; }else if(formate == 2){ return yyyy +'-'+ mm +'-'+ dd; } } function clearSelectCity(){ $("#select_city").hide();$("#select_city>div").html(''); } function setSelectCity(e){ if(e.target != $('#city').get(0)){ clearSelectCity();return; } $("#select_city>div").html('').append('
Top CityX
'); $.each(Daytrip.Data.city,function(){ $("#select_city>div").append(''+this.Name+''); }); $("#select_city").fadeIn("fast"); } function setCode2(Text){ $("#triptype").val(Text); $("#code2").val(Text); } function setSelectType(e){ if(e.target != $('#triptype').get(0)){ if($("#triptype").val().length<1){//If Extern Type was Empty $("#code2").val(''); } $("#select_type").hide().html('');return; } var types={}; $.each(Daytrip.Data.city,function(){ if(this.Name==$('#city').val()){ types=this; return false; } }); if(typeof types.type =='undefined' || types.type.length<1){ $("#triptype").css("background-color","rgb(240, 240, 240)").val(''); }else{ $("#triptype").css("background-color",""); $("#select_type").html('
'); $("#select_type>div").html('').append('
Trip TypeX
'); $.each(types.type,function(){ $("#select_type>div").append(''+this.n+''); }); $("#select_type").fadeIn("fast"); } } function setTourcommon(msg){ var i=msg.data.length; var obj=$("#review"); if(i>0){ obj.append('

Customer Review

'); } for(ii=0;ii\ \

by '+ msg.data[ii].UserName +' '+ msg.data[ii].PostTime +'

\

'+ msg.data[ii].commentbody +'

\ ') } } //-----split line----------------------------------------------- //-----Data Segment----- Daytrip.Data={"city":[ {"Name":"Beijing","type":[ {"n":"Essence","c":"39010"},{"n":"Great Wall Tours","c":"39011"},{"n":"Night Tours","c":"39016"},{"n":"Hutong Tour","c":"39027"},{"n":"Beijing Forbidden City Tours","c":"39042"},{"n":"Beijing City Tours","c":"39043"},{"n":"Beijing Discovery Tours","c":"39045"},{"n":"Beijing Sightseeing Tours","c":"39046"},{"n":"Beijing Summer Palace Tours","c":"39050"},{"n":"Beijing Temple of Heaven Tours","c":"39052"},{"n":"Beijing Night Tours","c":"39058"},{"n":"Beijing Great Wall Tours","c":"39065"},{"n":"Beijing Hutong Tours","c":"39066"}] }, {"Name":"Shanghai","type":[ {"n":"Culture Experience","c":"39001"},{"n":"Essence","c":"39010"},{"n":"Night Tours","c":"39016"},{"n":"Watertown Tours","c":"39017"},{"n":"Shanghai Night Tours","c":"39070"},{"n":"Shanghai City Tours","c":"39074"},{"n":"Shanghai Local Tours","c":"39076"},{"n":"Shanghai Hangzhou Tours","c":"39080"} ]}, {"Name":"Guilin","type":[ {"n":"Essence","c":"39010"},{"n":"Neighbor Tours","c":"39018"},{"n":"Guilin Li River Tours","c":"39127"},{"n":"Guilin Countryside Tours","c":"39132"}] }, {"Name":"Hong Kong","type":[ {"n":"Essence","c":"39010"},{"n":"Countryside Tours","c":"39014"},{"n":"Night Tours","c":"39016"},{"n":"Hong Kong Island Tours","c":"39093"},{"n":"Hong Kong Night Tours","c":"39094"},{"n":"Hong Kong Big Bus Tours","c":"39098"},{"n":"Hong Kong Half Day Tours","c":"39109"}] } ] }; //-----End Data Segment----- // JavaScript Document //首页的切换 $(function(){ //首页 if($(".otherCityList li").size()>0){ $(".otherCityList li").each(function(i){ $(this).bind("click",function(){ $(this).siblings().find('a').removeClass("active").end(); $(this).find('a').addClass("active"); $(".tourPro").filter(":not(:eq("+i+"))").hide().end().eq(i).show(); }); }); } $('#index_search_btn').click(function(){ var code2 = $('#triptype').val(); if(code2 != ''){ code2 = code2.replace(/(^\s*)|(\s*$)/g, '').replace(/[&]/g, '%26').replace(/\s+/g,'-'); code2 = (code2!='')?'?code2='+code2:''; window.location='/daytrip/list_'+$('#city').val().toLowerCase().replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g,'-')+'/'+code2; }else{ window.location='/daytrip/list_'+$('#city').val().toLowerCase().replace(/(^\s*)|(\s*$)/g, '').replace(/\s+/g,'-')+'/'; } }); //详细页 //价格包括与不包括,切换 $(".priceIncl .title li").click(function(){ $(this).siblings('li').removeClass('active').end().addClass('active'); $(".priceIncl .priceList").hide(); $(".priceIncl .priceList").eq($(this).index()).show(); }); //图片切换播放效果 if(typeof $().orbit == 'function'){ $('#featured').orbit({animation: 'fade', bullets: true, 'bulletThumbs': false, captions: false}); $(".advertising-container").mouseover(function(){ $(".slider-nav .right,.slider-nav .left").show(); }).mouseout(function(){ $(".slider-nav .right,.slider-nav .left").hide(); }); } //左则漂浮,效果 var sTags = $(".smallCRight"); if(sTags.size()>0){ window.r_i = 0; var ma_default = {anchortag: "href", anchorSmooth: true}; $(".tourType li").each(function(i){ r_i = i+1; $(".at"+r_i).mAnchor(ma_default); }); sTags_top = sTags.offset().top; $(window).unbind("scroll"); $(window).bind("scroll", function() { try{ var arr_t = []; //console.log(r_i); for(var i = 0; i < r_i; i++){ arr_t.push($("#t"+(i+1)).eq(0)); } var self_top = $(this).scrollTop(); if( self_top > sTags_top ){ sTags.css({"position": "fixed", "top": 0, "z-index": 10}); for(var i = 0; i < r_i; i++){ if(self_top > arr_t[i].offset().top - 10 && arr_t[i].offset().top != 0){ //console.log(i); changingOverTab($(".smallCRight .at"+(i+1))); } } }else{ sTags.css({"position": "static", "background": "none"}); changingOverTab($("#smallCityLeft .at1")); } }catch(err){} }); } if(typeof $.datepicker =="object"){ $("#Starting_Date").datepicker( {showAnim:"fadeIn",duration:0,minDate: "+3", numberOfMonths: 2,showButtonPanel: true} );//detail page } //List page if($("#city").size()>0){ $("body").click(function(e){setSelectCity(e);setSelectType(e);}); } });