var _class;

var ClassArr = _class; ////类别数据
////set类别名称
function setClassName() {
    var x = document.getElementById("ContentPlaceHolder1_ClassID").value;
    if (x) {
        var a = GetClassNameByclassID(x);
        if (a) { ClassName(a); }
    }
}
////类别名称
function ClassName(x) {
    var classname = document.getElementById("ClassName");
    if (!classname) {
        return;
    }
    if (x) {
        classname.innerHTML = "原(" + x + ") <br/>";
    } else {
        return classname.innerHTML;
    }
}



function GetClassNameByclassID(ID) {
    var c = "";
    var ClassArray = new Array();
    for (var x in ClassArr) {
        if (x == ID) {
            var _classArray = _class[x];
            c = _classArray[0];
            if (_classArray[1] != "0") {
                c = GetClassNameByclassID(_classArray[1]) + " > " + c;
            }
            break;
        }
    }
    return c;
}


function GetClassByParentID(ParentID) {
    var ClassArray = new Array();
    for (var x in _class) {
        var _classArray = _class[x]
        if (_classArray[1] == ParentID) {
            var _array = new Array();
            _array[0] = _classArray[0];
            _array[1] = x;
            _array[2] = _classArray[2];
            ClassArray.push(_array);
        }
    }
    return ClassArray;
}

function Hidden(x) {
    var obj = document.getElementById("table" + x);
    if (obj.style.display == "") {
        obj.style.display = "none";
    } else {
        obj.style.display = "";
    }
}

function changeTeam() {
    var obj = document.getElementById("DropTeamNum");
    var objvalue = obj.options[obj.selectedIndex].value;
    for (var i = 1; i <= 5; i++) {
        if (i <= objvalue) {
            document.getElementById("team_" + i).style.display = "";
        } else {
            document.getElementById("team_" + i).style.display = "none";
        }
    }
}
function selectProductPublishTime() {
    if (document.getElementById("ProductPublishTime_1").checked) {
        document.getElementById("PublishStartTr").style.display = "";
    } else {
        document.getElementById("PublishStartTr").style.display = "none";
    }
}





function SumCommodityprices() {
    if (document.getElementById("txtProcessFee").value == "" || document.getElementById("txtWaterPrice").value == "") {
        return;
    }
    document.getElementById("txtCommodityprices").value = (98 + parseFloat(document.getElementById("txtProcessFee").value) + parseFloat(document.getElementById("txtWaterPrice").value)) * parseFloat(document.getElementById("ProductStock").value);
}
var isFirstSelect = false;
function SelectClass() {
    var html;
    var classArray = GetClassByParentID(0);
    html = "<select id='firstSelect'  onchange=\"isFirstSelect=true;return slectchild(this.value,this.options[this.selectedIndex].text,0)\">";
    html += "<option value='-1'>请选择...</option>";
    for (var i = 0; i < classArray.length; i++) {
        var _name = classArray[i][0];
        if (classArray[i][2] != "0") {
            _name = _name + " > ";
        }
        html += "<option value=" + classArray[i][1] + ">" + _name + "</option>";
    }
    html += "</select>";
    //document.getElementById("ContentPlaceHolder1_ClassBarDiv").style.display = 'block';
    document.getElementById("ctl00_ContentPlaceHolder1_ClassBarDiv").style.display = 'block';
    document.getElementById("ChangeClass").style.display = 'none';
    //    var ObjDIV = document.getElementById("ClassBar");
    //    ObjDIV.style.display="";
    //    ObjDIV.style.position="absolute";
    //    document.getElementById("ClassBarContent").innerHTML = html;
    //
    document.getElementById("ctl00_ContentPlaceHolder1_ClassBarDiv").innerHTML = html;
}

function slectchild(id, text, barid) {
    var ObjDIV = document.getElementById("ctl00_ContentPlaceHolder1_ClassBarDiv");
    if (isFirstSelect) {
        var tempSelect = document.getElementById("firstSelect").cloneNode(true);
        tempSelect.value = id;
        ObjDIV.innerHTML = "";
        ObjDIV.appendChild(tempSelect);
        isFirstSelect = false;
        if (id == -1) {
            return;
        }
    }

    var html;
    var classArray = GetClassByParentID(id);
    var boj = document.all("hlClassBarItem");

    if (boj == "[object]") {
        var length = 0;
        if (boj.length == undefined) {
            length = 1;
        } else {
            length = boj.length;
        }
        for (var j = barid; j < length; j++) {
            if (length == 1) {
                //    document.getElementById("ClassBarContent").removeChild(boj);
                ObjDIV.removeChild(boj);
            } else {
                // document.getElementById("ClassBarContent").removeChild(boj[barid]);
                ObjDIV.removeChild(boj[barid]);
            }
        }
    }
    var classnameobj = document.all("hlclassname");
    if (classnameobj == "[object]") {

        var length = 0;
        if (classnameobj.length == undefined) {
            length = 1;
        } else {
            length = classnameobj.length;
        }
        for (var j = barid; j < length; j++) {
            if (length == 1) {
                document.getElementById("ContentPlaceHolder1_ClassName").removeChild(classnameobj);
            } else {

                document.getElementById("ContentPlaceHolder1_ClassName").removeChild(classnameobj[barid]);
            }
        }
    }

    // document.getElementById("ClassName").innerHTML += "<span id='hlclassname'>"+text+"</span>";
    document.getElementById("ctl00_ContentPlaceHolder1_ClassID").value = id;
    if (classArray.length == 0) { return; }

    html = "<select onchange=\"return slectchild(this.value,this.options[this.selectedIndex].text," + barid + 1 + ")\">";
    html += "<option value='-1'>请选择...</option>";
    for (var i = 0; i < classArray.length; i++) {
        var _name = classArray[i][0];
        if (classArray[i][2] != "0") {
            _name += " > ";
        }
        html += "<option value=" + classArray[i][1] + " onclick='return slectchild(" + classArray[i][1] + ")'>" + _name + "</option>";
    }
    html += "</select>";
    ObjDIV.innerHTML += html;
}



        
       
