$( function()
{
	var subnav_opacity 	= '0.9';
	
	var nieuwsblock 	= $( '.nieuwsHomeBlock', '#content' );
	var mainnav 		= $( '#main_navigatie li' );
	var subnav 			= $( '.sub_navigatie > li' );
	var popup 			= $( '#sub_popup' );
	
	nieuwsblock.hover( function()
	{
		//alert("Testset");
		$(this).css( 'cursor', 'pointer' );
		$(this).children( 'div' ).append( '<div class="hoverBorder"></div>' );
		$(this).children( 'h2' ).children( 'a' ).css( { 'color'  : '#fedf00', 'text-decoration' : 'underline' } );
		$(this).children( 'p' ).children( 'a' ).css( { 'color'  : '#fedf00', 'text-decoration' : 'underline' } );
		$(this).children( 'a' ).children( 'p' ).css( { 'color'  : '#fedf00', 'text-decoration' : 'underline' } );
		
		return false;
	},
	function()
	{
		$(this).children( 'div' ).children( 'div' ).remove();
		$(this).children( 'h2' ).children( 'a' ).css( { 'color'  : '#fff', 'text-decoration' : 'none' } );
		$(this).children( 'p' ).children( 'a' ).css( { 'color'  : '#ccd1ee', 'text-decoration' : 'none' } );
		$(this).children( 'a' ).children( 'p' ).css( { 'color'  : '#ccd1ee', 'text-decoration' : 'none' } );
		
		return false;
	});
	
	nieuwsblock.click( function()
	{
		var href = $(this).children( 'h2' ).children( 'a' ).attr( 'href' );
		window.location = href;
		
		return false;
	} );
	
	function sluitSubPopup()
	{
		popup.css( { 'height' : 0, 'opacity' : 0, 'display' : 'none' } );
		
		return false;
	}
	
	$( '#trappers_logo, #header_bovendeel').hover( function()
	{
		sluitSubPopup();	
		
		mainnav.css( 'background-position', 'left top' );	
		
		return false;
	});
	
	$( '#main_navigatie > li.sub_disabled').hover( function()
	{
		mainnav.css( 'background-position', 'left top' );
		
		$( this ).css( 'background-position', 'left bottom' );
		
		sluitSubPopup();
		
		return false;
		
	}, function()
	{
		mainnav.css( 'background-position', 'left top' );
		
		sluitSubPopup();
		
		return false;
	});
		
	$( '#main_navigatie > li:not(.sub_disabled)').hover( function()
	{
		mainnav.css( 'background-position', 'left top' );
		$( this ).css( 'background-position', 'left bottom' );
		
		popup.css( { 'height' : '150px', 'display' : 'block', 'opacity' : subnav_opacity, 'z-index' : 2 } );
		popup.focus();
		
		$('.jelectbox_main').css( 'z-index', 1 );
			
		$( '#sub_popup > div').css( 'display', 'none' );
		$( '#sub_popup .' + $( this ).attr( 'id') ).css( 'display', 'block' );
		
		return false;
		
	}, function()
	{
		popup.hover( function()
		{
			return false;
			
		}, function()
		{	
			sluitSubPopup();

			mainnav.css( 'background-position', 'left top' );
			
			return false;
		});
		
		return false;
	});
	
	subnav.hover( function()
	{
		$( this ).css( { 	'cursor' : 'pointer', 
							'background-image' : 'url(/images/btnSubnavigatie.gif)',
							'background-position' : 'left bottom' } );
							
		$( this ).children( 'a' ).css( 'color', '#fedf00' );
		
		return false;
		
	}, function()
	{
		$( this ).css( { 	'cursor' : 'normal', 
							'background-image' : 'url(/images/btnSubnavigatie.gif)',
							'background-position' : 'left top' } );
							
		$( this ).children( 'a' ).css( 'color', '#fff' );
		
		return false;
	});
	
	subnav.click( function()
	{
		href = $( this ).children( 'a' ).attr( 'href' );
		window.location.href = href;
		
		return false;
	});
});