function envia_form(){

	erro = false;

	
	if($('area').value == ''){
		$('spanarea').innerHTML = '<img src="img/cadastro/legenda_erro.gif">';
		erro = true;
	}else{
		$('spanarea').innerHTML = '<img src="img/cadastro/legenda_ok.gif">';
	}

	if($('nome').value == ''){
		$('nome').className = 'txt_erro';
		erro = true;
	}else{
		$('nome').className = 'txt_ok';
	}

	if($('email').value == ''){
		$('email').className = 'txt_erro';
		erro = true;
	}else{
		$('email').className = 'txt_ok';
	}

	if($('assunto').value == ''){
		$('assunto').className = 'txt_erro';
		erro = true;
	}else{
		$('assunto').className = 'txt_ok';
	}

	if($('texto').value == ''){
		$('spanmensagem').innerHTML = '<img src="img/cadastro/legenda_erro.gif">';
		erro = true;
	}else{
		$('spanmensagem').innerHTML = '<img src="img/cadastro/legenda_ok.gif">';
	}

	//alert("passou");
	//alert(limpa($('texto').value));
	
	var params = 'nome='+ limpa($('nome').value) + '&area='+ $('area').value + '&email='+ $('email').value + '&assunto='+ limpa($('assunto').value) + '&telefone='+ $('telefone').value + '&texto='+ limpa($('texto').value);


	while(params.indexOf('?') !== -1){
		params = params.replace('?', '');	
	}	

	if(!erro){
		
		var retorno = new Ajax.Request('fale_conosco.php', {method:'post', parameters: params, onComplete: resposta});
		
		$('assunto').className		= 'txt';
		$('nome').className			= 'txt';
		$('email').className		= 'txt';
		$('spanarea').innerHTML		= '';
		$('spanmensagem').innerHTML = '';
		$('nome').value  	= '';
		$('email').value 	= '';
		$('assunto').value 	= '';
		$('telefone').value = ''
		$('texto').value 	= '';
		$('nome').focus();
		
	}else{
		
		$('mensagem').innerHTML = "Preencha todos os campos assinalados com erro, com valores v&aacute;lidos!";
		return false;
	}
	
	
	return false;
}

function limpa(str){
	
	while(str.indexOf('Á') !== -1){
		str = str.replace("Á", ";Aacute;");
	}	
	
	while(str.indexOf('á') !== -1){
		str = str.replace("á", ";aacute;");
	}	
	
	while(str.indexOf('é') !== -1){
		str = str.replace("é", ";eacute;");
	}	
	
	while(str.indexOf('É') !== -1){
		str = str.replace("É", ";Eacute;");
	}	
	
	while(str.indexOf('Í') !== -1){
		str = str.replace("Í", ";Iacute;");
	}	
	
	while(str.indexOf('í') !== -1){
		str = str.replace("í", ";iacute;");
	}	
	
	while(str.indexOf('Ó') !== -1){
		str = str.replace("Ó", ";Iacute;");
	}	
	
	while(str.indexOf('ó') !== -1){
		str = str.replace("ó", ";iacute;");
	}	
	
	while(str.indexOf('Ú') !== -1){
		str = str.replace("Ú", ";Iacute;");
	}	
	
	while(str.indexOf('ú') !== -1){
		str = str.replace("ú", ";iacute;");
	}	
	
	while(str.indexOf('Â') !== -1){
		str = str.replace("Â", ";Acirc;");
	}	
	
	while(str.indexOf('â') !== -1){
		str = str.replace("â", ";acirc;");
	}	
	
	while(str.indexOf('Ê') !== -1){
		str = str.replace("Ê", ";Ecirc;");
	}	
	
	while(str.indexOf('ê') !== -1){
		str = str.replace("ê", ";ecirc;");
	}	
	
	while(str.indexOf('Ô') !== -1){
		str = str.replace("Ô", ";Ocirc;");
	}	
	
	while(str.indexOf('ô') !== -1){
		str = str.replace("ô", ";ocirc;");
	}	
	
	while(str.indexOf('Ã') !== -1){
		str = str.replace("Ã", ";Atilde;");
	}	
	
	while(str.indexOf('ã') !== -1){
		str = str.replace("ã", ";atilde;");
	}	
	
	while(str.indexOf('Õ') !== -1){
		str = str.replace("Õ", ";Otilde;");
	}	
	
	while(str.indexOf('õ') !== -1){
		str = str.replace("õ", ";otilde;");
	}	
	
	while(str.indexOf('Ç') !== -1){
		str = str.replace("Ç", ";Ccedil;");
	}	
	
	while(str.indexOf('À') !== -1){
		str = str.replace("À", ";Agrave;");
	}	
	
	while(str.indexOf('à') !== -1){
		str = str.replace("à", ";agrave;");
	}	
	
		
	return str;
}


function mensagem(msg, obj){
	$(obj).innerHTML = msg;
}

function resposta(resp){
	$('mensagem').innerHTML = resp.responseText;
}
