
//  through what was essentially a mistake in the DOM specification, mozilla builds generally do not implement a click method for anchor elements. This little block of javascript essentially gives them one. 
if (!document.all) {
  try {
		// this ensures that the document is not empty. 
		document.createElement('a');
		HTMLElement.prototype.click = function () {
			if (typeof this.onclick == 'function') {
				if (this.onclick({type: 'click'}) && this.href) 
					window.open(this.href, this.target ? this.target : '_self');
			}
			else if (this.href)
				window.open(this.href, this.target ? this.target : '_self');
		}
	}
	catch (e) {
		window.status='Warning: your browser is unable to attach click methods to all elements.';
	}
}



/* your everyday rollover function */
function roll(divName, imgName, which) {
	if ((is.ns4)&&(divName!=-1)) {
		var imgObject = eval("document." + divName +".document.images['"+imgName +"_image']");
		imgObject.src = eval(imgName + "_" + which + ".src");
	}	
	else {
		document.images[imgName +"_image"].src = eval(imgName + "_" + which + ".src");
	} 
}

function appendClassName(obj, newClassName) {
	if (obj.className.indexOf(newClassName)!=-1) return true;
	if (!obj.className) obj.className = newClassName;
	else obj.className = obj.className + " " + newClassName;
}
function removeClassName(obj, classNameToRemove) {
	var newClassName = obj.className.replace(" "+classNameToRemove,"");
	newClassName = newClassName.replace(classNameToRemove+" ","");
	if (obj.className.length == newClassName.length) {
		newClassName = newClassName.replace(classNameToRemove,"");
	}
	obj.className = newClassName;
}


function cacheImages() {
	if (is.ns4) nsRedirect();
	// one useful assumption:  the index of an image within the page will not change during the page's lifetime.  ie no new images will be created in the Dom.  so if you actually start doing this type of stuff, expect to see bugs with this script. As of the writing of this comment though, this script does not use this assumption
	if (!is.ns4) {
		var index = 0;
		for (i=0; i<document.images.length; i++) {
			var im = document.images[i];
			if (im.getAttribute("overimage")) {
				// this array will have very large gaps in it. 
				imCache[++index] = new Array(2);

				imCache[index]["over"] = new Image(); 
				imCache[index]["over"].src = im.getAttribute('overimage')
				imCache[index]["off"] = new Image(); 
				// since this is only run onload, we can assume that the src at runtime will be the src as specified in the html
				imCache[index]["off"].src = im.getAttribute("src");

				eval("im.onmouseover = function() {this.src =imCache["+index+"]['over'].src;}");
				eval("im.onmouseout = function() {this.src =imCache["+index+"]['off'].src;}");
			}
		}
	}
}
// this is needed to explicitly setup rollovers for type="image" buttons.  these buttons are not well reflected in the DOM, so they must call this function individually, passing themselves in as a parameter, as 'this'
function setupButtonRollover(elt) {
	if (elt.getAttribute("overimage") ) {			
		// attach the onmouseover and onmouseout, using overimage and src attributes. 
		eval("elt.onmouseover = function() {this.src ='"+elt.getAttribute('overimage')+"'}");
		eval("elt.onmouseout = function() {this.src ='"+elt.getAttribute('src')+"'}");
		// strip out setupButtonRollover from the onload, or else it'll load with every mouseover and mouseout
		eval("elt.onload=function(){}");
	}
}


var imCache = new Array();
var mcp; 

function init() {
	cacheImages();
	mcp = new MenuManager();
}
window.onload=init;

