﻿// JScript File
var popup = null;

var bln_popup = false;

function openlink(URL, w, h) {
    LeftPosition = (screen.width) ? (screen.width - w) / 2 : 0;
    TopPosition = (screen.height) ? (screen.height - h) / 2 : 0;
    settings = 'toolbar=0,scrollbars=0,location=0,status=0,menubar=0,resizable=0,width=' + w + ',height=' + h + ',left=' + LeftPosition + ',top=' + TopPosition + ''
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "',settings);");
}

function tamanhoJanela(width, height, top, left) {
    this.dlgFeatures = "dialogHeight:" + height + "px;" +
  	  					"dialogWidth:" + width + "px;" +
  	  					"status:no;" +
  	  					"help:no;" +
  	  					"center:yes;" +
  	  					"edge:sunken;" +
  	  					"scroll:no";

}

function Poup(sURL, width, height, scroll, nome_janela) {
    var url = sURL + '&rnd=' + Math.round(Math.random() * 899999) + 100000;
    var nome;

    if (nome_janela == '') {
        nome = 'popup_stc';
    } else {
        nome = nome_janela;
    }

    if (popup != null && !popup.closed) {
        popup.focus();
    } else {

        LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
        TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;

        settings = 'height=' + height + ',width=' + width + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll;

        popup = window.open(url, nome, settings);

        //popup = window.open(url,'popup_stc','height=' + height + ',width=' + width);
        popup.focus();
    }

}

function AbrePopupPesquisa2(sURL, width, height, txt_id, txt_dsc, txt_id2) {

    var url = sURL + '&campo_id=' + txt_id + '&campo_dsc=' + txt_dsc + '&campo_id2=' + txt_id2;

    if (popup != null && !popup.closed) {
        popup.focus();
    } else {

        LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
        TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;

        settings = 'height=' + height + ',width=' + width + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll;

        popup = window.open(url, 'STC', settings);
        popup.focus();
    }

}

function AbrePopupPesquisa(sURL, width, height, txt_id, txt_dsc) {

    var url = sURL + '&campo_id=' + txt_id + '&campo_dsc=' + txt_dsc;

    if (popup != null && !popup.closed) {
        popup.focus();
    } else {

        LeftPosition = (screen.width) ? (screen.width - width) / 2 : 0;
        TopPosition = (screen.height) ? (screen.height - height) / 2 : 0;

        settings = 'height=' + height + ',width=' + width + ',top=' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll;

        popup = window.open(url, 'STC', settings);
        popup.focus();
    }

}

function PoupCep(sURL, width, height, txt_cep, ddl_estado, txt_id_cidade, txt_cidade, txt_logradouro, txt_bairro, txt_hidden_uf, valor_cep) {

    if (bln_popup == true) {

        bln_popup = false;

        var str_cep = '';

        if (valor_cep != '' && valor_cep != undefined) {
            str_cep = valor_cep;
        } else {
            if (document.getElementById(txt_cep).value != undefined) {
                str_cep = document.getElementById(txt_cep).value;
            }
        }

        var url = sURL + str_cep + '&rnd=' + Math.round(Math.random() * 899999) + 100000 + '&campo_cep=' + txt_cep + '&campo_estado=' + ddl_estado + '&campo_id_cidade=' + txt_id_cidade + '&campo_cidade=' + txt_cidade + '&campo_logradouro=' + txt_logradouro + '&campo_bairro=' + txt_bairro + '&campo_estado_hidden=' + txt_hidden_uf;

        //alert('URL' + url)

        if (popup != null && !popup.closed) {
            popup.focus();
        } else {
            popup = window.open(url, 'CEP', 'height=' + height + ',width=' + width + 'scrollbars=yes');
            popup.focus();
        }

    }

}

function PoupCepCesta(sURL, width, height, txt_cep, valor_cep) {

    var str_cep = '';

    if (valor_cep != '' && valor_cep != undefined) {
        str_cep = valor_cep;
    } else {
        if (document.getElementById(txt_cep).value != undefined) {
            str_cep = document.getElementById(txt_cep).value;
        }
    }

    var url = sURL + str_cep + '&campo_cep=' + txt_cep;

    if (popup != null && !popup.closed) {
        popup.focus();
    } else {
        popup = window.open(url, 'CEP', 'height=' + height + ',width=' + width + 'scrollbars=yes');
        popup.focus();
    }
}

function setValorPesquisa2(campo_id, campo_dsc, campo_id2) {

    var array_id = campo_id.split('*');
    var array_dsc = campo_dsc.split('*');
    var array_id2 = campo_id2.split('*');

    window.opener.document.getElementById(array_id[0]).value = array_id[1];
    window.opener.document.getElementById(array_dsc[0]).value = array_dsc[1];
    window.opener.document.getElementById(array_id2[0]).value = array_id2[1];

    window.close();

}

function setValorPesquisa(campo_id, campo_dsc) {

    var array_id = campo_id.split('*');
    var array_dsc = campo_dsc.split('*');

    window.opener.document.getElementById(array_id[0]).value = array_id[1];
    window.opener.document.getElementById(array_dsc[0]).value = array_dsc[1];

    window.close();

}

function setValorCep(campo_cep, campo_estado, campo_id_cidade, campo_cidade, campo_logradouro, campo_bairro, campo_estado_hidden) {

    var array_cep = campo_cep.split('*');
    var array_estado = campo_estado.split('*');
    var array_id_cidade = campo_id_cidade.split('*');
    var array_cidade = campo_cidade.split('*');
    var array_logradouro = campo_logradouro.split('*');
    var array_bairro = campo_bairro.split('*');

    if (campo_estado_hidden != 'undefined') { var array_estado_hidden = campo_estado_hidden.split('*'); }

    //alert(array_id_cidade[0] + '-' + array_id_cidade[1]);

    window.opener.document.getElementById(array_cep[0]).value = array_cep[1];

    if (array_estado[0] != 'undefined') {
        if (array_estado[0] != '') window.opener.document.getElementById(array_estado[0]).value = array_estado[1];
    };

    if (array_id_cidade[0] != 'undefined') {
        if (array_id_cidade[0] != '') window.opener.document.getElementById(array_id_cidade[0]).value = array_id_cidade[1];
    }

    if (array_cidade[0] != 'undefined') {
        if (array_cidade[0] != '') window.opener.document.getElementById(array_cidade[0]).value = array_cidade[1];
    }

    if (campo_estado_hidden != 'undefined') {
        if (array_estado_hidden[0] != 'undefined') {
            if (array_estado_hidden[0] != '') window.opener.document.getElementById(array_estado_hidden[0]).value = array_estado_hidden[1];
        }
    }

    if (array_logradouro[0] != 'undefined') {
        if (array_logradouro[0] != '') {
            window.opener.document.getElementById(array_logradouro[0]).value = array_logradouro[1];
        }
        //        else {
        //            window.opener.document.getElementById(array_logradouro[0]).readonly = false;
        //        }
    }

    if (array_bairro[0] != 'undefined') {
        if (array_bairro[0] != '') {
            window.opener.document.getElementById(array_bairro[0]).value = array_bairro[1];
        }
        //        else {
        //            window.opener.document.getElementById(array_bairro[0]).readonly = false;
        //        }
    }

    bln_popup = false;

    window.close();

}



function ModalCep(sURL, width, height, top, left, txt_cep, ddl_estado, txt_cidade, txt_logradouro, txt_bairro, valor_cep) {
    var str_cep;
    if (valor_cep != '') {
        str_cep = valor_cep;
    } else {
        str_cep = document.getElementById(txt_cep).value;
    }

    var url = sURL + str_cep + '&rnd=' + Math.round(Math.random() * 899999) + 100000;
    var sFeatures = new tamanhoJanela(width, height, top, left);
    var retornoModal = window.showModalDialog(url, '', sFeatures.dlgFeatures);

    if (retornoModal != undefined) {
        var array_cep = retornoModal.split('*');

        document.getElementById(txt_cep).value = array_cep[0];

        document.getElementById(txt_logradouro).value = array_cep[1];
        document.getElementById(txt_logradouro).disabled = true;

        document.getElementById(txt_bairro).value = array_cep[2];
        document.getElementById(txt_bairro).disabled = true;

        document.getElementById(ddl_estado).value = array_cep[3];
        document.getElementById(ddl_estado).disabled = true;

        document.getElementById(txt_cidade).value = array_cep[4];
        document.getElementById(txt_cidade).disabled = true;

    } else {
        document.getElementById(txt_logradouro).value = '';
        document.getElementById(txt_logradouro).disabled = false;

        document.getElementById(txt_bairro).value = '';
        document.getElementById(txt_bairro).disabled = false;

        document.getElementById(ddl_estado).value = '';
        document.getElementById(ddl_estado).disabled = false;

        document.getElementById(txt_cidade).value = '';
        document.getElementById(txt_cidade).disabled = false;
    }

}

/* Para usar radio button em Repeater */
function SetUniqueRadioButton(nameregex, current) {
    re = new RegExp(nameregex);
    for (i = 0; i < document.forms[0].elements.length; i++) {
        elm = document.forms[0].elements[i]
        if (elm.type == 'radio') {
            if (re.test(elm.name)) {
                elm.checked = false;
            }
        }
    }
    current.checked = true;
}
/***************************************************/

function MM_formtCep(e, src, mask) {
    if (window.event) { _TXT = e.keyCode; }
    else if (e.which) { _TXT = e.which; }
    if (_TXT > 47 && _TXT < 58) {
        var i = src.value.length; var saida = mask.substring(0, 1); var texto = mask.substring(i)
        if (texto.substring(0, 1) != saida) { src.value += texto.substring(0, 1); }
        return true;
    } else {
        if (_TXT != 8) { return false; }
        else { return true; }
    }
}

function MascaraCNPJ(cnpj) {
    if (mascaraInteiro(cnpj) == false) {
        event.returnValue = false;
    }
    return formataCampo(cnpj, '00.000.000/0000-00', event);
}

//adiciona mascara de cep
function MascaraCep(cep) {
    if (mascaraInteiro(cep) == false) {
        event.returnValue = false;
    }
    return formataCampo(cep, '00.000-000', event);
}

//adiciona mascara de data
function MascaraData(data) {
    if (mascaraInteiro(data) == false) {
        event.returnValue = false;
    }
    return formataCampo(data, '00/00/0000', event);
}

//adiciona mascara ao telefone
function MascaraTelefone(tel) {
    if (mascaraInteiro(tel) == false) {
        event.returnValue = false;
    }
    return formataCampo(tel, '(00) 0000-0000', event);
}

//adiciona mascara ao CPF
function MascaraCPF(cpf) {
    if (mascaraInteiro(cpf) == false) {
        event.returnValue = false;
    }
    return formataCampo(cpf, '000.000.000-00', event);
}

//valida telefone
function ValidaTelefone(tel) {
    exp = /\(\d{2}\)\ \d{4}\-\d{4}/
    if (!exp.test(tel.value))
        alert('Numero de Telefone Invalido!');
}

//valida CEP
function ValidaCep(cep) {
    exp = /\d{2}\.\d{3}\-\d{3}/
    if (!exp.test(cep.value))
        alert('Numero de Cep Invalido!');
}

//valida data
function ValidaData(data) {
    exp = /\d{2}\/\d{2}\/\d{4}/
    if (!exp.test(data.value))
        alert('Data Invalida!');
}

//valida o CPF digitado
function ValidarCPF(Objcpf) {
    var CPF = Objcpf.value;

    var wVr, wTam, wSoma, wSoma2, i, wDig1, wDig2,
		wVETOR_CC = new Array(11),
		wVETOR_PESO = new Array(11),
		Erro = false;

    wVr = "";

    for (i = 0; i < CPF.length; i++) {
        if (!isNaN(parseInt(CPF.charAt(i)))) {
            wVr = wVr + CPF.charAt(i);
        }
    }

    wTam = wVr.length + 1;

    if (wTam < 11) {
        alert("Faltam dígitos no CPF. Por favor, tente novamente.");
        return false;
    }


    if (wVr == '11111111111' || wVr == '22222222222' || wVr == '33333333333' || wVr == '44444444444' || wVr == '55555555555' ||
		wVr == '66666666666' || wVr == '77777777777' || wVr == '88888888888' || wVr == '99999999999') {
        alert("CPF Inválido. Por favor, tente novamente.");
        Objcpf.value = '';
        Objcpf.focus();
        return false;
    }

    wSoma = 0;
    wSoma2 = 0;

    for (i = 0; i < 11; i++) {
        wVETOR_CC[i] = wVr.charAt(i);
        wVETOR_PESO[i] = i + 2;
    }

    i = 0;
    while (i < 9) {
        i++;

        if (i < 10) {
            wSoma += wVETOR_CC[9 - i] * wVETOR_PESO[i - 1];
        }

        wSoma2 += wVETOR_CC[10 - i] * wVETOR_PESO[i - 1];
    }

    wDig1 = (wSoma * 10) % 11;
    wDig2 = (wSoma2 * 10) % 11;

    if (wDig1 == 10) {
        wDig1 = 0;
    }

    if (wDig2 == 10) {
        wDig2 = 0;
    }

    if (parseInt(wVr.charAt(9)) != wDig1 || parseInt(wVr.charAt(10)) != wDig2) {
        alert("CPF inválido. Por favor, tente novamente.");
        Objcpf.value = '';
        Objcpf.focus();
        return false;
    }

    return true;

}

//valida numero inteiro com mascara
function mascaraInteiro() {
    if (event.keyCode < 48 || event.keyCode > 57) {
        event.returnValue = false;
        return false;
    }
    return true;
}

//valida o CNPJ digitado
function ValidarCNPJ(ObjCnpj) {
    var cnpj = ObjCnpj.value;
    var valida = new Array(6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2);
    var dig1 = new Number;
    var dig2 = new Number;

    exp = /\.|\-|\//g
    cnpj = cnpj.toString().replace(exp, "");
    var digito = new Number(eval(cnpj.charAt(12) + cnpj.charAt(13)));

    for (i = 0; i < valida.length; i++) {
        dig1 += (i > 0 ? (cnpj.charAt(i - 1) * valida[i]) : 0);
        dig2 += cnpj.charAt(i) * valida[i];
    }
    dig1 = (((dig1 % 11) < 2) ? 0 : (11 - (dig1 % 11)));
    dig2 = (((dig2 % 11) < 2) ? 0 : (11 - (dig2 % 11)));

    if (((dig1 * 10) + dig2) != digito) {
        alert('CNPJ Invalido!');
        ObjCnpj.value = '';
        ObjCnpj.focus();
    }
}

//formata de forma generica os campos
function formataCampo(campo, Mascara, evento) {
    var boleanoMascara;

    var Digitato = evento.keyCode;
    exp = /\-|\.|\/|\(|\)| /g
    campoSoNumeros = campo.value.toString().replace(exp, "");

    var posicaoCampo = 0;
    var NovoValorCampo = "";
    var TamanhoMascara = campoSoNumeros.length; ;

    if (Digitato != 8) { // backspace 
        for (i = 0; i <= TamanhoMascara; i++) {
            boleanoMascara = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
                                || (Mascara.charAt(i) == "/"))
            boleanoMascara = boleanoMascara || ((Mascara.charAt(i) == "(")
                                || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " "))
            if (boleanoMascara) {
                NovoValorCampo += Mascara.charAt(i);
                TamanhoMascara++;
            } else {
                NovoValorCampo += campoSoNumeros.charAt(posicaoCampo);
                posicaoCampo++;
            }
        }
        campo.value = NovoValorCampo;
        return true;
    } else {
        return true;
    }
}

function NumericText(e) {
    var keyNumber = (isIE) ? event.keyCode : e.which;
        
    if (((keyNumber < 48) || (keyNumber > 57)) && (keyNumber != 13) && (keyNumber != "0") && (keyNumber != 8) && (keyNumber != 9)) {
        if (isIE) {
            event.keyCode = 0
        }
            return false;
    }
    
    return true;
}
function MascaraMoeda_(objTextBox, SeparadorMilesimo, SeparadorDecimal, e) {
    var sep = 0;
    var key = '';
    var i = j = 0;
    var len = len2 = 0;
    var strCheck = '0123456789';
    var aux = aux2 = '';
    var whichCode = (window.Event) ? event.which : event.keyCode;

    if (whichCode == 13) return true; // Tecla Enter
    if (whichCode == 8) return true; // Tecla Delete

    if (whichCode >= 96 && whichCode <= 105) return true;
    key = String.fromCharCode(whichCode); // Pegando o valor digitado
    if (strCheck.indexOf(key) == -1) return false; // Valor inválido (não inteiro)
    len = 10;
    for (i = 0; i < len; i++)
        if ((objTextBox.value.charAt(i) != '0') && (objTextBox.value.charAt(i) != SeparadorDecimal)) break;
    aux = '';
    for (; i < len; i++)
        if (strCheck.indexOf(objTextBox.value.charAt(i)) != -1) aux += objTextBox.value.charAt(i);
    aux += key;
    len = aux.length;
    if (len == 0) objTextBox.value = '';
    if (len == 1) objTextBox.value = '0' + SeparadorDecimal + '0' + aux;
    if (len == 2) objTextBox.value = '0' + SeparadorDecimal + aux;

    if (len > 2) {
        aux2 = '';

        for (j = 0, i = len - 3; i >= 0; i--) {
            if (j == 3) {
                aux2 += SeparadorMilesimo;
                j = 0;
            }
            aux2 += aux.charAt(i);
            j++;
        }

        objTextBox.value = '';
        len2 = aux2.length;
        for (i = len2 - 1; i >= 0; i--)
            objTextBox.value += aux2.charAt(i);
        objTextBox.value += SeparadorDecimal + aux.substr(len - 2, len);
    }

    return false;

}

function isNumberKey(evt) {
    var charCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;


    if ((charCode > 47 && charCode < 58) || (charCode > 95 && charCode < 106))
        return true;
    else {
        if (charCode == 8 || charCode == 9 || charCode == 46 || (charCode >= 37 && charCode <= 40)) // backspace, delete, setas, tab;
            return true;
        else
            return false;
    }

}

function formatarMascara_(src, mask) {
    // Função utilizada para formatação de letras, numeros e ambos.
    // # -> [0-9]
    // Z -> [a-z] ou [A-Z]
    // * -> [0-9],[a-z] ou [A-Z]

    var i = src.value.length;
    var saida = mask.substring(i, i + 1);
    var texto = mask.substring(i)

    if (saida == '') {
        event.keyCode = 0;
        return false;
    }
    if (!(mask.substring(i, i + 1) == '#' || mask.substring(i, i + 1) == 'Z' || mask.substring(i, i + 1) == '*')) {
        i = i + 1;
        saida = mask.substring(i, i + 1);
    }
    if (texto.substring(0, 1) != saida) {
        src.value += texto.substring(0, 1);
    }

    if ((saida == '#') && (NumericText(event) == false)) { // Formata a mascara como numero = #
        event.keyCode = 0;
        return false;
    } else if ((saida == 'Z') && (ConteudoText(event) == false)) { // Formata a mascara como texto [a-z][A-Z] = #
        event.keyCode = 0;
        return false;
    } else if ((saida == '*') && ((NumericText(event) == false) && (ConteudoText(event) == false))) { // Formata a mascara como numero e texto= #
        event.keyCode = 0;
        return false;
    }
}

function isNumberandCommaKey(evt) {
    var charCode = (evt.which) ? evt.which : event.keyCode

    var ContentTXT = evt.value;
    var i = 0;
    var length = ContentTXT.length;

    if (charCode == 188 || charCode == 110) {
        for (i = 0; i <= length; i++) {
            if (ContentTXT.charAt(i) == ',')
                return false;
        }
        return true;
    }



    if ((charCode > 47 && charCode < 58) || (charCode > 95 && charCode < 106))
        return true;
    else {
        if (charCode == 8 || charCode == 9 || charCode == 46 || (charCode >= 37 && charCode <= 40)) // backspace, delete, setas, tab;
            return true;
        else
            return false;
    }

}


function formatar(src, mask) {
    var i = src.value.length;
    var saida = mask.substring(0, 1);
    var texto = mask.substring(i)
    if (texto.substring(0, 1) != saida) {
        src.value += texto.substring(0, 1);
    }
}

function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
    else
        countfield.value = maxlimit - field.value.length;
}

/* BUSCA AVANCADA */

/* Barra Slider(Controle de volume) */
function Slider(valMin, ValMax) {
    var A_TPL3h = {
        'b_vertical': false,
        'b_watch': true,
        'n_controlWidth': 120,
        'n_controlHeight': 16,
        'n_sliderWidth': 19,
        'n_sliderHeight': 16,
        'n_pathLeft': 1,
        'n_pathTop': 0,
        'n_pathLength': 98,
        's_imgControl': 'img/sldr2h_bg.gif',
        's_imgSlider': 'img/sldr2h_sl.gif',
        'n_zIndex': 1
    }
    var A_INIT3h = {
        's_form': 0,
        's_name': 'sliderValue3h',
        'n_minValue': 0,
        'n_maxValue': 100,
        'n_value': 50,
        'n_step': 1
    }

    new slider(A_INIT3h, A_TPL3h);

}


function qtd_setVaule(qtd, vlrInc, vlrMax, s_name) {

    var qtdCompra = qtd

    /*Joga a quantidade de produto para a proxima do multiplo*/

    if (vlrInc != 0) {

        if ((qtdCompra % vlrInc) != 0) {
            qtdCompra = (Math.ceil(qtdCompra / vlrInc)) * vlrInc;

        }
    }

    if (vlrMax <= qtdCompra) {
        qtdCompra = vlrMax;
    }


    //Joga a quantidade de produto para a proxima do multiplo
    if (vlrMax < qtdCompra) {
        if (vlrInc != 0) {

            if (vlrMax < vlrInc) {

                qtdCompra = vlrMax;

            } else
                if ((qtdCompra % vlrInc) != 0) {

                qtdCompra = (Math.floor(qtdCompra / vlrInc)) * vlrInc;

            }

        }
    }


    var e_input;
    e_input = get_element(s_name);

    var qtdFinal = qtdCompra;

    e_input.value = parseFloat(qtdFinal).toFixed(2).toString().replace(".", ",");


}

function YouTubeBox(url, tituloJanela) {

    Shadowbox.open({
        player: 'swf',
        content: url,
        width: 405,
        height: 340,
        handleOversize: 'none',
        title: tituloJanela
    });
}

function FlashBox(url, tituloJanela) {

    Shadowbox.open({
        player: 'swf',
        content: url,
        width: 405,
        height: 340,
        handleOversize: 'none',
        title: tituloJanela
    });
}

function ModalBox(url, width, height, tituloJanela) {

    Shadowbox.open({
        player: 'iframe',
        content: url,
        width: width,
        height: height,
        title: tituloJanela
    });
}

function ImgBox(url, width, height, tituloJanela) {
    Shadowbox.open({
        player: 'img',
        content: url.src.replace('b', 'c'),
        width: width,
        height: height,
        title: tituloJanela

    });
}

function AmpliaModelo(obj, width, height, tituloJanela) {

    Shadowbox.open({
    player: 'img',
        content: obj,
        title: tituloJanela

    });
}

function VerificaEmail(pcampo) {
    //pcampo.value = pcampo.value.toLowerCase();

    $(pcampo).val($(pcampo).val().toLowerCase());

    //parametro = pcampo.value;

    parametro = $(pcampo).val();

    teste_parametro = "false";
    tamanho_parametro = parametro.length;
    aposicao = 0; //posicao @
    pposicao = 0; //poiscao ponto
    narrobas = 0; // numero de @
    for (i = 0; i < tamanho_parametro; i++) { /*verifica se existe espaco em branco */
        if (parametro.charAt(i) == "@") {
            narrobas = narrobas + 1
            aposicao = i;
        }
        if (parametro.charAt(i) == ".") {
            pposicao = i;
        }
    }
    if (aposicao > 0 && aposicao + 1 < pposicao && narrobas < 2) {
        teste_parametro = "true";
    }

    for (i = 0; i < tamanho_parametro; i++) { /*verifica se existe espaco em branco */
        if (parametro.charAt(i) == " ") {
            teste_parametro = "false";
        }
    }

    if (tamanho_parametro < 5) {
        teste_parametro = "false"; /*tamanho minimo*/
    }

    if (parametro.charAt(0) == " " || parametro.charAt(1) == " ") {
        teste_parametro = "false";
    }

    if (teste_parametro == "false" && tamanho_parametro != 0) {
        return false;
    }
    else
        return true;
}


function showLoading() { $('#divLoading').show(); }
function hideLoading() { $('#divLoading').hide(); }
