$("#sender_name").livequery('keydown', function(event) {
	$("#acf-note").hide(300);
});

$("#sender_email").livequery('keydown', function(event) {	
	$("#acf-note").hide(300);	
});

$("#sender_message").livequery('keydown', function(event) {	
	$("#acf-note").hide(300);	
});



$("#submit-button").livequery('click', function(event) {	

		var sender_name = document.getElementById('sender_name').value;
		var sender_email = document.getElementById('sender_email').value;
		var sender_message = document.getElementById('sender_message').value;

		if (sender_name.length == 0) 
		{
				$('#acf-note').html("<img src='images/error.png'>&nbsp;All the fields are necessary!");				
				$("#acf-note:hidden").show(300);
				$("#sender_name").css("border-color","#933"); 				
		}

		else if ((sender_name.length > 0) && (sender_name.length < 3))
		{
				$('#acf-note').html("Minimum 3 characters allowed!");				
				$("#acf-note:hidden").show(300);
		}
		
		else if (sender_email.length == 0) 
		{
				$('#acf-note').html("<img src='images/error.png'>&nbsp;All the fields are necessary!");				
				$("#acf-note:hidden").show(300);
				$("#sender_email").css("border-color","#933"); 								
		}

		else if ((sender_email.length > 0) && (sender_email.length < 3))
		{
				$('#acf-note').html("Fill a valid e-mail address");				
				$("#acf-note:hidden").show(300);
		}		
		

		else if (sender_message.length == 0) 
		{
				$('#acf-note').html("<img src='images/error.png'>&nbsp;All the fields are necessary!");				
				$("#acf-note:hidden").show(300);
				$("#sender_message").css("border-color","#933"); 								
		}

		else if ((sender_message.length > 0) && (sender_message.length < 3))
		{
				$('#acf-note').html("Minimum 3 characters allowed!");				
				$("#acf-note:hidden").show(300);
		}	
		
		
	    else
	    { 
				$.alerts.okButton = "&nbsp;&nbsp;Yes&nbsp;&nbsp;";
				jConfirm('Are you sure you want to send this information?', 'Confirmation Dialog', 
				function(r) {
					
						if(r==true)
						{

						var str = $('#ajax-contact-form').serialize();
   						$.ajax({
   							type: "POST",
   							url: "contact.php",
   							data: str,
							async: false,
   							success: function(msg){
								
									if(msg == 'OK') 
									{
									result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
									$("#ajax-contact-form")[0].reset();
									$("#acf-fields").hide(300)
										.fadeIn(2500, function() {
										});
									}
									else
									{
									result = msg;
									}
									$("#acf-note").html(result);
									$("#acf-note").show(300).delay(2500).hide(300);		
									
							}
						});






					    }
					
				});	
		}			
	}); 
