function abrePopMaquiagem() {
    window.open('http://portal.lojasrenner.com.br/hotsite/cursos_de_maquiagem/index.html?utm_source=portal_lojas_renner&utm_medium=destaque_home&utm_content=cursos_maquiagem&utm_campaign=tempo_de_mulher','mostra','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=400');
}

function abrePop(idSorteado) {
    window.open('${pageContext.request.contextPath}/servicosFinanceiros/comentario.action?idSorteado=' + idSorteado, 'popAviso', 'width=400,height=125,top=300,left=600,status=yes,scrollbars=no');
}
function abrePopFoto(idSorteado) {
    window.open('${pageContext.request.contextPath}/servicosFinanceiros/foto.action?idSorteado=' + idSorteado, 'popAviso', 'width=200,height=150,top=100,left=200,status=yes,scrollbars=no');
}

function sL(object) {
    obj = document.getElementById(object);
    obj.style.display = "block";
}

function hL(object) {
    obj = document.getElementById(object);
    obj.style.display = "none";
}

function mostraEsconde(object) {
    obj = document.getElementById(object);
    obj.style.display = obj.style.display == "none" ? "block" : "none";	
}

function mostraEsconde2(object) {
    obj = document.getElementById(object);
    obj.style.display = obj.style.display == "block" ? "none" : "block";	
}

function ativa(object,css1,css2) {
    obj = document.getElementById(object);
    obj.className = obj.className == css1 ? css2 : css1;	
}

function deactive(object,css2) {
    obj = document.getElementById(object);
    obj.className = css2;
}

function ativaTab(object,classe) {
    obj = document.getElementById(object);
    obj.className = classe;
}

function desativaTabs(classe,numTabs) {
    for(i = 1; i <= numTabs; i++) {
        abas = "tab0" + i;
        content = document.getElementById(abas);
        content.className = classe;
    }
}
function hLall() {
    for (x = 1; x <= numContent; x++) {
        conteudo = "content0" + x;
        obj = document.getElementById(conteudo);
        obj.style.display = "none";
    }
}


function runTransform(docXSL, docXML, saida){
    if(document.implementation && document.implementation.createDocument){
        // Mozilla
        
        var xsltProcessor = new XSLTProcessor();
        
        // load the xslt file
        var myXMLHTTPRequest = new XMLHttpRequest();
        myXMLHTTPRequest.open("GET", docXSL, false);
        myXMLHTTPRequest.send(null);
        
        // get the XML document
        xslStylesheet = myXMLHTTPRequest.responseXML;
        xsltProcessor.importStylesheet(xslStylesheet);
        
        // load the xml file
        myXMLHTTPRequest = new XMLHttpRequest();
        myXMLHTTPRequest.open("GET", docXML, false);
        myXMLHTTPRequest.send(null);
        
        var xmlSource = myXMLHTTPRequest.responseXML;
        
        //transform
        var resultDocument = xsltProcessor.transformToFragment(xmlSource, document);
        document.getElementById(saida).appendChild(resultDocument);
        
    }else if(window.ActiveXObject){
        // IE
    
        // Load XML
        xml = new ActiveXObject("MSXML2.DOMDocument");
        xml.async = false
        xml.load(docXML)
    
        // Load XSL
        xsl = new ActiveXObject("MSXML2.DOMDocument");
        xsl.async = false
        xsl.load(docXSL)
    
    
        // Transform
        document.getElementById(saida).innerHTML=xml.transformNode(xsl);
    }else{
        // Browser unknown
        alert("Browser unknown");
    }
}

function ativaBt(object) {
    ativo = document.getElementById(object);
    ativo.className = "ativo";
}
function desativaBt(object) {
    ativo = document.getElementById(object);
    ativo.className = "inativo";
}

function posDiv(object, top, left) {
    div = document.getElementById(object);
    div.style.top = top;
    div.style.left = left;
}

var t

function timeout(object) {
    obj = document.getElementById(object);
    t = setTimeout("hL(obj.id);",500);
}

function stopTime() {
    clearTimeout(t);
}

function hideItens() {
    hL("mnFeminino");
    hL("mnMasculino");
    hL("mnInfantil");
    hL("subMnMenina");
    hL("subMnMenino");
    hL("subMnInfantil");
    hL("mnAcessorios");
    hL("mnBeleza");
    hL("mnPerfumes");
    hL("mnCalcados");
    hL("mnModaIntima");
    hL("mnPraiaSurfe");
    hL("mnEsporte");
    hL("mnRelogios");
}

var infantil
var menina
var menino
var infantilCalcados;
var calcados;

function hideInfantil() {
    infantilCalcados = setTimeout("hL('subMnInfantil');",500);
    calcados = setTimeout("hL('mnCalcados');",500);
    infantil = setTimeout("hL('mnInfantil');",500);
    menina = setTimeout("hL('subMnMenina');",500);
    menino = setTimeout("hL('subMnMenino');",500);
}

function stopTime2() {
    clearTimeout(infantilCalcados);
    clearTimeout(calcados);
    clearTimeout(infantil);
    clearTimeout(menina);
    clearTimeout(menino);
}

/* Flashs em geral */
function GerarSWF($arquivo,$altura,$largura){
    document.writeln('    <object type="application/x-shockwave-flash" data="'+ $arquivo +'" width="'+ $largura +'" height="'+ $altura +'">');
    document.writeln('        <param name="movie" value="' + $arquivo + '" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="wmode" value="transparent" />');
    document.writeln('    </object>');
}

//Para Flash sobre a p�gina
function GerarInterv($arquivo,$largura,$altura){
    document.writeln('    <object type="application/x-shockwave-flash" data="'+ $arquivo +'" width="'+ $largura +'" height="'+ $altura +'">');
    document.writeln('        <param name="movie" value="' + $arquivo + '" />');
    document.writeln('        <param name="menu" value="false" />');
    document.writeln('        <param name="quality" value="high" />');
    document.writeln('        <param name="wmode" value="transparent" />');
    document.writeln('    </object>');
}

function Trim(str){
    return str.replace(/^\s+|\s+$/g,"");
}

function blockNumbers(e)
{
    var key;
    var keychar;
    var reg;
    
    if(window.event) {
        // for IE, e.keyCode or window.event.keyCode can be used
        key = e.keyCode;
    }
    else if(e.which) {
        // netscape
        key = e.which;
    }
    else {
        // no event, so pass through
        return true;
    }
    
    keychar = String.fromCharCode(key);
    reg = /\d/;
    // return !reg.test(keychar); ===> para tirar números é necessário tirar o exclamação (!)
    return reg.test(keychar);
}

function validaConsultaCartao(){
    
    var nroCartao = document.getElementById('nroCartao').value;
    
    if (nroCartao == '') {
        alert('Informe o número do cartão presente.');
        return;
    }else if (nroCartao.length != 22){
        alert('O número do cartão presente deve ter 22 caracteres.');
        return;
    }else if(nroCartao.substr(0,2) != 88){
        alert('Número do cartão presente Inválido. Tente novamente.');
        return;
    }
    document.consultaSaldo.submit();
}

function limparCampos(){
    
    document.getElementById('nroCartao').value='';
    document.getElementById('saldo').value='';
}

/**
 * Simplifica a chamada e mantem o codigo limpo
 */
function $(sId) {
    return document.getElementById(sId);
}

/**
 * Funcao auxiliar, adiciona uma option dentro de um select
 */
function addSelectOption(oSelect, sValue, sText) {
    var browser = navigator.appName;
    var myEle;
    myEle = document.createElement("option");
    myEle.value = sValue;
    myEle.text = sText;

    if (browser=="Microsoft Internet Explorer") {
        oSelect.add(myEle);
    } else {
        oSelect.appendChild(myEle);
    }
}

/**
 * Remove todos os itens de um select
 */
function clearSelectOptions(oSelect) {
    while(oSelect.options.length != 0) {
        oSelect.remove(0);
    }
}


// Function de validação de CPF.
function validacpf(sParam){

    var i;

    s = sParam;

    var c = s.substr(0,9);

    var dv = s.substr(9,2);

    var d1 = 0;

    for (i = 0; i < 9; i++)

    {

            d1 += c.charAt(i)*(10-i);

        }

    if (d1 == 0){

        alert("CPF Invalido")

        return false;

    }

    d1 = 11 - (d1 % 11);

    if (d1 > 9) d1 = 0;

    if (dv.charAt(0) != d1)

    {

        alert("CPF Invalido")

        return false;

    }


    d1 *= 2;

    for (i = 0; i < 9; i++)

    {

            d1 += c.charAt(i)*(11-i);

        }

    d1 = 11 - (d1 % 11);

    if (d1 > 9) d1 = 0;

    if (dv.charAt(1) != d1)

    {

        alert("CPF Invalido")

        return false;

    }

    return true;

}

function getTecla(e){
    return (window.event) ? e.keyCode: e.charCode;
}

//Permite digitar somente número
function somenteNumero(e){
    var tecla = getTecla(e);
    if((tecla > 47 && tecla < 58) || tecla == 13 || tecla == 0){
        return true;
    }else{
        if (tecla != 8){
            if (e && e.preventDefault) {
                e.preventDefault();
            }else{
                return false;
            }
        }else{
            return true;
        }
    }
}

function is_email(email) {
    er = /^[a-zA-Z0-9][a-zA-Z0-9\._-]+@([a-zA-Z0-9\._-]+\.)[a-zA-Z-0-9]{2}/;

    if(er.exec(email)) {
        return true;
    } else {
        return false;
    }
}
