﻿//全局通用JS文件

//pngIE6透明
function correctPNG() {
    var arVersion = navigator.appVersion.split("MSIE")
    var version = parseFloat(arVersion[1])
    if ((version >= 5.5) && (document.body.filters)) {
        for (var j = 0; j < document.images.length; j++) {
            var img = document.images[j]
            var imgName = img.src.toUpperCase()
            if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
                var imgID = (img.id) ? "id='" + img.id + "' " : ""
                var imgClass = (img.className) ? "class='" + img.className + "' " : ""
                var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
                var imgStyle = "display:inline-block;" + img.style.cssText
                if (img.align == "left") imgStyle = "float:left;" + imgStyle
                if (img.align == "right") imgStyle = "float:right;" + imgStyle
                if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
                var strNewHTML = "<span " + imgID + imgClass + imgTitle
     + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
     + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
                img.outerHTML = strNewHTML
                j = j - 1
            }
        }
    }
}
var isIE6 = false;
document.write("<!--[if lte IE 6]><script>isIE6=true;</scr" + "ipt><![endif]-->");
if (isIE6) {
    window.attachEvent("onload", correctPNG);
}

//获取对象
function GetObj(objName){
    if(document.getElementById){
        return document.getElementById(objName);
    }
    else if(document.layers){
        return document.layers[objName];
    }
    else{
        return document.all(objName);
    }
}

//去掉字符串的前后空格
String.prototype.Trim = function(){
    return this.replace(/(^\s*)|(\s*$)/g,"");
}

//判断是否为空
function IsEmpty(obj){
    return (obj.value=="");
}

//将回车指定到按钮提交 Start
var btnObj_Glb = null;

function enterClick(name){
    btnObj_Glb = document.getElementById(name);
}

document.onkeydown = function(){
    if(window.event.keyCode == 13){
        if(btnObj_Glb != null){
            btnObj_Glb.click();
            return false;
        }
        else{
            return true;
        }
    }
    else{
        return true;
    }
}
//End


//Start 判断输入字符串是否符合指定的长度区间
function ValiStrLength(vStr,vMinLength,vMaxLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength < vMinLength){
        return false;
    }
    else if(vLength > vMaxLength){
        return false;
    }
    else{
        return true;
    }
}


function ValiStrLengthMin(vStr,vMinLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength < vMinLength){
        return false;
    }
    else{
        return true;
    }
}

function ValiStrLengthMax(vStr,vMaxLength){
    var vLength = vStr.Trim().length;
    
    for(var i=0;i<vLength;i++){
        if(vStr.Trim().charCodeAt(i)>255){
            vLength ++;
        }
    }
    
    if(vLength > vMaxLength){
        return false;
    }
    else{
        return true;
    }
}

//End

function LoginOut(){
    if(confirm('确定退出？')){
        window.location.href("LoginOut.aspx");
        window.close();
        }
    else{
        return false;}
}

