//Funoces de GR News-----------------------------------------

var ativarVerificacaoEmail,validar_email,campo,campoDefault,aviso,rep,existeErro


function HideEmail(campo){
	
	     if (campo.value == campo.defaultValue) {
                campo.value = "";
         }

	     $(".aviso_emailGR").hide("slow");
		 ativarVerificacaoEmail = true;
		 
		 
		 $("table#gr_news input#emailGR").css({
				"background":"url(images/frontend/fundo_input.png) no-repeat"
		 });	
					  
				 
}


function HideNome(campo){
	
	     if (campo.value == campo.defaultValue) {
                campo.value = "";
         }
	
	
		 $(".aviso_nomeGR").hide("slow");


		 $("table#gr_news input#nomeGR").css({
				"background":"url(images/frontend/fundo_input.png) no-repeat"
		 });	
					  
		 		
}


function escreverPadraoGR(campo) {
        if (campo.value == "") {
                campo.value = campo.defaultValue;
				ativarVerificacaoEmail = false;
        }
		
		if(ativarVerificacaoEmail == true){	
		
			if(document.grNews.emailGR.value != null || document.grNews.emailGR.value != ''){
				
				  $(".aviso_emailGR").load("validando_email.php?emailGR="+ document.grNews.emailGR.value);
				  
			}
			
			if(document.grNews.emailGR.value == document.grNews.emailGR.defaultValue){
				
				  $(".aviso_emailGR").load("validando_email.php?emailGR=nulo");
			}
		
     }
}





function validar(){
	
	     
	    if(document.grNews.emailGR.value != null || document.grNewss.emailGR.value != ''){
	
              $(".aviso_emailGR").load("validando_email.php?emailGR="+ document.grNews.emailGR.value);
		 	  
	    }
		
		if(document.grNews.emailGR.value == document.grNews.emailGR.defaultValue){
			
              $(".aviso_emailGR").load("validando_email.php?emailGR=nulo");
	    }
		
		if(document.grNews.emailGR.value.indexOf('@',0) == -1 && document.grNews.emailGR.value.indexOf('.com',0) == -1){
			
			validar_email = false;
			
		}else{
				
			validar_email = true;
			
		}
	
	
	   campo = new  Array (2);
	   campoDefault = new  Array (2);
	   aviso = new  Array (2);
	   fundo = new Array (2);
	   image = new Array (2);
		
	   campo[1] = document.grNews.nomeGR.value
	   campo[2] = document.grNews.emailGR.value
	   campoDefault[1] = document.grNews.nomeGR.defaultValue
	   campoDefault[2] = document.grNews.emailGR.defaultValue
	   aviso[1] = ".aviso_nomeGR"
	   aviso[2] = ".aviso_emailGR"
	   fundo[1] = ".janela_GRNews input#nomeGR"
	   fundo[2] = ".janela_GRNews input#emailGR"
	   image[1] = "table#gr_news input#nomeGR"
	   image[2] = "table#gr_news input#emailGR"
	   
	   for(rep=1;rep<=2;rep++){
  
		      if(campo[rep] == '' || campo[rep] == null || campo[rep] == campoDefault[rep]){

		       
		          $(aviso[rep]).show("slow");
				  
	              $(fundo[rep]).css({
						   "background":"#FFB3B3"
				  });
				  
				  
				  existeErro = rep;
				  
				  $(image[rep]).css({
						"background":"url(images/frontend/fundo_inputERRO.jpg) no-repeat"
				  });
				  
			  }
				
		   
	   }
	
		
		if((validar_email == false) || (existeErro != null)){
		
		      existeErro = null;
		      return false;
		
	    }
		
		
		
	}
	
	
