$(function(){
	
	$("div#wrapper-content form.search input[type='submit']").val('');
	
	// Search
	var sDefaultValue = "Zoekterm";	
	$("input.search_input").bind("focus", function(){		
		if(sDefaultValue == $(this).val())
		{
			$(this).css("font-style", "normal");
			$(this).css("color", "normal");
			$(this).val("");
		}
	});
	
	$("input.search_input").bind("blur", function(){
		setTimeout(function()
		{						
			$("div#header_search_results").hide();
			if("" == $(this).val())
			{
				$(this).css("font-style", "italic");
				$(this).css("color", "normal");
				$(this).val(sDefaultValue);
			}
		}, 500);
		
		if("" == $(this).val())
		{
			$(this).css("font-style", "italic");
			$(this).css("color", "normal");
			$(this).val(sDefaultValue);
		}
	});										
	
	
	$("input.search_input").bind("keyup", function(){
		var sSearchTerm = $(this).val();
		if($("div#header_search_results").css("display") == "none")
		{
			$("div#header_search_results").show();
			$("div#header_search_results").append("<p class=\"defaulttext\">Loading data...</p>");
		}																							
		
		$.ajax({
				url: "/search/searches/livesearchResults/"+sSearchTerm				
			,	cache: false
			,	async: true
			,	success: function(data){
					$("div#header_search_results").html(data);
				}
		});
	});
	
	$("div#header_search_results div").mouseover(function(){
		$(this).css("background-color", "#f3f3f3");
	});
	$("div#header_search_results div").mouseout(function(){
		$(this).css("background-color", "#FFFFFF");
	});
	
	
	var sDefaultFooterVest = 'Vul postcode of plaatsnaam in';
	$("input#FortunepostalcodePostalcode").bind("focus", function(){
		if(sDefaultFooterVest == $(this).val())
		{
			$(this).css("font-style", "normal");			
			$(this).val("");
		}
	}).bind('blur', function(){
		if('' == $(this).val())
		{
			$(this).css("font-style", "italic");
			$(this).val(sDefaultFooterVest);
		}
	});
	
	var sDefaultFooterSearch = 'Zoekterm';
	$("input#searchSearchTerm").bind("focus", function(){
		if(sDefaultFooterSearch == $(this).val())
		{
			$(this).css("font-style", "normal");			
			$(this).val("");
		}
	}).bind('blur', function(){
		if('' == $(this).val())
		{
			$(this).css("font-style", "italic");
			$(this).val(sDefaultFooterSearch);
		}
	});
	
	var sDefaultFooterNewsletterName = 'Voor- en achternaam';
	$("input#newsletterName").bind("focus", function(){
		if(sDefaultFooterNewsletterName == $(this).val())
		{
			$(this).css("font-style", "normal");			
			$(this).val("");
		}
	}).bind('blur', function(){
		if('' == $(this).val())
		{
			$(this).css("font-style", "italic");
			$(this).val(sDefaultFooterNewsletterName);
		}
	});
	
	var sDefaultFooterNewsletterEmail = 'E-mailadres';
	$("input#newsletterEmail").bind("focus", function(){
		if(sDefaultFooterNewsletterEmail == $(this).val())
		{
			$(this).css("font-style", "normal");
			$(this).val("");
		}
	}).bind('blur', function(){
		if('' == $(this).val())
		{
			$(this).css("font-style", "italic");
			$(this).val(sDefaultFooterNewsletterEmail);
		}
	});
	
	
});
