$(function(){
	$("#search_center #advSearch").live('click',function(){
		//Change the height of the header
		$("#header").animate({"height": "+=33px"}, "toggle");
		//Change the height of the box
		$("#search_box_middle").animate({"height": "+=33px"}, "toggle");
		//Clear the input button
		$("#search_center").css('display', 'none');
		
		$("#search_box_middle_content").css('display', 'block');
	});

	$(".asearchbutton").live('click',function(e){
		var obj = $(this).prev().children("span").toggle();
		var obj = $(this).prev().children("ul").toggle();
	});

	
	$(".dropdown_container").click(function(e){
		$(this).children("span").toggle();
		$(this).children("ul").toggle();
	});
	
	$(".asearchbutton").bind( "clickoutside", function(event){
		if(event.target.className != "img active" && event.target.className != 'dropdown_container' && event.target.className != 'text'){
			if($(this).prev().children("ul").css('display') == 'block'){
				var obj = $(this).prev().children("ul").toggle();		
				var obj = $(this).prev().children("span").toggle();		
			}
		}
	});
	
	
	$(".searchUl li.active").each(function(){
		$(this).parent().prev().text($(this).text());
	})
	
	$(".searchUl li").live('click',function(){
		$(this).parent().find('li').each(function(){
			$(this).removeClass('active')
		});
		$(this).addClass('active');
		
		$(this).parent().prev().text($(this).text());
		$(this).parent().next().attr('value',$(this).attr('value'));
		
		$(this).parent().toggle();
		$(this).parent().prev().toggle();
		
	
	})	
	
	$("form1").submit(function() {
		var mSearchValue = $(this).children(':first-child').attr('value');
		if(mSearchValue=='') alert('poe')
		
		return true;
		});
	
	$("form").submit(function() {
		var mSearchValue = $(this).children(':first-child').attr('value');
		if(mSearchValue==''){
			alert('vul een zoekterm in')
			return false;
		} 
		
		return true;
		
	});

})
