var pages = "";
var current = 0;

// The following function is called when ever an item in the 
// navigation pane is clicked. Its main purpose it to show the
// first page in the selection and to setup the next and previous pages.
function update_content (arg1) {

	// If there are no pages, ignore any click events.
	if (arg1.split ("|").length == 1) {
	
		return "IGNORED";
	}

	// Get the pages.
	pages = arg1.split ("|");

	// Set the currnt page to 0 index to mark the begining of a new
	// group of pages.
	current = 0;

	$("content_main_img").src = "pages/" + pages[current];	
	$("page_nav_index").innerHTML = "(" + (current + 1) + " of " + (pages.length - 1) + ")";
}

function prev_page () {

	// Make sure the pages are set.
	if (pages == "") {
		return;
	}
	
	// Decrement the current page.
	current -= 1;
	
	// Make sure the current page doesn't exceed 0.
	if (current < 0) {
		current = 0;
	}
	
	// Set the page.
	$("content_main_img").src = "pages/" + pages[current];	
	$("page_nav_index").innerHTML = "(" + (current + 1) + " of " + (pages.length - 1) + ")";
}

function next_page () {

	// Make sure the pages are set.
	if (pages == "") {
		return;
	}
	
	// Increment the current page.
	current += 1;
	
	// Make sure the current page doesn't exceed the max.
	if (current == pages.length - 1) {
		current = pages.length - 2;
	}
	
	// Set the page.
	$("content_main_img").src = "pages/" + pages[current];	
	$("page_nav_index").innerHTML = "(" + (current + 1) + " of " + (pages.length - 1) + ")";
}

