function selectSubmit(form, option) {
    form.SUBMIT.value = option;
    form.submit();
}

function cleanAction(form) {
    alert(form);
    form.action  =  "";
//    form.submit()
}

function setStyleVisible(divId) {
    document.getElementById(divId).style.visibility = 'visible';
}

function setStyleHidden(divId) {
    document.getElementById(divId).style.visibility = 'hidden';
}

function toggleAlert() {
    toggleDisabled(document.getElementById("content"));
}

function toggleDisabled(el) {
    try {
        el.disabled = el.disabled ? false : true;
    }catch(E){
    }
    if (el.childNodes && el.childNodes.length > 0) {
        for (var x = 0; x < el.childNodes.length; x++) {
            toggleDisabled(el.childNodes[x]);
        }
    }
}

function onLoadBody(option) {
    if (option == 'subcategorias') {
        disableOptions(this.document.formManagement, option);
    }
    else if (option == 'productos') {
        disableOptions(this.document.formManagement, option);
    }
    else {
        disableOptions(this.document.formManagement, null);
    }
}

function disableOptions(form, option){
    if (option == 'subcategorias') {
        form.categoriesId.disabled = false;
        form.categoriesId.focus();
        return true;
    }
    else if (option == 'productos') {
        form.categoriesId.disabled = false;
        form.subcategoriesId.disabled = false;
        if (form.categoriesId.selectedIndex > 0) {
            form.subcategoriesId.focus();
        }
        else {
            form.categoriesId.focus();
        }
        return true;
    }
    else{
        form.categoriesId.disabled = true;
        form.subcategoriesId.disabled = true;
        return true;
    }
    return false;
}
