/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


function ValidaEmail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){
            return true;
        }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
            return true;
        }
    }else{
        return false;
    }
}

function validarTel(tel){

    var er = new RegExp(/^[0-9]+-[0-9]?/);
    if(tel.length==9){
        if(typeof(tel) == "string"){
            if(er.test(tel)){
                return true;
            }
        }else if(typeof(tel) == "object"){
            if(er.test(tel.value)){
                return true;
            }
        }else{
            return false;
        }
    }else{
        return false;
    }
}

function validarConfirmacaoSenha(senha1,senha2){
    if(senha1!=senha2) return false;
    return true;
}

function number_format(valor,casas){
    casas = parseInt(casas);
    valor = new Number(valor);
    valor = valor.toFixed(2);
    return valor;
}

function formatar_preco_br(t){
    var st = ' ';
    st = st+t;
    st = st.replace(".",",");
    st = st.replace(" ","");
    return st;
}