$(document).ready(function()
{     		
	$('#submitButton').attr('disabled','disabled');
	
	$('#email').change(function()
	{
		$.ajax({
					type: "POST",  					
  					url: "checkmail.php",
  					data: "email=" + $('#email').attr('value'),
  					cache: false,
  					success: function(html)
  					{
    					$("#mailCheck").html(html);
  					}
			});			
	});
	$('#submitButton').click(function() 
	{ 
			if ($('#name').attr('value')=='')
			{
				window.alert('Το πεδίο Ονοματεπώνυμο είναι υποχρεωτικό');
				return;
			}
			
			if ($('#spFilter').attr('value')!='')
			{
				window.alert('Στο ΔΙΠΑΕ δεν θέλουμε spam μηνύματα..');				
				return;
			}
					
			var nameElement = document.getElementById('name');
			var mailElement = document.getElementById('email');
			var messageElement = document.getElementById('message');
        
 			$("#contactDiv").ajaxStart(function()
			{
				$(this).html("<img src=\"img/ajax-loader.gif\" width=\"16px\" height=\"16px\" alt=\"ajax progress indicator\" />");
			});
			$.ajax({
					type: "POST",  					
  					url: "contact.php",
  					data: "name=" + $('#name').attr('value') + "&email=" + $('#email').attr('value') + "&message=" + $('#message').attr('value'),
  					cache: false,
					success: function(html)
  					{
    					$("#contactDiv").html(html);
  					}
			});			
    });	
})

