function init(){
    insereFlash();
//abrePagina("home.php");
}
function limiteText(caixa,limite){
    var texto = caixa.value;
    var tamanho = caixa.value.length;
    if(tamanho>=limite){
        caixa.value = texto.substring(0,limite);
        tamanho = caixa.value.length;
    }
    document.getElementById("cont").innerHTML = (limite - tamanho);

}

function confirmaContato(status){
    if(status=="ok"){
        alert("Dados enviados com sucesso!");
    }else{
        alert("Ocorreu um erro no envio dos dados, por favor tente novamente.");
    }
}

function validaFormContato(){
    Email = document.getElementById("email");
    Nome = document.getElementById("nome");
    Texto = document.getElementById("texto");
    Assunto = document.getElementById("assunto");
    if(!validaEmail(Email)){
        alert("Email inválido!");
        Email.focus();
        return false;
    }

    if((trim(Email.value)) == "" || (trim(Nome.value)) == "" || (trim(Texto.value)) == "" || (trim(Assunto.value)) == "" ){
        alert("Por favor, preencha todos os campos!");
        //Email.value="";
        //Nome.value="";
        //Texto.value="";
        Assunto.focus();
        return false;
    }
    if(Nome.value.length<4){
        alert("Nome muito curto! Assim não vamos saber de quem você se trata.");
        Nome.focus();
        return false;
    }
    if(Texto.value.length<20){
        alert("Texto muito curto! Assim não vamos entender o que você deseja.");
        Texto.focus();
        return false;
    }

    return true;

}

function limpaFormContato(){
    document.getElementById('texto').value='';
    limiteText(document.getElementById('texto'),1024);
    document.getElementById('assunto').focus();
}

function validaEmail(email){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(email) == "string"){
        if(er.test(email)){
            return true;
        }
    }else if(typeof(email) == "object"){
        if(er.test(email.value)){
            return true;
        }
    }else{
        return false;
    }
}

function trim(string){
    return string.replace(/^\s+|\s+$/g,"");
}


function insereFlash(){
    document.getElementById("flash").innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='195' height='154'><param name='movie' value='img/banner.swf' /><param name='quality' value='high' /><param name='wmode' value='transparent' /><embed src='img/banner.swf' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' wmode='transparent' type='application/x-shockwave-flash' width='195' height='154'></embed></object>";
}
//--------------------------------------
// Implantando Ajax
var http_request = false;
function makeRequest(url,params) {

    http_request = false;

    if (window.XMLHttpRequest) { // Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) { // IE
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }

    if (!http_request) {
        alert('Erro de criação');
        return false;
    }
				
    http_request.onreadystatechange = alertContents;
    http_request.open('GET', url, true);
    document.getElementById("conteudo").innerHTML = "<center><img src='./img/loading.gif' /><br /> Carregando</center>" ;
    http_request.send(url);

}

function alertContents() {

    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            document.getElementById("conteudo").innerHTML = http_request.responseText;
        } else {
            alert('Ouve um erro ao efetuar requesição.');
        }
    }

}

function abrePagina(curl){
    makeRequest(curl);
}
//---------------------------------------
