function LimparTexto(input) {
    if (input.defaultValue == input.value) {
        input.value = "";
    }
}
function rand(l, u) {
    return Math.floor((Math.random() * (u - l + 1)) + l);
}
function Sexo(valor) {
    if (valor == "m") {
        return "Masculino";
    } else {
        return "Feminino";
    }
}

function strlen(string) {
    return ("" + string).length;
}

function limita_texto(frase, numero_letras) {
    var texto = new String(frase);
    var numero_letras;
    if (strlen(texto) > numero_letras) {
        var f_text = texto.substr(0, numero_letras) + "...";
    } else {
        var f_text = texto;
    }
    return f_text;
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function checkCookie() {
    username = getCookie('username');
    if (username != null && username != "") {
        alert('Welcome again ' + username + '!');
    } else {
        username = prompt('Please enter your name:', "");
        if (username != null && username != "") {
            setCookie('username', username, 365);
        }
    }
}

function Relogio() {
    setInterval(function () {
        var datahora = new Date()

        var ano = datahora.getYear()
        var semana = datahora.getDay()
        var mes = datahora.getMonth()
        var dia = datahora.getDate()

        if (ano < 1000) ano += 1900
        if (dia < 10) dia = "0" + dia

        var dia_array = new Array("Domingo", "Segunda-Feira", "Ter&ccedil;a-Feira", "Quarta-Feira", "Quinta-Feira", "Sexta-Feira", "Sábado")
        var mes_array = new Array("Janeiro", "Fevereiro", "Mar&ccedil;o", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro")

        var hora = datahora.getHours()
        var minutos = datahora.getMinutes()
        var segundos = datahora.getSeconds()

        if (hora <= 9) hora = "0" + hora
        if (minutos <= 9) minutos = "0" + minutos
        if (segundos <= 9) segundos = "0" + segundos

        $('#relogio').html("<strong>" + hora + ":" + minutos + ":" + segundos + " - " + dia_array[semana] + ", " + dia + " de " + mes_array[mes] + " de " + ano + "</strong>");

    }, 1000);
}



function Esconde_Perfil() {
    $("div#caixas_login div#login_portal div.meio").mouseover(function () {
        $("div#login_ola", this).show("slow");
        $("div#login_ultimo_login", this).show("slow");
    }).mouseleave(function () {
        $("div#login_ola", this).hide("slow");
        $("div#login_ultimo_login", this).hide("slow");
    });
}
$.preloadImages = function () {
    for (var i = 0; i < arguments.length; i++) {
        img = new Image();
        img.src = arguments[i];
    }
}