//Function to enable image switching. Useful for hover effects etc.
//(C) 2003 Thomas Wittek, tw@zentrufuge.biz

//Usage: <img name="button" onmouseover="hover(button);" onmouseout="leave(button);" />
//This will set the image according to its name an the settings in this script

//Setting:
//Quiet (put error message in window status if not quiet)
var hover_quiet   = false;
//Load (put out error messages in a alert box)
var hover_loud    = false;
//The src of your image will be set according to the following variables. It will be "prefix + img.name + hovered + postfix" or prefix + img.name + normal + postfix".
var hover_prefix  = "/gfx/nav_";
var hover_postfix = ".jpg";
var hover_normal  = "";
var hover_hovered = "_hover";

//Code...
var hover_errors = "";
function hoverLoadError(src) {
	if (hover_errors != "") hover_errors += ", ";
	hover_errors += src;
	if ((hover_errors != "") && (hover_quiet == false)) {
		window.status = "Couldn't load images " + hover_errors;
		if (hover_loud == true) alert("Couldn't load images " + hover_errors);
		hover_error = "";
	}
}
function hover(img) {
	setimg(img, hover_hovered);
}
function leave(img) {
	setimg(img, hover_normal);
}
function setimg(img, modifier) {
	var path = hover_prefix + img.name + modifier + hover_postfix;
	img.onerror = new Function("hoverLoadError('" + path + "');");
	img.src = path;
}


