	$(document).ready(function(){
		initStuurVacatureDoor();
		initSearchBox();
		initSearchResults();
	});
	
	function initStuurVacatureDoor(){
		$(".btn-stuur-door").click(function(e){
			e.preventDefault();
			
			var overlayUrl = "/vacature-doorsturen?vac="+vacatureId;
			
			$("body").overlay({
				opacity: '85',
				color: '#2a94b8',
				window_width: '519',
				window_height: '385',
				close_img: '/images/close-btn.gif',
				src: '<iframe class="iframe-doorstuur-form" frameborder="0" scrolling="no" src="'+overlayUrl+'"></iframe>'
			});
		});
	}
	
	function initSearchBox(){
		$(".btn-search").click(function(e){
			e.preventDefault();
			var searchVal = $(":input[@name='search']").val();
			toSearch(searchVal);
		});
		$(":input[@name='search']").keyup(function(e){
			var code = e.keyCode;
			if (code == 13 && $(this).val().length > 2)
				toSearch($(this).val());
		});
	}
	
	function toSearch(keyword){
		window.location="/search?q="+keyword;
	}
	
	function initSearchResults(){
		var i = 0;
		$(".google-results").children("table").each(function(){
			if (i == 0 || i == 1)
			{
				$(this).remove();
			}
			i++;
		});
		
		var i = 0;
		$("div.n table").children().children().children().each(function(){
			if (i == 0)
			{
				$(this).remove();
			}
			i++;
		});
		
	}
