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

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

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


if (typeof window.jQuery != 'undefined')
{
	
	Shadowbox.init({
		language: 		'nl',
	    players:  		['img', 'flv'],
		initialHeight: 	460,
		initialWidth: 	686,
		animSequence: 	'sync',
		continuous: 	false,
		displayCounter: false,
		flvPlayer: 		'../assets/flv/player.swf',
		overlayOpacity: '0.5'
	});
	
	$(function()
	{
		
		initNavigation();
		initCaptions();
		initMovie();

	});
	

	/**
	 * Navigation
	 */
	
	function initNavigation()
	{
		
		$('div#branding ul li:not(.active) a').fadeTo(0, 0);
		$('div#branding ul li:not(.active) div').fadeTo(0, 0);
		
		$('div#branding ul li:not(.active) a').hover(
			
			function() {

				$('div#content').stop().fadeTo(300, 0);
				$('div#branding ul li.active div').stop().fadeTo(300, 0);
				$(this).fadeTo(300, 1).next().fadeTo(300, 1);
							
				$(this).parent().addClass('hover');
				
			},
			
			function() {
				
				$('div#content').stop().fadeTo(300, 1);
				$('div#branding ul li.active div').stop().fadeTo(300, 1);
				$(this).next().fadeTo(300, 0);
								
				$(this).fadeTo(300, 0, function() {
					$(this).parent().removeClass('hover');
				});
				
			}
			
		);
		
	}
	
	
	/**
	 * ScrollPane
	 */
	
	function initScrollPane()
	{
		
		$('html').removeClass('noscript').addClass('jquery');
		
		$(window).resize(function() {
			
			$('div.jScrollPaneContainer').height( $(window).height() );

			$('div#content').jScrollPane({
				scrollbarOnLeft: true,
				showArrows: true, 
				scrollbarWidth: 11,
				scrollbarMargin: 0,
				dragMaxHeight: 50,
				maintainPosition: true,
				reinitialiseOnImageLoad: true
			});
			
		});
		
		$(window).trigger('resize');
		
	}
	
	
	/**
	 * Captions
	 */
	
	function initCaptions()
	{
		
		if ($('body').hasClass('actueel')) {
			
			$('a[rel^=shadowbox]').each(function(i,n) {			
				$(n).attr('title', '<h4>' + $(this).parents('ul').next('h3').text() + '</h4><p>' + $(n).attr('title') + '</p>');			
			});
			
		}
		
		else {

			$('a[rel^=shadowbox]').each(function(i,n) {			
				$(n).attr('title', '<h4>' + $('div#branding li.active div h2').text() + '</h4><p>' + $(n).attr('title') + '</p>');			
			});
			
		}
		
	}
		
			
	/**
	 *	Movie
	 */
	
	function initMovie()
	{
		
		if ($('div#movie').size()) {
			
			var flashvars = {};
			    flashvars.file = '../../' + $('div#movie a').attr('rel');
			  	flashvars.image = $('div#movie img').attr('rel');
				flashvars.skin = 'assets/flv/skin.swf';

			var params = {}
			    params.allowScriptAccess = 'always';
			    params.allowFullScreen = 'true';
			    params.wmode = 'transparent';
			    params.menu = 'false';
			    params.quality = 'high';

			swfobject.embedSWF('assets/flv/player.swf', 'movie', '446', '369', '9.0.0', null, flashvars, params, null);
			
		}
		
	}
	
}
