锘?(function () { $("#head_search_btn").click(function () { var kwd = $("#keyword").val(); //window.location.href = "/ProductList_En.aspx?kwd=" + encodeURIComponent(kwd); if (pageName().toLowerCase() == "productlist_en.aspx") { window.location.href = "/ProductList_En.aspx?kwd=" + encodeURIComponent(kwd); } else { window.location.href = "/Search_EN.aspx?keyword=" + encodeURIComponent(kwd); } }); $("#keyword").keyup(function (event) { var which = event.which; if (which == 13) { $(".search_btn").trigger("click"); } }); $(".buy").click(function () { var cas = $("#bt_delegate_list").attr("data-cas"); var productname = $("#bt_delegate_list").attr("data-productname"); var cbnumber = $("#bt_delegate_list").attr("data-cbnumber"); source = "pagerightmenu"; location.href = "/InquiryToSupplier.aspx?cas=" + cas + "&n=" + productname + "&cbnumber=" + cbnumber + "&source=" + source; }); $("#keyword").val(getSearchKeyWord()); $("#btn_for_quotation_top").click(function () { var cas = $("#bt_delegate_list").attr("data-cas"); var productname = $("#bt_delegate_list").attr("data-productname"); var cbnumber = $("#bt_delegate_list").attr("data-cbnumber"); var source = "Head RFQ"; location.href = "/InquiryToSupplier.aspx?cas=" + cas + "&n=" + productname + "&cbnumber=" + cbnumber + "&source=" + source; }); $("#btn_for_quotation_top_hide").click(function () { var cas = $("#bt_delegate_list").attr("data-cas"); var productname = $("#bt_delegate_list").attr("data-productname"); cbnumber = $("#bt_delegate_list").attr("data-cbnumber"); source = "Head RFQ"; location.href = "InquiryToSupplier.aspx?cas=" + cas + "&n=" + productname + "&cbnumber=" + cbnumber + "&source=" + source; }); //var userName = $("#cookie_userName").val(); //if (userName) { // $(".Myaccount[data-field='nologin']").hide(); // $(".Myaccount[data-field='login']").show(); // $("#username").text("Hi " + userName + "!"); // //$.ajax({ // // url: "/UserProfile/GetMemberInfo.ashx", // // dataType: "json", // // cache: false, // // success: function (data) { // // $("#username").text("Hi " + data.ContactInfo.ContactPerson + "!"); // // } // //}); //} //else { // $(".Myaccount[data-field='nologin']").show(); // $(".Myaccount[data-field='login']").hide(); //} $("#Myaccountdiv").one("mouseover", function () { $.ajax({ url: "/UserProfile/GetMyAccount.ashx", dataType: "json", cache: false, success: function (json) { if (json != 0) { var count = json.InquiryCount + json.Quotation; if (count > 0) { //$("#inquiry_count").text(count); var inquiryandquotecount = 0; if (json.Quotation > 0) { $("#my_quote").text(json.Quotation); inquiryandquotecount += json.Quotation; } if (json.InquiryCount > 0) { $("#my_inquiry").text(json.InquiryCount); inquiryandquotecount += json.InquiryCount; } if (inquiryandquotecount > 0) { $("#inquiryandquote").html(inquiryandquotecount > 99 ? 99 : inquiryandquotecount); $("#inquiryandquote").show(); } else { $("#inquiryandquote").hide(); } } else { //$("#inquiry_count").addClass("nodata"); //$("#inquiry_count").text("0"); } //$("#inquiry_count").css('visibility', 'visible'); } } }); }); }); function getSearchKeyWord() { var search = window.location.search; if (search) { var reg = new RegExp(/kwd=([^&]+)/); var matchs = reg.exec(search); if (matchs != null && matchs.length >= 2) { return decodeURIComponent(matchs[1]).replace("<", "").replace(">", "").replace("script", "").replace("%2c", ","); } } return ""; }; function getCookie(name) { var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); if (arr = document.cookie.match(reg)) return unescape(arr[2]); else return null; } function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval = getCookie(name); if (cval != null) document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); } function setCookie(name, value, time) { var strsec = getsec(time); var exp = new Date(); exp.setTime(exp.getTime() + strsec * 1); document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString() + ";Path=/"; } function getsec(str) { var str1 = str.substring(1, str.length) * 1; var str2 = str.substring(0, 1); if (str2 == "s") { return str1 * 1000; } else if (str2 == "h") { return str1 * 60 * 60 * 1000; } else if (str2 == "d") { return str1 * 24 * 60 * 60 * 1000; } } function pageName() { var strUrl = location.href; var arrUrl = strUrl.split("/"); var strPage = arrUrl[arrUrl.length - 1]; strPage = strPage.substring(0, strPage.lastIndexOf("?")); return strPage; } Array.prototype.removeByValue = function (val) { for (var i = 0; i < this.length; i++) { if (this[i] == val) { this.splice(i, 1); break; } } } function inquiryclick() { if ($("[data-field='inquiry']").length > 0) { $("[data-field='inquiry']").click(); } else if ($("#bt_delegate_list").length > 0) { $("#bt_delegate_list").click(); } else { location.href = "/InquiryToSupplier.aspx"; } } function gotomessage(username, CompanyName_EN) { location.href = '/UserProfile/Message.aspx?messageusername=' + username + '&companyname=' + CompanyName_EN; }