jQuery(document).ready(function(){
    alertas();
});

function alertas()
{
    var html = "";    
    html += "<div id=\"alert\" onclick=\"hidealert()\"></div>";
    jQuery("body").append(html);
}

function alertErro(msg) {
    jQuery("#alert").css("background-color", "#AA0000");

    var erro = '<img src="imagens/error.png" />&nbsp;';

    jQuery("#alert").html(erro + msg);
    jQuery("#alert").fadeIn(300);
    setTimeout("hidealert()", 5000);
}

function alertSucesso(msg){
    jQuery("#alert").css("background-color", "#006600");
    jQuery("#alert").html(msg);
    jQuery("#alert").fadeIn(300);
    setTimeout("hidealert()", 5000);
}

/**
 *  Esconder o alert
 **/
function hidealert(){
    jQuery("#alert").fadeOut(300);
}

// FUNCTION TRIM
String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
}

/**
 *  Função para testar se campo está vazio ou não.
 *  @return boolean
 **/
function empty(valor) {
    valor = valor.trim();
    return (valor=="") ? true : false;
}

function validarEmail(email)
{
    var str = email;
    var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    return (filter.test(str)) ? true : false;
}