
function handleForm() {
	// check newsletter form
	$("#email2").hover(
		function(){
			if($(this).val() == "" || $(this).val() == "Email")
				$(this).val("").focus();
		},
		function(){
			if($(this).val() == "")
				$(this).val("Email");
		});
	
	//check contato form
	$("#nome").hover(
			function(){
				if($(this).val() == "" || $(this).val() == "Nome Completo")
					$(this).val("").focus();
			},
			function(){
				if($(this).val() == "")
					$(this).val("Nome Completo");
			});
	
	$("#email").hover(
			function(){
				if($(this).val() == "" || $(this).val() == "Email")
					$(this).val("").focus();
			},
			function(){
				if($(this).val() == "")
					$(this).val("Email");
			});
	
	$("#telefone").hover(
			function(){
				if($(this).val() == "" || $(this).val() == "Telefone")
					$(this).val("").focus();
			},
			function(){
				if($(this).val() == "")
					$(this).val("Telefone");
			});
	
	$("#assunto").hover(
			function(){
				if($(this).val() == "" || $(this).val() == "Assunto")
					$(this).val("").focus();
			},
			function(){
				if($(this).val() == "")
					$(this).val("Assunto");
			});
	
	$("#mensagem").hover(
			function(){
				if($(this).val() == "" || $(this).val() == "Mensagem")
					$(this).val("").focus();
			},
			function(){
				if($(this).val() == "")
					$(this).val("Mensagem");
			});	
}

//VALIDACAO FORMULARIOS
//valida o e-mail
function validaEmail(str)
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1) return false;
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false;
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	
	return true;
}

//valida o formulario de contato antes de enviar.
function checkForm()
{	
	if ($("#nome").val() == '' || $("#nome").val() == "Preencha o nome!" || $("#nome").val() == "Nome Completo") {
		$("#nome").focus();
		$("#nome").val("Preencha o nome!");
		return false;
	} else if ($("#email").val() == '' || $("#email").val() == "Preencha o e-mail!" || $("#email").val() == "Email") {
		$("#email").focus();
		$("#email").val("Preencha o e-mail!");
		return false;
	} else if (!validaEmail($("#email").val()) || $("#email").val() == "E-mail inválido!") {
		$("#email").focus();
		$("#email").val("E-mail inválido!");
		return false;	
	} else if ($("#telefone").val() == '' || $("#telefone").val() == "Preencha o telefone!" || $("#telefone").val() == "Telefone") {
		$("#telefone").focus();
		$("#telefone").val("Preencha o telefone!");
		return false;
	} else if ($("#assunto").val() == '' || $("#assunto").val() == "Preencha o assunto!" || $("#assunto").val() == "Assunto") {
		$("#assunto").focus();
		$("#assunto").val("Preencha o assunto!");
		return false;
	} else if ($("#mensagem").attr('value') == '' || $("#mensagem").attr('value') == "Preencha a mensagem!" || $("#mensagem").attr('value') == "Mensagem") {
		$("#mensagem").focus();
		$("#mensagem").attr("value","Preencha a mensagem!");		
		return false;
	}
	else 
		$("#formcontato").submit();
}
