
message_timeout = 0;
function show_message(message)
{
	if(!message) return false;	
	if(message=="") return false;
	clearTimeout(message_timeout);
	var $message = $("#message_bar");
	$message.stop().empty().css("top",-50);
	$message.html(message);
	Cufon.replace("#message_bar");
	$message.animate({
		top: 0
	}, 300);
	message_timeout = setTimeout(function(){
		$message.animate({
			top: -60
		}, 300);
	}, 2500);
	
}


$("document").ready(function(){
	$("#logo").click(function(){
		window.location = "/";
	});
	$("#contact_message").blur(function(){
		if($(this).val() == "")
		{
			$(this).val("Uw bericht hier");
			$(this).css("color","#bbbbbb");
		}
	}).focus(function(){
		var text = $(this).val();
		if((text == "Uw bericht hier") || (text == "Dit veld is verplicht"))
		{
			$(this).val("");
			$(this).css("color","#3e3e3e");
		}
	});
	
	$("#contact_form form").submit(function(){
		var error = false;
		var message = $("#contact_message").val();
		var sender = $("#contact_sender").val();
		if((message == "") || (message == "Uw bericht hier") || (message == "Dit veld is verplicht")){
			error = true;
			$("#contact_message").val("Dit veld is verplicht");
			$("#contact_message").css("color","#ae0000");
		}
		
		if((sender == "") || (sender == "Uw email adres hier") || (sender == "Dit veld is verplicht")){
			error = true;
			$("#contact_sender").val("Dit veld is verplicht");
			$("#contact_sender").css("color","#ae0000");
		}
		
		
		if(!error)
		{
		
			$("#contact_send, #contact_form textarea").animate({opacity:0}, 300);
			$("#contact_sender").animate({opacity:0}, 300,function(){
			
				$("#contact_form form").remove();
				$.post("/send_mail", {"action":"send_mail","sender":sender,"message":message},function(data){
					if(data == "SUCCES")
					{					
						$(".contact_succes")
						.css({"opacity":0,display:"block"})
						.animate({opacity:1},300);
					}
					else
					{
						$(".contact_error")
						.css({"opacity":0,display:"block"})
						.animate({opacity:1},300);
					}
				});
			
			});
			
		}
		return false;
	});
	
	$("#contact_sender").blur(function(){
		var text = $(this).val();
		if((text == ""))
		{
			$(this).val("Uw email adres hier");
			$(this).css("color","#bbbbbb");
		}
	
	}).focus(function(){
		var text = $(this).val();
		if((text == "Uw email adres hier") || (text == "Dit veld is verplicht"))
		{
			$(this).val("");
			$(this).css("color","#3e3e3e");
		}
	});

	Cufon.replace(".cufon, h1, h2, h3", {hover: true});
	
	$(".work").work_image();
	$("#logo_black").css("opacity",0);
	$(".menu_contact").click(function(e){
		e.preventDefault();
		$("#contact_wrapper").animate({height: 300}, 650);
		$("#logo").animate({top: -300}, 650);
		$("#logo_black").animate({opacity: 1}, 650);
		Cufon.replace(".contact_succes, .contact_error");
	});
	
	$("#contact_close").click(function(e){
		e.preventDefault();
		$("#contact_wrapper").animate({height: 0}, 650);
		$("#logo").animate({top: -75}, 650);
		$("#logo_black").animate({opacity: 0}, 650);
	});
	$("#contact_close, #contact_send").hoverClass("hover");

});
