$(document).ready(function(){

	//how much items per page to show
	var show_per_page = 20;
	//getting the amount of elements inside content div
	var number_of_items = $('.imagenes').children().size();
	//calculate the number of pages we are going to have
	var number_of_pages = Math.ceil(number_of_items/show_per_page);

	//set the value of our hidden input fields
	$('#current_page').val(0);
	$('#show_per_page').val(show_per_page);

	//now when we got all we need for the navigation let's make it '

	/*
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
	if (number_of_items > show_per_page ) {
		var navigation_html = '<a href="javascript:previous();"><div class="previous_link"></div></a>';
		var current_link = 0;
		while(number_of_pages > current_link){
			navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'"></a>';
			current_link++;
		}
		navigation_html += '<a href="javascript:next();"><div class="next_link"></div></a>';
	
		$('#page_navigation').html(navigation_html);
	
		//add active_page class to the first page link
		$('#page_navigation .page_link:first').addClass('active_page');
	
		//hide all the elements inside content div
		$('.imagenes').children().css('display', 'none');
	
		//and show the first n (show_per_page) elements
		$('.imagenes').children().slice(0, show_per_page).css('display', 'inline-block');
	}

});
