$(function() {
	$('#name').blur(function() {
		var name = $(this).val();
		if (name.length > 0) {
			$('#name_status').hide().html('<img src="images/tick.png" width="16" height="16" alt="">').fadeIn(300);
		} else {
			$('#name_status').hide().html('<img src="images/cross.png" width="16" height="16" alt=""> Please provide a contact name').fadeIn(300);
		}
	});
	$('#email').blur(function() {
		var email = $(this).val();
		if (email.length > 0) {
			$('#email_status').hide().html('<img src="images/tick.png" width="16" height="16" alt="">').fadeIn(300);
		} else {
			$('#email_status').hide().html('<img src="images/cross.png" width="16" height="16" alt=""> Please provide an email address').fadeIn(300);
		}
	});
	$('#phone').blur(function() {
		var phone = $(this).val();
		if (phone.length > 0) {
			$('#phone_status').hide().html('<img src="images/tick.png" width="16" height="16" alt="">').fadeIn(300);
		} else {
			$('#phone_status').hide().html('<img src="images/cross.png" width="16" height="16" alt=""> Please provide a contact number').fadeIn(300);
		}
	});
	$('#desc').blur(function() {
		var desc = $(this).val();
		if (desc.length > 0) {
			$('#desc_status').hide().html('<img src="images/tick.png" width="16" height="16" alt="">').fadeIn(300);
		} else {
			$('#desc_status').hide().html('<br /><img src="images/cross.png" width="16" height="16" alt=""> Please provide us with your questions/comments').fadeIn(300);
		}
	});
/*
	$('#submit').click(function() {
		$('#contactform').append('<img src="../images/loading.gif" width="32" height="32" alt="Loading" id="loading" />');
		var name = $('#name').val();
		var email = $('#email').val();
		var phone = $('#phone').val();
		var desc = $('#desc').val();
		var pages = $("input[@name='emailto']:checked").val();
		$.ajax ({
			url: 'add2.php',
			type: 'POST',
			data: 'name=' + name + '&email=' + email + 
			      '&phone=' + phone + '&desc=' + desc + '&pages=' + pages,
			success: function(results) {
				$('#response').remove();
				$('#contactform').append('<p style="color:#fff;" id="response">' + results + '</p>');
				$('#loading').fadeOut(500, function() {
					$(this).remove();
				});
				return false;
			}
		});
		return false;
	});

	$('#attach').click(function() {
		$.ajaxFileUpload ({
			url: 'upload.php',
			secureuri: false,
			fileElementId: 'fileInput',
			dataType: 'json',
			success: function (data, status) {
				if(typeof(data.error) != 'undefined') {
					if(data.error != '') {
						alert(data.error);
					} else {
						alert(data.msg);
					}
				}
			},
			error: function (data, status, e) {
				alert(e);
			}
		});
		return false;
	});
*/
});
