// 设置左侧导航高度和宽度
var fnSetMenuStyle = function(obj) {

    var oMenu   = $('menu_ul');
    var oChilds = oMenu.childNodes;
    var iNum   = oChilds.length;

    for (var i = 0; i < iNum; i++) {
        oChilds[i].className = 'menu_li';
    }
    obj.parentNode.className = 'menu_li menu_li_cur';
}

var fnAutoSetWindow = function() {
    $('main').style.width = (parseInt(document.body.scrollWidth) - 198) + "px";
}

// 全选或最不选中checkbox
var fnSelectCheckbox = function(obj, element) {
    var oLiCheck = $(element).getElementsByTagName('input');
    var iNum     = oLiCheck.length;

    for(i = 0; i < iNum; i++) {
        if (oLiCheck[i].type == 'checkbox') {
            if (obj.checked == true) {
                oLiCheck[i].checked = true;
            } else {
                oLiCheck[i].checked = false;
            }
        }
    }
}

var fnSelectOne = function(obj, sUrl, sDelId) {
    sUrl += "&tag_id=";
    if (obj.checked == true) {
        sUrl += obj.value + ',';
        $(sDelId).value = sUrl;
    } else {
// sUrl = sUrl.substr(0, sUrl.indexOf(obj.value + ','));
}

   
}

// 选择标签
var fnSetTags = function(oObj, tId, sTagsId) {
    var sValue = $(sTagsId).value;
    var aValue = sValue.split(',');
    var fIsSel = null;
    for (i = 0; i < aValue.length; i++) {
        if (tId == aValue[i]) {
            fIsSel = i;
        }
    }

    if (fIsSel == null) {
        $(sTagsId).value += tId + ',';
        oObj.style.backgroundColor = "#e3f6e5";
        oObj.style.border = "1px solid #b4e3b9";
    } else {
        aValue.remove(fIsSel);
        $(sTagsId).value = aValue.toString();
        oObj.style.backgroundColor = "#FFF";
        oObj.style.border = "";
    }
    return;
}

// 选择分类
var fnSetCategory = function(oObj, tId, sCatId) {
    var sValue = ($(sCatId).value + "").replace(/(\S+?)(\s+?)(\S+?)/,"$2");
    var oP = oObj.parentNode.parentNode;
    if(oP)
    {
        var as = oP.getElementsByTagName("a");
        for(var i = as.length - 1 ; i >= 0 ; i--)
        {
            as[i].style.backgroundColor = "#FFF";
            as[i].style.border = "";
        }
    }
        
    if(sValue != "")
    {
        if(sValue != (tId + ""))
        {
            $(sCatId).value = tId + '';
            oObj.style.backgroundColor = "#e3f6e5";
            oObj.style.border = "1px solid #b4e3b9";
        }else
        {
            $(sCatId).value = "";
        }
    }else
    {
        $(sCatId).value = tId + '';
        oObj.style.backgroundColor = "#e3f6e5";
        oObj.style.border = "1px solid #b4e3b9";
    }
    return;
}