function contato(){
	var mensarem_erro="", cont_erro=0;
	var ad = document.getElementById('form_contato');
	var d = document.getElementById('erro').style;
	
	$('html,body').animate({scrollTop: $('.tit-h2').offset().top}, 800);
	
			
	if (ad.nome_cont.value == "") {
        mensarem_erro += "<b>Nome:</b> é de preenchimento obrigatório<br />";
		d.display = 'block';
		cont_erro++;
		
	}
			
			
	if (ad.email_cont.value == "") {
        mensarem_erro += "<b>Email:</b> é de preenchimento obrigatório<br />";	
		d.display = 'block';
		
		cont_erro++;				
	}
			
   if (ad.email_cont.value != "") {			
   		if(!(/^\w+([\.-_-]?\w+)*@\w+([\.-_-]?\w+)*(\.\w{2,4})+$/.test(ad.email_cont.value))) { 
			mensarem_erro += "<b>E-mail:</b> Inválido<br />";
			d.display = 'block';
			cont_erro++;			
	   }		
   }

	if (ad.cidade_cont.value == "") {
         mensarem_erro += "<b>Cidade:</b> é de preenchimento obrigatório<br />";
		 d.display = 'block';
	     cont_erro++;				
	}
	
	if (ad.estado_cont.value == "") {
         mensarem_erro += "<b>Estado:</b> é de preenchimento obrigatório<br />";	
		 d.display = 'block';
	     cont_erro++;				
	}
	
	if (ad.assunto_cont.value == "") {
         mensarem_erro += "<b>Assunto:</b> é de preenchimento obrigatório<br />";
		 d.display = 'block';
	     cont_erro++;				
	}	
	
	if (ad.texto_cont.value == "") {
         mensarem_erro += "<b>Comentário:</b> é de preenchimento obrigatório<br />";
		 d.display = 'block';
	     cont_erro++;				
	}
			
	if (cont_erro > 0) {
				
		document.getElementById("erro").style.display="block";
		var mensagem_final = "<h4>Foram encontrados "+ cont_erro +" erros no formulário.</h4><p class=\"er\">"+ mensarem_erro +"</p>";
		document.getElementById("erro").innerHTML = mensagem_final;			
		//location.href="#erro";	
		return false;
	}
	
	return true;
			
}



function indique(){
var mensarem_erro="", cont_erro=0;
var ad = document.form_indique;

$('html,body').animate({scrollTop: $('.tit-h2').offset().top}, 800);

if (ad.nome.value == "") {
			mensarem_erro += "<b>Seu Nome:</b> é de preenchimento obrigatório<br />";
		    cont_erro++;	}
if (ad.email.value == "") {
        mensarem_erro += "<b>Seu e-mail:</b> é de preenchimento obrigatório<br />";				
		cont_erro++;				
	}
if(!(/^\w+([\.-_-]?\w+)*@\w+([\.-_-]?\w+)*(\.\w{2,4})+$/.test(ad.email.value))) {
			mensarem_erro += "<b>Seu e-mail:</b> inválido<br />";
		    cont_erro++;}
if (ad.nome_a.value == "") {
			mensarem_erro += "<b>Nome amigo:</b> é de preenchimento obrigatório<br />";
		    cont_erro++;}
if (ad.email_a.value == "") {
        mensarem_erro += "<b>E-mail amigo:</b> é de preenchimento obrigatório<br />";				
		cont_erro++;				
	}
if(!(/^\w+([\.-_-]?\w+)*@\w+([\.-_-]?\w+)*(\.\w{2,4})+$/.test(ad.email_a.value))) {
		mensarem_erro += "<b>E-mail amigo:</b> inválido<br />";
		    cont_erro++;}
if (ad.comentario.value == "") {
			mensarem_erro += "<b>Comentário:</b> é de preenchimento obrigatório<br />";
		    cont_erro++;}
if (cont_erro > 0) {
		document.getElementById("erro").style.display="block";
		var mensagem_final = "<h4>Foram encontrados "+ cont_erro +" erros no formulário.</h4><p class=\"er\">"+ mensarem_erro +"</p>";
		document.getElementById("erro").innerHTML = mensagem_final;			
		return false;
	}
}


/********telefone***********/
function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

function telefone(v){
    v=v.replace(/\D/g,"")                
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2")
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    
    return v
}


function aboft(){
        var xmlhttp=false;
        try{
                xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
                try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }catch(E){
                        xmlhttp = false;
                }
        }

        if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
                xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
}





function limp(obj){
 document.getElementById(obj).style.display="none";
}

function indique_receita(field){
        var conteudo;
        c = document.getElementById('loading_indique_receita');
		var ad = document.getElementById('form_indica_receita');
		
		c.style.display = "block";
			
	if (ad.ip_seu_nome.value == "") {
        c.innerHTML = "Campo <b>Seu nome</b> é obrigatório";
		ad.ip_seu_nome.focus();
		return false;
	}
	
	if (ad.ip_seu_email.value == "") {
        c.innerHTML = "Campo <b>Seu e-mail</b> é obrigatório";
		ad.ip_seu_email.focus();
		return false;
	}
	if(!(/^\w+([\.-_-]?\w+)*@\w+([\.-_-]?\w+)*(\.\w{2,4})+$/.test(ad.ip_seu_email.value))) { 
		c.innerHTML = "<b>Seu email</b> inválido";
		ad.ip_seu_email.focus();
		return false;		
	}
	if (ad.ip_nome_amigo.value == "") {
        c.innerHTML = "Campo <b>Nome amigo</b> é obrigatório";
		ad.ip_nome_amigo.focus();
		return false;
	}
	if (ad.ip_email_amigo.value == "") {
        c.innerHTML = "Campo <b>E-mail amigo</b> é obrigatório";
		ad.ip_email_amigo.focus();
		return false;
	}
	if(!(/^\w+([\.-_-]?\w+)*@\w+([\.-_-]?\w+)*(\.\w{2,4})+$/.test(ad.ip_email_amigo.value))) { 
		c.innerHTML = "<b>E-mail amigo</b> inválido";
		ad.ip_email_amigo.focus();
		return false;		
	}
	
 
        ajax=aboft(); 
		
var IE = document.all?true:false;
if(!IE){
  metho = 'GET';
}else{
  metho = 'POST';
}

        ajax.open(metho, 'ajax/indique_receita.php?'+field, true);
		ajax.setRequestHeader("Cache-Control", "no-cache");
        ajax.setRequestHeader("Pragma", "no-cache");
        ajax.setRequestHeader("Charset", "ISO-8859-1");
		
		c.innerHTML= '<span style="color:#fc0;"><img src="images/loading.gif" align="absmiddle" style="margin-right:3px;" />Enviando...</span>';
		
        ajax.onreadystatechange=function(){
                if(ajax.readyState==1){	
                      
                }else if(ajax.readyState==4){
	                        if(ajax.status==200){
							
							  c.innerHTML = ajax.responseText;
                              setInterval("c.style.display='none'", 6000);
							  setTimeout("document.getElementById('box-indica-receita').style.display='none'", 6000);
							  LimpaCampos('form_indica_receita');
							  
                            }else if(ajax.status==404){
                                conteudo.innerHTML = "Página năo encontrada";
                        }else{

                                conteudo.innerHTML = "Error:".ajax.status; 
                        }
                }
        }
        ajax.send(field);

}

function setFieldReceita() {

field = "&nome="+encodeURI(document.getElementById('ip_seu_nome').value)+"&email="+encodeURI(document.getElementById('ip_seu_email').value)+"&nome_a="+encodeURI(document.getElementById('ip_nome_amigo').value)+"&email_a="+encodeURI(document.getElementById('ip_email_amigo').value)+"&titulo_receita="+encodeURI(document.getElementById('titulo_receita').value)+"&url_receita="+encodeURI(document.getElementById('url_receita').value);

}


function LimpaCampos(form){
		var input	   = document.getElementById(form).getElementsByTagName('input')
		var select	   = document.getElementById(form).getElementsByTagName('select')
		var textarea   = document.getElementById(form).getElementsByTagName('textarea')
		
		for(var i=0; i<select.length; i++)
			select[i].selectedIndex = 0;
			
		for(var i=0; i<textarea.length; i++)
			textarea[i].value = '';
					   
		for(var i=0; i<input.length; i++)
			switch (input[i].type){
				case 'text'	 :   input[i].value	  = ''; break;
				case 'radio'	:   input[i].checked	= ''; break;
				case 'checkbox' :   input[i].checked	= ''; break;				
			}
						
}


function fecharBox(obj){
  $("#"+obj).slideUp(600);	 
}


var Convert = {
initialize: function() {
var spans = document.getElementsByTagName("span");
for (var i = 0; i < spans.length; i++) {
if(spans[i].getAttribute("class") == "maskemail") {
string = spans[i].childNodes[0].nodeValue;
email = string.split("_")[0] + "@" + string.split("_")[1] + "." + string.split("_")[2]+ "." + string.split("_")[3];
spans[i].innerHTML = '<a class="email" href="mailto:' + email + '">' + email + '<\/a>';
}
}
}
}
window.onload = Convert.initialize;



function OpenAjax(obj, url, ajax){
var obj;
obj = document.getElementById(obj);

ajax=aboft(); 
  
ajax.open("GET", '/ajax/'+url+'.php', true); 

obj.style.display = 'block';

ajax.onreadystatechange=function(){
if(ajax.readyState==1){	
  obj.innerHTML = 'Carregando...';
}else if(ajax.readyState==4){
if(ajax.status==200){
	
  obj.innerHTML = ajax.responseText;
  
}else if(ajax.status==404){
obj.innerHTML = "Pgina no encontrada";
}else{
obj.innerHTML = "Error:".ajax.status; 
}}}
ajax.send(null);
}




function opacity(id, opacStart, opacEnd) { 
var speed = Math.round(1500 / 150); 
var timer = 0; 
	
if(opacStart > opacEnd) { 
for(i = opacStart; i >= opacEnd; i--) { 
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
timer++; 
} 
}else if(opacStart < opacEnd) { 
for(i = opacStart; i <= opacEnd; i++) 
{ 
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
timer++; 
} 
} 
} 

function changeOpac(opacity, id) { 
var object = document.getElementById(id).style; 
object.opacity = (opacity / 100); 
object.MozOpacity = (opacity / 100); 
object.KhtmlOpacity = (opacity / 100); 
object.filter = "alpha(opacity=" + opacity + ")"; 
} 


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name){
  var cookieValue = "";
  var search = name + "=";
  if(document.cookie.length > 0){ 
offset = document.cookie.indexOf(search);
if (offset != -1){ 
  offset += search.length;
  end = document.cookie.indexOf(";", offset);
  if (end == -1) end = document.cookie.length;
  cookieValue = unescape(document.cookie.substring(offset, end))
}
  }
  return cookieValue;
}


function zoomText( tipo )
{
      
	if (tipo== 0 ){        
       tam = 13;
    }else{
      tam = 16;
    } 

	createCookie('TextSize',tam,86400);
    document.getElementById('all-paginas').style.fontSize=tam+'px';
	document.getElementById('footer').style.fontSize=tam+'px';
     	
}


function getZoomText() {
	
	var setTamCookie = readCookie('TextSize');
	
	document.getElementById('all-paginas').style.fontSize=setTamCookie+'px';
	document.getElementById('footer').style.fontSize=setTamCookie+'px';
	
}


function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}




function functionsJquery(){
  
  		$("#nav li a").hover(
		function(){
			$(this).animate({ lineHeight: "35px" }, 200 );

		},function(){
			$(this).animate({ lineHeight: "44px" }, 200 );
		});
		
		$(".list-lp li a").hover(
		function(){
			$(this).animate({ textIndent: "15px" }, 500 );

		},function(){
			$(this).animate({ textIndent: "0px" }, 500 );
		});
		
		$("#open-indica-receita").click(function () {
           if ($("#box-indica-receita:first").is(":hidden")) {
             $("#box-indica-receita").slideDown(600);
           } else {
             $("#box-indica-receita").slideUp(600);
           }
         });
	
}
