var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
function doDate(data_formulario){
	if (!reDate.test(data_formulario)) {
		return false;
	}else{
		return true;
	}
} 

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function tiraEspaco(texto){
	while(texto.indexOf(" ") != -1){
	  texto = texto.replace(" ","");
	}
    return texto;
}

function caixa_alta(palavra){
	document.getElementById('palavra').value = palavra.value.toUpperCase();
}

function chamaPortSelect(pagina){
    mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:508px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('content',pagina,mensagem);
}

function chamaQuemSomos(){
    mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:425px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('content','quem-somos.php',mensagem);
}
function chamaContato(){
    mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:425px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('content','contato.php',mensagem);
}
function chamaProdutosServicos(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:425px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('content','servicos.php',mensagem);
}
function chamaPortfolio(){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:425px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('content','portfolio.php',mensagem);
}
function abreNoticiaCentral(){	
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando ...</div>';
	enviaRequisicao('aconteceu','scripts/abreNoticia.php',mensagem);
}
function abreNoticiaLateral(){	
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando ...</div>';
	enviaRequisicao3('outras-noticias','scripts/noticiaLateral.php?id='+id,mensagem);
}
function mascaraData(campoData, id){
	
  var data = campoData.value;
  if (data.length == 2){
      data = data + '/';
      document.getElementById(id).value = data;
      return true;              
  }
  if (data.length == 5){
      data = data + '/';
      document.getElementById(id).value = data;
      return true;
  }
}
function sonumeros(numero){
	//verifica o enter (13), o delete (46), o backspace (8), o end (35), o home (36) e as setas (37,38,39,40)
	if ((numero.keyCode >= 35 && numero.keyCode <= 40) || (numero.keyCode == 46) ||
		(numero.keyCode == 8) || (numero.keyCode == 13) || (numero.keyCode == 9) ||
		(numero.keyCode >= 48 && numero.keyCode <= 57) || (numero.keyCode >= 96 && numero.keyCode <= 105)){
		return true;
	}else{
		return false;
	}
}

function abreTrabalho(tipo){
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:210px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
   // alert(document.getElementById("check").value) ;
   var chkid = "";
	var chk = document.getElementsByTagName("INPUT");
	     for  (var i=0;i<chk.length;i++){  
          	if (chk[i].checked == true){ 
          		var chkvalue = chk[i].value;
	     		if(chkid==""){
	     			chkid = chkvalue+"/";
	     		}else{
	     			chkid = chkid+chkvalue+"/";
	   	  		} 
	   	  		
     		}chk[i].checked=0;
    	 } 
     enviaRequisicao('clientes','scripts/abrePortfolio.php?id='+chkid+'&tipo='+tipo,mensagem);
}
function abreNoticiaIndex(){
     mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:210px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
     enviaRequisicao2('noticia','scripts/abreNoticia.php',mensagem);
}
function abreComentario(id){
	mensagem = '<div align="center" id="loading"><img src=img/loading.gif border=0><br>Carregando...</div>'
	enviaRequisicao4('postsC','scripts/Comentarios.php?id='+id,mensagem);
}
function abreNoticiaMais(id){
     mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:210px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
     enviaRequisicao('aconteceu','scripts/abreNoticia.php?id='+id,mensagem);
}

function enviaComentario(id,id2){
     if(document.getElementById("nome").value == ""){
		document.getElementById("nome").focus();
		alert("Informe o nome");
		return
	}
	if(document.getElementById("mensagem").value == ""){
		document.getElementById("mensagem").focus();
		alert("Informe a mensagem.");
		return
	}
	campos = "nome="+encodeURI(document.getElementById('nome').value);
	campos +="&mensagem="+encodeURI(document.getElementById('mensagem').value);
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:210px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
    enviaRequisicao('comentarios','enviaComentario.php?id='+id+'&id2='+id2+'&'+campos,mensagem);
	
}
function submeterComentario(){
	if(tiraEspaco(document.getElementById('nomeComentario').value) == ""){	
		alert("Informe o nome");
		document.getElementById('nomeComentario').focus();
		return;
	}
	if(tiraEspaco(document.getElementById('emailComentario').value) == ""){
		alert("Informe o email");
		document.getElementById('emailComentario').focus();
		return;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailComentario').value))){ 
			alert("Informe o email");
	        document.getElementById('emailComentario').focus(); 
	   	    return;
	    }
	} 	
	if(tiraEspaco(document.getElementById('comentarioTexto').value) == ""){
		alert("Informe o comentÃ£¡rio");
		document.getElementById('comentarioTexto').focus();
		return;
	}
	if(tiraEspaco(document.getElementById('palavra').value) == ""){	
		alert("Palavra incorreta");
		document.getElementById('palavra').focus();
		return;
	}	
	setarCamposComentarios();
	mensagem = '<div align="center" style="position:relative;left:-180px" id="loading"><img src=img/loading.gif border=0><br>Carregando...</div>';
	enviaRequisicao3('postsC','scripts/Comentarios.php?'+campos,mensagem);
}

function setarCamposComentarios(){
	campos = "nome="+encodeURI(document.getElementById('nomeComentario').value);
	campos += "&email="+encodeURI(document.getElementById('emailComentario').value);
	campos +="&comentario="+encodeURI(document.getElementById('comentarioTexto').value);
	campos +="&palavra="+document.getElementById('palavra').value;
	campos +="&noticia="+document.getElementById('noticia').value;
}
function listaComentario(id){
	 mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:210px;float:center"><br><br><img src=img/loading.gif border=0><br>Carregando...</div>'
     enviaRequisicao('comentarios','enviaComentario.php?id='+id,mensagem);
}
function mostrarCurriculo(){
	var curriculo = document.getElementById('curriculo');
	curriculo.style.display = 'block';
}
function submeterCurriculo(){
	if(tiraEspaco(document.getElementById("nomeup").value) == ""){	
		alert("Informe o nome.");
		document.getElementById("nomeup").focus();
		return false;
	}	
	if(tiraEspaco(document.getElementById("emailup").value) == ""){	
		alert("Informe o Email.");
		document.getElementById("emailup").focus();
		return false;
	}	
    if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('emailup').value))){ 
       	alert("Email invÃ¡lido.");
        document.getElementById('emailup').focus();
   	    return false;
    }
	if(tiraEspaco(document.getElementById("anexar").value) == ""){	
		alert("Informe o arquivo a ser enviado.");
		document.getElementById("anexar").focus();
		return false;
	} 
	document.getElementById("formCurriculo").submit();
	
}
function submeterContato(){
	if(document.getElementById("nome").value == ""){
		document.getElementById("nome").focus();
		alert("Informe o nome");
		return
	}
	if(document.getElementById('email').value == ""){
		alert("Informe o e-mail.");
		document.getElementById('email').focus();
		return ;	
	}else{	
		if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value))){ 
			alert("Email invÃ¡lido.");
	        document.getElementById('email').focus(); 
	   	    return;
	    }
	}
	if(document.getElementById("mensagem").value == ""){
		document.getElementById("mensagem").focus();
		alert("Informe a mensagem.");
		return
	}	
	setarSubmeterContato();
	mensagem = '<div align=center style="font-family:Arial, Helvetica;font-size:10px;height:110px;float:center"><br><br><br><img src=img/loading.gif border=0><br>Enviando...<br/><br/><br/><br/></div>';
	enviarForm('contato_02.php', campos, 'formContato', mensagem);
}
function setarSubmeterContato(){
	campos = "nome="+encodeURI(document.getElementById('nome').value);
	campos +="&email="+encodeURI(document.getElementById('email').value);
	campos +="&mensagem="+encodeURI(document.getElementById('mensagem').value);
}
function carregaLight(nomeDiv){
	document.getElementById(nomeDiv).style.display='block';
}
function descarregaLight(nomeDiv){
	document.getElementById(nomeDiv).style.display='none';
}

