// guide_bar.js
// 
// Javascript 1.2
// 
// JEMWorks Software, 2000
// http://www.jasonya.com/jemworks/
// jemworks@jasonya.com
// 
// Javascript utility to create a guide bar with text and/or graphics
// based on an array which contains information about the links
// 
// 

// Index Array should look like this:
// 		this_index = new Array(
// 			[name, URL, caption, image],
// 			[name2, URL2, caption2, image2],
// 			...)
// 			 	
// Global Variables: Can be set by user
GIMAGE_PREFIX = "images/"
GIMAGE_SUFFIX = ".gif"

IBAR_VSPACE = 6
IBAR_HSPACE = 0
IBAR_ONSUFFIX = "_on"
IBAR_OFFSUFFIX = "_off"

function image_bar(index_array, this_index, orientation) {
	self.status = "Pre-Loading Images..."
	
	preload(index_array)
	self.status = ""
	
	i = 0
	while (index_array[i]) {
		title = index_array[i][0]
		link = index_array[i][1]
		caption = index_array[i][2]
		image = index_array[i][3]
		

		img_entry = "<IMG SRC=\"" + GIMAGE_PREFIX + image + IBAR_OFFSUFFIX + GIMAGE_SUFFIX +
					"\" NAME=\"" + title + "\" ALT=\""+ caption + "\"" + 
					"BORDER=0 HSPACE=" + IBAR_HSPACE + 
					" VSPACE=" + IBAR_VSPACE + " ALIGN=MIDDLE>";
		if ((this_index) != link) {
				bar_entry = "<A HREF=\"" + link +
							"\" onMouseOver=\"guide_over(\'" + 
							title + "\',\'" + image + "\')\;" +
							"self.status=\'" + caption + 
							"\'\; return true\" onMouseOut=\"guide_out(\'" +
							title + "\',\'" + image + 
							"\')\; self.status=\'\'\;return true\">";
				document.write(bar_entry);
				document.write(img_entry);
				document.write("</A><BR>");
		} 
		else {
			document.write(img_entry + "<BR>")
		}
		i = i + 1
	}
}

function guide_over(target, name) {
	    imgOn= eval(name + IBAR_ONSUFFIX + ".src");
		document [target].src = imgOn;
}
	
function guide_out(target, name) {
		imgOff= eval(name + IBAR_OFFSUFFIX + ".src");
		document [target].src = imgOff;
}

function preload(index_list) {
	ret_array = new Array()
	
	j = 0
	while (index_list[j]) {
		image = index_list[j][3]
	
		guide_image_plain(image, GIMAGE_PREFIX, IBAR_ONSUFFIX, GIMAGE_SUFFIX)
		guide_image_plain(image, GIMAGE_PREFIX, IBAR_OFFSUFFIX, GIMAGE_SUFFIX)
		j = j + 1;
	}	
	return ret_array
}

function guide_image_plain(image, prefix, sub, suffix) {
	if (prefix == 0) prefix = GIMAGE_PREFIX;
	if (sub == 0) sub = "";
	if (suffix == 0) suffix = GIMAGE_SUFFIX;
	img_target = image + sub + " = new Image()";
	img_get = image + sub + ".src = \"" + prefix + image + sub + suffix + "\"";
	ret_image = eval (img_target);
	eval (img_get);
	
	return ret_image
}

