//---------------------------------------------------------------------
//Variaveis Globais
//---------------------------------------------------------------------
navegad = "";
resulNavegad = "";


//---------------------------------------------------------------------
//Funções
//---------------------------------------------------------------------
function registro(url,titlePag,w,h){
    eval(window.showModalDialog(url, titlePag,'Resizable:no; DialogHeight:'+w+'px ; \n\
    DialogWidth:'+h+'px; Edge:raised; Help:no; Scroll:no; Status:no; Center:yes;'));
}

//Verifiar mais tarde;
function idNavegador(){
    
    //navegad = navigator.appName;

    navegad = navigator.userAgent.toLowerCase();

    //alert(navegad);

    if(navegad == navegad.indexOf("Microsoft Internet Explorer")){
        return (1);
    }
    else if (navegad == indexOf("Mozilla Firefox")){

       return ("Mozilla Firefox");

    }
    else if(navegad == indexOf("netcape")){

        return ('netcape');

    }
    else{
        return ('netcape');
    }
}


//Função que verifica se é um numero do teclado lateral
function numLateral(tecla,codigo){
    
     if(isNaN(tecla)){
        if(codigo >= 96 && codigo <= 105){
            return true;
        }
        else{
            return false;
        }
    }
    else if(codigo >= 48 && codigo <= 57){
            return true;
    }
    else if(codigo == 9){
            return true;
    }
    else{
        return false;
    }
}

//----------------------------------------------------------------
// Funções de Marcaras
//----------------------------------------------------------------
function mascaraCPF(e, campo) {

    codigo = e.keyCode;
    tecla = String.fromCharCode(codigo);

    caixa = document.forms[0].cpf.value;


    if(codigo == 8 || codigo == 46 ){
        return true;
    }
    if(!numLateral(tecla,codigo)){
        return false;
    }
    if(caixa.length == 3){
        document.forms[0].cpf.value = caixa + ".";
        return true;
    }
    if(caixa.length == 7){
        document.forms[0].cpf.value = caixa + ".";
        return true;
    }
    if(caixa.length == 11){
        document.forms[0].cpf.value = caixa + "-";
        return true;
    }

    if(caixa.length > 13){
        return false;
    }
}
function mascaraTele(e, campo){

    codigo = e.keyCode;
    tecla = String.fromCharCode(codigo);
    
    caixa = campo.value;

    if(codigo == 8){
       return true;
    }
    if(codigo == 9){
       return true;
    }
    if(!numLateral(tecla,codigo)){
        return false;
    }
    if(caixa.length == 4){
        campo.value = caixa+"-";
    }    
    if(caixa.length > 8){
        return false;
    }

}

function verCodFone(e, campo){

    codigo = e.keyCode
    tecla = String.fromCharCode(codigo);

    if(codigo == 8){
        return true;
    }
    if(numLateral(tecla,codigo)){
        return true;
    }
    else{
        return false;
    }   
}

function peguntRegis(){

    if(confirm("Para enviar suas fotos e necessário que tenha uma cadastro \n Deseja se cadastrar agora ?")){
        registro('registro.php','::. Cadastro de Cliente Fan Fato .::',800,780);
    }
    
}


function mascaraCep(e, campo){

    cod = e.keyCode;

    tecla = String.fromCharCode(cod);



    if(cod == 8){
        return true;
    }

    if(numLateral(tecla,cod)){

        if(campo.value.length == 5){

            campo.value = campo.value + '-';
            return true;
        }
        if(campo.value.length == 9){
            return false;
        }
    }
    else{
        return false;
    }

}