	$(document).ready(function() {
		var name = $("#name").val();
		var mail = $("#mail").val();
		var message = $("#message").val();
		$(".work-entry-box").hover(function() {
			$(this).find("img").animate({
				top:"50px"
			},100);
		}, function() {
			$(this).find("img").animate({
				top:"0px"
			},100);
		});
		//$("#contact").show();
		
		
			$("#name").focus(function() {
				if ($(this).val() == name) {
					$(this).val("");
				
				}
			});
			$("#name").blur(function() {
				if ($(this).val() == "") {
					$(this).val(name);	
				}
			});
		
			$("#mail").focus(function() {
				if ($(this).val() == mail) {
					$(this).val("");
				}
			});
			$("#mail").blur(function() {
				if ($(this).val() == "") {
					$(this).val(mail);	
				}
			});
		
			$("#message").focus(function() {
				if ($(this).val() == message) {
					$(this).val("");
				}
			});
			$("#message").blur(function() {
				if ($(this).val() == "") {
					$(this).val(message);	
				}
			});
			
			$("#submit").click(function(event) {
				event.preventDefault();
				$(".error").hide();
				var bool = true;
				if ($("#name").val() == "" || $("#name").val() == name){
					bool = false;
					$("#name").parent().before("<span class='error'>Please insert a name</span>");	
				}
				if ($("#mail").val() == "" || $("#mail").val() == mail){
					bool = false;
					$("#mail").parent().before("<span class='error'>Please insert a correct mail</span>");	
				}
				if ($("#message").val() == "" || $("#message").val() == message){
					bool = false;
					$("#message").parent().before("<span class='error'>Please insert a message</span>");	
				}
				if (bool) {
					var height = $("#contact").css("height");
					$("#contact").html("<img src='img/loadinfo.net.gif' alt='Loading...'/>");
					$("#contact").css("height",height);
					var fname = $("#name").val();
					var fmail = $("#mail").val();
					alert ($("#name").val());
					var nachricht = $("#message").val()
					$.post("mail.php",{"name_val":fname,"mail_val":fmail,"message_val":nachricht},mail_success);	
				}
				
				//return false;
			});
			
			function mail_success(d,state) {
				if (state == "success") {
					$("#contact").html("Success!").delay(2000);	
					$("#contact").animate({
						"height":"30px"	
					});
				}
				else {
					$("#contact").html("Error.").delay(2000);	
					$("#contact").animate({
						"height":"30px"	
					});
				
				}
			}
			
	});

