/* This file will create a mechanism for flipping images as the mouse clicks,
 * rolls over or otherwise interacts with images  Netscape compatibility is
 * left for a future day :) */

 /* all pages that use this script will need to include a handler:
  * <body onload="initpg();"> or somefunction thereof that performs the
  * following initializations
  
  1.	Loads all images:
  2.	Initialize a variable named imgslded to 1

  example

function initpg() {
  	img_int_name_norm = new Image();
	img_int_name_norm.src = "image location";
  	img_int_name_over = new Image();
	img_int_name_over.src = "image location";
  	img_int_name_down = new Image();
	img_int_name_down.src = "image location";
	...
	...
	...
	...
	...
	...
	imgslded = 1;
} */

/* Then we create functions for events: */
// OnMouseOver		This will flip to img_int_name_over 	mover
// OnMouseOut		This will flip to img_int_name_norm		mout
// OnMouseDown		This will flip to img_int_name_down		mdown
/* we assume that upon clicking an image a new page will be loaded so no
 * release is needed from a OnMouseDown event :) */

/* These events are NOT available in an <img> tag in netscape so for 
 * compatibility place them in the <a> tag where such tags exist */

/* Also from the above initpg() function the img tag would be named
 * img_int_name ie <img name=img_int_name src=...> */
imgslded = 0;
curst = 0;
curst = 0;

function mover(obj) {
	//alert("Entered Mover " + obj);
	if (imgslded == 1) {
		//alert("Inside Mover");
		if (curst != 0) mout(curobj);
		objname = eval(obj + "_over");
		//alert(objname);
		//alert(objname.src);
		document.images[obj].src = objname.src;
		curobj = obj;
		curst = 1;
	}
	//alert("exiting...");
}

function mdown(obj) {
	//alert("Entered Mdown " + obj);
	if (imgslded == 1) {
	//	alert("Inside Mdown");
		objname = eval(obj + "_down");
		document.images[obj].src = objname.src;
		curobj = obj;
		curst = 2;
	}
	//alert("exiting...");
}

function mout(obj) {
	//alert("Entered Mout " + obj);
	if (imgslded == 1) {
		//alert("Inside Mout");
		objname = eval(obj + "_norm");
		document.images[obj].src = objname.src;
		curobj = obj;
		curst = 0;
	}
	//alert("exiting...");
}
