function showerrmsg(msg) { layer.msg(msg, { icon: 5, time: 4000, shade: 0.2, shadeclose: true }); } function showerrmsgandrefresh(msg) { layer.msg(msg, { icon: 5, time: 4000, shade: 0.5, shadeclose: true, end: function (index) { location.reload(true); } }); } function showerrmsgtime(msg, times) { layer.msg(msg, { icon: 5, time: (times * 1000), shade: 0.5, shadeclose: true }); } function showerrmsgtimeandrefresh(msg, times) { layer.msg(msg, { icon: 5, time: (times * 1000), shade: 0.5, shadeclose: true, end: function (index) { location.reload(true); } }); } function showok(msg) { layer.msg(msg, { icon: 1, time: 3000, shade: 0.5, shadeclose: true }); } function showokandrefresh(msg) { layer.msg(msg, { icon: 1, time: 3000, shade: 0.5, shadeclose: true, end: function (index) { location.reload(true); } }); } function showoktime(msg, times) { layer.msg(msg, { icon: 1, time: (times * 1000), shade: 0.5, shadeclose: true }); } function showoktimeandrefresh(msg, times) { layer.msg(msg, { icon: 1, time: (times * 1000), shade: 0.5, shadeclose: true, end: function (index) { location.reload(true); } }); } function showokandjump(msg, url) { layer.msg(msg, { icon: 1, time: 3000, shade: 0.5, shadeclose: true, end: function () { location.href = url; } }); } function showloading() { layer.load(1); } /*=======================手机端封装方法开始===========================================*/ function mobilinfo(msg) { //信息框 layer.msg(msg); } function mobilinfomsgtime(msg, time) { //信息框 layer.msg(msg, { time: time * 1000 }); } function mobileerror(msg) { //信息框 layer.open({ content: '' + msg + '', time: 2, skin: 'msg' }); } function mobileconfimurl(msg, url) { layer.open({ content: msg, time: 2, skin: 'msg', end: function () { location.href = url; } }); } /*========================手机端封装方法结束============================================================*/ function pcshowinfo(msg) { layer.msg(msg, { shade: [0.3], shadeclose: true, time: 2000 }); } function pcshowconfirmtourl(msg, btnyes, btnno, url) { layer.open({ content: msg, btn: [btnyes, btnno], shadeclose: true, yes: function (index) { location.href = url; }, no: function () { } }); } function showclosewindow(msg, url) { layer.alert('' + msg + '', { closebtn: 0 }, function () { location.href = url; }); } function pcshowinfoandjumpinfo(times, msg, url) { layer.msg(msg, { time: (times * 1000), shade: [0.3], shadeclose: true, end: function (index) { location.href = url; } }); } function pcshowinfoandjump(msg, url) { layer.msg(msg, { time: 3000, shade: [0.3], shadeclose: true, end: function (index) { location.href = url; } }); } /*=================================================*/ function getrequest() { var url = location.search; var therequest = new object(); if (url.indexof("?") != -1) { var str = url.substr(1); strs = str.split("&"); for (var i = 0; i < strs.length; i++) { therequest[strs[i].split("=")[0]] = decodeuri(strs[i].split("=")[1]); } } return therequest; } function importcheck(value, msg) { if ($.trim(value).length == 0) { mobilinfo(msg); return false; } return true; } function inputcheck(input_type, input) { switch (input_type) { case "num": if (!(/^\d+$/.test(input))) { return false; } return true; case "qq": if (!(/^[1-9]{1}[0-9]{4,}$/.test(input))) { return false; } return true; case "email": if (!(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-za-z]{2,4}|[0-9]{1,3})(\]?)$/.test(input))) { return false; } return true; case "mobile": if (!(/^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])[0-9]{8}$/.test(input))) { return false; } return true; case "phone": if (/^(400|800)([0-9\\-]{7,10})?$/.test(input)) { return true; } if (/^(\d{4}-|\d{3}-)?(\d{8}|\d{7})?$/.test(input)) { return true; } return false; case "fax": if (/^(400|800)([0-9\\-]{7,10})?$/.test(input)) { return true; } if (/^(\d{4}-|\d{3}-)?(\d{8}|\d{7})?$/.test(input)) { return true; } return true; case "postalcode": if (!(/^\d{6}$/.test(input))) { return false; } return true; case "username": if (input.length < 4 || input.length > 20) { //用户名必须是4-20位 return false; } if (!(/^[a-za-z]+|[a-za-z].*[0-9]|[0-9].*[a-za-z]$/.test(input))) { //用户名中不能是纯数字 return false; } return true; case "money": if (!(/^[0-9]+(.[0-9]{1,2})?$/.test(input))) { return false; } return true; case "password": if (input.length < 8 || input.length > 20) {//密码必须是8-20位 return false; } if (!(/^[a-za-z].*[0-9]|[0-9].*[a-za-z]$/.test(input))) {//密码中数字和英文字母必须同时存在 return false; } return true; case "en": if (!(/^[a-za-z ]+$/.test(input))) { //用户名中不能是纯数字 return false; } return true; case "enandnumber": if (!(/^[a-za-z\d ]+$/.test(input))) { //用户名中不能是纯数字 return false; } return true; case "domain": if (!/^(([0-9a-z_!~*'().&=+$%-]+:)?[0-9a-z_!~*'().&=+$%-]+@)?(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z_!~*'()-]+\.)*([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.[a-z]{2,6})$/.test(input)) {//判断是否合法的域名 return false; } return true; default: return true; } } //写cookie function addcookie(objname, objvalue, objhours) { var str = objname + "=" + escape(objvalue); if (objhours > 0) {//为0时不设定过期时间,浏览器关闭时cookie自动消失 var date = new date(); var ms = objhours * 3600 * 1000; date.settime(date.gettime() + ms); str += "; expires=" + date.togmtstring(); } document.cookie = str; } //读cookie function getcookie(objname) {//获取指定名称的cookie的值 var arrstr = document.cookie.split("; "); for (var i = 0; i < arrstr.length; i++) { var temp = arrstr[i].split("="); if (temp[0] == objname) return unescape(temp[1]); } return ""; } //删除cookie 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 () { document.onkeydown = function (e) { var ev = document.all ? window.event : e; if (ev.keycode == 13) { var inputid = $(":input:focus").attr("id"); if (inputid == "txttopkeyword") { topsearch(1); } else if (inputid == "txtsearchkeyword") { topsearch(2); } } } }); function postmessage() { var message_phone_tip = "请输入您的电话"; var message_email_tip = "请输入您的邮箱"; var message_email_error_tip = "邮箱格式不正确,请检查"; var message_content_tip = "请输入留言内容"; var message_policy_tip = "您需同意隐私条款后才可提交留言"; var message_success_tip = "留言提交成功,我们将会尽快与您联系!"; if (currentlanguagetype == 2) { message_phone_tip = "please enter your phone number"; message_email_tip = "please enter your email address"; message_email_error_tip = "the email format is incorrect, please check"; message_content_tip = "please enter the message content"; message_policy_tip = "you need to agree to the privacy terms before submitting a message"; message_success_tip = "the message has been successfully submitted, and we will contact you as soon as possible!"; } else if (currentlanguagetype == 3) { message_phone_tip = "請輸入您的電話"; message_email_tip = "請輸入您的郵箱"; message_email_error_tip = "郵箱格式不正確,請檢查"; message_content_tip = "請輸入留言內容"; message_policy_tip = "您需同意隱私條款後才可提交留言"; message_success_tip = "留言提交成功,我們將會儘快與您聯系!"; } if (!importcheck($("#txtfooterphone").val(), message_phone_tip)) { $("#txtfooterphone").focus(); return; } if (!importcheck($("#txtfooteremail").val(), message_email_tip)) { $("#txtfooteremail").focus(); return; } if (!inputcheck("email", $("#txtfooteremail").val())) { mobilinfomsgtime(message_email_error_tip, 5); $("#txtfooteremail").focus(); return; } if (!importcheck($("#txtfootercontent").val(), message_content_tip)) { $("#txtfootercontent").focus(); return; } if ($('#policy').is(':checked')) { } else { mobilinfomsgtime(message_policy_tip, 6); return; } $.ajax({ url: "/ajaxpage/ajax.ashx?action=postguestbook", data: { "l": currentlanguagetype, "tel": $("#txtfooterphone").val(), "email": $("#txtfooteremail").val(), "address": $("#txtfooteraddress").val(), "content": $("#txtfootercontent").val() }, type: "post", datatype: "json", beforesend: function () { showloading(); }, success: function (result) { layer.closeall(); if (result.status == 1) { $("#txtfooterphone").val(""); $("#txtfooteremail").val(""); $("#txtfooteraddress").val(""); $("#txtfootercontent").val(""); mobilinfomsgtime(message_success_tip, 10); } else { showerrmsg(result.msg); } }, error: function () { layer.closeall(); layer.msg("抱歉,留言提交失败,请联系客服!"); } }); } var currentlanguagetype = 1; function topsearch(locationtype) { var searchkeyword = $.trim($("#txttopkeyword").val()); if (locationtype == 2) { searchkeyword = $.trim($("#txtsearchkeyword").val()); } var showtips = "总得告诉我您要找的内容吧 :)"; var servarurl = "/search.html?keyword=" + encodeuricomponent(searchkeyword); if (currentlanguagetype == 2) { showtips = "please enter what you want to search"; servarurl = "/en" + servarurl; } else if (currentlanguagetype == 3) { showtips = "請填寫您要搜尋的關鍵字"; servarurl = "/ft" + servarurl; } if (searchkeyword.length == 0) { mobilinfomsgtime(showtips, 7); $("#txttopkeyword").focus(); if (locationtype == 2) { $("#txtsearchkeyword").focus(); } return; } location.href = servarurl; }