// JavaScript Document

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function loadPage(url,cible)
{
	//Changement du contenu
	var xhr_object = null; 
	document.getElementById(cible).innerHTML = '<center><img src="/img-le-roannais/loading.gif"></center>';
	document.getElementById(cible).style.visibility = 'visible';
	
	if(window.XMLHttpRequest) // Firefox 
	   xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur 
	   alert("Votre navigateur ne supporte pas les fonctionnalités avancées du site..."); 
	   return; 
	} 
	xhr_object.open("GET", url, true);
	xhr_object.onreadystatechange = function() 
	{ 
	   if(xhr_object.readyState == 4)
	   {
	   		document.getElementById(cible).innerHTML = xhr_object.responseText;
			document.getElementById(cible).style.visibility = 'visible';
		}
	} 
	xhr_object.send(null); 
}

function affaideimg(obj,text) {	
	var objdivWidth=200;
	
	objdiv.style.display='none';
	objdiv.style.position='absolute';
	objdiv.style.border='1px solid #FFFFFF';
	objdiv.style.background='#FFFFFF';
	objdiv.style.color="#EE842E";
	objdiv.innerHTML="Chargement...";
	var imgzoom = document.createElement('IMG');
	document.body.appendChild (objdiv);	
	obj.onmouseout=function() {obj.onmousemove='';document.body.removeChild (objdiv);}
	obj.onmousemove=function(e) {
		var y=document.documentElement.scrollTop;
		var x=document.documentElement.scrollLeft;
		objdiv.y=y;
		objdiv.x=x;
		if (e) {
			objdiv.ey=e.clientY;
			objdiv.ex=e.clientX;
			x+=e.clientX;
			y+=e.clientY;
		}
		else {
			objdiv.ey=event.y;
			objdiv.ex=event.x;
			x+=event.x;
			y+=event.y;
		}
		objdiv.style.top=y+'px';
		//objdiv.style.top=(y-(objdiv.offsetHeight/2))+'px';
		//(x > parseInt(screen.width)/2) ? objdiv.style.left=(x-objdivWidth)+"px" : objdiv.style.left=(x+20)+"px";	
		//objdiv.innerHTML=x+'/'+screen.width+' - '+y;
		objdiv.style.left=(x+20)+"px";
		objdiv.style.display=''	
	}
	//document.getElementById("imgzoom").onload=function() {
	imgzoom.onload=function() {
		objdiv.innerHTML="";
		objdiv.appendChild(imgzoom);		
		//alert(objdiv.ey);
		//objdiv.style.top=((objdiv.ey+document.documentElement.scrollTop)-(objdiv.offsetHeight/2))+'px';//
	}
	imgzoom.src=text;
}