$(document).ready(function(){
	$("#sendmail").click(function(){
		var valid = '';
		var isr = ' is required.<br />';
		var name = $("#name").val();
		var mail = $("#mail").val();
		var subject = $("#subject").val();
		var text = $("#text").val();
		if (name.length<1) {
			valid += 'We need your name!<br />';
		}
		if (!mail.match(/^([a-z0-9._-]+@[a-z0-9._-]+\.[a-z]{2,4}$)/i)) {
			valid += 'A valid email'+isr;
		}
		if (subject.length<1) {
			valid += 'Subject'+isr;
		}
		if (text.length<1) {
			valid += 'Did you forgot your message?';
		}
		if (valid!='') {
			$("#response").fadeIn("slow");
			$("#response").html("Error:"+valid);
			
			
			
			
			$.alerts.dialogClass = $(this).attr('id'); // set custom style class
						jAlert(valid, 'Error',false, function() {
							$.alerts.dialogClass = null; // reset to default
						});
			
			
		}
		else {
			
			var datastr ='name=' + name + '&mail=' + mail + '&subject=' + subject + '&text=' + text;
			$("#response").css("display", "block");
			$("#response").html("Sending message .... ");
			$("#response").fadeIn("slow");
			$.alerts.dialogClass = $(this).attr('id'); // set custom style class
						jAlert('"Sending message... <br/>A moment please.', 'Wait A Moment',true, function() {
							$.alerts.dialogClass = null; // reset to default
						});
			setTimeout("send('"+datastr+"')",2000);
		}
		return false;
	});
});

