	function validateEmail(text){
		apos=text.indexOf("@");
		dotpos=text.lastIndexOf(".");
		if (apos<1||dotpos-apos<2){
			return false;
		}else{
			return true;
		}
	}

	
	
	$(function() {
		
		$("#submitbutton2").click(function() {
		var email 	= $("#email2").val();
		
		
		if (validateEmail(email) == false) 
		{	
			alert('Podaj poprawny adres email!');
			return false;
		}
		
		//else alert('adres email!');
		
		//var action = $("input[@name='action']:checked").val();
		
		
		var dataString = 'email='+ email;
		//alert (dataString);return false;	
		$.ajax({
				type: "POST",
				url: "mailform.php?a=send",
				data: dataString,
				success: function() {
				  $('#searchform').attr("id", 'searchform2');
				  $('#searchform2').html("<div id='message'></div>");
				  $('#message').html("<h4>Dziękujemy, Twój e-mail został zapisany</h4>")
				  .append("<div style='overflow:auto;'>Postaramy się odpisać najszybciej jak tylko będzie to możliwe.</p>")
				  .hide()
				  .fadeIn(1500, function() {
					$('#message').append("");
				  });
				}
			  });
			  return false;
		});
	
	});
