
function valida(e)
{
    if (e.keyCode == 13)
    {
        document.getElementById('add').click();
    }
}
$(document).ready(function() {
						   
	

						   
    $('#add').click(function() {

	if (document.form_add.email.value == '' ||  document.form_add.email.value == 'Digite seu e-mail') {
	document.form_add.email.value = "PREENCHA O CAMPO E-MAIL";
	document.form_add.email.style.background="#FFc";
	document.form_add.email.select();
	return false;
	
	}else{
	document.form_add.email.style.background="#fff";
	}
	
	parte3 = document.form_add.email.value.length;
	
	if (document.form_add.email.value.indexOf("@")==-1||document.form_add.email.value.indexOf(".")==-1||parte3 <= 5){
	alert('Este email parece ser um email invalido. Por favor digite outro!');
	
	document.form_add.email.style.background="#FFc";
	
	document.form_add.email.select();

return false;
	} else {
		
		envia();
		
	

}
});
	
	function envia(){
		
		$('.accordion').slideUp("slow");
	
var str = $("#form_add").serialize();

$.ajax ({
		url: "cadastra.php",
			type: "post",
			data: str, 
			success: function () {

	
					
	 setTimeout("$('.accordion').html('<img src=images/ok.png />').slideDown('slow');", 1000);
				

					
$(':input').clearForm();
             
                }

});

	
	}
});



/* CLEAR */

	$.fn.clearForm = function() {

  return this.each(function() {

	var type = this.type, tag = this.tagName.toLowerCase();

	if (tag == 'form')

	  return $(':input',this).clearForm();

	if (type == 'text' || type == 'password' || tag == 'textarea')

	  this.value = '';

	else if (type == 'checkbox' || type == 'radio')

	  this.checked = false;

	else if (tag == 'select')

	  this.selectedIndex = -1;

  });

};