// JavaScript Document

$(document).ready(function(){

	$("#nome").click(function(){
		if($("#nome").attr("value") == "Campo obrigatório")
			$("#nome").attr("value", "")
	})
	
	$("#email").click(function(){
		if($("#email").attr("value") == "Campo obrigatório")
			$("#email").attr("value", "")
	})
	
	$("#telefone").click(function(){
		if($("#telefone").attr("value") == "Campo obrigatório")
			$("#telefone").attr("value", "")
	})
	
	$("#telefone").mask("(99) 9999-9999")

	$("#enviar").click(function(){
		enviar = true
		
		if($("#nome").attr("value") == "" || $("#nome").attr("value") == "Seu Nome!")
		{
			$("#nome").attr("class", "camp_obrigatorio")
			$("#nome").attr("value", "Preencher Nome")
			enviar = false
		}	
		else
			$("#nome").attr("class", "")
			
			
		/************************************/

		if($("#telefone").attr("value") == "" || $("#telefone").attr("value") == "Seu Telefone!")
		{
			$("#telefone").attr("class", "camp_obrigatorio")
			$("#telefone").attr("value", "Preencher telefone")
			enviar = false
		}
		else
			$("#tel").attr("class", "")	

		/************************************/

		if($("#email").attr("value") == "" || $("#email").attr("value") == "Seu Email!")
		{
			$("#email").attr("class", "camp_obrigatorio")
			$("#email").attr("value", "Preencher Email")
			enviar = false
		}
		else
			$("#email").attr("class", "")	
			
		/************************************/
		
		if ($("#email").val() != '') {
			  var regmail = /^[\w!#$%&amp;'*+\/=?^`{|}~-]+(\.[\w!#$%&amp;'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
			  if (!regmail.test($("#email").val())) {
				   $("#email").attr("class", "camp_obrigatorio")
				   enviar = false
			  }
		 }
		 
		 /***************************************/
		
		if(enviar == false)
		{
			alert("Verifique se os campos em Vermelho estao corretos!")
			return false
		}
		else
			return true
	})

})
