$(document).ready(function(){
	
	// border weghalen bij laatste menu item (boven aan de pagina)
	$('div#menu > ul > li > a:last').css({border:"0px"});
	
	$("#main_default_left > ul > li.product:has(ul.close)").click(function(e) { 
		$('#main_default_left > ul > li.merk:has(ul.close) > ul').hide(); 
		$('ul.sub_menu', this).toggle(); 
	});	
	
	$("#main_default_left > ul > li.merk:has(ul.close)").click(function(e) { 
		$('#main_default_left > ul > li.product:has(ul.close) > ul').hide(); 
		$('ul.sub_menu', this).toggle(); 
	});	
	
	//menu items linkerkant bij food en pharma
	$("#main_default_left > ul > li > ul > li:has(ul)").mouseover(function(e) { 
		$('a:first', this).addClass('selected');
		$('ul', this).show();  
	});
	
	$("#main_default_left > ul > li > ul > li:has(ul)").mouseout(function() { 				
		$('a', this).removeClass('selected');
		$('ul', this).hide();  
	});
	

	// inputfield searchbox
	$('div.search_text').click(function() {
		$(this).css({'display': 'none'});
		$('input#input_search').css({'display': 'inline'}).get(0).focus();
	});
	
	$('input#input_search').blur( function() {
		if ((this).value == ''){
			$('div.search_text').css({'display': 'inline'});
			$('input#input_search').css({'display': 'none'});
		}
	});
	
	// kijken of het zoek woord meer dan 3 tekens heeft. en of de volgende woorden er niet in worden gebruikt
	$('#zoekblokform').submit( function() {
		if(this['zoekbloktekst'].value.length <= 3) {
			return false;
		} else if(this['zoekbloktekst'].value == 'Zoeken' 
			   || this['zoekbloktekst'].value == 'zoeken' 
			   || this['zoekbloktekst'].value == 'zoek'
			   || this['zoekbloktekst'].value == 'Zoek'
			   || this['zoekbloktekst'].value == 'Search'
			   || this['zoekbloktekst'].value == 'search'
			   || this['zoekbloktekst'].value == 'Recherche'
			   || this['zoekbloktekst'].value == 'recherche') {
			return false;
		}
	});
	
	// button voor zoeken.
	$('#zoekbloksubmit').click( function() {
		formobj = this.parentNode.parentNode;
		$(formobj).submit();
	});
	
	// bij laatste nieuwsitem op nieuwspagina class last-item toevoegen:
	$('div.main_default_nieuws_block_footer:last').addClass('last-item');
	
	//bij laatste product class last-item toevoegen
	$('div.main_product_block_footer:last').addClass('last-item');
	
	//als class firstlink is dan hele blok als link door middel van 1 a tag
	$('.firstlink').each(function() {
		$(this).click(function() {
			document.location.href = $(this).find('a[href]').get(0).href;
		});
		$(this).bind('mouseenter',function() {
			$(this).find('a[href]').eq(0).addClass('hover');
		});
		$(this).bind('mouseleave',function() {
			$(this).find('a[href]').eq(0).removeClass('hover');
		});
	});
	
	//nieuws archief items tonen als er op des betreffende maand word geklikt
	$('ul.nieuwsarchief li div').click(function() {
		$(this).toggleClass('folder_open').siblings('ul').eq(0).slideToggle();
		return false;
	});
	
	//nieuws archief altijd het eerste item open zetten
	$('ul.nieuwsarchief > li:first > div').addClass('folder_open');
	$('ul.nieuwsarchief > li:first ul').css({display:"block"});
	
	// PrettyPhoto (lightbox)
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animationSpeed: 'normal', 		/* fast/slow/normal */
		padding: 40, 					/* padding for each side of the picture */
		opacity: 0.35, 					/* Value between 0 and 1 */
		showTitle: true, 				/* true/false */
		allowresize: true, 				/* true/false */
		counter_separator_label: ' van de ', 	/* The separator for the gallery counter 1 "of" 2 */
		theme: 'light_rounded', 			/* light_rounded / dark_rounded / light_square / dark_square */
		callback: function(){}
	});
	
	$('a.new-window').click(function(){
		   window.open(this.href);
		   return false;
	});
	
	// kijken welke brower aan staat -> alleen ie6
	if($.browser.name == 'msie' && $.browser.version == '6.0') {
		$('#main_default_left > ul > li> ul >li:last-child a').css({border: "0px"});
		$('#main_default_left > ul > li> ul >li > ul > li:first-child').css({border: "0px"});
	}
});

