﻿function setTab(name, cursel, n, hiddenID) { $("#" + hiddenID).val(cursel); for (i = 1; i <= n; i++) { var menu = document.getElementById(name + i); var con = document.getElementById("con_" + name + "_" + i); menu.className = i == cursel ? "hover" : ""; con.style.display = i == cursel ? "block" : "none"; } } function GetUrlParms() { var args = new Object(); var query = location.search.substring(1); var pairs = query.split("&"); for (var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf('='); if (pos == -1) continue; var argname = pairs[i].substring(0, pos); var value = pairs[i].substring(pos + 1); args[argname] = unescape(value); } return args; } function ShowError(msg) { ShowAlertInfomation("errornote", msg); } function ShowAlertInfomation(resultType, msg) { $("#ClientValidator").removeClass("infonote").removeClass("errornote").removeClass("successnote"); $("#ClientValidator").addClass(resultType); $("#ClientValidator").text(msg); $("#ClientValidator").show(); } function HideAlertInfomation() { $("#ClientValidator").removeClass(resultType); $("#ClientValidator").text(""); $("#ClientValidator").hide(); } function SetInfomationBanelCss() {
    $(".syswin-banel .m_r").click(function() {
        if ($(".syswin-content").css("display") == "none") $(".syswin-content").fadeIn("normal"); else
            $(".syswin-content").fadeOut("normal");
    });
} function SetMenuCss2() { $("ul.topnav li").click(function() { $(this).find("ul.subnav:has(li)").show(); $(this).hover(function() { }, function() { $(this).find("ul.subnav").hide(); }); }); } function SetMenuCss() {
    $("ul.topnav li").hover(function() {$(this).find("ul.subnav:has(li)").show();}, function() {$(this).find("ul.subnav:has(li)").hide();});
} function SetGridViewRowCss() { $(".rowstyle,.alternatingrowstyle").mouseover(function() { $(this).addClass('mouseover'); }); $(".rowstyle,.alternatingrowstyle").mouseout(function() { $(this).removeClass('mouseover'); }); } function SelectAllCheckbox() {
    var headerChk = $(".chkheader"); var itemChk = $(".chkitem input"); headerChk.bind("click", function() {
        itemChk.each(function() {
            this.checked = headerChk[0].checked; if (this.checked) $(this).parent().parent().parent().addClass("selectedrowstyle"); else
                $(this).parent().parent().parent().removeClass("selectedrowstyle");
        })
    }); itemChk.bind("click", function() {
        if (this.checked == false) { $(this).parent().parent().parent().removeClass("selectedrowstyle"); headerChk[0].checked = false; } else
        { $(this).parent().parent().parent().addClass("selectedrowstyle"); } 
    }); var singleChk = $(".singlechk input"); singleChk.bind("click", function() {
        var c = this; if (this.checked == false) { $(this).parent().parent().parent().removeClass("selectedrowstyle"); } else
        { $(".singlechk input").not($(this)).each(function() { $(this).attr("checked", false); $(this).parent().parent().parent().removeClass("selectedrowstyle"); }); $(this).parent().parent().parent().addClass("selectedrowstyle"); } 
    });
} function SetTextAndButtonCss() { $(document.getElementsByName("JQValidate")).each(function() { $("#" + $(this).attr("field")).addClass("text-required").attr("title", "必填项"); if ($(this).attr("field2") != undefined) $("#" + $(this).attr("field2")).addClass("text-required").attr("title", "必填项"); }); $(":text").focus(function() { $(this).addClass('text-focus'); }); $(":text").blur(function() { $(this).removeClass('text-focus'); }); } function removeRequiredCss(obj) { $(obj).removeClass("text-required"); } function ShowModalUrl(title, url, querystring, width, height) { JqueryDialog.Open(title, url + '?rd=' + new Date().getMilliseconds() + '&' + querystring, width, height); } function ShowModalUrl2(title, url, querystring, width, height, isSubmitButton, isCancelButton) { JqueryDialog.Open1(title, url + '?rd=' + new Date().getMilliseconds() + '&' + querystring, width, height, isSubmitButton, isCancelButton, true); } function validate() { var group = arguments[0]; var isValidPassed = true; var objCollection = document.getElementsByName("JQValidate"); var i = 0; for (i = 0; i < objCollection.length; i++) { objValidate = $(objCollection[i]); if (objValidate.attr("group") == group || group == undefined) { if (objValidate.attr("isValidate") == "true") { var ctype = objValidate.attr("ctype"); if (ctype == "text") { isValidPassed = InputValid(objValidate); } else if (ctype == "select") { isValidPassed = SelectValid(objValidate); } else { isValidPassed = RadioValid(objValidate); } if (!isValidPassed) { return false; } } } } return true; } function RadioValid() { var lable = radioValidate.attr("lableText"); var alt = radioValidate.attr("altText"); var field = $("#" + radioValidate.attr("field")); var flag = true; for (var j = 0; j < field.length; j++) { if (field[j].checked) { flag = false; break; } if (flag) { if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "为必选项！"); } return false; } } return true; } function SelectValid(selectValidate) { var lable = selectValidate.attr("lableText"); var alt = selectValidate.attr("altText"); var noValue = selectValidate.attr("noValue"); var field = $("#" + selectValidate.attr("field")); if (field.val() == noValue) { if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "为必选项！"); } return false; } return true; } function InputValid(textValidate) { var lable = textValidate.attr("lableText"); var min = textValidate.attr("min"); var max = textValidate.attr("max"); var datatype = textValidate.attr("dataType"); var alt = textValidate.attr("altText"); var field = $("#" + textValidate.attr("field")); var field2 = $("#" + textValidate.attr("field2")); var required = textValidate.attr("required"); var fieldvalue = field2 != undefined ? $.trim(field.val()) : ""; var field2value = field2 != undefined ? $.trim(field2.val()) : ""; if (required && required == "true" && fieldvalue.length == 0) { ShowError(lable + "不能为空！"); return false; } if (required && required == "true" && field2.val() != undefined && field2value.length == 0) { ShowError(lable + "不能为空！"); return false; } if (min && min.length > 0 && fieldvalue.length < min) { if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "不能小于" + min + "位！"); } if (field.select) field.select(); field.focus(); return false; } if (max && max.length > 0 && fieldvalue.replace(/[^x00-xff]/g, "aa").length > max) { if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "不能大于" + max + "位！"); } if (field.select) field.select(); field.focus(); return false; } if (datatype && datatype.length > 0) { if (datatype == "int") { if (!/^[0-9]+$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "只能输入整数！"); } return false; } } else if (datatype == "email") { if (!/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError("Email格式不正确！"); } return false; } } else if (datatype == "account") { if (!/^[a-zA-Z0-9_]+$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "只能是数字，字母和下划线！"); } return false; } } else if (datatype == "phone") { if (!/^d{3}-d{8}|d{4}-d{7}$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError("电话号码格式不正确，正确格式：0511-4405222 或 021-87888822"); } return false; } } else if (datatype == "postcode") { if (!/^[1-9]d{5}(?!d)$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError("邮政编码不正确"); } return false; } } else if (datatype == "code") { if (!/^d{15}|d{18}$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError("身份证号码不正确"); } return false; } } else if (datatype == "ip") { if (!/^(((1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))\.){3}((1?[0-9]{1,2})|(2[0-4][0-9])|(25[0-5]))$/g.test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError("IP地址格式不正确"); } return false; } } else if (datatype == "awbno") { var abwprefix = fieldvalue; var abwno = field2value; if (!/^\d{3}$/g.test(abwprefix)) { ShowError("运单前缀必须是3位数字"); return false; } if (!/^\d{8}$/g.test(abwno)) { ShowError("运单号必须是8位数字"); return false; } if (abwno.substr(0, 7) % 7 != abwno.substr(7, 1)) { ShowError("运单号未通过模7校验"); return false; } } else { if (!new RegExp(datatype, "g").test(field.val())) { if (field.select) field.select(); field.focus(); if (alt && alt.length > 0) { ShowError(alt); } else { ShowError(lable + "输入格式不正确！"); } return false; } } } return true; } $.fn.LimitUpperCase = function() {
    $(this).css("ime-mode", "disabled"); var req1 = eval("/\w*/"); this.bind("keypress", function(evt) {
        var charCode = (evt.which) ? evt.which : window.event.keyCode; if (charCode <= 13) { return true; } else
        { var keyChar = String.fromCharCode(charCode); var re = /\w/; return re.test(keyChar); } 
    }); this.bind("paste", function() { var s = clipboardData.getData('text'); if (!req1.test(s)); this.value = s.replace(/\W*/, ''); return false; }); this.bind("keyup", function() { this.value = this.value.toUpperCase(); });
}; $.fn.LimitNumber = function() { var type = arguments[0]; $(this).css("ime-mode", "disabled"); this.bind("keypress", function() { if (event.keyCode == 46) { if (type != 0) return false; if (this.value.indexOf(".") != -1) { return false; } } else { return event.keyCode >= 46 && event.keyCode <= 57; } }); this.bind("blur", function() { this.value = this.value.replace(/\D*/, ''); if (type != 2) { if (this.value.lastIndexOf(".") == (this.value.length - 1)) { this.value = this.value.substr(0, this.value.length - 1); } else if (isNaN(this.value)) { this.value = ""; } } }); this.bind("paste", function() { var s = clipboardData.getData('text'); this.value = s.replace(/\D*/, ''); }); this.bind("dragenter", function() { return false; }); this.bind("keyup", function() { if (type != 2 && type != 0) { if (/(^0+)/.test(this.value)) { this.value = this.value.replace(/^0*/, ''); } } if (this.value.lastIndexOf(".") == 0) this.value = this.value.substr(1, this.value.length - 1); }); }; $.fn.JumpNextCotnrol = function() { var jumpLength = arguments[0]; var nextControlID = arguments[1]; this.bind("keyup", function() { if (this.value.length >= jumpLength) { $(nextControlID).focus(); if (this.value.length > jumpLength) { this.value = this.value.substr(1, 3); } } }); };
