var xmlHttp;
var avt0 = "#CB2929";
var avt50 = "#E98213";
var avt100 = "#2BB028";


//Fonction Apercu

function closeApercu(element,bg,dest) {
   document.getElementById(dest).src = '';
   document.getElementById(bg).style.display = "none";
   document.getElementById(dest).style.display = "none";
}

function closeApercuPrint(element,bg,dest) {
   parent.document.getElementById(dest).src = '';
   parent.document.getElementById(dest).style.position = "absolute";
   parent.document.getElementById(bg).style.display = "none";
   parent.document.getElementById(dest).style.display = "none";
}

//function viewApercu(element,bg,dest,url,champ_id,level) {
function viewApercu(element,bg,dest,url) {
   document.getElementById(dest).src = url;
   
	document.getElementById(bg).style.display = "inline";
	document.getElementById(dest).style.display = "inline";
	
	var nsv=document.layers;
	var iev=document.all;
	if(!iev)var mov=document.getElementById;
	var MouseX=0;
	var MouseY=0;
	var ScrollX=0;
	var ScrollY=0;
	var pageHeight=0;
	var pageWidth=0;
	
	if(nsv){
		ScrollX=window.pageXOffset;
		ScrollY=window.pageYOffset;
		pageHeight = window.innerHeight;
		pageWidth = window.innerWidth;
	}else{
		if(document.documentElement.scrollLeft)
			ScrollX=document.documentElement.scrollLeft;
		else ScrollX=document.body.scrollLeft;
		if(document.documentElement.scrollTop)
			ScrollY=document.documentElement.scrollTop;
		else ScrollY=document.body.scrollTop;
		if(document.documentElement.clientHeight)
			pageHeight = document.body.clientHeight;
		else pageHeight=document.documentElement.clientHeight;
		if(document.documentElement.clientWidth)
			pageWidth = document.body.clientWidth;
		else pageWidth=document.documentElement.clientWidth;
	}
	
	screenX = window.screen.availWidth;
	screenY = window.screen.availHeight;
	elementHeight = document.getElementById(dest).style.height;
	elementWidth = document.getElementById(dest).style.width;
	
	
	//document.getElementById(bg).style.top = Math.round(ScrollY) + "px";
	document.getElementById(bg).style.top ="0px";
	document.getElementById(bg).style.left = Math.round(ScrollX) + "px";
	if (pageHeight > screenY) {
		document.getElementById(bg).style.height = Math.round(pageHeight) + "px";
	} else {
		document.getElementById(bg).style.height = Math.round(screenY) + "px";
	}
	document.getElementById(bg).style.width = Math.round(pageWidth) + "px";
	
	//document.getElementById(dest).style.top = Math.round(ScrollY + ((screenY - elementHeight)/4)) + "px";
	document.getElementById(dest).style.top = Math.round(ScrollY + 75) + "px";
	document.getElementById(dest).style.left = Math.round(ScrollX + ((pageWidth - elementWidth)/2)) + "px";
	
	
   if (document.all) {
      document.getElementById(dest).style.position = "absolute";
   } else {
      document.getElementById(dest).style.position = "absolute";
   }
	
}

//Fonction centrage d'un div
/*
function centerElement(element,elementcalc) {
   if (document.scrollTop) {
      document.getElementById(element).style.top = document.scrollTop + (document.getElementById(elementcalc).offsetHeight / 2) - (document.getElementById(elementcalc).offsetHeight / 2.5);
   } else {
      document.getElementById(element).style.top = document.body.scrollTop + (document.getElementById(elementcalc).offsetHeight / 2) - (document.getElementById(elementcalc).offsetHeight / 2.5);
   }
   if (document.width) {
      document.getElementById(element).style.left = (document.width / 2) - (document.getElementById(elementcalc).offsetWidth / 2) - 20;
   } else {
      document.getElementById(element).style.left = (document.body.scrollWidth / 2) - (document.getElementById(elementcalc).offsetWidth / 2) - 20;
   }
}
*/

function centerElement(element,elementcalc) {
	
	var nsv=document.layers;
	var iev=document.all;
	if(!iev)var mov=document.getElementById;
	var MouseX=0;
	var MouseY=0;
	var ScrollX=0;
	var ScrollY=0;
	var pageHeight=0;
	var pageWidth=0;
	
	if(nsv){
		ScrollX=window.pageXOffset;
		ScrollY=window.pageYOffset;
		pageHeight = window.innerHeight;
		pageWidth = window.innerWidth;
	}else{
		if(document.documentElement.scrollLeft)
			ScrollX=document.documentElement.scrollLeft;
		else ScrollX=document.body.scrollLeft;
		if(document.documentElement.scrollTop)
			ScrollY=document.documentElement.scrollTop;
		else ScrollY=document.body.scrollTop;
		if(document.documentElement.clientHeight)
			pageHeight = document.body.clientHeight;
		else pageHeight=document.documentElement.clientHeight;
		if(document.documentElement.clientWidth)
			pageWidth = document.body.clientWidth;
		else pageWidth=document.documentElement.clientWidth;
	}
	
	screenX = window.screen.availWidth;
	screenY = window.screen.availHeight;
	elementHeight = document.getElementById(element).offsetHeight;
	elementWidth = document.getElementById(element).offsetWidth;
	
	
	document.getElementById(element).style.top = Math.round(ScrollY + ((screenY - elementHeight)/3)) + "px";
	document.getElementById(element).style.left = Math.round(ScrollX + ((pageWidth - elementWidth)/2)) + "px";
	
	
   if (document.all) {
      document.getElementById(element).style.position = "absolute";
   } else {
      document.getElementById(element).style.position = "absolute";
   }
	
}


//-----------------------------------------------------
//Fonction de communication globale
//-----------------------------------------------------
function GetXmlHttpObject(handler)
{ 
var objXmlHttp=null

if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera") 
return 
}
if (navigator.userAgent.indexOf("MSIE")>=0)
{ 
var strName="Msxml2.XMLHTTP"
if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
{
strName="Microsoft.XMLHTTP"
} 
try
{ 
objXmlHttp=new ActiveXObject(strName)
objXmlHttp.onreadystatechange=handler 
return objXmlHttp
} 
catch(e)
{ 
alert("Error. Scripting for ActiveX might be disabled") 
return 
} 
} 
if (navigator.userAgent.indexOf("Mozilla")>=0)
{
objXmlHttp=new XMLHttpRequest()
objXmlHttp.onload=handler
objXmlHttp.onerror=handler 
return objXmlHttp
}
} 
