var cms_map_areas = new Array();
cms_map_areas[0] = new Array('map/area5.gif','technico-commercial-eismo-blotzheim-7.html',			'SIEGE<br>Tél. : 03 89 68 45 66',	'66,111,73,93,90,92,101,99,122,81,133,84,138,99,125,107,121,146,118,157,137,166,115,176,114,197,59,181');
cms_map_areas[1] = new Array('map/area1.gif','technico-commercial-eismo-nord-4.html',						'M. Sébastien DEGARDIN<br>Tél. portable : 06 85 71 25 14','90,38,113,24,113,6,133,3,159,23,143,52,115,48,101,57');
cms_map_areas[2] = new Array('map/area2.gif','technico-commercial-eismo-bretagne-loire-5.html',	'M. Philippe BEAUGE<br>Tél. portable : 06 85 71 25 10', 	'55,36,94,42,103,70,123,83,101,99,75,94,73,110,64,111,42,87,8,72,8,62,30,55,60,57');
cms_map_areas[3] = new Array('map/area3.gif','technico-commercial-eismo-blotzheim-7.html',			'SIEGE<br>Tél. : 03 89 68 45 66', 												'100,57,114,46,143,51,140,64,132,83,121,82,102,70');
cms_map_areas[4] = new Array('map/area9.gif','technico-commercial-eismo-blotzheim-7.html',			'SIEGE<br>Tél. : 03 89 68 45 66', 												'207,48,223,51,213,82,206,83,205,74,209,55');
cms_map_areas[5] = new Array('map/area4.gif','technico-commercial-eismo-nord-est-8.html',				'M. Alain ZIMMERMANN<br>Tél. portable : 06 08 78 09 67', 	'159,24,206,46,205,84,185,107,138,100,131,82,143,51');
cms_map_areas[6] = new Array('map/area6.gif','technico-commercial-eismo-rhone-alpes-18.html',			'M. Cédric DOUCHET<br>Tél. portable : 06 85 71 25 11',													'125,102,149,103,201,108,203,135,184,143,165,133,146,144,121,146,124,110');
cms_map_areas[7] = new Array('map/area7.gif','technico-commercial-eismo-paca-corse-6.html',			'M. Luc JOYON<br>Tél. portable : 06 85 71 25 12',					'122,146,152,142,164,132,184,144,199,137,216,162,192,185,156,174,139,198,115,198,114,178,135,168,118,156');
cms_map_areas[8] = new Array('map/area7.gif','technico-commercial-eismo-paca-corse-6.html',			'M. Luc JOYON<br>Tél. portable : 06 85 71 25 12',					'226,180,249,201,224,219,208,197');


var mouseX = 0;
var mouseY = 0;
var IE = document.all?true:false;
if (!IE) document.captureEvents(Event.MOUSEMOVE);
// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;

var cms_map_id = 'my_map';
var cms_map_name = 'regionmap';
var cms_map_src = '';
var cms_map_info = '';
var cms_map_width = 0;
var cms_map_height = 0;
var cms_preload_delay = 1000;

window.onload=map_init; 
function map_init() {
	
cms_map_src = document.getElementById(cms_map_id).src;
document.getElementById(cms_map_id).style.border='0';
document.getElementById(cms_map_id).style.width=document.getElementById(cms_map_id).width+'px';
document.getElementById(cms_map_id).style.height=document.getElementById(cms_map_id).height+'px';
if(!document.getElementById(cms_map_id).style.backgroundImage) document.getElementById(cms_map_id).style.backgroundImage = 'url(' + document.getElementById(cms_map_id).src + ')';	
cms_map_width = document.getElementById(cms_map_id).width;
cms_map_height = document.getElementById(cms_map_id).height;


document.getElementById(cms_map_id).setAttribute('usemap','#'+cms_map_name,0);
	var add_map = document.createElement("div");       
	
	var add_link = '';       
	var add_area = '';       
	var add_div = '';       
	var add_preload = '';       
	for (var i=0;i<cms_map_areas.length;i++){
		if(cms_map_areas[i][1])add_link = 'href="'+cms_map_areas[i][1]+'"';       
		else add_link = 'nohref="nohref"';
		add_area+= '<area shape="poly" coords="'+cms_map_areas[i][3]+'" '+add_link+' alt="" onmouseover="cms_map_show('+i+',1);" onmouseout="cms_map_show('+i+');" />';
		add_div+= '<div id="'+cms_map_name+i+'" class="cms_map_info" style="border:1px solid #aaaaaa; padding:10px; background:white; position:absolute; color:#474747; font: normal 12px Verdana,Tahoma,Arial,sans-serif; visibility:hidden; filter:alpha(opacity=70); opacity: 0.7; -moz-opacity:0.7;">'+cms_map_areas[i][2]+'</div>';	  	
		add_preload+= '<img src="'+cms_map_areas[i][0]+'" style="visibility:hidden;" />';	  	
	}
	
	add_map.innerHTML='<map name="'+cms_map_name+'">'+add_area+'</map>';
	add_map.innerHTML+=add_div;
	add_map.innerHTML+='<div style="width:1px; height:1px; overflow:hidden;" style="visibility:hidden;">'+add_preload+'</div>';
	document.body.appendChild(add_map);
	cms_map_preload();
	//setTimeout('cms_map_preload()',cms_preload_delay);	
}

function cms_map_preload(check){	
	var count=0;
	for (var i=0;i<cms_map_areas.length;i++){
	  preload = new Image();
	  preload.src = cms_map_areas[i][0];
	  //if(preload.width!=cms_map_width) {
	  if(preload.width>50) {
	  	cms_map_areas[i][5] = cms_map_areas[i][0];		
		}else{
	  	cms_map_areas[i][5] = cms_map_src;		
			count++;
		}
	}					
	
	if(count>0){
		cms_preload_delay = cms_preload_delay*3;
		setTimeout('cms_map_preload()',cms_preload_delay);	
	}
}

function cms_map_show(id,show){
	if(show){		
		cms_map_info = cms_map_name+id;
		document.getElementById(cms_map_id).src=cms_map_areas[id][5];	
		//document.getElementById(cms_map_id).width=cms_map_width;	
		//document.getElementById(cms_map_id).height=cms_map_height;	
		document.getElementById(cms_map_info).style.left = (mouseX-120)+'px'; 
		document.getElementById(cms_map_info).style.top = (mouseY+22)+'px'; 
		document.getElementById(cms_map_info).style.visibility = 'visible';
	}else{	
		cms_map_info = '';
		document.getElementById(cms_map_id).src=cms_map_src;
		document.getElementById(cms_map_name+id).style.visibility = 'hidden';
	}
	
	return true;	
}


function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    mouseX = event.clientX + document.documentElement.scrollLeft;
    mouseY = event.clientY + document.documentElement.scrollTop;    
  } else {  // grab the x-y pos.s if browser is NS
    mouseX = e.pageX;
    mouseY = e.pageY;
  }  
  // catch possible negative values in NS4
  if (mouseX < 0){mouseX = 0}
  if (mouseY < 0){mouseY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  
  if(cms_map_info){
		document.getElementById(cms_map_info).style.left = (mouseX-120)+'px'; 
		document.getElementById(cms_map_info).style.top = (mouseY+22)+'px';   	
  }
    
  return true
}
