﻿
// JScript 文件/*create time 2008-3-03 by jans*/
//分页条
function ShowPage(TotalCount, TotalPage, CurrentPage, Condition) {
    document.write("<div class=page><span class=disabled title=\"总共有" + TotalCount + "条记录,共" + TotalPage + "页,当前第" + CurrentPage + "页\"><b class=redtext>" + TotalCount + "</b>/<b class=redtext>" + TotalPage + "</b>/<b class=redtext>" + CurrentPage + "</b></span>");
    if (CurrentPage < 6) {
        PageLength = 11 - CurrentPage;
    }
    else
        if (TotalPage - CurrentPage < 6) {
        PageLength = 10 - (TotalPage - CurrentPage)
    }
    else {
        PageLength = 5;
    }
    for (var i = 1; i <= TotalPage; i++) {
        if (i < (CurrentPage + PageLength) && i > (CurrentPage - PageLength) || i == 1 || i == TotalPage) {
            if (CurrentPage == i) {
                document.write("<span class=current>" + i + "</span>");
            }
            else {
                document.write("<a href=?CurrentPage=" + i + Condition + ">" + i + "</a>");
            }
        }
    }
    document.write("<span class=pageboxspan title=\"输入页码回车即可 \">转到第<input type=\"text\"  maxlength=\"5\" id=\"jansy\"  class=\"pagebox\" onkeyup=\"if(isNaN(this.value)){this.value=''}\" onkeypress=\"if(event.keyCode==13&&this.value!=''){window.location.href='?CurrentPage='+ this.value +'" + Condition + "';return false;}\" />页</span></div>")
}

// 静态提示框
// 主要用途：页面出错、页面中不显示数据时给出的提示内容。并非JavaScript中的alert()
function ShowStaticPrompt(PromptMessage) {
    document.write("<div id=\"divErrorMessage\" class=\"SearchFriendts\"><span class=\"sp\">" + PromptMessage + "</span></div>");
}

// 获取当前页面CheckBox被选取个数
function GetCheckBoxSelectCount() {
    var selectCount = 0;
    $(":checkbox").each(function() {
        if ($(this).attr("checked"))
            selectCount++;
    })
    return selectCount;
}

// CheckBox智能全选 / 取消全选器
function autoSelectCheckBoxAllOrNot() {
    if ($(":checkbox").attr("checked"))
        $(":checkbox").each(function() { $(this).attr("checked", ""); })
    else
        $(":checkbox").each(function() { $(this).attr("checked", "true"); })
}

//全选与全不选
function checkAll(bool) {
    var objs = document.getElementsByTagName("input"); //HH
    for (var i = 0; i < objs.length; i++) {
        if (objs[i].type.toLowerCase() == "checkbox")
            objs[i].checked = bool;
    }
}

//当有一个没有选时，那么全选就应该是FALSE
function checkOne(bool) {
    if (bool == false)
        document.getElementById("all").checked = false;
}

//检查要输入的控件是否为空或是null
function check(ID, alertContent) {
    var everyID, everyContent, newValue, i;
    everyID = ID.split(",");
    everyContent = alertContent.split(",");
    for (i = 0; i < everyID.length; i++) {
        if (everyID[i]) {
            newValue = document.getElementById(everyID[i]).value;
            newValue = newValue.replace(/(^[\s]*)|([\s]*$)/g, "");
            if (newValue == "" || newValue.length == 0) {
                window.alert(everyContent[i]);
                //document.getElementById(everyID[i]).style.border="solid 1px #ff0000";
                document.getElementById(everyID[i]).focus();
                return false;
            }
        }
        else {
            window.alert("对不起,要验证的控件ID并不存在");
            return false;
        }
    }
    return true;
}

/*******************************************/
/*	hiddle the left frame				   */
/*******************************************/
function hiddeLeftFrm() {
    var obj = document.getElementById("ScrollImg");
    if (parent.bodyFrame.cols == "0,12,*") {
        parent.bodyFrame.cols = "19%,12,*";
        obj.src = "../Style/1/images/collapse.gif";
        obj.title = "点击折叠";
    }
    else {
        parent.bodyFrame.cols = "0,12,*";
        obj.src = "../Style/1/images/expand.gif";
        obj.title = "点击展开";
    }
}

//common submit function used to prevent somebody from clicking button again
function buttonSubmit(id, idPrompt, confirmPrompt, disabledID, disabledPrompt, hiddenID, hiddenIDValue, hiddenSomeID) {
    var flag, everyID, j, everyIDPrompt, everyHiddenID;
    everyID = id.split(",");
    everyIDPrompt = idPrompt.split(",");
    for (j = 0; j < everyID.length; j++) {
        if (document.getElementById(everyID[j])) {
            var a = document.getElementById(everyID[j]).value;
            var aa = a.replace(/(^[\s]*)|([\s]*$)/g, "");
            if (a.length == 0 || aa.length == 0) {
                window.alert(everyIDPrompt[j]);
                document.getElementById(everyID[j]).focus();
                flag = false;
                return flag;
                break;
            }
        }
    }
    if (confirmPrompt.toLowerCase() == "no") {
        flag = true;
    }
    else {
        flag = confirm(confirmPrompt);
    }
    if (flag) {
        document.getElementById(disabledID).value = disabledPrompt;
        if (document.getElementById(hiddenID))//change the hiddenID's value into hiddenIDValue
        {
            document.getElementById(hiddenID).value = hiddenIDValue;
        }
        everyHiddenID = hiddenSomeID.split(",");
        for (j = 0; j < everyHiddenID.length; j++) {
            if (document.getElementById(everyHiddenID[j])) {
                document.getElementById(everyHiddenID[j]).style.display = "none";
            }
        }
        //alert("dddd");
        document.forms[0].submit();
        document.getElementById(disabledID).disabled = true;
    }
    return flag;
}

//page's progress start
var pos = 0;
var dir = 2;
var len = 0;
function animate() {
    var elem = document.getElementById('progress');
    if (elem != null) {
        if (pos == 0)
            len += dir;
        if (len > 32 || pos > 79)
            pos += dir;
        if (pos > 79)
            len -= dir;
        if (pos > 79 && len == 0)
            pos = 0;
        elem.style.left = pos;
        elem.style.width = len;
    }
}

function loading() {
    this.clearInterval(setInterval(animate, 20));
    var targelem = document.getElementById('loader_container');
    document.getElementById('loader_container').style.display = 'none';
}

function pageProgress() {
    document.write("<div id=\"loader_container\">")
    document.write("<div id=\"loader\">")
    document.write("<div style=\"text-align:center\">数据正在载入中 ...</div>")
    document.write("<div id=\"loader_bg\"><div id=\"progress\"> </div></div>")
    document.write("</div>")
    document.write("</div>")
}

//page's progress end

//change pagesize
function changePageSize(ID, condition, pagesize) {
    document.getElementById(ID).disabled = true;
    var queryString;
    queryString = condition + "&PageSize=" + pagesize;
    window.location.href = queryString;
    //alert("ddd");
    document.getElementById(ID).disabled = false;
}

//document.write page's select
function pageSelect(changePageSize) {
    document.write("<select name=\"PageSize\" id=\"PageSize\" class=\"textbox\" onchange=\"changePageSize('PageSize','" + changePageSize + "', this.options[this.selectedIndex].value)\">")
    document.write("<option value=\"\">每页大小</option>")
    document.write("<option value=\"10\">10条/页</option>")
    document.write("<option value=\"20\">20条/页</option>")
    document.write("<option value=\"30\">30条/页</option>")
    document.write("<option value=\"40\">40条/页</option>")
    document.write("<option value=\"50\">50条/页</option>")
    document.write("<option value=\"60\">60条/页</option>")
    document.write("</select>")

}

//change ordertype
function changeOrderType(ID, condition, ordertype) {
    if (ordertype != "") {
        if (document.getElementById(ID)) {
            document.getElementById(ID).disabled = true;
        }
        var queryString, everyValue;
        everyValue = ordertype.split(",");
        queryString = condition + "&OrderType=" + everyValue[0];
        if (everyValue[1] != "") {
            queryString = queryString + "&OrderNumber=" + everyValue[1];
        }
        //alert(queryString);
        window.location.href = queryString;
        //alert("ddd");
        if (document.getElementById(ID)) {
            document.getElementById(ID).disabled = false;
        }
    }
}

//check the textbox's value is number or not 
function isNumber(id) {
    var boxValue = document.getElementById(id).value;
    if (isNaN(boxValue)) {
        document.getElementById(id).value = ""
    }
}

//clear page's value
function clearValue() {
    var objs = document.getElementsByTagName("input");
    for (var i = 0; i < objs.length; i++) {
        if (objs[i].type.toLowerCase() == "text") {
            //alert(objs[i].type.toLowerCase());
            objs[i].value = "";
        }
    }
}

//show div start
function getElementPos(elementId) {

    var ua = navigator.userAgent.toLowerCase();
    var isOpera = (ua.indexOf('opera') != -1);
    var isIE = (ua.indexOf('msie') != -1 && !isOpera); // not opera spoof
    var el = document.getElementById(elementId);

    if (el.parentNode === null || el.style.display == 'none') {
        return false;
    }

    var parent = null;
    var pos = [];
    var box;

    if (el.getBoundingClientRect) //IE
    {
        box = el.getBoundingClientRect();
        var scrollTop = Math.max(document.documentElement.scrollTop, document.body.scrollTop);
        var scrollLeft = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft);

        return {
            x: box.left + scrollLeft,
            y: box.top + scrollTop
        };
    }
    else
        if (document.getBoxObjectFor) // gecko
    {
        box = document.getBoxObjectFor(el);

        var borderLeft = (el.style.borderLeftWidth) ? parseInt(el.style.borderLeftWidth) : 0;
        var borderTop = (el.style.borderTopWidth) ? parseInt(el.style.borderTopWidth) : 0;

        pos = [box.x - borderLeft, box.y - borderTop];
    }
    else // safari & opera
    {
        pos = [el.offsetLeft, el.offsetTop];
        parent = el.offsetParent;
        if (parent != el) {
            while (parent) {
                pos[0] += parent.offsetLeft;
                pos[1] += parent.offsetTop;
                parent = parent.offsetParent;
            }
        }
        if (ua.indexOf('opera') != -1 ||
            (ua.indexOf('safari') != -1 && el.style.position == 'absolute')) {
            pos[0] -= document.body.offsetLeft;
            pos[1] -= document.body.offsetTop;
        }
    }

    if (el.parentNode) {
        parent = el.parentNode;
    }
    else {
        parent = null;
    }

    while (parent && parent.tagName != 'BODY' && parent.tagName != 'HTML') { // account for any scrolled ancestors
        pos[0] -= parent.scrollLeft;
        pos[1] -= parent.scrollTop;

        if (parent.parentNode) {
            parent = parent.parentNode;
        }
        else {
            parent = null;
        }
    }
    return {
        x: pos[0],
        y: pos[1]
    };
}

//move div
function moveStart(event, id) {
    var oObj = document.getElementById(id);
    oObj.onmousemove = mousemove;
    oObj.onmouseup = mouseup;
    oObj.setCapture ? oObj.setCapture() : function() {
    };
    oEvent = window.event ? window.event : event;
    var dragData = {
        x: oEvent.clientX,
        y: oEvent.clientY
    };
    var backData = {
        x: parseInt(oObj.style.top),
        y: parseInt(oObj.style.left)
    };
    function mousemove() {
        var oEvent = window.event ? window.event : event;
        var iLeft = oEvent.clientX - dragData["x"] + parseInt(oObj.style.left);
        var iTop = oEvent.clientY - dragData["y"] + parseInt(oObj.style.top);
        oObj.style.left = iLeft;
        oObj.style.top = iTop;
        dragData = {
            x: oEvent.clientX,
            y: oEvent.clientY
        };
    }
    function mouseup() {
        var oEvent = window.event ? window.event : event;
        oObj.onmousemove = null;
        oObj.onmouseup = null;
        if (oEvent.clientX < 1 || oEvent.clientY < 1 || oEvent.clientX > document.body.clientWidth || oEvent.clientY > document.body.clientHeight) {
            oObj.style.left = backData.y;
            oObj.style.top = backData.x;
        }
        oObj.releaseCapture ? oObj.releaseCapture() : function() {
        };
    }
}

//show help div
function showDiv(id, divID, msg) {
    document.getElementById(divID).style.display = "";
    document.getElementById("ChildDiv").innerHTML = msg;
    var dd = getElementPos(id);
    //alert(dd.x);
    //alert(dd.y);
    var divWidth = parseInt(document.getElementById(divID).style.width);
    var divHeight = parseInt(document.getElementById("ChildDiv").offsetHeight);
    //可能以后需要增加判断网页被卷去的高与宽
    //alert(divWidth);
    divHeight += 40;
    if (dd.x - divWidth < 0) {
        document.getElementById(divID).style.left = dd.x + "px";
    }
    else {
        document.getElementById(divID).style.left = dd.x - divWidth + "px";
    }
    //alert(dd.x);
    //alert(dd.x- divWidth );
    if (dd.y - divHeight < 0) {
        document.getElementById(divID).style.top = dd.y + 30 + "px";
    }
    else {
        document.getElementById(divID).style.top = dd.y - divHeight + "px";
    }
}

//show menu div
function showMenuDiv(id, divID, width, msg) {
    document.getElementById(divID).style.width = width + "px";
    document.getElementById(divID).style.display = "";
    document.getElementById("ChildMenuDiv").innerHTML = msg;
    var dd = getElementPos(id);
    //alert(dd.x);
    //alert(dd.y);
    var divWidth = width;
    var divHeight = parseInt(document.getElementById("ChildMenuDiv").offsetHeight);
    //可能以后需要增加判断网页被卷去的高与宽
    //alert(divWidth);
    divHeight += 45;
    if (dd.x - divWidth < 0) {
        document.getElementById(divID).style.left = dd.x + "px";
    }
    else {
        document.getElementById(divID).style.left = dd.x - divWidth + "px";
    }
    //alert(dd.x);
    //alert(dd.x- divWidth );
    if (dd.y - divHeight < 0) {
        document.getElementById(divID).style.top = dd.y + 30 + "px";
    }
    else {
        document.getElementById(divID).style.top = dd.y - divHeight + "px";
    }
}
//立即关闭DIV
function closeHelpDiv(divID) {
    if (document.getElementById(divID)) {
        document.getElementById(divID).style.display = "none";
    }
}
//延时关闭div
function closeMyDiv(divID) {
    setTimeout("closeHelpDiv('" + divID + "')", 5000);
}

function printHelpDiv() {
    document.write("<div id=\"HelpDiv\" style=\"position:absolute;z-index:9998;width:252px;display:none;overflow:visible;background-color:#ffffff;border:solid 1px #cd3636;border-top-style:none;\">")
    document.write("<div class=\"childdiv\" onmousedown=javascript:moveStart(event,'HelpDiv')  id=\"ChildDiv1\"><span id=\"CloseDiv\" style=\"cursor:pointer;cursor:hand;height:25px;width:30px;\"  onclick=\"closeHelpDiv('HelpDiv');\">关闭</span></div>")
    document.write("<div class=\"childdiv2\"  id=\"ChildDiv\"></div>")
    document.write("<div class=\"childdiv3\"  id=\"ChildDiv3\">小提示,红色区域内按住鼠标,可拖动层</div>")
    document.write("</div>")
    document.write("<div id=\"MenuDiv\"  onmouseover=\"document.getElementById('MenuDiv').style.display=''\" style=\"position:absolute;z-index:9999;width:350px;display:none;overflow:visible;background-color:#ffffff;border:solid 1px #cd3636;border-top-style:none;\">")
    document.write("<div class=\"childdiv\"  onmouseover=\"document.getElementById('MenuDiv').style.display=''\" onmousedown=javascript:moveStart(event,'MenuDiv')  id=\"ChildMenuDiv1\"><span id=\"CloseDiv\" style=\"cursor:pointer;cursor:hand;height:25px;width:30px;\"  onclick=\"closeHelpDiv('MenuDiv');\">关闭</span></div>")
    document.write("<div class=\"childdiv2\" onmouseover=\"document.getElementById('MenuDiv').style.display=''\" id=\"ChildMenuDiv\"></div>")
    document.write("<div class=\"childdiv3\" onmouseover=\"document.getElementById('MenuDiv').style.display=''\" id=\"ChildMenuDiv3\">小提示,红色区域内按住鼠标不放,可拖动菜单</div>")
    document.write("</div>")
}

//show div end
//make a focus
function changeFocus(id) {
    var everyID;
    everyID = id.split(",");
    for (var i = 0; i < everyID.length; i++) {
        if (document.getElementById(everyID[i])) {
            document.getElementById(everyID[i]).focus();
            document.getElementById(everyID[i]).select();
            break;
        }
    }
}

//check the order is right or not
function isRightOrder(id) {
    var str = document.getElementById(id).value;
    var str2 = str.replace(/(^[\s]*)|([\s]*$)/g, "");
    if (str2.length != 0) {
        var regex = /^[BCDRQSHPbcdrqshp]\d{11}$/;
        if (regex.exec(str) == null) {
            //alert(regex.exec(str));
            alert("对不起，您输入的单子格式有误,请重试!");
        }
    }
}

//when html control'value changed,this function can location to new url
function goToUrl(url) {
    window.location.href = url;
}

//选中下拉框中的值
function selectMyValue(id, svalue) {
    var myid = id.split(",");
    var myValue = svalue.split(",");
    alert(svalue);
    for (var j = 0; j < myid.length; j++) {
        if (document.getElementById(myid[j])) {
            //alert(myid[0]);
            for (var i = 0; i < document.getElementById(myid[j]).options.length; i++) {
                if (document.getElementById(myid[j]).options(i).value == myValue[j]) {
                    document.getElementById(myid[j]).selectedIndex = i;
                }
            }
        }
    }
}



//show div and give action message
//id--you want show this id,wordID--show message id,sword--when id display show sword,pword--when id not display show pword
function spread(id, wordID, sword, pword) {
    if (document.getElementById(id) && document.getElementById(wordID)) {
        if (document.getElementById(id).style.display == 'none') {
            document.getElementById(id).style.display = '';
            document.getElementById(wordID).innerHTML = sword;
        }
        else {
            document.getElementById(id).style.display = 'none';
            document.getElementById(wordID).innerHTML = pword;
        }
    }
}

//if id's value is not right then clear it, but if id's value input by user you can't clear it
function onKeyUp(id, oldValue) {
    var v = document.getElementById(id).value;
    if (v == oldValue) {
        document.getElementById(id).value = "";
    }
}

//resize the window
function resizeWindow(id, reType) {
    if (document.getElementById(id)) {
        var width = document.getElementById(id).offsetWidth;
        var height = document.getElementById(id).offsetHeight;
        width = eval(width + 50);
        height = eval(height + 60);

        if (reType == 1) {
            if (width > screen.width)
                width = screen.width;
            window.dialogWidth = width + "px";
        }
        else
            if (reType == 2) {
            if (height > screen.height)
                height = screen.height;
            window.dialogHeight = height + "px";
        }
        else
            if (reType == 3) {
            if (width > screen.width)
                width = screen.width;
            if (height > screen.height)
                height = screen.height;
            window.dialogWidth = width + "px";
            window.dialogHeight = height + "px";
        }
        //alert(width);alert(height); 
    }
}

//中国邮政编号
function zipCode(str) {
    var regex = /^\d{6}$/;
    if (regex.exec(str) == null) {
        alert("邮政编号错误");
    }
}
//中国邮政编号
function IsCode(id) {
    var codes = document.getElementById(id).value;
    var regex = /^\d{6}$/gi;
    if (codes != "") {
        var zipcode = regex.exec(codes);
        if (zipcode == null) {
            alert("邮政编号错误");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
            return false;
        }
    }
}

//验证email－－－小新
function IsEmail(id) {
    var emailStr = document.getElementById(id).value;
    var emailPat = (/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/);
    var matchArray = emailStr.match(emailPat);
    if (matchArray == null) {
        // alert("电子邮件地址必须包括 ( @ 和 .与com )");
        // document.getElementById(id).focus();
        // document.getElementById(id).value = "";
        return false;
    } else {
        return true;
    }
}


///验证电话号码
function IsPhoneNumber(id) {
    var val = document.getElementById(id).value;
    if (val != "") {
        //var re0 = /^((0)\d{2,3}-)?\d{7,8}(-\d{2,4})?$/gi;
        var re1 = /^(0)?(13|15)\d{9}$/gi;
        //var ff = re0.exec(val);
        var ee = re1.exec(val);
        if (ee == null) {
            alert("对不起，您输入的格式不正确!");
            document.getElementById(id).value = "";
            document.getElementById(id).focus();
            return false;
        }
    }
}
//验证家庭电话
function IsFiamlyPhone(id) {
    var val = document.getElementById(id).value;
    if (val != "") {
        var re0 = /^((0)\d{2,3}(-)?)?\d{7,8}(-\d{2,4})?$/gi;
        var ff = re0.exec(val);
        if (ff == null) {
            alert("对不起，您输入的格式不正确!");
            document.getElementById(id).value = "";
            document.getElementById(id).focus();
            return false;
        }
    }

}

//验证身份证号
function IsIDCard(id) {
    var Idcard = document.getElementById(id).value;
    if (Idcard != "") {
        var isIDcard = /^(\d{15}|\d{17}[x0-9])$/gi;
        var idcards = isIDcard.exec(Idcard);
        if (idcards == null) {
            alert("请重新输入正确的身份证码！");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
            return false;
        }
    }
}


//验证id为positionid的货位号值是否正确
function IsPosition(id) {
    if (document.getElementById(id).value != "") {
        var re = /^\d{2}-\d\d-\d\d$/g;
        var ff = re.exec(document.getElementById(id).value);
        if (ff == null) {

            var val = document.getElementById(id).value;
            var re = /^\d{5}$/g;
            var ff = re.exec(val);
            if (ff == null || val.length > 5) {
                alert("请输入正确的货位号！");
                document.getElementById(id).focus();
                document.getElementById(id).value = "";
            }
            else {
                var vall = "";
                var t = 6 - val.length;
                for (var i = 0; i < t; i++) {
                    vall = vall + '0';
                }
                vall = vall + val;
                var vall1 = vall.substring(0, 2);
                var vall2 = vall.substring(2, 4);
                var vall3 = vall.substring(4, 6);
                var vall0 = vall1 + '-' + vall2 + '-' + vall3;
                document.getElementById(id).value = vall0;
            }
        }
    }
}


///验证数字
function isnum(id) {

    if (document.getElementById(id).value != "") {
        var re = /^(-)?\d*$/;
        var ff = re.exec(document.getElementById(id).value);
        if (ff == null) {
            alert("对不起，只能输入数字!");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
        }
    }
}

///清空控件值
function clearValue(id) {
    document.getElementById(id).value = "";
}


//点击隐藏控件
function hidid(id, getvalid) {
    if (document.getElementById(id).style.display == "none") {
        document.getElementById(id).style.display = "";
        if (getvalid != "") {
            document.getElementById(getvalid).value = "0";
        }
    }
    else {
        document.getElementById(id).style.display = "none";
        if (getvalid != "") {
            document.getElementById(getvalid).value = "1";
        }
    }

}

///验证输入金额格式
function IsDecimal(id) {
    if (document.getElementById(id).value != "") {
        var re = /^\d{0,18}\.?\d{0,2}$/;
        var ff = re.exec(document.getElementById(id).value);
        if (ff == null) {
            alert("对不起，您输入的金额格式不正确！");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
        }
    }
}

///验证输入折扣格式
function IsDiscount(id) {
    if (document.getElementById(id).value != "") {
        var re = /^0(.\d{0,4})?$/;
        var ff = re.exec(document.getElementById(id).value);
        if (ff == null) {
            alert("对不起，您输入的折扣格式不正确！");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
        }
    }
}

/// 验证输入百分比格式
function isPercent(id) {
    if (document.getElementById(id).value != "") {
        var re = /^\d{1,3}(\.\d{1,2})?$/;
        var ff = re.exec(document.getElementById(id).value);
        if (ff == null) {
            alert("对不起，输入的格式不正确！");
            document.getElementById(id).focus();
            document.getElementById(id).value = "";
        }
    }
}

//判断单子编号是否正确
function isOrder(id) {
    var val = document.getElementById(id).value;
    if (val != "") {
        var rr = /^[a-zA-Z]{1,1}\d{11}$/;
        var ff = rr.exec(val);
        if (ff == null) {
            alert("输入的单子编号不正确！");
            document.getElementById(id).value = "";
            document.getElementById(id).focus();

        }
    }
}
//转换回车为Tab
function nextFocus() {
    if (event.keyCode == '13') {
        event.keyCode = '9';
    }
}

//弹出窗口居中显示
function openwindow(url, winName, resizable, width, height) {
    xposition = 0;
    yposition = 0;
    if ((parseInt(navigator.appVersion) >= 4)) {
        xposition = (screen.width - width - 10) / 2;
        yposition = (screen.height - height - 80) / 2;
    }
    theproperty = "width=" + width + "," +
    "height=" +
    height +
    "," +
    "location=0," +
    "menubar=0," +
    "resizable=" +
    resizable +
    "," +
    "scrollbars=1," +
    "status=0," +
    "titlebar=0," +
    "toolbar=0," +
    "hotkeys=0," +
    "screenx=" +
    xposition +
    "," //for Netscape
 +
    "screeny=" +
    yposition +
    "," //for Netscape
 +
    "left=" +
    xposition +
    "," //for IE
 +
    "top=" +
    yposition; //for IE 
    window.open(url, winName, theproperty);
}


//检测年份
function IsYear(paraName) {
    var nums = document.getElementById(paraName).value;
    if (isNaN(nums) || nums.length != 4) {
        alert("请输入四位的数字！如：2008");
        document.getElementById(paraName).value = "";
        document.getElementById(paraName).focus();
    }
}

//检测高级检索中条件不能为空（必须有一个条件）
function CheckData() {
    var flag = true;
    var name1 = document.getElementById("bookname").value;
    var name2 = document.getElementById("author").value;
    var name3 = document.getElementById("publish").value;
    var name4 = document.getElementById("pubtimeS").value;
    var name5 = document.getElementById("pubtimeEnd").value;
    var name6 = document.getElementById("LpriceStart").value;
    var name7 = document.getElementById("LpriceEnd").value;
    var name8 = document.getElementById("selectDiscountS").value;
    var name9 = document.getElementById("selectDiscountE").value;
    if (name1 == "" && name2 == "" && name3 == "" && name4 == "" && name5 == "" && name6 == "" && name7 == "" && name8 == "" && name9 == "") {
        alert("请您输入检索条件！");
        flag = false;
    }
    else {
        document.forms[0].submit();
    }
    return flag;
}



//show(id,id1,ev,width,heigth)方法弹出一个DIV层窗口，id为弹出的div层，id1为拖动的div层，ev为event，width为弹出的DIV层的宽，heigth为弹出的DIV层的高
var prox;
var proy;
var proxc;
var proyc;
var isIe = (document.all) ? true : false;
function setSelectState(state) {
    var objl = document.getElementsByTagName('select');
    for (var i = 0; i < objl.length; i++) {
        objl[i].style.visibility = state;
    }
}
function mousePosition(ev) {
    if (ev.pageX || ev.pageY) {
        return { x: ev.pageX, y: ev.pageY };
    }
    return {
        x: ev.clientX + document.body.scrollLeft - document.body.clientLeft, y: ev.clientY + document.body.scrollTop - document.body.clientTop
    };
}
//关闭窗口
function closeWindow() {
    if (document.getElementById('back') != null) {
        document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
    }
    if (document.getElementById('mesWindow') != null) {
        document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
    }
    if (isIe) {
        setSelectState('');
    }
}
function show(id, id1, ev, width, heigth) {/*--打开--*/
    closeWindow();
    var bWidth = parseInt(document.documentElement.scrollWidth);
    var bHeight = parseInt(document.documentElement.scrollHeight) < 800 ? 800 : parseInt(document.documentElement.scrollHeight);
    if (isIe) {
        setSelectState('hidden');
    }
    var back = document.createElement("div");
    back.id = "back";
    var styleStr = "top:0px;left:0px;position:absolute;background:#666;width:" + bWidth + "px;height:" + bHeight + "px;";
    styleStr += (isIe) ? "filter:alpha(opacity=40);" : "opacity:0.40;";
    back.style.cssText = styleStr;
    document.body.appendChild(back);

    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = document.getElementById(id);
    o.style.display = "block";
    o.style.width = "1px";
    o.style.height = "1px";
    prox = setInterval(function() { openx(o, width, heigth) }, 10);

    /*-------------------------鼠标拖动---------------------*/
    var od = document.getElementById(id);
    var dd = document.getElementById(id1);
    var dx, dy, mx, my, mouseD;
    var odrag;
    var isIE = document.all ? true : false;
    document.onmousedown = function(e) {
        var e = e ? e : event;
        if (e.button == (document.all ? 1 : 0)) {
            mouseD = true;
        }
    }
    document.onmouseup = function() {
        mouseD = false;
        odrag = "";
        if (isIE) {
            od.releaseCapture();
            //   od.filters.alpha.opacity = 100;
        }
        else {
            window.releaseEvents(od.MOUSEMOVE);
            od.style.opacity = 1;
        }
    }


    //function readyMove(e){    
    dd.onmousedown = function(e) {
        odrag = this;
        var e = e ? e : event;
        if (e.button == (document.all ? 1 : 0)) {
            mx = e.clientX;
            my = e.clientY;
            od.style.left = od.offsetLeft + "px";
            od.style.top = od.offsetTop + "px";
            if (isIE) {
                od.setCapture();
                // od.filters.alpha.opacity = 50;
            }
            else {
                window.captureEvents(Event.MOUSEMOVE);
                od.style.opacity = 0.5;
            }

            //alert(mx);
            //alert(my);

        }
    }
    document.onmousemove = function(e) {
        var e = e ? e : event;

        //alert(mrx);
        //alert(e.button);        
        if (mouseD == true && odrag) {
            var mrx = e.clientX - mx;
            var mry = e.clientY - my;
            od.style.left = parseInt(od.style.left) + mrx + "px";
            od.style.top = parseInt(od.style.top) + mry + "px";
            mx = e.clientX;
            my = e.clientY;

        }
    }
    function showBackground(obj, endInt) {
        obj.filters.alpha.opacity += 1;
        if (obj.filters.alpha.opacity < endInt) {
            setTimeout(function() { showBackground(obj, endInt) }, 8);
        }
    }

}
function openx(o, x, heigth) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx < x) {
        o.style.width = (cx + Math.ceil((x - cx) / 5)) + "px";
    }
    else {
        clearInterval(prox);
        proy = setInterval(function() { openy(o, heigth) }, 10);
    }
}
function openy(o, y) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy < y) {
        o.style.height = (cy + Math.ceil((y - cy) / 5)) + "px";
    }
    else {
        clearInterval(proy);
    }
}
function closeed(id) {/*--关闭--*/
    closeWindow();
    clearInterval(prox);
    clearInterval(proy);
    clearInterval(proxc);
    clearInterval(proyc);
    var o = document.getElementById(id);
    if (o.style.display == "block") {
        proyc = setInterval(function() { closey(o) }, 10);
    }
}
function closey(o) {/*--打开y--*/
    var cy = parseInt(o.style.height);
    if (cy > 0) {
        o.style.height = (cy - Math.ceil(cy / 5)) + "px";
    }
    else {
        clearInterval(proyc);
        proxc = setInterval(function() { closex(o) }, 10);
    }
}
function closex(o) {/*--打开x--*/
    var cx = parseInt(o.style.width);
    if (cx > 0) {
        o.style.width = (cx - Math.ceil(cx / 5)) + "px";
    }
    else {
        clearInterval(proxc);
        o.style.display = "none";
    }
}


//不被拦截的弹窗....
function OpenNewW(abc, height, width) {

    var open1 = window.open(abc, "open1", "height=" + height + ",width=" + width + ", toolbar =no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
    open1.focus();
}

//不被拦截的弹窗....外加弹出定位
function OpenNewWLoc(abc, height, width, top, left) {
    //  var width = width;
    //        var height = 300;
    var left1 = parseInt((screen.availWidth / 2) - (width / 2)); //屏幕居中
    var top1 = parseInt((screen.availHeight / 2) - (height / 2));
    var open = window.open(abc, "open", "height=" + height + ",width=" + width + ",top=" + top1 + ",left=" + left1 + ", toolbar =no, menubar=no, scrollbars=yes, resizable=yes, status=yes");
    open.focus();
}


function OpenNewWLoc3(abc, height, width, top, left) {
    var left1 = parseInt((screen.availWidth / 2) - (width / 2)); //屏幕居中
    var top1 = parseInt((screen.availHeight / 2) - (height / 2));
    var open1 = window.open(abc, "open3", "height=" + height + ",width=" + width + ",top=" + top1 + ",left=" + left1 + ", toolbar =no, menubar=no, scrollbars=yes, resizable=yes, status=no");
    open1.focus();
}

function OpenNewWLoc6(abc, height, width, top, left) {
    var left1 = parseInt((screen.availWidth / 2) - (width / 2)); //屏幕居中
    var top1 = parseInt((screen.availHeight / 2) - (height / 2));
    var open2 = window.open(abc, "open2", "height=" + height + ",width=" + width + ",top=" + top1 + ",left=" + left1 + ", toolbar =no, menubar=no, scrollbars=yes, resizable=yes, status=no");
    open2.focus();
}

//不被拦截的弹窗....外加弹出定位
function OpenNewWLocResource(abc, height, width, top, left) {
    var left1 = parseInt((screen.availWidth / 2) - (width / 2)); //屏幕居中
    var top1 = parseInt((screen.availHeight / 2) - (height / 2));
    var open1 = window.open(abc, "open1", "height=" + height + ",width=" + width + ",top=" + top1 + ",left=" + left1 + ", toolbar =no, menubar=no, scrollbars=no, resizable=yes, status=no");
    open1.focus();
}

//不被拦截的弹窗....外加弹出定位和滚动条
function OpenNewWLoc1(abc, height, width, top, left) {
    var left1 = parseInt((screen.availWidth / 2) - (width / 2)); //屏幕居中
    var top1 = parseInt((screen.availHeight / 2) - (height / 2));
    var open1 = window.open(abc, "open1", "height=" + height + ",width=" + width + ",top=" + top1 + ",left=" + left1 + ", toolbar =no, menubar=no, scrollbars=yes, resizable=no, status=no");
    open1.focus();
}

function colsed() {
    window.close();
}
//master..nav
function signTitle(titleNum) {
    switch (titleNum) {
        case 1:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 2:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 3:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 4:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 5:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 6:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        case 8:
            $("#a_0" + titleNum).attr("class", "a_01");
            break;
        
    }
}

 function settab(m,n){
      var tli=document.getElementById("tabs"+m).getElementsByTagName("li");
      for(i=0;i<tli.length;i++){
       tli[i].className=i==n?"blue":"li";
 }
} 

