//------
//  Scriptable Image Maps by Danny Goodman (www.dannyg.com)
//  A bonus recipe for readers of O'Reilly's
//    "JavaScript & DHTML Cookbook"
//  This recipe first published at O'Reilly Network (www.oreillynet.com)
//  For full implementation notes, read the article.
//------
// @TL@ : Avril 2008 : onload auto de initMaps('Map_Bottom')
//  Pas de Down ...
//------

function Roll_Over_Init() {
	if (document.getElementById) {
		var mapIds = Roll_Over_Init.arguments;			// pass string IDs of containing map elements
		
		var i, j, area, areas;
		
		for (i = 0; i < mapIds.length; i++) {

			areas = document.getElementById( mapIds[ i ] ).getElementsByTagName( "area" );

			//alert("arg=" + areas.length);

			for (j = 0; j < areas.length; j++) {	// loop thru img elements
				area = areas[ j ];
				area.onmousedown = imgSwap;			// set event handlers
				area.onmouseout  = imgSwap;
				area.onmouseover = imgSwap;
				area.onmouseup   = imgSwap;
				
				if ( area.shape == "poly" ) {
					//alert("->" + area.alt );
				}
			}
		}
	}
}

function imgSwap() {
alert("ok");
}

// image swapping event handling
function imgSwap(evt) {
	evt = (evt) ? evt : event;
	var elem = (evt.target) ? evt.target : evt.srcElement;
	var imgClass = elem.parentNode.name;
	
	var shape = elem.shape.substring( 0, 4 );
	var coordr;

	if ( shape == "poly" ) {
		shape = "POLY";
	}	

	if ( shape == "POLY" ) {
	    var Attr_coordr = elem.getAttribute("coordr")
		coordr = Attr_coordr.split(",");
	} else {
		coordr = elem.coords.split(",");
	}
  
	var clipVal = "rect(" + coordr[1] + "px " +
							coordr[2] + "px " +
							coordr[3] + "px " +
							coordr[0] + "px)";
	var imgStyle;

	switch (evt.type) {
		case "mouseout" :
			document.getElementById(imgClass + "_over").style.visibility = "hidden";
			//document.getElementById(imgClass + "Down").style.visibility = "hidden";
			break;
		case "mousedown" :
			//imgStyle = document.getElementById(imgClass + "Down").style;
			//imgStyle.clip = clipVal;
			//imgStyle.visibility = "visible";
			break;
		case "mouseover" :
			//alert(shape + " = " + clipVal);
			imgStyle = document.getElementById(imgClass + "_over").style;
			imgStyle.clip = clipVal;
			imgStyle.visibility = "visible";
			break
		case "mouseup" :
			//document.getElementById(imgClass + "Down").style.visibility = "hidden";
			// guarantee click in IE
			if (elem.click) {
				elem.click();
			}
			break;
	}

	evt.cancelBubble = true;
	return false;
}

function addLoadEvent( func ) {
	var oldonload = window.onload;
  
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
		if (oldonload) {
			oldonload();
		}
		func();
    }
  }
}

//addLoadEvent( Maps_Init ); 

var Previous_Onload = (window.onload) ? window.onload : function(){};

window.onload = function() { 
	//Previous_Onload();
	Roll_Over_Init('menubarMap');
}

