//函数定义 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("
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);}); } });