//Repeater全选
function Check(parentChk, ChildId, ControlName) {
    var oElements = document.getElementsByTagName("INPUT");
    var bIsChecked = parentChk.checked;

    for (i = 0; i < oElements.length; i++) {
        if (IsCheckBox(oElements[i]) &&
                IsMatch(oElements[i].id, ChildId, ControlName)) {
            oElements[i].checked = bIsChecked;
        }
    }
}

function IsMatch(id, ChildId, ControlName) {
    var sPattern = '^' + ControlName + '.*' + ChildId + '$';
    var oRegExp = new RegExp(sPattern);
    if (oRegExp.exec(id))
        return true;
    else
        return false;
}

function IsCheckBox(chk) {
    if (chk.type == 'checkbox') return true;
    else return false;
}

/*第一种形式 第二种形式 更换显示样式*/
function setTab(name, cursel, n) {
    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 setClass(name, cursel, n) {
    for (i = 1; i <= n; i++) {
        var menu = document.getElementById(name + i);
        menu.className = i == cursel ? "hover" : "";
    }
}

function SetTag(TagName) {
    if (document.getElementById("ControlTag").value == "") {
        document.getElementById("ControlTag").value = TagName;
    }
    else {
        document.getElementById("ControlTag").value += "," + TagName;
    }
}

//删除指定节点
function Delete(ObjID) {
    var Row = document.getElementById(ObjID);
    Row.parentNode.removeChild(Row);   //删除
    //document.getElementById("fileDiv").removeChild(document.getElementById("file" + obj));
}
//清空指定节点
function Clear(ObjID) {
    var div = document.getElementById(ObjID);
    div.innerHTML = "";
}

//显示或隐藏添加属性
function ShowHide(id) {
    if (document.getElementById(id).style.display == "none") {
        document.getElementById(id).style.display = "block";
    }
    else {
        document.getElementById(id).style.display = "none";
    }
}

//显示属性
function Show(id) {
    if (document.getElementById(id).style.display == "none") {
        document.getElementById(id).style.display = "block";
    }
}

//显示属性
function Hide(id) {
    if (document.getElementById(id).style.display == "block") {
        document.getElementById(id).style.display = "none";
    }
}

//生成随机数字
var chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
        'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
        'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
function generateMixed(n) {
    var res = "";
    for (var i = 0; i < n; i++) {
        var id = Math.ceil(Math.random() * 62);
        res += chars[id];
    }
    return res;
} 