$(document).ready(function(){
	//function for contact form dropdown
	function contact() {
		if ($("#contactForm").is(":hidden")){
			$("#contactForm").slideDown("slow");
		}
		else{
			$("#contactForm").slideUp("slow");
			$("#backgroundPopup").fadeOut("slow");
			
		}
	}
	 
	//run contact form when any contact link is clicked
	$(".cadastro_newsletter").click(function(){contact()});
	$(".cadastro_newsletter").height("300px");
	//animation for same page links #



   //submission scripts
  $('.contactForm').submit( function(){
		//statements to validate the form	
		var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
		var email = document.getElementById('email');
		if (!filter.test(email.value)) {
			$('#email-missing').show();
		} else {$('#email-missing').hide();}
		if ((document.cform.email.value == "") || (!filter.test(email.value)) || (document.cform.email.value == "")){
			return false;
		} 
		
		if ((document.cform.email.value != "") && (filter.test(email.value)) && (document.cform.email.value != "")) {
			//hide the form
			$('.contactForm').hide();
			//show the loading bar
			$('.loader').append($('.bar'));
			$('.bar').css({display:'block'});
		
			//send the ajax request

			$.post('envio_cadastro_newsletter.php',{
							  email:$('#email').val()},
		
			//return the data
			
			function(data){
			  //hide the graphic
			  $('.bar').css({display:'none'});
			  $('.loader').append(data);
			});
						$("form").each(function() {
        this.reset();
});

			//waits 2000, then closes the form and fades out
			setTimeout('$("#backgroundPopup").fadeOut("slow"); $("#contactForm").slideUp("slow")', 2000);

			//stay on the page
			return false;
		} 
  });
	//only need force for IE6  
	$("#backgroundPopup").css({  
		"height": document.documentElement.clientHeight 
	});  
});
	

/**
 * jQuery resetDefaultValue plugin
 * @version 0.9.1
 * @author Leandro Vieira Pinho 
 */

