$(function(){
	
	if($(".box a img").length != 0)
	{		
		$(".box a img").parent().colorbox({maxWidth:"90%", maxHeight: "90%"});
	}
	
	$("a.popup").colorbox({maxWidth:"90%", maxHeight: "90%"});
	
	var sDefaultValue = "Zoeken";	
	$("input.search_input").bind("focus", function(){		
		if(sDefaultValue == $(this).val())
		{
			$(this).val("");
		}
	});
	
	$("input.search_input").bind("blur", function(){
		setTimeout(function()
		{						
			$("div#header_search_results").hide();
			if("" == $(this).val())
			{
				$(this).val(sDefaultValue);
			}
		}, 500);
		
		if("" == $(this).val())
		{
			$(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");
	});
	
});
