/***********************************************************************

Author:     Arno Hoogma
URL:        http://www.4rn0.nl

***********************************************************************/


if (typeof window.jQuery != 'undefined') {

	$(function()
	{
		
		innerFade();
		menuHelper();
		// initPortal();
		// hoverCorporate();
		
	});
	
	function innerFade()
	{
		
		if (!$('div#impression').hasClass('custom')) {
			
			$('div#impression').append('<img src="/wp-content/themes/pudding/assets/images/pudding_01.jpg">');
			$('div#impression').append('<img src="/wp-content/themes/pudding/assets/images/pudding_02.jpg">');
					
			$('div#impression').innerfade({ 
				speed: 1000, 
				timeout: 5000, 
				type: 'sequence', 
				containerheight: '272px'
			});
			
		}
		
	}
	
	function menuHelper()
	{
		
		if ($.cookie('menu') == 'closed') {
			$('div#navigatie h2:first').css('margin', '0 0 3px');
			$('div#navigatie h2:first').next().hide();
		}
		
		$('div#navigatie h2:first').css('cursor', 'pointer').hover(
			function() { $(this).css('color', '#edd43a'); },
			function() { $(this).css('color', '#fff'); }
		);
		
		$('div#navigatie h2:first').click(function() {
			
			var cookie = ($.cookie('menu') == 'closed') ? 'open' : ($.cookie('menu') == 'open' ? 'closed' : ($('body').hasClass('bedrijf')) ? 'open' : 'closed');

			if (cookie == 'open') {
				$('div#navigatie h2:first').css('margin', '0');
			}				
			
			$(this).next().slideToggle('fast', function() {
				if (cookie == 'closed') {
					$('div#navigatie h2:first').css('margin', '0 0 3px');
				}				
			});
			
			$.cookie('menu', cookie, { path: '/', expires: 31 });
			
		});
		
	}	
	
	function hoverCorporate()
	{

		if ($.browser.mozilla || $.browser.safari) {
		
			$('.corporate').hover(
				function() { 
					$('body').prepend('<div id="corporate"></div>'); 
					$(this).css('cursor', 'pointer').click(function(){
						document.location.href = $('a', $(this)).attr('href');
					});
				},
				function() { $('#corporate').remove(); }
			);
		
		}
		
	}
	
	function initPortal()
	{
		
		$('a.portal').click(function() {
			
			$('div#overlay, div#portal').fadeOut(200, function() {
				$('html').removeClass('portal');
				$(this).remove();
			});
			
			return false;
			
		});
		
	}

}