// JavaScript Document

// This is a very simple demo that shows how a range of elements can
// be paginated.

/**
	* Callback function that displays the content.
 	*
 	* Gets called every time the user clicks on a pagination link.
 	*
 	* @param {int}page_index New Page index
 	* @param {jQuery} jq the container with the pagination links as a jQuery object
 */
	function pageselectCallback(page_index, jq) {
		var new_content = $('div#hidden-content ul.gallery:eq('+page_index+')').clone().hide('slow').fadeIn(1500);
	 	$('#gallery-paginated').empty().append(new_content);
		
		// Set Image Overlay here, to ensure it runs on ALL pages
		$("div#gallery-paginated a.group").fancybox({
			'overlayShow' : false,
			'hideOnContentClick': true,
			'zoomSpeedIn' : 900,
			'zoomSpeedOut' : 500,			
			'easingIn' : 'easeOutBack',
			'easingOut' : 'easeInBack',
			'overlayShow' : true,
			'overlayOpacity' : 0.7
		});
		
	 	return false;
	}

/** 
 * Callback function for the AJAX content loader.
 */
	function initPagination() {
    	
	
		var num_entries = $('div#hidden-content ul.gallery').length;
    	// Create pagination element
    	$("#gallery-nav").pagination(num_entries, {
			num_edge_entries: 1,
			num_display_entries: 10,
			callback: pageselectCallback,
			items_per_page:1
		});
		
		
		
	}

	// == Document Main ==
	$(document).ready(function(){
							   
		//initPagination(); // Initialise Pagination 
		
		// Set Image Overlay here, to ensure it runs on ALL pages
		$("div#gallery-paginated a.group").fancybox({
			'overlayShow' : false,
			'hideOnContentClick': true,
			'zoomSpeedIn' : 900,
			'zoomSpeedOut' : 500,			
			'easingIn' : 'easeOutBack',
			'easingOut' : 'easeInBack',
			'overlayShow' : true,
			'overlayOpacity' : 0.7
		});
			
		
	});