 $(document).ready(function(){
	$("#submitbutton").click(function(){
		var valid = '';
		var name = $("#name").val();
		var phone = $("#phone").val();
		var mail = $("#email").val();
		var message = $("#message").val();
		
		if (name.length<1) {
			valid += '<br />Please enter your name!';
		}
		if (mail.length<1) {
			valid += '<br />Please enter you E-Mail address!';
		}
		if (phone.length<1) {
			valid += '<br />Please enter your Phone number!';
		}
		if (message.length<1) {
			valid += '<br />Please enter your message!';
		}

		if (valid!='') {
			$("#response").fadeIn("slow");
			$("#response").html("Error!"+valid);
		}

		else { 
			message = message.replace('\n', '<br />', 'g');
			var datastr ='name=' + name + '&mail=' + mail + '&phone=' + phone + '&message=' + message;
			$("#response").css("display", "block");
			$("#response").html("Sending message...<img src='http://<?php echo $_SERVER['HTTP_HOST']; ?>/wp-content/themes/betontrend//images/sendingmail.gif'>");
			$("#response").fadeIn("slow");
			setTimeout("send('"+datastr+"')",2000);
		}
		return false;
	});
});

function send(datastr){
	$.ajax({	
		type: "POST",
		url: "http://<?php echo $_SERVER['HTTP_HOST']; ?>/wp-content/themes/betontrend/contact-eng.php",
		data: datastr,
		cache: false,
		success: function(html){
		$("#response").fadeIn("slow");
		$("#response").html(html);
		setTimeout('$("#response").fadeOut("slow")',8000);
		setTimeout('$.fancybox.close()', 1000);
	}
	});
}