if (typeof MM_preloadImages != 'function') {
	function MM_preloadImages() { //v3.0
	 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
}

function MapHover() {
	var targetID = this.parentNode.targetID;
	if(targetID && this.swapImg) {
		document.getElementById(targetID).src = this.swapImg;
	}
	/*Check for syncronized link and highlight it too */
	if(this.syncLink) {
		var linked = document.getElementById(this.syncLink);
		linked.className = linked.className + " syncMap";
	}
}

function MapOut() {
	var baseImg = this.parentNode.baseImg;
	var targetID = this.parentNode.targetID;
	if(targetID && baseImg) {
		document.getElementById(targetID).src = baseImg;
	}
	/*Check for syncronized link and un-highlight it too */
	if(this.syncLink) {
		var linked = document.getElementById(this.syncLink);
		linked.className = linked.className.replace("syncMap"," ");
	}

}

function SyncLinkMapHover() {
	var imgTag = document.getElementById(document.getElementById(this.parentNode.syncMap).targetID);
	var swapImg = document.getElementById(this.id.slice(1)).swapImg;
	imgTag.src = swapImg;
}

function SyncLinkMapOut() {
	var map = document.getElementById(this.parentNode.syncMap);
	var imgTag = document.getElementById(map.targetID);
	imgTag.src = map.baseImg;
}

/* This function is called onload of page and requires ID's be associated with the IMG, MAP, and AREAS in the MAP to work, and it takes at least 3 parameters:
	1) the ID of the MAP tag to link areas to images
	2) the ID of the IMG tag associated to the MAP
	3) One or more image paths that must end (prior to the file type .gif/.jpg etc.) in the ID of the AREA tag to associate with the image  */
function InitMapHover(mapID, imgID) {
	var arg = InitMapHover.arguments;
	var map = document.getElementById(mapID);
	var img = document.getElementById(imgID);
	
	/* Check for at least one image path */
	if(!map || !img || !arg[2]) {
		alert("Invalid or insufficient parameters for InitMapHover() to initialize.");
		return;
	} 
	else {
		map.baseImg = img.src; /*Save base image source to the map*/
		map.targetID = img.id; /*Save base image id*/
		var swapAreas = map.getElementsByTagName('area');
		for(i = 2; i < arg.length; i++) {
			MM_preloadImages(arg[i]);
			for (j = 0; j < swapAreas.length; j++) {
				if(arg[i].match(swapAreas[j].id + ".")) {
					swapAreas[j].swapImg = arg[i];
					addEvent(swapAreas[j], 'mouseover', MapHover);
					addEvent(swapAreas[j], 'mouseout' , MapOut);
				}
			}			
		}
	}		
}

/*This function syncronizes seperate ANCHOR tags to operate in conjuction with AREA tags of a map that have
been initialized with InitMapHover. It requires each ANCHOR to have an ID that equals 'a'+ the associate AREA ID
(e.g. if AREA id="OneArea" then the anchor to associate must have id="aOneArea"). It takes two parameters:
	1) The ID of the MAP tag with AREAS to associate 
	2) The ID of a container to the ANCHOR tags to associate
Any styling changes to the ANCHOR tages for the hover should be styled with a class named syncMap that matches color
of the a:hover style for the link*/
function InitMapLinksSync(mapID, anchorContainerID) {
	var map = document.getElementById(mapID);
	var aGrp = document.getElementById(anchorContainerID);
	if(!map || !aGrp) {
		alert("Map or Anchor Link group not found!");
		return;
	} 
	else {
		aGrp.syncMap = map.id;
		var areas = map.getElementsByTagName('area');
		var aTags = aGrp.getElementsByTagName('a');
		for(i = 0; i < aTags.length; i++) {
			for(j = 0; j < areas.length; j++) {
				if(aTags[i].id.match('a'+areas[j].id) && (aTags[i].length == areas[j].length)) {
					areas[j].syncLink = aTags[i].id;
					addEvent(aTags[i], 'mouseover', SyncLinkMapHover);
					addEvent(aTags[i], 'mouseout', SyncLinkMapOut);
				}
			}
		}
	}
}
