$(document).ready(function() {	
	$().bind('slide_loaded', function(event, link) { // everytime this page is loaded, remove and reattach hooks for this page
		if ($('.content.gallery').length > 0) {
			$()
				.unbind('.gallery')
				.bind('slide_start.gallery', function(event, link) {
					if ($('.content.gallery').length > 0) {
						var galleryLinks = $('.gallery-item a');
						
						galleryLinks.disableGalleryPreview();
					}
				})
				.bind('slide_complete.gallery', function(event, link) {
					var galleryLinks = $('.gallery-item a');
					
					if ($('.content.gallery').length > 0) { // we've finished sliding to the gallery page
						showNavigationItem($('#navigation li.video')); // Change the navigation link to "video"
						
						$('#navigation a').ifixpng();
						
						galleryLinks.galleryPreview();
						
						if (!isUnderIE8()) {
							$.imageFrame.defaultFrameStyle = 'sharp';
							galleryLinks.children('img').imageFrame();
						}
						
						$().bind('cbox_load', function() { // Remove any open gallery image once the colorbox opens
							$.fn.galleryPreview.removePreviewContainer(); // remove the gallery box when the colorbox modal opens
						});
					} else {
						$().unbind('.gallery');
					}
			});
		}
	});
});