$(document).ready( function(){ 
														
	$('.ngg-widget a').attr('href', '/portfolio/');
	
	/* Video BG
	*************************/
	
	if( $("#bg-video").size() > 0 ) {
	
		var videoWidth  = 960;
		var videoHeight = 540;
		var videoAspect = videoWidth / videoHeight;
		
		$(window).resize(function() {
				
			var windowAspect = $(window).width() / $(window).height();
			
			if( windowAspect <= videoAspect ) { //alert('Fit to height');
				
				$("#bg-video").css( 'top', 0 );
				
				var scale = $(window).height() / videoHeight;
				var over = ( (scale * videoWidth) - $(window).width() );
	
				//$("#bg-video").height( $(window).height() );
				$("#bg-video").width( (scale * videoWidth) );
				$("#bg-video").css( 'left', (over / 2) * -1 );
				
			} else { //alert('Fit to width');
				
				$("#bg-video").css( 'left', 0 );
				
				var scale = $(window).width() / videoWidth;
				var over = ( (scale * videoHeight) - $(window).height() );
				
				$("#bg-video").width( $(window).width() );
				$("#bg-video").css( 'top', (over / 2) * -1 );
				
			}
	
		});
		
		$("#bg-video").bind('play', function(){ 
				// Fade in								
		});
		
		$("#bg-video").bind('ended', function(){ 
			this.play();
		});
	
	} // end if
	
	/* Footer
	*************************/
	
	var init_height = $('#mainContainer').height();	
	
	$(window).resize(function() {

		var new_height = $(window).height() - $('#footerContainer').height() - $('#headerContainer').height();
		
		if(new_height <= init_height)
			$('#mainContainer').height('auto');
		else
			$('#mainContainer').height( new_height );

	}); 
	
	/* prettyPhoto
	*************************/
	$("a[rel^='prettyPhoto']").prettyPhoto({
		animation_speed:'normal',
		overlay_gallery: false,
		theme:'facebook'
	});
	
	//http://www.constructivemedia.com.au.internal/portfolio/#!prettyPhoto[portfolio]/62/
	
	/* nivoSlider
	*************************/
	$('#slider').nivoSlider({
		controlNav: false,
		pauseTime: 9000
	});
	
	/* init resize code
	*************************/
	$(window).resize(); 

}); 
