function addFavorite(productTypeId,productId,site,a){ // if (!isLogined) { // showLoginBox({ // onSuccess:function(){ // hideLoginBox(); $(a).addClass("click"); doAddFavorite(productTypeId, productId, site, a); // } // }); // } else { // doAddFavorite(productTypeId, productId, site, a); // } } function doAddFavorite(productTypeId, productId, site, a) { headCheckLogin(function(loginData){ if (isUserLogined) { standardFrameWindowWrapper({ url:memberDomain+"/favorites.html?productTypeId="+productTypeId+"&productId="+productId+"&site="+site, width:600, height:268, success:function(obj){ if(!$("#notLogined,.user-not-logined").hasClass("undis")){ checkLoginAndDisplay(); } } }); } else { var singleQuotationMarks = 'singleQuotationMarks'; var params = [productTypeId, productId, site].join(","); standardFrameWindowWrapper({ url:memberDomain+"/user/login/mini?redirectURL="+encodeURIComponent("http:"+domain+"/loginSuccess.jsp?m=doAddFavorite&addtionalData="+params)+"&otherLoginRedirectURL="+encodeURIComponent(window.location.href), width:883, height:510, success:function(obj){ obj.find("#removea").css("top", "125px").css("left","730px"); } }); } }); // var width = 688; // var height=368; // var html = ""; // $(document.body).append(html); // // $.createWrapper(); // $("#favoriteDiv").show().absCenter(); // $("#favoriteDiv").find("iframe").attr("src",memberDomain+"/favorites.html?productTypeId="+productTypeId+"&productId="+productId+"&site="+site); // $("#tourListShoucangId"+productId).text("已收藏"); // $("#tourListShoucangId"+productId).addClass("click"); //// $.removeWrapper(); //// $("#favoriteDiv").slideUp().remove(); } //function closeFavorite(){ // $.removeWrapper(); // $("#favoriteDiv").slideUp().remove(); //} var eventManager = eventManager || new joytrav.EventManager(); $(function(){ checkLoginAndDisplay(); headCheckLoginOld(); $("a.loginTrigger").click(function(){ var url = domain; if(url.indexOf("http") != -1){ url.replace("http", window.location.protocol); }else{ url = window.location.protocol+url; } standardFrameWindowWrapper({ url:memberDomain+"/user/login/mini?redirectURL="+encodeURIComponent(url+"/loginSuccess.jsp?m=loginSuccess")+"&r="+Math.random()+"&otherLoginRedirectURL="+encodeURIComponent(window.location.href), width:683, height:510, success:function(obj){ obj.find("#removea").css("top", "125px").css("left","630px"); } }); }); $("a.regTrigger").click(function(){ window.location=memberDomain+"/user/reg?redirectURL="+encodeURIComponent(window.location.href); }); $("a.logoutTrigger").click(function(){ window.location=memberDomain+"/user/logout?redirectURL="+encodeURIComponent(window.location.href)+"&r="+Math.random(); }); }); function checkLoginAndDisplay() { headCheckLogin(function(loginData){ if (isUserLogined) { eventManager.post("LOGIN_SUCCESS", loginData); $("#loginedUserName").html(userNickName); $("#cartCount").html($("#cartCount").html()+" ( "+cartCount+" )"); $("#logined,.user-logined").removeClass("undis").show().addClass("inline"); $("#notLogined,.user-not-logined").addClass("undis").hide().removeClass("inline"); } else { eventManager.post("LOGIN_FAILURE", loginData); $("#logined,.user-logined").addClass("undis").hide().removeClass("inline"); $("#notLogined,.user-not-logined").removeClass("undis").show().addClass("inline"); } }); } function headCheckLogin(a) { if ($("#couponCountLabel").size() == 0) { $.ajax({ url: memberDomain+"/user/passport/check?r="+Math.random(), dataType:"jsonp", jsonp:"jsonpcallback", success:function(loginData){ isUserLogined = loginData.isLogined; userNickName = loginData.userNickName; cartCount = loginData.cartCount; if (typeof a =="function") a(loginData); } }); } } function loginSuccess() { $.removeWrapper(); checkLoginAndDisplay(); $("div#standardFrameWindowWrapper").remove(); } function headCheckLoginOld() { if ($("#couponCountLabel").size() == 1) { $.post("/checkCookie.html?r="+Math.random(),{}, function(result){ if (result != '') { var arr = result.split("||"); if(arr[3] != "Customer"){ if(arr[1]!="0"){ $("#cartCountLabel").html($("#cartCountLabel").html()+" ( "+arr[1]+" )"); } } }else{ $("#cartCountLabel").html($("#cartCountLabel").html()+" (0)"); } }); } } $(function(){ lazyload("img.laz"); $.each($("[toggle]"), function(index, obj){ var $obj = $(obj); var defaultVal = $obj.attr("toggle"); if (!$obj.val()) { if (typeof(Worker) !== "undefined") { $obj.attr("placeholder", defaultVal); } else { $obj.val(defaultVal); $obj.focus(function(){ if ($(this).val()==defaultVal) $(this).val(""); }); $obj.blur(function(){ if (!$(this).val()) $(this).val(defaultVal); }); } } }); }); function updateLazyload(){ $(window).trigger("resize"); } function lazyload(selectora, placeholder){ var config = { failure_limit: 3, effect: "fadeIn", data_attribute: "o" }; if (typeof placeholder != "undefined") { config.placeholder = placeholder; } $(selectora).lazyload(config); updateLazyload(); } $(function() { $("a.currency").click(function() { var $obj = $(this); if (!$obj.hasClass("current")) { var currency = $obj.attr("currency"); $.ajax({ url : memberDomain + "/currency/", data : { currency : currency }, dataType : "jsonp", jsonp : "jsonpcallback", success : function() { window.location.reload(true); } }); } }); //搜索框:当地玩乐 切换 $(".Head_Stypelist").on("click", "li", function() { $("#currentType").text($(this).text()); var keyword = $("#keyword"); var type = $(this).attr("data-id"); var $url = ""; switch (type) { case "1": $url = "/search/tour"; break; case "2": $url = "/search/ticket"; break; case "3": $url = "/search/hotel"; break; case "4": $url = "/search/cruise"; break; case "5": $url = "/visa/" break; case "7": $url = "/search/bus" break; case "8": $url = "/search/trip" break; case "10": $url = "/search/activity"; break; case "11": $url = "/search/hotelnew"; break; } //因同时需要匹配member和site,所以添加domain keyword.parent().attr("action", domain+$url); }); }); var tran_Simple=0; var tran_Tradition=1; //转换文本 function StranText(txt, flag) { return flag == tran_Tradition ? Traditionalized(txt) : Simplized(txt); } //转换对象,使用递归,逐层剥到文本 function translateObjects(objs) { var flag = getCookie(getCookieName()); var obj = null; if(typeof(objs)=="object"){ obj=objs.childNodes; } else { obj=document.body.childNodes; } for(var i=0;i10000&&ss.indexOf(cc.charAt(i))!=-1)str+=tt.charAt(ss.indexOf(cc.charAt(i))); else str+=cc.charAt(i); } return str; } function Simplized(cc){ var str='',ss=JTPYStr(),tt=FTPYStr(); for(var i=0;i10000&&tt.indexOf(cc.charAt(i))!=-1)str+=ss.charAt(tt.indexOf(cc.charAt(i))); else str+=cc.charAt(i); } return str; } function setCookie(name, value) //cookies设置 { var argv = setCookie.arguments; var argc = setCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; if(expires!=null) { var LargeExpDate = new Date (); LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24)); } document.cookie = name + "=" + escape(value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()))+"; path=/; domain="+document.domain; } /** * cookies读取 * @param Name cookie name * @returns the cookie value */ function getCookie(Name) { var search = Name + "="; if(document.cookie.length > 0) { offset = document.cookie.indexOf(search); if(offset != -1) { offset += search.length; end = document.cookie.indexOf(";", offset); if(end == -1) end = document.cookie.length; return unescape(document.cookie.substring(offset, end)); } else return ""; } } function getCookieName() { return "ft"+document.domain.substring(document.domain.indexOf(".")); } function changeUrl(domain, traditional){ var cookieName = getCookieName(); if (domain.indexOf(document.domain) != -1) { if (typeof traditional != "undefined") { if (traditional) { //translate to traditional chinese setCookie(cookieName,tran_Tradition,7); $("#ddw").attr("style","display:none"); $("#traditional2").attr("style",""); $("#traditional1").attr("style","display:none"); $("#simplified").attr("style",""); } else { //translate to simplified chinese setCookie(cookieName,tran_Simple,7); $("#ddw").attr("style",""); $("#traditional2").attr("style","display:none"); $("#traditional1").attr("style",""); $("#simplified").attr("style","display:none"); } } translate(true); return; } else { setCookie(cookieName,0,-100); } window.location.href=domain; } function translate(force) { var flag = getCookie(getCookieName()); if ((typeof force != 'undefined' && force == true) || flag == tran_Tradition) // 初始化显示繁体简体 if(flag != undefined && flag == 1 ){ $("#ddw").attr("style","display:none"); $("#traditional2").attr("style",""); $("#traditional1").attr("style","display:none"); $("#simplified").attr("style",""); translateObjects(); }else{ $("#ddw").attr("style",""); $("#traditional2").attr("style","display:none"); $("#traditional1").attr("style",""); $("#simplified").attr("style","display:none"); if(flag != undefined){ translateObjects(); } } } if (typeof document.all=="object") { window.attachEvent('onload', translate); } else { window.addEventListener('load', translate, false); } if (typeof i18n == 'undefined') { i18n= { getMessage:function(){ var args = Array.prototype.slice.call(arguments); var callback = args[args.length-1]; if (args.length < 2) return; if (typeof callback != 'function') return; args.length = args.length-1; getJsonResult('/i18n/getMessage', {keys:args.join(",")},callback); }, getConstant:function(key,callback) { getJsonResult('/i18n/getConstant', {key:key},callback); } }; function getJsonResult(url,data,callback) { $.ajax({ url:url, type:'post', dataType:'json', data:data, error:function(a,b,e){ callback(a.responseText); }, success:function(data){ callback(data); } }); } } $(function(){ var url= window.location.pathname; var urlstr=url.split("/"); if(urlstr[1]=='west_yellowstone'){ $("#yellowstone").attr("class","click"); }else{ $(".levelOneNav").each(function(){ if(urlstr[1]==$(this).attr("id")){ if($(this).attr("name")=="Navtop"){ $(this).parent().attr("class","click"); }else{ $(this).attr("class","click"); } }else{ if($(this).attr("name")=="Navtop"){ $(this).parent().removeClass("click"); }else{ $(this).removeClass("click"); } } }); } if(urlstr[1]=="tt"){ //主题旅行 $("#c_headnav_1").hide(); $("#c_headnav_2").hide(); $("#c_headnav_3").hide(); $("#c_headnav_4").show(); $(".navtop >a").each(function(){ if("headnav4"==$(this).attr("id")){ $(this).attr("class","click"); }else{ $(this).removeClass("click"); } }); }else if(urlstr[1]=="tripplan" || urlstr[1]=="ticket" || urlstr[1]=="bus"){ //自由行首页 $("#c_headnav_1").hide(); $("#c_headnav_2").show(); $("#c_headnav_3").hide(); $("#c_headnav_4").hide(); $(".navtop >a").each(function(){ if("headnav2"==$(this).attr("id")){ $(this).attr("class","click"); }else{ $(this).removeClass("click"); } }); }else if(urlstr[1]=="customize"){ $("#c_headnav_1").hide(); $("#c_headnav_2").hide(); $("#c_headnav_3").show(); $("#c_headnav_4").hide(); $(".navtop >a").each(function(){ if("headnav3"==$(this).attr("id")){ $(this).attr("class","click"); }else{ $(this).removeClass("click"); } }); }else if(urlstr[1].trim()!=''){ $("#c_headnav_1").show(); $("#c_headnav_2").hide(); $("#c_headnav_3").hide(); $("#c_headnav_4").hide(); $(".navtop >a").each(function(){ if("headnav1"==$(this).attr("id")){ $(this).attr("class","click"); }else{ $(this).removeClass("click"); } }); } if(urlstr.length>=4){ var ischange; if(urlstr[2].indexOf("-")==-1){ ischange=true; }else{ ischange=false; } if(ischange){ $(".view_bar >a").each(function(){ if(urlstr[2]==$(this).attr("id")){ $(this).attr("class","click"); }else{ $(this).removeClass("click"); } }); } } });