﻿function OnPageLoad() {
    if (self.document.getElementById("TelefoneUsuarioTextBox") != null) {
        InitializeTrimBox("TelefoneUsuarioTextBox");
        InitializeMaskEdit("TelefoneUsuarioTextBox", "($d$d)$d$d$d$d-$d$d$d$d");
    }
    if (self.document.getElementById("NascimentoUsuarioTextBox") != null) {
        InitializeTrimBox("NascimentoUsuarioTextBox");
        InitializeMaskEdit("NascimentoUsuarioTextBox", "$d$d/$d$d/$d$d$d$d");
    }
    if (self.document.getElementById("PrecoProdutoTextBox") != null) {
        if (self.document.getElementById("CodigoProdutoTextBox1").disabled == false) {
            self.document.getElementById("PrecoProdutoTextBox").value = "";
        }
        InitializeTrimBox("PrecoProdutoTextBox");
        InitializeTextbox("PrecoProdutoTextBox", InputType.Currency);
    }
    if (self.document.getElementById("CodigoProdutoTextBox1") != null) {
        if (self.document.getElementById("CodigoProdutoTextBox1").disabled == false) {
            self.document.getElementById("CodigoProdutoTextBox1").value = "";
        }
        InitializeTrimBox("CodigoProdutoTextBox1");
        InitializeTextbox("CodigoProdutoTextBox1", InputType.NonnegativeInteger);
    }
    if (self.document.getElementById("CodigoProdutoTextBox2") != null) {
        self.document.getElementById("CodigoProdutoTextBox2").value = "";
        InitializeTrimBox("CodigoProdutoTextBox2");
        InitializeTextbox("CodigoProdutoTextBox2", InputType.NonnegativeInteger);
    }
}

function outroSiteRadioButtonCheckedChanged() {
    self.document.getElementById("FazerUploadFileUpload").setAttribute("disabled", "disabled");
    self.document.getElementById("OutroSiteDownloadTextBox").removeAttribute("disabled");
    downloadItemValueChanged();
}

function fazerUploadRadioButtonCheckedChanged() {
    self.document.getElementById("OutroSiteDownloadTextBox").setAttribute("disabled", "disabled");
    self.document.getElementById("FazerUploadFileUpload").removeAttribute("disabled");
    downloadItemValueChanged();
}

function removerDownloadIDCheckedChanged() {
    self.document.getElementById("RemoverDownloadButton").removeAttribute("disabled");
}

function removerLinkIDCheckedChanged() {
    self.document.getElementById("RemoverLinkButton").removeAttribute("disabled");
}

function removerPostIDCheckedChanged() {
    self.document.getElementById("RemoverPostButton").removeAttribute("disabled");
}

function postarItemValueChanged() {
    if (self.document.getElementById("TituloPostTextBox").value.trim() != "" && self.document.getElementById("ConteudoPostTextBox").value.trim() != "") {
        self.document.getElementById("PostarButton").removeAttribute("disabled");
    } else {
        self.document.getElementById("PostarButton").setAttribute("disabled", "disabled");
    }
}

function produtoItemValueChanged() {
    if (self.document.getElementById("CodigoProdutoTextBox1").value.trim() != "" && self.document.getElementById("NomeProdutoTextBox").value.trim() != "" && self.document.getElementById("DescricaoProdutoTextBox").value.trim() != "" && self.document.getElementById("CategoriaProdutoDropDownList").value.trim() != "" && self.document.getElementById("MarcaProdutoTextBox").value.trim() != "" && self.document.getElementById("PrecoProdutoTextBox").value.trim() != "" && self.document.getElementById("FotoProdutoFileUpload").value.trim() != "") {
        self.document.getElementById("SalvarProdutoButton").removeAttribute("disabled");
    } else {
        self.document.getElementById("SalvarProdutoButton").setAttribute("disabled", "disabled");
    }
}

function usuarioItemValueChanged() {
    if (self.document.getElementById("NomeUsuarioTextBox").value.trim() != "" && self.document.getElementById("AreaUsuarioDropDownList").value.trim() != "" && self.document.getElementById("FuncaoUsuarioDropDownList").value.trim() != "" && self.document.getElementById("TelefoneUsuarioTextBox").value.indexOf('_') < 0 && self.document.getElementById("NascimentoUsuarioTextBox").value.indexOf('_') < 0) {
        self.document.getElementById("SalvarDadosUsuarioButton").removeAttribute("disabled");
    } else {
        self.document.getElementById("SalvarDadosUsuarioButton").setAttribute("disabled", "disabled");
    }
}

function downloadItemValueChanged() {
    if (self.document.getElementById("OutroSiteRadioButton").checked == true) {
        if (self.document.getElementById("DescricaoDownloadTextBox").value.trim() != "" && self.document.getElementById("OutroSiteDownloadTextBox").value.trim() != "") {
            self.document.getElementById("SalvarDownloadButton").removeAttribute("disabled");
        } else {
            self.document.getElementById("SalvarDownloadButton").setAttribute("disabled", "disabled");
        }
    } else {
        if (self.document.getElementById("DescricaoDownloadTextBox").value.trim() != "" && self.document.getElementById("FazerUploadFileUpload").value.trim() != "") {
            self.document.getElementById("SalvarDownloadButton").removeAttribute("disabled");
        } else {
            self.document.getElementById("SalvarDownloadButton").setAttribute("disabled", "disabled");
        }
    }
}

function linkItemValueChanged() {
    if (self.document.getElementById("DescricaoLinkTextBox").value.trim() != "" && self.document.getElementById("EnderecoLinkTextBox").value.trim() != "") {
        self.document.getElementById("SalvarCadastrarLinkButton").removeAttribute("disabled");
    } else {
        self.document.getElementById("SalvarCadastrarLinkButton").setAttribute("disabled", "disabled");
    }
}

function loginItemValueChanged() {
    if (self.document.getElementById("LoginTextBox").value.trim() != "" && self.document.getElementById("PasswordTextBox").value.trim() != "") {
        self.document.getElementById("LoginButton").removeAttribute("disabled");
    } else {
        self.document.getElementById("LoginButton").setAttribute("disabled", "disabled");
    }
}

function inserirCodigoItemValueChanged() {
    if (self.document.getElementById("CodigoProdutoTextBox2").value.trim() != "") {
        self.document.getElementById("CodigoProdutoButton").removeAttribute("disabled");
    } else {
    self.document.getElementById("CodigoProdutoButton").setAttribute("disabled", "disabled");
    }
}
