var oPopUp = null;

/////////////////////////////////////////////////////////////////////////////////
	function getLeft(MyObject)
    {
		if (MyObject.offsetParent)
			return (MyObject.offsetLeft + getLeft(MyObject.offsetParent));
		else 
			return (MyObject.offsetLeft);
    } 

/////////////////////////////////////////////////////////////////////////////////
	function getTop(MyObject)
    {
		if (MyObject.offsetParent)
			return (MyObject.offsetTop + getTop(MyObject.offsetParent));
		else
			return (MyObject.offsetTop);
    }

/////////////////////////////////////////////////////////////////////////////////
function MM_openBrWindow(theURL,winName,features) 
{
	oPopUp = window.open(theURL,winName,features);
	if (oPopUp != null)
		oPopUp.focus();
}

/////////////////////////////////////////////////////////////////////////////////
function affichePopUp(id, bAffiche)
{
	var oObj =  document.getElementById(id);
	var nL = parseInt(oObj.style.width);
	var nH = parseInt(oObj.style.height);
	var nX = document.body.scrollLeft + (window.screen.width - nL)/ 2;
	var nY = (document.body.scrollTop + (window.screen.height)/3)-(oObj.style.height/2);

	//oStyle.posLeft = nX;
	//oObj.top = String(nY) + "px";
	oObj.style.top= String(nY) + "px";						
	if (bAffiche)
		oObj.style.visibility =  "visible";
	else
		oObj.style.visibility =  "hidden";
		
}

	function IEcompattest()
	{
		return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
	}
	
/*/////////////////////////////////////////////////////////////////////////////////
function affichePopUp2(id, bAffiche)
{
	var oObj =  document.getElementById(id);
	var nY;
	
	if (String(IEcompattest().scrollTop) != 'undefined')
		nY = IEcompattest().scrollTop + window.screen.height / 4;
	else
		nY = pageYOffset + window.screen.height / 4;
		
	oObj.style.top = String(nY) + "px";
							
	if (bAffiche)
		oObj.style.visibility =  "visible";
	else
		oObj.style.visibility =  "hidden";	
}
*/

function affichePopUpBis(id, bAffiche,evt)
{
	if (evt != null)
	{
		var oObj;
		/*var msg;
		msg = "<table width=\"150\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" bgcolor=\"#E7E7E7\">";
		msg = msg + "<tr height=\"25\"><td align=\"center\" >Veuillez patienter ...</td></tr>";
		msg = msg + "<tr height=\"25\"><td align=\"center\" ><img src=\"/images/divers/attente.gif\"/></td></tr>";
		msg = msg + "</table>";
	*/
		var xfenetre,yfenetre,xpage,ypage;
		if (document.layers) 
		{
			alert('layer');
			oObj=document.layers['patientez'];
			xpage = evt.pageX ; ypage  = evt.pageY;
			xfenetre = xpage ;yfenetre = ypage ;
			oObj.style.top= (document.body.scrollTop + (window.screen.height)/3)-(oObj.style.height/2);
		} 
		else if (document.all) 
		{
			oObj=document.all['patientez'];
			xfenetre = evt.clientX ;yfenetre = evt.clientY ;		
			xpage=xfenetre ; ypage=yfenetre	;
			oObj.style.top= (document.body.scrollTop + (window.screen.height)/3)-(oObj.style.height/2);	
			if (document.body.scrollLeft) xpage = xfenetre + document.body.scrollLeft ; 
			if (document.body.scrollTop) ypage = yfenetre + document.body.scrollTop;
			
			
		} 
		else if (document.getElementById) 
		{
		
			oObj=document.getElementById('patientez');
			oObj.style.top= (document.body.scrollTop + (window.screen.height)/3)-(oObj.style.height/2);
			xfenetre = evt.clientX;
			yfenetre = evt.clientY;
			xpage=xfenetre;
			ypage=yfenetre;
			if(evt.pageX) xpage = evt.pageX ;
			if(evt.pageY) ypage  = evt.pageY ;
		}
	
		if (ypage > 300)
			ypage = ypage - 100;
		
		//oObj.style.top = String(ypage) + "px";
		
		//oObj.innerHTML = msg;
								
		if (bAffiche)
			oObj.style.visibility =  "visible";
		else
			oObj.style.visibility =  "hidden";
	}
}

/////////////////////////////////////////////////////////////////////////////////
	function convertPrix(fPrix)
	{
		var sPrix;
		var nIndexPoint;
		var i;
		var nZeroManquant;
		
		sPrix = String(Math.round(fPrix * 100) / 100);
		nIndexPoint = sPrix.indexOf(".");
		if (nIndexPoint != -1)
			sPrix = sPrix.substring(0, nIndexPoint + 3);
		else
			sPrix = sPrix + ".";
			
		nZeroManquant = 3 - (sPrix.length - sPrix.indexOf("."));
		for (i = 1 ; i <= nZeroManquant ; i++)
			sPrix = sPrix + "0";
		
		return sPrix;
	}
	
/////////////////////////////////////////////////////////////////////////////////
	function getIndexTab(tab,nValeur)
	{
		var bTrouve;
		var i;
		
		i = 0;
		bTrouve = false;
		while (i < tab.length && !bTrouve)
		{
			if (tab[i] == nValeur)
				bTrouve = true;
			else
				i++;
		}
		
		if (bTrouve)
			return i;
		else
			return -1;
	}

/////////////////////////////////////////////////////////////////////////////////
	function getUrl(sChaine)
	{
		var nPos = 0, nOcc = 1;
		while (nOcc <= 3)
		{
			nPos = sChaine.indexOf('/', nPos + 1);
			nOcc++;
		}
		return sChaine.substr(nPos,sChaine.length - nPos)
	}
	
/////////////////////////////////////////////////////////////////////////////////
function getServeur(sChaine)
{
	return sChaine.substring(7,sChaine.indexOf('/',7));
}