$(function() {

	// Make PHOTOGRAPHY Menu ACTIVE if in sub-menus that aren't quite sub-menus
	
	if (window.location.href.indexOf("photo") >= 0) {
		$("#main_nav a:contains('Photography')").parent('li').addClass('current_page_item');
	};
	
	// Fix Hover over Non-linking Pagination
	
	$('.pagination li:before').hover(function() {
		if (!($(this).has('a'))) {
			$(this).css({background:'#353535'});
		}
		});
		

	/////////////////////////// HOMEPAGE VIDEOS /////////////////////////////
	
	$('#motion_reel iframe, #live_action_reel iframe').css({height: '166px', width: '295px'});
	
	$('#featured_video iframe').css({height: '253px', width: '450px'});
		
	/////////////////////////// FANCYBOX //////////////////////////////
	
	// Insert Splash BG
	$('<div id="fancybox-splash-bg"></div>').insertAfter('#fancybox-overlay');
	$('#fancybox-splash-bg').height($(document).height());
	
	// Change Close Button
	$('#fancybox-close').addClass('frame_wrapper').html('<span class="frame">Close</span>');
		
	$(".video_thumb a").click(function() {
	
		// JUKES - GET INFO
		var info = $(this).find('.project_info p').html();
		
		// BACK TO NORMAL
		$.fancybox({
        'padding'       : 10,
        'cyclic'        : true,
        'autoScale'     : false,
        'transitionIn'  : 'fade',
        'transitionOut' : 'fade',
        //'width'         : 601,
        //'height'        : 338,
		'href'			: this.href,
        'type'          : 'iframe',
        'showNavArrows' : false,
		'title'			: this.title,
		'titleFormat'	: function(title) {
			return '<div class="fancybox-info"><h4>'+title+'</h4><p>'+info+'</p></div>'
		},
		'onStart'		: myFancyboxStart(),
		'onClosed'		: function() {
			myFancyboxClose();
		}
		});
		
		return false;
    });	
	
	// Show splash bg image
	function myFancyboxStart() {
		var window_height = $(window).height();
		var window_width = $(window).width();
		var scroll_position_y = $(window).scrollTop();
		var scroll_position_x = $(window).scrollLeft();
		var image_height = 902;
		var image_width = 1362;
		var pos_y = (window_height/2) + scroll_position_y - (image_height/2) + 35;
		var pos_x = (window_width/2) + scroll_position_x - (image_width/2) - 10;
		$('#fancybox-splash-bg').css({display: 'block'});
		$('#fancybox-splash-bg').css({backgroundPosition: pos_x+'px '+pos_y+'px'});
	}
	
	function myFancyboxClose() {
		$('#fancybox-splash-bg').hide();
	}
	
});
