	
	$(document).ready(function()
	{		
		
		$(".txtField").each(function()
		{			
			$(this).focus(function()
			{				
				$(this).attr("value", "").addClass("focus");				
			});
			
			
			$(this).blur(function()
			{													
				$(this).removeClass("focus");					
					
				if($(this).attr("value") == "" || $(this).attr("value") == " " )
				{
					if($(this).attr("id") == "txt_nome")										
						$(this).attr("value", "Nome:");
						
					else
						$(this).attr("value", "Email:");
				}					
			});
		})		
	});
	
	

	function valida()
	{
		var sucesso = true;
		
		document.getElementById("erronome").style.display = "none";
		document.getElementById("erroemail").style.display = "none";
		document.getElementById("erroemailincorreto").style.display = "none";
		
								
		if(document.getElementById("txt_nome").value == "" || document.getElementById("txt_nome").value == "Nome:" )
		{
			alert("O campo Nome não foi preenchido.");
			//document.getElementById("erronome").style.display = "block";
			sucesso = false;
		}
		
		if(document.getElementById("txt_email").value == "")
		{
			alert("O campo E-mail não foi preenchido.");
			//document.getElementById("erroemail").style.display = "block";
			sucesso = false;
			
		}else if(!valida_email(document.getElementById("txt_email").value))
		{
			//document.getElementById("erroemailincorreto").style.display = "block";
			alert("O campo E-mail não é válido.")
			sucesso = false;
		}
		
		if(sucesso == true)
		{
			 document.getElementById("campos").style.display = "none";
			 document.getElementById("camposErro").style.display = "none";
		}else{
			document.getElementById("camposErro").style.display = "block";
		}
		return sucesso;
	}
	
	function valida_email(campo_email) {
		if ( campo_email != '' ) {
			//Expressao Regular utilizada para validar o endereco de email
			var ExpReg = /^[a-zA-Z0-9_\.-]{2,}@([A-Za-z0-9_-]{2,}\.)+[A-Za-z]{2,4}$/;
			if ( !ExpReg.test(campo_email) ) {
				return false;
			}
			return true;
		}
	}
