<!--<SCRIPT Language=Javascript>-->
//****************************************************************//
// Objet 'Browser'servant à identifier le navigateur utilisé
//****************************************************************//
function CheckBrowser() 
{
	var b = navigator.appName
	if (b=="Netscape") this.b = "ns"
	else if (b=="Microsoft Internet Explorer") this.b = "ie"
	else this.b = b
	this.v = parseInt(navigator.appVersion)
	this.ns = (this.b=="ns" && this.v>=4)
	this.ns4 = (this.b=="ns" && this.v==4)
	this.ns5 = (this.b=="ns" && this.v==5)
	this.ie = (this.b=="ie" && this.v>=4)
	this.ie4 = (navigator.userAgent.indexOf('MSIE 4')>0)
	this.ie5 = (navigator.userAgent.indexOf('MSIE 5')>0)
	if (this.ie5) this.v = 5
	this.min = (this.ns||this.ie)
}

// automatically create the "is" object
BrowserIs = new CheckBrowser();

//***************************************************************//
// Fonctions nécessaire à la capture de la position de la souris //
//***************************************************************//
function init() {
	document.onmousedown = mouseDown
	document.onmousemove = mouseMove
	document.onmouseup = mouseUp
	if (BrowserIs.ns) document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
}

function mouseDown(e) {
	if ((BrowserIs.ns && e.which!=1) || (BrowserIs.ie && event.button!=1)) return true
	var x = (BrowserIs.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (BrowserIs.ns)? e.pageY : event.y+document.body.scrollTop
	
	document.mouseDownX = x;
	document.mouseDownY = y;
	
	return true
}

function mouseMove(e) {
	var x = (BrowserIs.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (BrowserIs.ns)? e.pageY : event.y+document.body.scrollTop
	
	document.mouseX = x;
	document.mouseY = y;
	
	return true
}

function mouseUp(e) {
	var x = (BrowserIs.ns)? e.pageX : event.x+document.body.scrollLeft
	var y = (BrowserIs.ns)? e.pageY : event.y+document.body.scrollTop
	
	document.mouseDownX = null;
	document.mouseDownY = null;

	document.mouseUpX = x;
	document.mouseUpY = y;
	
	return true
}

//*****************************************************************//

//*****************************************************************//
//	Fonctions utiles aux fenêtres								   //
//*****************************************************************//
function ibGenerateUniqueID(sPrefix)
{
	var iUniqueID = 0; //= document.uniqueID;
	var iIDSeeker = 0;
	
	if (iUniqueID == 0)
	{
		while (iUniqueID != undefined)
		{
			iIDSeeker++;
			iUniqueID = eval("document." + sPrefix + iIDSeeker);
		}
		iUniqueID = sPrefix + iIDSeeker;
	}
	
	return (iUniqueID);
}

// -----------------------------------------------
// Affiche un spacer
// -----------------------------------------------
function ibMakeSpacer(iWidth,iHeight)
{
	var sSpacer;
	
	sSpacer = "<IMG SRC=\"./inc/images/spacer.gif\" width=" + iWidth + " height=" + iHeight + " border=0>";
	return sSpacer;
}

//Définition de la class ibWindow
function ibWindow(sName,oContainer)
{
	//Déclaration des variables membres
	this.v_iUniqueID = ibGenerateUniqueID("ibWin_");
	this.v_iWidth = 150;
	this.v_iHeight = 50;
	this.v_iPosX = 0;
	this.v_iPosY = 0;
	this.v_sURL = "";
	this.v_sName = sName;
	this.v_sCaption = sName;
	this.v_bMinButton = true;
	this.v_bMaxButton = true;
	this.v_bResizable = true;
	this.v_bActive = true;
	this.v_iBorderWidth = 1;
	this.v_sBorderColor = "black";
	this.v_sBorderStyle = "solid";
	this.v_sTitleBarBgColor = "";
	this.v_sTitleBarUnderlineColor = "";
	this.v_iTitleBarHeight = 20;
	this.v_oContainer = oContainer; //Où le code de la fenêtre sera contenu
	this.v_oParent = null;   // La fenêtre parent de cette fenêtre
	
	//Zone d'action
	this.v_zoneDrag = new ibZone(this.v_iPosX,this.v_iPosY,this.v_iWidth - 100,this.v_iTitleBarHeight);
	
	//Laisse une référence de l'objet dans le document
	eval("document." + this.v_iUniqueID + " = this");
		
	//Déclaration des methodes de l'objet
	if (typeof(_ibWindow_prototype_called) == 'undefined')
	{
		_ibWindow_prototype_called = true;
		
		//------------- GET/SET pour les variables ------------//
		//----------  ID
		ibWindow.prototype.m_GetID = m_GetID;
		
		//----------  Name
		ibWindow.prototype.m_GetName = m_GetName;
		ibWindow.prototype.m_SetName = m_SetName;
		
		//---------- Width
		ibWindow.prototype.m_GetWidth = m_GetWidth;
		ibWindow.prototype.m_SetWidth = m_SetWidth;
		
		//----------  Height
		ibWindow.prototype.m_GetHeight = m_GetHeight;
		ibWindow.prototype.m_SetHeight = m_SetHeight;
		
		//----------  Position
		ibWindow.prototype.m_SetPos = m_SetPos;
		ibWindow.prototype.m_GetPosX = m_GetPosX;
		ibWindow.prototype.m_GetPosY = m_GetPosY;
		
		//----------  URL
		ibWindow.prototype.m_GetURL = m_GetURL;
		ibWindow.prototype.m_SetURL = m_SetURL;
		
		//----------  Caption
		ibWindow.prototype.m_GetCaption = m_GetCaption;
		ibWindow.prototype.m_SetCaption = m_SetCaption;
		
		//----------  MinButton
		ibWindow.prototype.m_GetMinButton = m_GetMinButton;
		ibWindow.prototype.m_SetMinButton = m_SetMinButton;
		
		//----------  MaxButton
		ibWindow.prototype.m_GetMaxButton = m_GetMaxButton;
		ibWindow.prototype.m_SetMaxButton = m_SetMaxButton;
		
		//----------  Resizable
		ibWindow.prototype.m_GetResizable = m_GetResizable;
		ibWindow.prototype.m_SetResizable = m_SetResizable;
		
		//----------  Parent
		ibWindow.prototype.m_GetParent = m_GetParent;
		ibWindow.prototype.m_SetParent = m_SetParent;
		
		//----------  Border
		ibWindow.prototype.m_GetBorderWidth = m_GetBorderWidth;
		ibWindow.prototype.m_SetBorderWidth = m_SetBorderWidth;
		ibWindow.prototype.m_GetBorderColor = m_GetBorderColor;
		ibWindow.prototype.m_SetBorderColor = m_SetBorderColor;
		ibWindow.prototype.m_GetBorderStyle = m_GetBorderStyle;
		ibWindow.prototype.m_SetBorderStyle = m_SetBorderStyle;
		
		ibWindow.prototype.m_SetActive = m_SetActive;
		ibWindow.prototype.m_SetTitleBarColors = m_SetTitleBarColors;
		
		//------------ Methodes générales -----------------------//
		ibWindow.prototype.m_RefreshWindowElement = m_RefreshWindowElement;
		ibWindow.prototype.m_GetWindowReference = m_GetWindowReference;
		ibWindow.prototype.m_CenterWindow = m_CenterWindow;
		ibWindow.prototype.m_Draw = m_Draw;
		ibWindow.prototype.m_DrawTitleBar = m_DrawTitleBar;
		ibWindow.prototype.m_DrawContent = m_DrawContent;
		ibWindow.prototype.m_DrawStatusBar = m_DrawStatusBar;
		ibWindow.prototype.m_CloseWindow = m_CloseWindow;
		
		//------------- Évènement ------------------------------//
		ibWindow.prototype.e_onMouseMove = e_onMouseMove;
		ibWindow.prototype.e_onMouseOut = e_onMouseOut;
		ibWindow.prototype.e_onMouseDown = e_onMouseDown;
		ibWindow.prototype.e_onMouseUp = e_onMouseUp;
	}

	// ---------- DEFINITION DES METHODES DE LA CLASSE -------------
	
	// Fonction Get ------------------------------------------------
	function m_GetID()
	{return (this.v_iUniqueID);}
	
	function m_GetName()
	{return (this.v_sName);}
	
	function m_GetWidth()
	{return (this.v_iWidth);}
	
	function m_GetHeight()
	{return (this.v_iHeight);}
	
	function m_GetURL()
	{return (this.v_sURL);}
	
	function m_GetCaption()
	{return (this.v_sCaption);}
	
	function m_GetMinButton()
	{return (this.v_bMinButton);}
	
	function m_GetMaxButton()
	{return (this.v_bMaxButton);}
	
	function m_GetResizable()
	{return (this.v_bResizable);}
	
	function m_GetPosX()
	{return (this.v_iPosX);}
	
	function m_GetPosY()
	{return (this.v_iPosY);}
	
	function m_GetParent()
	{return (this.v_oParent);}
	
	function m_GetBorderWidth()
	{return (this.v_iBorderWidth);}
	
	function m_GetBorderColor()
	{return (this.v_sBorderColor);}
	
	function m_GetBorderStyle()
	{return (this.v_sBorderStyle);}
	
	// Fonction Set ------------------------------------------
	function m_SetName(sName)
	{this.v_sName = sName;}
	
	function m_SetWidth(iWidth)
	{this.v_iWidth = iWidth;}
	
	function m_SetHeight(iHeight)
	{this.v_iHeight = iHeight;}
	
	function m_SetURL(sURL)
	{
		var sNewURL = new String(sURL);
		
		if (sNewURL.indexOf("?",1) < 1)
		{
			sNewURL += "?ContainerWindow=" + this.m_GetID();
		}
		else
		{
			sNewURL += "&ContainerWindow=" + this.m_GetID();
		}
		
		this.v_sURL = sNewURL;
	}
	
	function m_SetCaption(sCaption)
	{this.v_sCaption = sCaption;}
	
	function m_SetMinButton(bMinButton)
	{this.v_bMinButton = bMinButton;}
	
	function m_SetMaxButton(bMaxButton)
	{this.v_bMaxButton = bMaxButton;}
	
	function m_SetResizable(bResizable)
	{this.v_bResizable = bResizable;}
	
	function m_SetPos(x,y)
	{
		this.v_iPosX = x;
		this.v_iPosY = y;
	}
	
	function m_SetParent(oParent)
	{this.v_oParent = oParent;}
	
	function m_SetBorderWidth(iWidth)
	{this.v_iBorderWidth = iWidth;}
	
	function m_SetBorderColor(sColor)
	{this.v_sBorderColor = sColor;}
	
	function m_SetBorderStyle(sStyle)
	{this.v_sBorderStyle = sStyle;}
	
	function m_SetTitleBarColors(sBgColor,sUnderlineColor)
	{
		this.v_sTitleBarBgColor = sBgColor;
		this.v_sTitleBarUnderlineColor = sUnderlineColor;
	}
	
	function m_SetActive(bActive)
	{this.v_bActive = bActive;}
	
	//*************************************//
	//			FONCTION GÉNÉRIQUE
	//*************************************//
	
	//Rafraîchissement des éléments de la fenêtre
	function m_RefreshWindowElement()
	{
		var oWindowRef,oDivsRef;
				
		//Obtient une référence sur la fenêtre
		oWindowRef = this.m_GetWindowReference();
		
		if (oWindowRef != undefined)
		{
			//rafraichit le style de la fenêtre
			oWindowRef.style.width = this.v_iWidth;
			oWindowRef.style.height =  this.v_iHeight;
			oWindowRef.style.top = this.v_iPosY;
			oWindowRef.style.left = this.v_iPosX;
			oWindowRef.style.borderWidth = this.v_iBorderWidth;
			oWindowRef.style.borderColor = this.v_sBorderColor;
			oWindowRef.style.borderStyle = this.v_sBorderStyle;
			
			//Obtient une référence sur le titre de la fenêtre
			oDivsRef = oWindowRef.getElementsByTagName("DIV");
			
			for (var i=0;i<oDivsRef.length;i++)
			{
				switch (oDivsRef[i].id)
				{
					case "win_title_bar_lbl":
						oDivsRef[i].innerHTML = this.m_GetCaption();
				}	
			}
		}
		this.v_zoneDrag.m_SetPos(this.v_iPosX,this.v_iPosY);
		this.v_zoneDrag.m_SetDimension(this.v_iWidth - 100,this.v_iTitleBarHeight);
	}
	
	function m_CloseWindow()
	{
		var oWindowRef;
		var objRef;
				
		//Obtient une référence sur la fenêtre
		oWindowRef = this.m_GetWindowReference();
		
		objRef = eval("document." + this.v_iUniqueID)
		
		oWindowRef.innerHTML = "";
		oWindowRef.outerHTML = "";
		oWindowRef.style.visibility = "hidden";
		
		this.v_zoneDrag.m_Delete();
		
		delete objRef;
	}
	
	function m_GetWindowReference()
	{
		var oWindowRef;
		
		oWindowRef = document.getElementById(this.v_iUniqueID);
		
		return oWindowRef;
	}
	
	function m_CenterWindow()
	{
		var xPos = 0,
			yPos = 0;
		
		xPos = Math.round(screen.availWidth / 2) - (this.m_GetWidth() / 2);
		yPos = Math.round(screen.availHeight / 2) - (this.m_GetHeight() / 2);

		this.m_SetPos(xPos,yPos);
	}
	
	function m_Draw()
	{
		var oWindowRef;
		var sEvent;
				
		//Créer le contour de la fenêtre
		sEvent =  "onMouseMove=\"document." + this.m_GetID() + ".e_onMouseMove();\" ";		
		sEvent += "onMouseOut=\"document." + this.m_GetID() + ".e_onMouseOut()\" ";		
		//sEvent += "onMouseDown=\"document." + this.m_GetID() + ".e_onMouseOver()\" ";		
		
		this.v_oContainer.innerHTML += "<DIV id=\"" + this.v_iUniqueID + "\" " + sEvent + "></DIV>";
		//Obtient une référence sur la fenêtre
		oWindowRef = this.m_GetWindowReference();
		
		//Définit le style de la fenêtre
		oWindowRef.style.visibility = "visible";
		oWindowRef.style.width = this.v_iWidth;
		oWindowRef.style.height =  this.v_iHeight;
		oWindowRef.style.overflow = "hidden";
		oWindowRef.style.position = "absolute";
		oWindowRef.style.top = this.v_iPosY;
		oWindowRef.style.left = this.v_iPosX;
		oWindowRef.style.borderWidth = this.v_iBorderWidth;
		oWindowRef.style.borderColor = this.v_sBorderColor;
		oWindowRef.style.borderStyle = this.v_sBorderStyle;
		
		sWinHTML = this.m_DrawTitleBar();
		sWinHTML += this.m_DrawContent();
		sWinHTML += this.m_DrawStatusBar();
		
		oWindowRef.innerHTML = sWinHTML
	}
	
	function m_DrawTitleBar()
	{		
		var sHTML;
				
		sHTML = "<TABLE cellpadding=0 cellspacing=0 border=0 width=100%>";		
		sHTML += "<TR>";
		sHTML += "<TD>";
		sHTML += "<TABLE cellspacing=0 cellpadding=0 border=0 width=100%>";
		sHTML += "<TR bgColor=\"" + this.v_sTitleBarBgColor + "\">";
		sHTML += "<TD><div id=\"win_title_bar_lbl\" class=\"win_modal_titlebar_lbl\">" + this.m_GetCaption() + "</DIV></TD>";
		sHTML += "<TD align=right><img border=0 src=\"./inc/images/btn_win_close.gif\" onClick=\"document." + this.v_iUniqueID + ".m_CloseWindow();\"></a></TD>";
		sHTML += "</TR></TABLE>";
		sHTML += "</TD>";
		sHTML += "</TR>";
		
		sHTML += "<TR bgColor=\"" + this.v_sTitleBarUnderlineColor + "\">";
		sHTML += "<TD>" + ibMakeSpacer(this.v_iWidth - (this.v_iBorderWidth * 2),3) + "</TD>";
		sHTML += "</TR>";
		
		return(sHTML);
	}
	
	function m_DrawContent()
	{
		var sHTML
				
		sHTML = "<TR>"
		sHTML += "<TD>"
		sHTML += "<IFRAME ID=\"WindowContent" + this.m_GetID() + "\" NAME=\"WindowContent" + this.m_GetID() + "\" frameborder=\"no\" src=\"" + this.v_sURL + "\" width=" + (this.v_iWidth - (this.v_iBorderWidth * 2)) + " height=" + (this.v_iHeight - 22)+ "></IFRAME>"
		sHTML += "</TD>"
		sHTML += "</TR>"
		
		return (sHTML);
	}
	
	function m_DrawStatusBar()
	{
		var sHTML
		
		sHTML = "</TABLE>"
		
		return (sHTML);
	}
	
	function e_onMouseMove()
	{
		var oWindowRef;
		
		//Obtient une référence sur la fenêtre
		oWindowRef = this.m_GetWindowReference();
		
		if (this.v_zoneDrag.m_InZone(document.mouseX,document.mouseY))
		{
			oWindowRef.style.cursor = "move";
		}
		else
		{
			oWindowRef.style.cursor = "default";
		}
	}
	
	function e_onMouseOut()
	{
		var oWindowRef;
		
		//Obtient une référence sur la fenêtre
		oWindowRef = this.m_GetWindowReference();
		
		if (this.v_zoneDrag.m_InZone(document.mouseX,document.mouseY))
		{
			oWindowRef.style.cursor = "default";
		}
	}
	
	function e_onMouseDown()
	{
	
	}
	
	function e_onMouseUp()
	{
	}
}

//-------------------------------------------------------
// CLASSE ibZone
//-------------------------------------------------------
function ibZone(xOr,yOr,width,height)
{
	this.v_iXOr = xOr;
	this.v_iYOr = yOr;
	this.v_iXEnd = xOr + width;
	this.v_iYEnd = yOr + height;
	
	//Déclaration des methodes
	if (typeof(_ibZone_prototype_called) == 'undefined')
	{
		_ibZone_prototype_called = true;
		
		ibZone.prototype.m_SetPos		= m_SetPos;
		ibZone.prototype.m_InZone		= m_InZone;
		ibZone.prototype.m_SetDimension	= m_SetDimension;
	}
			
	function m_SetPos(x,y)
	{
		this.v_iXOr = x;
		this.v_iYOr = y;
	}
	
	function m_SetDimension(width,height)
	{
		this.v_iXEnd = this.v_iXOr + width;
		this.v_iYEnd = this.v_iYOr + height;
	}
	
	function m_InZone(xPos,yPos)
	{
		var bIn = false;
		
		if ( (xPos > this.v_iXOr)&&(xPos<(this.v_iXEnd)) )
		{
			if ( (yPos > this.v_iYOr)&&(yPos<this.v_iYEnd) )
			{
				bIn = true;
			}
		}
		
		return(bIn);
	}
}


function gf_ShowEditionWindow(URL,WindowTitle, WindowName, WindowWidth, WindowHeight)
{
	var oContainer = top.document.getElementById("FooterHTMLContent");
	var winId
	
	var oWindow = new ibWindow(WindowTitle,oContainer);
	oWindow.m_SetURL(URL);
	oWindow.m_SetTitleBarColors("#6F95B5","#B4C64E");
	oWindow.m_SetWidth(WindowWidth);
	oWindow.m_SetHeight(WindowHeight);
	oWindow.m_CenterWindow();
	oWindow.m_Draw();
	
	oWindow.m_RefreshWindowElement();
}

// -----------------------------------------------
// Affiche un message box
// -----------------------------------------------
function gf_WUI_ShowMessageBox(sTitle,sText){
	alert(sText);
/*	
	var sWinStart;
	var sWinContent;
	var sWinStop;
	var iPosX,iPosY;
	var iWidth,iHeight;
	var btn_Close;
	var oContainer = top.document.getElementById("FooterHTMLContent");
	
	iWidth = 300;
	iHeight = 50;
	iPosX = Math.round(screen.width / 2) - (iWidth / 2);
	iPosY = Math.round(screen.height / 3) - (iHeight / 2) - 50;
	
	sWinStart = gf_WUI_ShowWindowStart(sTitle,"win_modal_MessageBox",iWidth,iHeight,iPosX,iPosY);
	sWinStop = gf_WUI_ShowWindowStop();
	
	sWinContent = "<TABLE width=\"100%\" cellpadding=0 cellspacing=5 border=0>"
	sWinContent = sWinContent + "<TR>"
	sWinContent = sWinContent + "<TD align=center><DIV ID=\"win_modal_lbl\">" + sText + "</DIV></TD>"
	sWinContent = sWinContent + "</TR>"
	sWinContent = sWinContent + "<TR>"
	sWinContent = sWinContent + "<TD align=center><INPUT TYPE=\"BUTTON\" VALUE=\"  OK  \" onClick=\"gf_KillWindow('win_modal_MessageBox')\" class=\"frm_button\"></TD>"
	sWinContent = sWinContent + "</TR>"
	sWinContent = sWinContent + "</TABLE>"
	
	oContainer.InnerHTML = sWinStart + sWinContent + sWinStop;
	
	btn_Close = eval("top.btn_close_win_modal_MessageBox");
	btn_Close.src = "./inc/images/btn_win_close.gif";
*/
}

// --------------------------------------------------
// Permet de "dragger" les fenêtres
// --------------------------------------------------

function MM_findObj(n, d) { //v3.0
	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); 

	return x;
}

function MM_dragLayer(objName,x,hL,hT,hW,hH,toFront,dropBack,cU,cD,cL,cR,targL,targT,tol,dropJS,et,dragJS) { //v 3.6
  //Copyright 1998 Macromedia, Inc. All rights reserved.
  var i,j,aLayer,retVal,
	  curDrag=null,
	  NS=document.layers,
	  MZ=(!document.all && document.getElementById),
	  curLeft, 
	  curTop;
	  
  if (!document.all && !document.layers && !document.getElementById) 
	return false;
	
  retVal = true; 
  
  if(!NS && !MZ && event) 
	event.returnValue = true;
	
  if (MM_dragLayer.arguments.length > 1)
  {
    curDrag = (MZ)?document.getElementById(objName):MM_findObj(objName); 
    if (!curDrag) return false;
    if (!document.allLayers) 
    { 
		document.allLayers = new Array();
		with (document) 
			if (NS) 
			{ 
				for (i=0; i < layers.length; i++) 
					allLayers[i]=layers[i];
				for (i=0; i < allLayers.length; i++) 
					if (allLayers[i].document && allLayers[i].document.layers)
						with (allLayers[i].document) 
							for (j=0; j < layers.length; j++) 
								allLayers[allLayers.length]=layers[j];
			} 
			else if(MZ)
			{
				var mzall = getElementsByTagName("div");
				for (i=0;i < mzall.length;i++) 
					if (mzall[i].style&&mzall[i].style.position) 
						allLayers[allLayers.length]=mzall[i];
			}
			else
			{
                for (i=0;i < all.length;i++) 
					if (all[i].style&&all[i].style.position) 
						allLayers[allLayers.length]=all[i];
			}
	}
	
    curDrag.MM_dragOk=true; 
    curDrag.MM_targL=targL;
    curDrag.MM_targT=targT;
    curDrag.MM_tol=Math.pow(tol,2); 
    curDrag.MM_hLeft=hL; 
    curDrag.MM_hTop=hT;
    curDrag.MM_hWidth=hW; 
    curDrag.MM_hHeight=hH; 
    curDrag.MM_toFront=toFront;
    curDrag.MM_dropBack=dropBack; 
    curDrag.MM_dropJS=dropJS;
    curDrag.MM_everyTime=et; 
    curDrag.MM_dragJS=dragJS;
    curDrag.MM_oldZ = (NS)?curDrag.zIndex:curDrag.style.zIndex;
    curLeft= (NS)?curDrag.left:(MZ)?curDrag.style.left.replace("px","")/1:curDrag.style.pixelLeft;
    curDrag.MM_startL = curLeft;
    curTop = (NS)?curDrag.top:(MZ)?curDrag.style.top.replace("px","")/1:curDrag.style.pixelTop;
    curDrag.MM_startT = curTop;
    curDrag.MM_bL=(cL<0)?null:curLeft-cL; 
    curDrag.MM_bT=(cU<0)?null:curTop -cU;
    curDrag.MM_bR=(cR<0)?null:curLeft+cR; 
    curDrag.MM_bB=(cD<0)?null:curTop +cD;
    curDrag.MM_LEFTRIGHT=0; 
    curDrag.MM_UPDOWN=0; 
    curDrag.MM_SNAPPED=false; //use in your JS!
    document.onmousedown = MM_dragLayer; 
    document.onmouseup = MM_dragLayer;
    if (NS||MZ) 
		document.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
	}
	else 
	{
		var theEvent = ((NS||MZ)?objName.type:event.type);
		if (theEvent == 'mousedown') 
		{
			var mouseX = (NS||MZ)?objName.pageX : event.clientX + document.body.scrollLeft;
			var mouseY = (NS||MZ)?objName.pageY : event.clientY + document.body.scrollTop;
			var maxDragZ=null; document.MM_maxZ = 0;
			for (i=0; i < document.allLayers.length; i++) 
			{ 
				aLayer = document.allLayers[i];
				var aLayerZ = (NS)?aLayer.zIndex:aLayer.style.zIndex/1;
				if (aLayerZ > document.MM_maxZ) 
					document.MM_maxZ = aLayerZ;
				var isVisible = (((NS)?aLayer.visibility:aLayer.style.visibility).indexOf('hid') == -1);
				if (aLayer.MM_dragOk != null && isVisible) with (aLayer) 
				{
					var parentL=0; 
					var parentT=0;
					if (!NS) 
					{ 
						parentLayer = (MZ)?aLayer.parentNode:aLayer.parentElement;
						while (parentLayer != null && parentLayer.style.position) 
						{
							parentL += parentLayer.offsetLeft/1; 
							parentT += parentLayer.offsetTop/1;
							parentLayer = (MZ)?parentLayer.parentNode:parentLayer.parentElement;
						}
					}
					var tmpX=mouseX-(((NS)?pageX:((MZ)?style.left.replace("px","")/1:style.pixelLeft)+parentL)+MM_hLeft);
					var tmpY=mouseY-(((NS)?pageY:((MZ)?style.top.replace("px","")/1:style.pixelTop) +parentT)+MM_hTop);
					var tmpW = MM_hWidth;  
					
					if (tmpW <= 0) 
						tmpW += ((NS)?clip.width :offsetWidth);
						
					var tmpH = MM_hHeight; 
					if (tmpH <= 0) 
						tmpH += ((NS)?clip.height:offsetHeight);
						
					if ((0 <= tmpX && tmpX < tmpW && 0 <= tmpY && tmpY < tmpH) && (maxDragZ == null
						|| maxDragZ <= aLayerZ)) 
					{ 
						curDrag = aLayer;
						maxDragZ = aLayerZ;
					}
				}
			}
			
			if (curDrag) 
			{
				document.onmousemove = MM_dragLayer; 
				if (NS) 
					document.captureEvents(Event.MOUSEMOVE);
				curLeft = (NS)?curDrag.left:(MZ)?curDrag.style.left.replace("px","")/1:curDrag.style.pixelLeft;
				curTop = (NS)?curDrag.top:(MZ)?curDrag.style.top.replace("px","")/1:curDrag.style.pixelTop;
				MM_oldX = mouseX - curLeft; 
				MM_oldY = mouseY - curTop;
				document.MM_curDrag = curDrag;
				curDrag.MM_SNAPPED=false;
				
				if(curDrag.MM_toFront)
				{
					eval('curDrag.'+((NS)?'':'style.')+'zIndex=document.MM_maxZ'+((MZ)?'':'+1') );
					if (!curDrag.MM_dropBack)
						document.MM_maxZ++;
				}
				retVal = false; 
				if(!NS&&!MZ) 
					event.returnValue = false;
			}
		} 
		else if (theEvent == 'mousemove') {
      if (document.MM_curDrag) with (document.MM_curDrag) {
        var mouseX = (NS||MZ)?objName.pageX : event.clientX + document.body.scrollLeft;
        var mouseY = (NS||MZ)?objName.pageY : event.clientY + document.body.scrollTop;
        newLeft = mouseX-MM_oldX; 
        newTop  = mouseY-MM_oldY;
        if (MM_bL!=null) 
			newLeft = Math.max(newLeft,MM_bL);
        if (MM_bR!=null) 
			newLeft = Math.min(newLeft,MM_bR);
        if (MM_bT!=null) 
			newTop  = Math.max(newTop ,MM_bT);
        if (MM_bB!=null) 
			newTop  = Math.min(newTop ,MM_bB);
			
        MM_LEFTRIGHT = newLeft-MM_startL; 
        MM_UPDOWN = newTop-MM_startT;
        
        if (NS) 
        {
			left = newLeft; 
			top = newTop;
		}
        else if (MZ){
			style.left = newLeft; 
			style.top = newTop;
		}
        else 
        {
			style.pixelLeft = newLeft;
			style.pixelTop = newTop;
		}
		
        if (MM_dragJS) 
			eval(MM_dragJS);
        retVal = false; 
        if(!NS&&!MZ) 
			event.returnValue = false;
	}
} 
else if (theEvent == 'mouseup') {
      document.onmousemove = null;
      if (NS||MZ) document.releaseEvents(Event.MOUSEMOVE);
      if (NS||MZ) document.captureEvents(Event.MOUSEDOWN); //for mac NS
      if (document.MM_curDrag) with (document.MM_curDrag) {
        if (typeof MM_targL =='number' && typeof MM_targT == 'number' &&
            (Math.pow(MM_targL-((NS)?left:(MZ)?style.left.replace("px","")/1:style.pixelLeft),2)+
             Math.pow(MM_targT-((NS)?top:(MZ)?style.top.replace("px","")/1:style.pixelTop),2))<=MM_tol) {
          if (NS) {left = MM_targL; top = MM_targT;}
                  else if(MZ){style.left = MM_targL; style.top = MM_targT;}
          else {style.pixelLeft = MM_targL; style.pixelTop = MM_targT;}
          MM_SNAPPED = true; MM_LEFTRIGHT = MM_startL-MM_targL; MM_UPDOWN = MM_startT-MM_targT; }
        if (MM_everyTime || MM_SNAPPED) eval(MM_dropJS);
        if(MM_dropBack) {if (NS) zIndex = MM_oldZ; else style.zIndex = MM_oldZ;}
        retVal = false; if(!NS&&!MZ) event.returnValue = false; }
      document.MM_curDrag = null;
    }
    if (NS||MZ) document.routeEvent(objName);
  } return retVal;
}

