/*

Gallery Script
$Id: gallery.js,v 1.1.1.1 2006/11/14 09:31:20 mattb Exp $
(C) Matthew Bonner <matthewbonneronline@yahoo.com.au>

NONE OF THIS CODE MAY BE COPIED WITHOUT PERMISSION

However, feel free to browse and apply any knowledge
gained in the process to your own scripts :-)

*/

var c_thumbnails = 6;

var g_page = 0;
var g_preview = new Image();
var g_caption = "";

function gallery_init() {
	gallery_update();
	display_preview(0);
}

function gallery_prev() {
	if (g_page) {
		g_page--;
		gallery_update();
	}
}

function gallery_next() {
	if (((g_page + 1) * c_thumbnails) < imageData.length) {
		g_page++;
		gallery_update();
	}
}

function display_preview_onload() {
	document.getElementById('full_sized').innerHTML =
		"<img class='display_preview' src='" + g_preview.src +
		"' border='0'><br/><b>" + g_caption + '</b>';
}

function display_preview(img) {
	var data = new Array;
	data = imageData[(g_page * c_thumbnails) + img].split('|');
	g_caption = data[0];
	document.getElementById('full_sized').innerHTML =
		"<img class='display_preview' src='graphics/squiggle.gif'>";
	g_preview.src = c_path_fullsize + data[1];
	g_preview.onload = display_preview_onload;
}

function gallery_update() {
	var displayHTML = '';
	var temp_caption;
	var offset = g_page * c_thumbnails;
	var data = new Array();
	for (var img = 0; img < c_thumbnails; img++) {
		if (imageData[offset + img]) {
			data = imageData[offset + img].split('|');
			temp_caption = data[0];
			temp_caption = temp_caption.replace(/(<([^>]+)>)/ig, " ");
			displayHTML += "<a style='cursor:pointer;' onclick='javascript:display_preview(" + img + ");'><img class='gallery_thumb' width='90' height='90' title='" + temp_caption + "' src='" + c_path_thumbnail + data[1] + "' border='0'></a>";
		} else {
			displayHTML += "<img class='gallery_thumb_empty' src='graphics/pix.gif' width='90' height='90' border='0'> ";
		}
	}
	document.getElementById('gallery_browser').innerHTML = displayHTML;
	display_preview(0);
}
