var clickedName; //clicked name
var subClickedName; //clicked name

/*
 *  turns ns4's image model into the same as other browsers,
 *  ie. all images are in document.images[]; does the same for forms.
 *  usage : automatic, just include this function
 */
 
 function getImages(obj)
 {
 	if(document.layers) with(obj.document)
	{
		for (i=0; i<images.length; i++) if (images[i].name) document.images[images[i].name] = images[i];
		for (i=0; i<forms.length; i++)  if (forms[i].name)  document.forms[forms[i].name]   = forms[i];
		//for (i=0; i<links.length; i++)  if (links[i].name)  document.links[links[i].name]   = links[i];
	}
 }
 
 //  rollover.js - everything needed for rollovers

/*
 *  simple rollover function including checks for images[] and images[name].
 */

 function imgOn(name)
 {
 	// need to turn everything else off here - use the same function as for normal rollover
	if ((clickedName != name)&&(canClick == true))
	{
	roll(name, "on");
	}
	
 }

/*
 *	default mouseout rollover code, implements roll()
 */

 function imgOff(name)
 {
	if ((clickedName != name)&&(canClick == true))
	{
	roll(name, "off");
	}
 }


 /*
 *	default mouseover rollover code, implements roll()
 */
 
 function roll(name, ext)
 {
	if(document.images&&eval("document.images."+name))
	{
		document.images[name].src = eval(name+ext+".src");
		//alert(document.images[name].src)
	}
 }
 
 /*
 * function to make the image stay highlighted once clicked on particular section
 */
 
 function highlight(name)
 {
 clickedName = name;
 subClickedName = null;
 // turn all others off - sub images and main images
 for (i=0;i<MainImgList.length;i++)
		{
		var ImgName = MainImgList[i].Name;
		//alert(ImgName)
		var ImgSource = MainImgList[i].Src;
			if (ImgName != clickedName)	document.images[ImgName].src = ImgSource;
		}
		
 //for(i=0;i<SubImgList.length;i++)
//	{
//		var SubImgName = SubImgList[i].Name;
//		var SubImgSource = SubImgList[i].Src;
//		document.images[SubImgName].src = SubImgSource;
//	}
		
 document.images[clickedName].src = eval(name+"on.src");
 }
 
 // THESE ARE THE FUNCTIONS FOR THE SUB OPTION ROLLOVERS.
 
 function subImgOn(name,arrayName)
 {
 	// need to turn everything else off here - use the same function as for normal rollover
	if ((subClickedName != name)&&(canClick == true))
	{
	roll(name, "on");
	}
	
 }

/*
 *	sub-option mouseout rollover code, implements roll()
 */

 function subImgOff(name)
 {
 	if ((subClickedName != name)&&(canClick == true))
	{
	roll(name, "off");
	}
 }
 
 /*
 * function to make the image stay highlighted once clicked on particular section
 */
 
 function subHighlight(name)
 {
 subClickedName = name;
 //alert("subClickedName is: " + subClickedName)
 // turn all others off
 for (i=0;i<SubImgList.length;i++)
		{
		var SubImgName = SubImgList[i].Name;
		var SubImgSource = SubImgList[i].Src;
			if (SubImgName != subClickedName)	
			{
			document.images[SubImgName].src = SubImgSource;
			//alert(document.images[SubImgName].src)
			}
		}
		
 document.images[subClickedName].src = eval(subClickedName+"on.src");		
 }
 
/*
 *  gif preload function. preloads images with deafult on/off extension.
 *  image in html needs the same name.
 *    names = imagename (minus suffix and .gif) as many as you need
 *    path = path to folder containing image eg. "images/"
 */
  
 document.preload =  function(path,names)
 {
 	arg = arguments;
	for(i=1; i<arg.length; i++)
	{
		window[arg[i] + "on"] = new Image();
		window[arg[i] + "off"] = new Image();
		window[arg[i] + "on"].src = path + arg[i] + "_on.gif";
		window[arg[i] + "off"].src = path + arg[i] + "_off.gif";
 	}
 }
 
 function preload(name, src)
 {
 	window[name] = new Image();
	window[name].src = src;
 }
 
