/**
 * 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 = jQuery('#hidden div.page:eq('+page_index+')').clone();
	$('#result').empty().append(new_content);
	return false;
}

/** 
 * Initialisation function for pagination
 */
function initPagination() {
	// Count entries inside the hidden content
	var num_entries = jQuery('#hidden div.page').length;
	// Create content inside pagination element
	$("#pagination").pagination(num_entries, {
		callback: pageselectCallback,
		items_per_page:1 // Show only one item per page
	});
	$('#hidden').css('display','none');
 }
	 
	 
$(document).ready(function() {

	$(".film").colorbox({innerWidth:640, innerHeight:480});
	$(".film460").colorbox({innerWidth:463, innerHeight:373});
	$(".youtube").colorbox({iframe:true, innerWidth:640, innerHeight:390});

	initPagination();

	$("#gallery a img").hover(
	  function(){
		var img = $(this).closest('a').attr('href');
		$('#gallerymain').show().attr('src',img);
	  }
	);
	
	$('#newsfeed').rssfeed('http://www.tomorrows-people.org.uk/news/feed');

});
