/* $Id: global_light.js,v 1.54 2008/07/29 13:57:35 meyer Exp $ */
/* $VtId: global_light.js,v 1.14 2004/06/02 15:32:38 nicolas Exp $ */
/* $VtId: global_light.js,v 1.12 2004/04/19 17:43:09 nicolas Exp $ */
/* $VtId: global_light.js,v 1.3 2003/12/02 14:18:03 nicolas Exp $ */
/* $VtId: global_light.js,v 1.2 2003/11/28 08:52:38 reno Exp $ */
//*******************************************************************************
// detect.js
// dhtmllib.js
// winutils.js
// date.js
// utils.js
// gfs.js
// img.js
// form.js
// tooltip.js
// bi_iframe.js (pour la fonction filterHtml
//*******************************************************************************
//*******************************************************************************

var bDHTMLDebug = false;	// show debug (object not found)

//-------------------------------------------------------------------------------
// DETECT.JS
//-------------------------------------------------------------------------------
// Determine Versions
var agent=navigator.userAgent.toLowerCase();
var browser=navigator.appName.toLowerCase();
var versMajor = parseInt(navigator.appVersion, 10);
var versMinor = parseFloat(navigator.appVersion, 10);
// Determine browser.
var isNS = (browser.indexOf("netscape") >= 0);
var isIE = (browser.indexOf("internet explorer") >= 0); // (agent.indexOf("msie") != -1);

// NS
var isNS2 = (isNS && (versMajor == 2));
var isNS3 = (isNS && (versMajor == 3));
var isNS4 = (isNS && (versMajor == 4));
var isNS5 = (isNS && (versMajor == 5));
var isNS6 = (isNS && document.getElementById != null);
var isMinNS6 = (isNS && document.getElementById != null);
var isMinNS4 = (isNS && (versMajor >= 4)) && ! isMinNS6;
var isNS4 = isMinNS4;
var isMinNS5 = (isNS && (versMajor >= 5));
// IE
var isMinIE4 = (isIE && versMajor >= 4);
var isIE4 = (isIE && (versMajor == 4) && (agent.indexOf("msie 5.")==-1) && (agent.indexOf("msie 6.")==-1));
var isMinIE6 = (navigator.appVersion.indexOf("6.") >= 0);
var isMinIE5 = (isMinIE4 && (navigator.appVersion.indexOf("5.") >= 0) || isMinIE6);
var isMinIE55 = (isMinIE4 && (navigator.appVersion.indexOf("5.5") >= 0));
var isIENS6 = isIE || isMinNS6 ;
// Determine OS
var isMac = (navigator.appVersion.indexOf("Mac") >= 0);

function isDefined(sVar) {
  if (typeof sVar == 'undefined') return false;
  else return true;
}

//*******************************************************************************
// DHTMLLIB.JS
//*******************************************************************************
function isNullLayer(layer,strFunc) {
	if (strFunc == null) strFunc = "";
	if (layer == null)	{
  	if (bDHTMLDebug) alert(strFunc+" : layer is null");
		return true;
	}
	return false;
}
function hideLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"hide")) return;
	if (layer.visibility != null) layer.visibility = "hide";
  if (layer.style && layer.style.visibility != null) layer.style.visibility = "hidden";
	return;
} // function hideLayer

function showLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"show")) return;
  if (layer.visibility != null) layer.visibility = "show";
  if (layer.style && layer.style.visibility != null) layer.style.visibility = "visible";
	return;
} // function showLayer

function openLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"display")) return;
  if (layer.style) layer.style.display="block";
  return;
}

function closeLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"display")) return;
  if (layer.style) layer.style.display="none";
  return;
}

//-----------------------------------------------------------------------------
// Layer content modification.
//-----------------------------------------------------------------------------
function writeLayer(layer,txt) 
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"write")) return;

  if (isMinNS4) 
	{
		layer.document.close();
	  layer.document.write(txt);
		layer.document.close();
		return;
	}
  if (layer.innerHTML != null) layer.innerHTML = txt;
  else if (layer.document) layer.document.body.innerHTML = txt;
	return;
} // function writeLayer

function SetOff() {
  var a=SetOff.arguments;
  for (i = 0; i < a.length; i++) {
    hideLayer(a[i]);
  }
}
function SetLayer(IdOn, IdOff, cx, cy) {
  if (IdOn) {
    if (isMinNS4) { cx-=0; cy-=0; }
    cx += getPageScrollX(); 
    cy += getPageScrollY(); 
  	moveLayerTo(IdOn, cx, cy);
    showLayer(IdOn);
  }
  if (IdOff) hideLayer(IdOff);
}
function getLeft(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"left")) return;
  if (layer.left) return layer.left;
  if (layer.style.pixelLeft) return layer.style.pixelLeft;
  if (layer.style.left) return layer.style.left;
  return;
}
function getTop(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"top")) return;
  if (layer.top) return layer.top;
  if (layer.style.pixelTop) return layer.style.pixelTop;
  if (layer.style.top) return layer.style.top;
  return;
}
function getRight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"right")) return;
  return getLeft(layer) + getWidth(layer);
}
function getBottom(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bottom")) return;
  return getTop(layer) + getHeight(layer);
}
function getPageLeft(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"left")) return 0;
  if (layer.pageX) return layer.pageX;
  if (isIENS6) {
    var x = 0;
    while (layer.offsetParent != null) {
      x += layer.offsetLeft;
      layer = layer.offsetParent;
    }
    x += layer.offsetLeft;
    return x;
  }
  return 0;
}
function getPageRight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"right")) return;
	return getPageLeft(layer)+getWidth(layer);
}
function getPageTop(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"top")) return 0;
  if (layer.pageY) return layer.pageY;
  if (isIENS6) 	{
    var y = 0;
    while (layer.offsetParent != null) 		{
      y += layer.offsetTop;
      layer = layer.offsetParent;
    }
    y += layer.offsetTop;
    return y;
  }
  return 0;
}
function getPageBottom(layer) 
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bottom")) return;
	return getPageTop(layer)+getHeight(layer);
}
function getHeight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"height")) return;
  if (isMinNS4) 
	{
    if (layer.document.height) return layer.document.height;
    else return layer.clip.bottom - layer.clip.top;
  }
  if (parseInt(layer.offsetHeight, 10)) return parseInt(layer.offsetHeight, 10);
  if (layer.style && layer.style.pixelHeight) return layer.style.pixelHeight;
  if (layer.style && layer.style.offsetHeight) return layer.style.offsetHeight;
  if (layer.clientHeight) return layer.clientHeight;
  return 0;
} 
function getWidth(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"width")) return;

  if (isMinNS4) 
	{
    if (layer.document.width) return layer.document.width;
    else return layer.clip.right - layer.clip.left;
  }
  if (parseInt(layer.offsetWidth, 10)) return parseInt(layer.offsetWidth, 10);
  if (layer.style && layer.style.pixelWidth) return layer.style.pixelWidth;
  if (layer.style && layer.style.offsetWidth) return layer.style.offsetWidth;
  if (layer.clientWidth) return layer.clientWidth;
  return 0;
}
function setWidth(layer,iWidth) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"width")) return;
  if (isMinNS4) 	{
    if (layer.document.width) layer.document.width = iWidth;
    return iWidth;
  }
  if (isMinNS6) {
    layer.offsetWidth = iWidth;
    return iWidth;
  }
  if (isMinIE4) 	{
    if (layer.style) layer.style.pixelWidth = iWidth;
    else layer.clientWidth = iWidth;
    return iWidth;
  }
  return iWidth;
}

function setHeight(layer,iHeight) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"height")) return;
  if (isMinNS4)	{
    if (layer.document.height) layer.document.height = iHeight;
  }
  if (isMinNS6) {
    layer.offsetHeight = iHeight;
  }
  if (isMinIE4)	{
    if (layer.style.pixelHeight) layer.style.pixelHeight = iHeight;
    else layer.clientHeight = iHeight;
  }
  return iHeight;
}
function getContentHeight(layer) { 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"height")) return;
  if (parseInt(layer.scrollHeight, 10)) return parseInt(layer.scrollHeight, 10);
  if (layer.document.height) return layer.document.height;
  if (layer.clip) return layer.clip.bottom - layer.clip.top;
  return 0;
}
function getContentWidth(layer) { 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"width")) return;
  if (parseInt(layer.scrollWidth, 10)) return parseInt(layer.scrollWidth, 10);
  if (layer.document.width) return layer.document.width;
  if (layer.clip) return layer.clip.right - layer.clip.left;
  return 0;
}
function resizeLayerTo(layer, pWidth, pHeight) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isMinNS4)	{
		layer.height = pHeight;
		layer.width = pWidth;
	}
  if (isIENS6) {
  	layer.style.width = pWidth;
  	layer.style.height = pHeight;
  }
  return;
}
function moveLayerTo(layer, x, y, bInScreen, strPosX, strPosY) {
  var dx = 0;
  var dy = 0;
  switch(strPosX) {
    case "left": dx = -getWidth(layer); break;
    case "right": dx = +getWidth(layer); break;
  }
  switch(strPosY) {
    case "bottom": dy = +getHeight(layer); break;
    case "top": dy = -getHeight(layer); break;
  }

  if (bInScreen) return moveLayerToInScreen(layer, x, y, dx, dy);
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"moveto ")) return;
  if (layer.moveTo) layer.moveTo(parseInt(x, 10), parseInt(y, 10));

  if (isIENS6) {
    var obj = layer.offsetParent;
    while (obj != null) {
      x -= parseInt(obj.offsetLeft, 10);
      y -= parseInt(obj.offsetTop, 10);
      var obj = obj.offsetParent;
    }
  }
  
  if (layer.style && layer.style.pixelLeft != null) {
    layer.style.pixelLeft = x;
    layer.style.pixelTop  = y;
  }
  else
  if (layer.style && layer.style.left != null) {
    layer.style.left = x+"px";
    layer.style.top = y+"px";
	}
  return;
} // function moveLayerTo
function moveLayerToInScreen(layer, x, y, dx, dy, strPosX, strPosY) {
  if (typeof(layer) == "string") layer = getLayer(layer);

  if (x == null) x = getPageLeft(layer);
  if (y == null) y = getPageTop(layer);
  if (dx == null) dx = 0;
  if (dy == null) dy = 0;

  switch(strPosX) {
    case "left": dx -= getWidth(layer); break;
    case "right": dx += getWidth(layer); break;
  }
  switch(strPosY) {
    case "bottom": dy += getHeight(layer); break;
    case "top": dy -= getHeight(layer); break;
  }
  
  var iLeft = x+dx ;
  var iRight = iLeft + getWidth(layer);
  var iTop = y+dy;
  var iBottom = iTop + getHeight(layer);
  
  var iLeftwin = getPageScrollX();
  var iRightwin = iLeftwin+getWindowWidth();
  var iTopwin = getPageScrollY();
  var iBottomwin = iTopwin+getWindowHeight();
  
	var ix = (iRight > iRightwin) ? iRightwin - getWidth(layer) : iLeft;
	var iy = (iBottom > iBottomwin) ? iBottomwin - getHeight(layer) : iTop;
	
	if (ix < iLeftwin) ix = iLeftwin;
	if (iy < iTopwin) iy = iTopwin;
	
  return moveLayerTo(layer, ix, iy, 0);
}
function setLayerTop(layer,y)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"moveto")) return;
  if (layer.moveTo) {layer.moveTo(getLeft(layer), parseInt(y, 10));return}
  if (layer.style && layer.style.pixelTop != null) {layer.style.pixelTop  = y;return}
  if (layer.style && layer.style.top != null) {layer.style.top = y+"px";return}
  return;
}
function setLayerLeft(layer,x)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"moveto")) return;
  if (layer.moveTo) {layer.moveTo(parseInt(x, 10), getTop(layer));return}
  if (layer.style && layer.style.pixelLeft != null) {layer.style.pixelLeft = x;return}
  if (layer.style && layer.style.left != null) {layer.style.left = x+"px";return}
  return;
}
function moveLayerBy(layer, dx, dy) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"moveby")) return;
  if (layer.moveBy) {layer.moveBy(dx, dy);return}
  if (layer.style && layer.style.pixelLeft != null) {
    layer.style.pixelLeft += dx;
    layer.style.pixelTop  += dy;
    return;
  }
  if (layer.style && layer.style.left != null) {
    layer.style.left = parseInt(layer.style.left, 10) + dx+"px";
    layer.style.top  = parseInt(layer.style.top, 10) + dy+"px";
  }
  return;
}
function moveLayerToLayer(layer, ilayer, dx , dy, bInScreen, strPosX, strPosY)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
  if (typeof(ilayer) == "string") ilayer = getLayer(ilayer);
  if (dx == null) dx = 0;
  if (dy == null) dy = 0;
	if (isNullLayer(layer, "movelayertolayer : layer") || isNullLayer(ilayer,"movelayertolayer :ilayer")) return;
  moveLayerTo(layer, getPageLeft(ilayer)+dx, getPageTop(ilayer)+dy, bInScreen, strPosX, strPosY);
  return;
} // function moveLayerToLayer

function moveLayerToEvent(layer, e, dx , dy, bInScreen, strPosX, strPosY)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer, "movelayertoevent : "+layer)) return;
  if (dx == null) dx = 0;
  if (dy == null) dy = 0;
  moveLayerTo(layer, getPageX(e)+dx, getPageY(e)+dy, bInScreen, strPosX, strPosY);
  return;
} // function moveLayerToEvent
function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clip")) return;
  if (isMinNS4) {
    layer.clip.left   = clipleft;
    layer.clip.top    = cliptop;
    layer.clip.right  = clipright;
    layer.clip.bottom = clipbottom;
  }
  if (isIENS6)
    layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
  return;
}
function getClipLeft(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clipleft")) return;
  if (isMinNS4) return layer.clip.left;
  if (isIENS6) {
    var str =  layer.style.clip;
    if (!str) return 0;
    var clip = getIEClipValues(layer.style.clip);
    return(clip[3]);
  }
  return;
}
function getClipTop(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"cliptop")) return;
  if (isMinNS4) return layer.clip.top;
  if (isIENS6) {
    var str =  layer.style.clip;
    if (!str) return 0;
    var clip = getIEClipValues(layer.style.clip);
    return clip[0];
  }
  return;
}
function getClipRight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clipright")) return;
  if (isMinNS4) return layer.clip.right;
  if (isIENS6) {
    var str =  layer.style.clip;
    if (!str) return layer.style.pixelWidth;
    var clip = getIEClipValues(layer.style.clip);
    return clip[1];
  }
  return;
}
function getClipBottom(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clipbottom")) return;
  if (isMinNS4) return layer.clip.bottom;
  if (isIENS6) {
    var str =  layer.style.clip;
    if (!str) return layer.style.pixelHeight;
    var clip = getIEClipValues(layer.style.clip);
    return clip[2];
  }
  return;
}
function getClipWidth(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clipwidth")) return;
  if (isMinNS4) return layer.clip.width;
  if (isIENS6) {
    var str = layer.style.clip;
    if (!str) return layer.style.pixelWidth;
    var clip = getIEClipValues(layer.style.clip);
    return clip[1] - clip[3];
  }
  return;
}
function getClipHeight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"clipheight")) return;
  if (isMinNS4) return layer.clip.height;
  if (isIENS6) {
    var str =  layer.style.clip;
    if (!str) return layer.style.pixelHeight;
    var clip = getIEClipValues(layer.style.clip);
    return clip[2] - clip[0];
  }
  return;
}
function getIEClipValues(str) {
  var clip = new Array();
  var i;
  i = str.indexOf("(");
  clip[0] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[1] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[2] = parseInt(str.substring(i + 1, str.length), 10);
  i = str.indexOf(" ", i + 1);
  clip[3] = parseInt(str.substring(i + 1, str.length), 10);
  return clip;
}
function setBgColor(layer, color) {
  if (!color.match(/^(\d|[a-fA-F]){6}$/)) return; 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bgcolor")) return;
  if (isMinNS4) layer.bgColor = color;
  if (isIENS6) layer.style.backgroundColor = color;
  return;
}
function getFrame(p_name, win) {
	if (win == null) win = window;
	if (isMinNS4) return findLayer(p_name, win.document);
  if (isMinIE4) return win.document.frames(p_name);
  return;
}
function getLayer(p_name, win) {
	if (win == null) win = window;
  if (typeof(p_name) == "object") return p_name ;
  if (isMinIE5 || isMinNS6)	return (win.document.getElementById(p_name));
	if (isMinNS4)  return findLayer(p_name, win.document);
	if (isMinIE4) return win.document.all(p_name);
  return (win.document.getElementById(p_name));
}
function findLayer(p_name, doc) {
  var i, layer;
  for (i = 0; i < doc.layers.length; i++) {
    layer = doc.layers[i];
    if (layer.name == p_name || layer.id == p_name) return layer;
    if (layer.document.layers.length > 0)
      if ((layer = findLayer(p_name, layer.document)) != null) return layer;
  }
  return null;
}
function getWindowWidth(win) {
	if (!win) win=window;
  if (win.innerWidth) return win.innerWidth;
  if (win.document.documentElement && document.documentElement.clientWidth) return win.document.documentElement.clientWidth;
  if (win.document.body) return win.document.body.clientWidth;
  return -1;
} // function getWindowWidth

function getWindowHeight(win) {
	if (!win) win=window;
  if (win.innerHeight) return win.innerHeight;
  if (win.document.documentElement && document.documentElement.clientHeight) return win.document.documentElement.clientHeight;
  if (win.document.body) return win.document.body.clientHeight;
  return -1;
} // function getWindowHeight
function getPageWidth(win) {
  if (!win) win=window;
  var h = 0 ;
  if ((win.document.width)&&(h<win.document.width)) h=win.document.width ;
  if (win.document.body) {
    if ((win.document.body.offsetWidth)&&(h<win.document.body.offsetWidth)) h=win.document.body.offsetWidth ;
    if ((win.document.body.scrollWidth)&&(h<win.document.body.scrollWidth)) h=win.document.body.scrollWidth ; 
  }
  return h;
}
function getPageHeight(win) {
  if (!win) win=window;
  var h = 0 ;
  if ((win.document.height)&&(h<win.document.height)) h=win.document.height ;
  if (win.document.body)  {
    if ((win.document.body.offsetHeight)&&(h<win.document.body.offsetHeight)) h=win.document.body.offsetHeight ;
    if ((win.document.body.scrollHeight)&&(h<win.document.body.scrollHeight)) h=win.document.body.scrollHeight ;
  }
  return h;
}

function getPageScrollX(win) {
	if (!win) win=window;
  if (win.pageXOffset) return win.pageXOffset;
  doc = (win.document.documentElement && win.document.documentElement.scrollLeft) ? win.document.documentElement : win.document.body;
  if (doc && doc.scrollLeft) return doc.scrollLeft;
  return 0;
} // function getPageScrollX(win) {

function getPageScrollY(win) {
	if (!win) win=window;
  if (win.pageYOffset) return win.pageYOffset;
  doc = (win.document.documentElement && win.document.documentElement.scrollTop) ? win.document.documentElement : win.document.body;
  if (doc && doc.scrollTop) return doc.scrollTop;
  return 0;
} // function getPageScrollY

function getPageX(e,win) 
{
  if (e.pageX) return e.pageX;
  if (e.clientX) return e.clientX + getPageScrollX(win);
  return;
} // function getPageX

function getPageY(e,win) 
{
  if (e.pageY) return e.pageY;
  if (e.clientY) return e.clientY + getPageScrollY(win);
  return;
} // function getPageY

function getElement(sObj) {
  if (document.all) return document.all(sObj);
  if (document.getElementById) return document.getElementById(sObj);
  return eval("document."+sObj);
}
function getPageVisibleHeight() {
  if (window.innerHeight) return window.innerHeight;
  if (document.body.clientHeight) return document.body.clientHeight;
  return -1;
} // function getPageVisibleHeight

function getPageVisibleWidth() {
  if (window.innerWidth) return window.innerWidth;
  if (document.body.clientWidth) return document.body.clientWidth;
  return -1;
} // function getPageVisibleWidth

function isDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

//*******************************************************************************
// WINUTILS.JS
//*******************************************************************************
// centre la fenetre sur l'ecran
function center(win) {
	if (!win) win = window;
	win.moveTo((screen.availWidth-getWindowWidth(win))/2,(screen.availHeight-getWindowHeight(win))/2);
  win.focus();
	return win;
}
// Test l'existence d'une fenetre
function ExistsWin(pWin) {
	if (pWin && pWin.open && !pWin.closed) return pWin;
	else return false;
}
function Pop2Print(strUrl, strName, isizeX, isizeY) {
  var iPop2Print = null;
  iPop2Print = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=yes,statusbar=no,menubar=yes,left=15,top=15,resizable=yes,personalbar=no,locationbar=no');
  if (iPop2Print) iPop2Print.focus();
  if (! isMinIE4) iPop2Print.print();
}
function PopWindow(strUrl, strName) {
  var iPopWindow = null;
  iPopWindow = window.open(strUrl, strName);
  if (iPopWindow) iPopWindow.focus();
}
function Pop2Show(strUrl, strName, isizeX, isizeY) {
  var iPop2Show = null;
  iPop2Show = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=no,statusbar=no,menubar=no,left=15,top=15,resizable=yes,personalbar=no,locationbar=no');
}
function Pop2ShowSta(strUrl, strName, isizeX, isizeY) { // avec status
  var P2S = null;
  P2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=no,statusbar=yes,menubar=no,left=15,top=15,resizable=yes,personalbar=no,locationbar=no');
  if (P2S) P2S.focus();
}
function Pop2ShowR(strUrl, strName, isizeX, isizeY) { // non resizable
  var P2S = null;
  P2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=no,statusbar=no,menubar=no,left=15,top=15,resizable=no,personalbar=no,locationbar=no');
  if (P2S) P2S.focus();
}
function Pop2ShowS(strUrl, strName, isizeX, isizeY) { // avec scroll
  var P2S = null;
  P2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=yes,statusbar=no,menubar=no,left=15,top=15,resizable=no,personalbar=no,locationbar=no');
  if (P2S) P2S.focus();
}
function Pop2ShowSR(strUrl, strName, isizeX, isizeY) { // avec scroll + resizable
  var P2S = null;
  P2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=yes,statusbar=no,menubar=no,left=15,top=15,resizable=yes,personalbar=no,locationbar=no');
  if (P2S) P2S.focus();
}
function Pop2ShowC(strUrl, strName, isizeX, isizeY, bScroll) {
  var cxx = (screen.width / 2) - (isizeX / 2);
  var cyy = (screen.height / 2) - (isizeY / 2);
  var Pop2Show = null;
  if (bScroll)
    Pop2Show = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=yes,statusbar=no,menubar=yes,left='+cxx+',top='+cyy+',resizable=no,personalbar=no,locationbar=no');
  else 
    Pop2Show = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=no,statusbar=no,menubar=yes,left='+cxx+',top='+cyy+',resizable=no,personalbar=no,locationbar=no');
  if (Pop2Show) Pop2Show.focus();
}
function Pop2ShowCNM(strUrl, strName, isizeX, isizeY, bScroll, bFocus) {
  var cxx = (screen.width / 2) - (isizeX / 2);
  var cyy = (screen.height / 2) - (isizeY / 2);
  var Pop2S = null;
  if (bScroll)
    Pop2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=yes,statusbar=no,menubar=no,left='+cxx+',top='+cyy+',resizable=no,personalbar=no,locationbar=no');
  else 
    Pop2S = window.open(strUrl, strName, 'width='+isizeX+',height='+isizeY+',toolbar=no,scrollbars=no,statusbar=no,menubar=no,left='+cxx+',top='+cyy+',resizable=no,personalbar=no,locationbar=no');
  if (bFocus && Pop2S) Pop2S.focus();
}

function PopImg(fic, x, y, sTitle, bScroll, bInTable, sClose) {
  var oPopImg = null;
  var sPopImg = '';

  var cxx = (screen.width / 2) - (x / 2);
  var cyy = (screen.height / 2) - (y / 2);
  var sScr = (bScroll) ? "yes" : "no";
  var sClose = (sClose) ? sClose : "Cliquez pour fermer la fen&ecirc;tre";
  oPopImg=window.open('','pop','width='+x+',height='+y+',toolbar=no,scrollbars='+sScr+',statusbar=no,titlebar=no,menubar=no,left='+cxx+',top='+cyy+',resizable=no,personalbar=no,locationbar=no');
  var sStartJS = '<scr'+''+'ipt language="JavaScript" > \
    function setClientSize(win, W, H)  {\
      win.resizeTo(W, H); \
      var cp = document.createElement("div"); \
      cp.style.position = "absolute"; \
      cp.style.width = "0px"; \
      cp.style.height = "0px"; \
      cp.style.left = "0px"; \
      cp.style.bottom = "0px"; \
      document.body.appendChild(cp); \
      var current_width = cp.offsetLeft; \
      var current_height = cp.offsetTop; \
      /*var dw = (isIE) ?  W - current_width : 0 ;*/ \
      var dw = (isIE) ?  10 : 0 ; \
      var dh = H - current_height; \
      win.resizeBy(dw, dh); \
      document.body.removeChild(cp); \
      return { missed_width: dw, missed_height: dh }; \
    } \
    function PopImgShow(fic, isIENS6, x, y) { \
      var im = document.getElementById("im"); \
      im.src = fic; \
      while (isIENS6 && !im.complete) { \
        setTimeout("PopImgShow(\'"+fic+"\', "+parseInt(isIENS6)+", "+x+", "+y+");", 1500); \
        return; \
      } \
      var popimgonload = document.getElementById("popimgonload"); \
      popimgonload.style.display="none"; \
      var aim = document.getElementById("aim"); \
      aim.style.display="block"; \
      setClientSize(window, x, y); \
    } ';
  sStartJS += 'var im = new Image();im.src="'+fic+'";var isIE='+isIE+';</scr'+''+'ipt>';
  sStart = '<div id="popimgonload" name="popimgonload" class="popimg" style="position:absolute;top:0px;left:0px;z-index:10;background-color:#FFF;color:#000;width:'+x+'px;height:'+y+'px;padding-top:'+Math.floor(y/2)+'px;text-align:center;"><h2>En cours de chargement...</h2></div>';
  sPopImg = '<html><head><title>'+sTitle+'</title>';
  sEnd = '<scr'+''+'ipt language="JavaScript" >';
  isOK = (isIENS6) ? 1 : 0;
  sEnd += "PopImgShow('"+fic+"',"+parseInt(isOK)+", "+x+", "+y+");";
  sEnd += "</script>";

  sPopImg += sStartJS+'</head><body style="margin:0;padding:0">'+sStart+'<a href="javascript:self.close();" id="aim" style="display:none;position:absolute;top:0px;left:0px;z-index:0;" title="'+sClose+'"><img src="/images/im_shim.gif" id="im" style="position:relative;margin:0;padding:0;border:0" alt="'+sClose+'"></a>';
  sPopImg += sEnd+'</body></html>';
  oPopImg.document.clear();
  oPopImg.document.open();
  oPopImg.document.write(sPopImg);
  oPopImg.document.close();
  oPopImg.focus();
}

function FullEcran(strUrl) {
  var Fen_imprim = null;
  Fenl=screen.width-50;
  FenL=screen.height-100;
  Fen_imprim = window.open(strUrl,'Pleinecran','width='+Fenl+',height='+FenL+',top=0,left=0,resizable=yes,toolbar=yes,scrollbars=yes,menubar=yes,statusbar=no');
  Fen_imprim.focus();
}
//*******************************************************************************
// DATE.JS
//*******************************************************************************
function TestTime(strTime) {
  var re = /^(\d{1,2}):(\d{1,2}):?(\d{1,2})?$/;
  var MyArray = re.exec(strTime);
  if (!MyArray) return false;
  var iHou = MyArray[1];
  var iMin = MyArray[2];
  if (MyArray.length > 3) {
    var iSec = MyArray[3];
    if (iSec < 0 && iSec > 59) return false;
  }
  if (iHou < 0 || iHou > 23) return false;
  if (iMin < 0 && iMin > 59) return false;
  return true;
}
function checkDate(iDay, iMonth, iYear) {
  if (iMonth < 1 || iMonth > 12) return false;
  if (iMonth == 2 && iDay > 28) {
    if (iYear%4 != 0) return false;
    if (iDay > 29) return false;
  } else
  if ((iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11) && iDay > 30) {
    return false;
  } else 
  if (iDay > 31) return false;
  return true;
}
function TestDate(strDate) {
  var re = /^(\d{4})-(\d{2})-(\d{2})\s?(\d{1,2}:\d{1,2}:\d{1,2})?$/;
  var MyArray = re.exec(strDate);
  if (MyArray) {
    var iDay = Number(MyArray[3]);
    var iMonth = Number(MyArray[2]);
    var iYear = Number(MyArray[1]);
    if (!checkDate(iDay, iMonth, iYear)) return false;
    if (MyArray[4]) if (!TestTime(MyArray[4])) return false;
    return true;
  }
  var re1 = /^(\d{1,2})[- \/](\d{1,2})[- \/](\d{2}|\d{4})$/;
  MyArray = re1.exec(strDate);
  if (MyArray) {
    var iDay = Number(MyArray[1]);
    var iMonth = Number(MyArray[2]);
    var iYear = Number(MyArray[3]);
    if (!checkDate(iDay, iMonth, iYear)) return false;
    return true;
  }
  return false;
}
function SetDateToSql(strDate) {
  if (!TestDate(strDate)) return false;
  var sDate = strDate;
  var re1 = /^(\d{1,2})[- \/](\d{1,2})[- \/](\d{2}|\d{4})$/;
  var MyArray = re1.exec(strDate);
  if (MyArray) {
    var iYear = Number(MyArray[3]);
    if (iYear < 100) iYear+=2000;
    var iMonth = Number(MyArray[2]);
    var sMonth = (iMonth < 10) ? "0"+iMonth : String(iMonth);
    var iDay = Number(MyArray[1]);
    var sDay = (iDay < 10) ? "0"+iDay : String(iDay);
    sDate = String(iYear)+"-"+sMonth+"-"+sDay;
  }
  return sDate;
}
//*******************************************************************************
// UTILS.JS
//*******************************************************************************
function printFrame(frame, onfinish) {
  if ( !frame ) frame = window;
//  if ( frame.document.readyState != "complete" &&
//       !confirm("Le document a imprimer n'est pas encore completement telecharge! Continuer l'impression?") )
//  {
//    if ( onfinish ) onfinish();
//    return;
//  }
  var isMinIE4 = (document.all) ? 1 : 0;
  if (!isMinIE4) {
    frame.print();
    return;
  }
  if (printIsNativeSupport() ) {
    /* focus handling for this scope is IE5Beta workaround,
       should be gone with IE5 RTM.
    */
    var focused = document.activeElement; 
    frame.focus();
    frame.self.print();
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    return;
  }
  var eventScope = printGetEventScope(frame);
  var focused = document.activeElement;
  window.printHelper = function() {
    execScript("on error resume next: printWB.ExecWB 6, 1", "VBScript");
    printFireEvent(frame, eventScope, "onafterprint");
    printWB.outerHTML = "";
    if ( onfinish ) onfinish();
    if ( focused && !focused.disabled ) focused.focus();
    window.printHelper = null;
  }
  document.body.insertAdjacentHTML("beforeEnd",
    "<object id=\"printWB\" width=0 height=0 \
    classid=\"clsid:8856F961-340A-11D0-A96B-00C04FD705A2\"></object>");
  printFireEvent(frame, eventScope, "onbeforeprint");
  frame.focus();
  window.printHelper = printHelper;
  setTimeout("window.printHelper()", 0);
}
// helpers
function printIsNativeSupport() {
  var agent = window.navigator.userAgent;
  var i = agent.indexOf("MSIE ")+5;
  return parseInt(agent.substr(i), 10) >= 5 && agent.indexOf("5.0b1") < 0;
}
function printFireEvent(frame, obj, name) {
  var handler = obj[name];
  switch ( typeof(handler) ) {
    case "string": frame.execScript(handler); break;
    case "function": handler();
  }
}
function printGetEventScope(frame) {
  var frameset = frame.document.all.tags("FRAMESET");
  if ( frameset.length ) return frameset[0];
  return frame.document.body;
}
//*******************************************************************************
// GFS.JS
//*******************************************************************************
var Gfs_Tab = new Array();
var Gfs_iNum, Gfs_iTypeCurs;
function Gfs_ChangeSrc(pstrSrc, piNum, iScroll) {
  var pObj = (piNum != null && piNum != -1) ? Gfs_Tab[piNum] : this ;
  pObj.pageLay = (isIENS6) ? getLayer(pObj.strId) : getLayer("LS"+pObj.strId);
  pObj.pageLay.src = pstrSrc;
  this.strSrc = pstrSrc;
}
function Gfs_SetFrameHide(piNum) {
  var pObj = (piNum && piNum != -1) ? Gfs_Tab[piNum] : this ;
  hideLayer(pObj.mainLay);
}
function Gfs_SetFrameShow(piNum) {
  var pObj = (piNum && piNum != -1) ? Gfs_Tab[piNum] : this ;
  showLayer(pObj.mainLay);
}
function Gfs_SetFramePos(iCx, iCy, pWidth, pHeight, piNum) {
  var pObj = (piNum && piNum != -1) ? Gfs_Tab[piNum] : this ;
  if (!iCy) iCy = 0;
  if (!iCx) iCx = 0;
  moveLayerTo(pObj.mainLay, iCx, iCy);
  if (pWidth && pWidth != 0 && pHeight && pHeight != 0) {
    resizeLayerTo(pObj.mainLay, pWidth, pHeight);
    clipLayer(pObj.mainLay, 0, 0, pWidth, pHeight);
    if (isMinNS4) {
    	iWidth = (pObj.bScrollV) ? pWidth-pObj.iSizeZoneScrollV : pWidth;
  	  iHeight = (pObj.bScrollH) ? pHeight-pObj.iSizeZoneScrollH : pHeight;
      resizeLayerTo(pObj.pageLay, iWidth, iHeight);
      clipLayer(pObj.pageLay, 0, 0, iWidth, iHeight);
    }
  }
}
function Gfs_SetFrameAdjust(pWidth, pHeight, piNum) {
  var pObj = (piNum && piNum != -1) ? Gfs_Tab[piNum] : this ;
  if (!pWidth || !pHeight) {
  	if (isIENS6) {
      if (!pWidth) pWidth = getWindowWidth(pObj.pageLay);
      if (!pHeight) pHeight = getWindowHeight(pObj.pageLay);
    } else {
      if (!pWidth) pWidth = getContentWidth(pObj.pageLay);
      if (!pHeight) pHeight = getContentHeight(pObj.pageLay);
    }
  }
  resizeLayerTo(pObj.mainLay, pWidth, pHeight);
  clipLayer(pObj.pageLay, 0, 0, pWidth, pHeight);
}
function Gfs_SetFrame(IdParent, bDown) { // bDown aligne sur le bas
  this.IdParent = IdParent;
	this.posLay = getLayer(this.strId+"p");
  this.iPosY = (isIENS6) ? getPageTop(this.posLay)+2 : getPageTop(this.posLay);
  this.iPosX = (isIENS6) ? getPageLeft(this.posLay)+2 : getPageLeft(this.posLay);
	if (isIENS6) {
		document.write('<IFRAME id="'+this.strId+'" name="'+this.strId+'" src="'+this.strSrc+'" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="'+this.scroll+'" style="position:absolute; visibility:hidden; '+this.sBorder+' width:'+this.iWidth+';height:'+this.iHeight+'">');
    document.write('</IFRAME>');
  	this.mainLay = getLayer(this.strId);
    moveLayerTo(this.mainLay, this.iPosX, this.iPosY);
  	clipLayer(this.mainLay, 0, 0, this.iWidth, this.iHeight);
    this.pageLay = this.mainLay;
    showLayer(this.mainLay);
  } else {
  	var ilWidth = this.iWidth;
	  var ilHeight = this.iHeight;
    if (!this.bIsToBeReload) {
      document.write('<LAYER id="'+this.strId+'" width="'+this.iWidth+'" height="'+this.iHeight+'" clip="0 0 '+this.iWidth+' '+this.iHeight+'" visibility="hide" >');
      document.write('<LAYER bgcolor="#'+this.strBg+'" id="LS'+this.strId+'" src="'+this.strSrc+'" top=0 left=0 width='+ilWidth+' height='+ilHeight+' clip="0 0 '+ilWidth+' '+ilHeight+'" ></LAYER>');
    }  
    if (this.bIsToBeReload) {
      document.write('<LAYER id="LS'+this.strId+'" width='+ilWidth+' height='+ilHeight+' clip="0 0 '+ilWidth+' '+ilHeight+'" visibility="hide" ></LAYER>');
    } else document.write('</LAYER>');
    this.pageLay = getLayer("LS"+this.strId);
    if (this.IdParent && !this.bIsToBeReload) this.IdParent.Attach(this);
    if (this.bIsToBeReload) {
    	this.mainLay = this.pageLay;
      this.pageLay.moveToAbsolute(this.iPosX, this.iPosY);
      sAction = "Gfs_ChangeSrc('"+this.strSrc+"', "+this.Num+")";
      setTimeout(sAction, 3000);
      showLayer(this.mainLay);
    } else {
    	this.mainLay = getLayer(this.strId);
      moveLayerTo(this.mainLay, this.iPosX, this.iPosY);
    	clipLayer(this.mainLay, 0, 0, this.iWidth, this.iHeight);
      showLayer(this.mainLay);
    }  
  }  
}
function Gfs_Frame(pstrId, pstrSrc, pstrBg, pbBorder, piCx, piCy) {
	this.Num = Gfs_Tab.length + 1;
 	Gfs_Tab[this.Num] = this;
	this.strId = pstrId;  // name
	this.strBg = (pstrBg != "") ? pstrBg : "FFFFFF";  // background color
  arrayOfWords = pstrSrc.split("?");
	this.strSrc = arrayOfWords[0]+"?BG="+this.strBg;  // source de la frame
  if (arrayOfWords.length > 1) this.strSrc += "&"+arrayOfWords[1];
  this.sBorder = (pbBorder && isIENS6) ? "border: 1px #000000 solid;" : "";
	this.iPosX = 0; 
	this.iPosY = 0; 
	this.iWidth = piCx;
	this.iHeight = piCy;
	this.IdParent = null;
  this.SetFrame = Gfs_SetFrame;
  this.SetFramePos = Gfs_SetFramePos;
  this.SetFrameAdjust = Gfs_SetFrameAdjust;
  this.SetFrameHide = Gfs_SetFrameHide;
  this.SetFrameShow = Gfs_SetFrameShow;
  this.ChangeSrc = Gfs_ChangeSrc;
  this.scroll = "no";
  this.posLay = null;
  this.mainLay = null;
  this.pageLay = null;
  this.bIsToBeReload = false;
  this.bIsToBeRedraw = false;
	if (isIENS6){
		document.write("<div id='"+this.strId+"p' style='visibility:hidden;height:"+this.iHeight+";width:"+this.iWidth+";'></div>");
	} else {
		document.write("<ilayer id='"+this.strId+"p' visibility='hide' height='"+this.iHeight+"' width='"+this.iWidth+" margin='0 0 0 0''></ilayer>");
  }
}
//*******************************************************************************
// IMG.JS
//*******************************************************************************
function getImage(name) {
 if (document.all) return document.all(name);
 if (document.getElementById && document.getElementById(name)) return (document.getElementById(name));
 if (document.images && document.images[name]) return document.images[name];
 return findImage(name, document);
}

function findImage(name, doc) {
  var i, img;
  if (doc == null) doc = window.document;
  if (doc.images) {
    for (i = 0; i < doc.images.length; i++) if (doc.images[i].name == name) return doc.images[i];
  }
  if (doc.layers) {
    for (i = 0; i < doc.layers.length; i++) if ((img = findImage(name, doc.layers[i].document)) != null) {
      img.container = doc.layers[i];
      return img;
    }
  }
  return null;
}

function getImagePageLeft(img) {
  var x, obj;
  if (isMinNS4) {
    if (img.container != null) return img.container.pageX + img.x;
    else return img.x;
  }
  if (isIENS6) {
    x = 0;
    obj = img;
    while (obj.offsetParent != null) {
      x += parseInt(obj.offsetLeft, 10);
      obj = obj.offsetParent;
    }
    x += parseInt(obj.offsetLeft, 10);
    return x;
  }
  return -1;
}
function getImagePageTop(img) {
  var y, obj;
  if (isMinNS4) {
    if (img.container != null) return img.container.pageY + img.y;
    else return img.y;
  }
  if (isIENS6) {
    y = 0;
    obj = img;
    while (obj.offsetParent != null) {
      y += parseInt(obj.offsetTop, 10);
      obj = obj.offsetParent;
    }
    y += parseInt(obj.offsetTop, 10);
    return y;
  }
  return -1;
}
function MM_preloadImages() { //v3.0
  var d=document; 
	if (d.images) { 
		if (!d.MM_p) d.MM_p=new Array();
    var i, j=d.MM_p.length, a=MM_preloadImages.arguments; 
		for(i=0; i < a.length; i++)
    	if (a[i].indexOf("#")!=0) { 
				d.MM_p[j]=new Image; 
				d.MM_p[j++].src=a[i];
			}
	}
}
//*******************************************************************************
// FORM.JS
//*******************************************************************************
function TestCpFrance(strCp, bShort) {
  var iDpt = 0; 
  var iVil = 0; 
  var iSiz = (bShort) ? 2 : 5;
  if (strCp.length < iSiz) return false;
  iDpt = parseInt(strCp.substr(0,2), 10);
  if (isNaN(iDpt)) return false;
  if (!bShort) {
    iVil = parseInt(strCp.substr(3,3), 10);
    if (isNaN(iVil)) return false;
  }
  if (iDpt < 1 || iDpt > 95) {
    if (iDpt != 97 && iDpt != 98) return false;
  }
  return true;
}
function isValidMail(Email) {
  var strTmp = Email;
  re1 = /^www\./i;
  MyArray = re1.exec(strTmp);
  if (MyArray) return false;
  re1 = /^[a-z0-9][-_a-z0-9.]+@[a-z0-9][-a-z0-9]+(\.[a-z][-_a-z0-9]+)+$/i;
  MyArray = re1.exec(strTmp);
  if (!MyArray) return false;
  return true;
}
function isValidTelephone(strTel, bMobile, bFrance) {
  if (bFrance) re1 = (bMobile) ? /^\+?\(?(\+?33)?\)?[-\.\s]*06([-\.\s]*\d\d){4}/ : /^\+?\(?(\+?33)?\)?[-\.\s]*([-\.\s]*\d\d){5}/;
  else re1 = /^[0-9][-\.0-9\s]+/;
  MyArray = re1.exec(strTel);
  if (!MyArray) return false;
  return true;
}
function GetRadioValue(pRadioButton) {
  var checkedButton = "";
  if (!pRadioButton.length) {
    if (pRadioButton.checked == true) {
      checkedButton = pRadioButton.value;
    }
  } else {
    for (i = 0; i < pRadioButton.length; i++) {
      if (pRadioButton[i].checked == true) {
        checkedButton = pRadioButton[i].value;
      }
    }
  }
  return checkedButton;
}
function SelectRadioByValue(pRadioButton, value) {
  for (i = 0; i < pRadioButton.length; i++) {
    if (pRadioButton[i].value == value) {
      pRadioButton[i].checked = true;
      break;
    }
  }
}
function m_UGetElement(strNam, pForm) {
	// modif TM 2008-01-16 12:15:53
	if (!pForm) return;
  var i0;
  for (i0 = 0; i0 < pForm.elements.length; i0++)
    if (pForm.elements[i0].name == strNam) return pForm.elements[i0];
  return false;
}
function AddElement(s_select, s_value, s_text, selected, doc) {
	if (!doc) doc = document;
	if (document.all){ // explorer
  	newOpt = doc.createElement("OPTION") ; 
		newOpt.text = s_text ;
		newOpt.value = s_value ;
		s_select.options.add(newOpt, s_select.length, false, selected) ;
	}
	else { // netscape
		var newOpt = new Option(s_text,s_value, false, selected);
		s_select.options[s_select.length]	= newOpt ;
	}
}
function m_UGetSelect(strObj, pForm) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel) return 0;
  return (pSel.length > 0 && pSel.selectedIndex >= 0) ? parseInt(pSel.options[pSel.selectedIndex].value, 10) : 0;
}
function m_UcleanSelect(strObj, pForm) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel) return ;
  while (pSel.length > 0) pSel.options[0] = null;
}
function m_UAddSelect(strObj, strTxt, strVal, pForm, bSelected) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel) return ;
  sel=(bSelected)?true:false;
  AddElement(pSel, strVal, strTxt, sel);
}

function m_UAddAllSelect(strObj, aOption, pForm, selected, aStyles) {
  if (isNS || isMac) {
    m_UcleanSelect(strObj, pForm) ;
    for (i in aOption) m_UAddSelect(strObj, aOption[i], i, pForm) ;
    if (selected) m_USetSelectByVal(strObj, selected, pForm);
    else m_USetSelect(strObj, 0, pForm);
  } else {
    var pSel = m_UGetElement(strObj, pForm);
    if (!pSel) return ;
    var aTab = pSel.outerHTML.match(/(<select[^>]*>)/i);
    var strText = "" ;
    for (i in aOption) {
      if (i==selected) {
				// modif GL - 30/09/2003 - ajout des styles
				if (aStyles) strText += "<OPTION selected value=\""+i+"\" style=\""+aStyles[i]+"\">"+aOption[i]+"</OPTION>" ; 
				else strText += "<OPTION selected value=\""+i+"\">"+aOption[i]+"</OPTION>" ; 
			}
      else {
				if (aStyles) strText += "<OPTION value=\""+i+"\" style=\""+aStyles[i]+"\">"+aOption[i]+"</OPTION>" ; 
				else strText += "<OPTION value=\""+i+"\">"+aOption[i]+"</OPTION>" ; 
			}
    }
    pSel.outerHTML = aTab[1] + strText + "</SELECT>" ;
  }
}

function m_USetSelectByVal(strObj, sVal, pForm) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel) return ;
  s = "(^|\\|)("+sVal+")(\\||$)";
  re = new RegExp(s);
  for (i=0; i<pSel.length; i++) {
    if (pSel.options[i].value.match(re)) {
      pSel.options[i].selected = true;
    }
  }
}
function m_USelectUnSel(strObj, pForm) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel) return ;
  for (i=0;i<pSel.options.length;i++)  pSel.options[i].selected = false;
}
function m_USetSelect(strObj, iNum, pForm) {
  var pSel = m_UGetElement(strObj, pForm);
  if (!pSel || pSel.length <= 0) return ;
  pSel.options[iNum].selected = true;
}
function m_UCopySelect(pSelSrc, pSelDest, strValue, bSelect)
{
  if (pSelSrc.name == pSelDest.name) return ; // evite de boucler
  for (i=0;i<pSelSrc.options.length;i++)
  {
    if (!bSelect || pSelSrc.options[i].selected == true) {
      AddElement(pSelDest, pSelSrc.options[i].value, pSelSrc.options[i].text, false);
      if (pSelSrc.options[i].value == strValue) pSelDest.options[i].selected = true;
    }
  }
}
function m_USetSelectByValue(strObj, strValue, pForm)
{
  var pSel = m_UGetElement(strObj, pForm);
  for (i=0;i<pSel.options.length;i++)
    if (pSel.options[i].value == strValue) m_USetSelect(strObj, i, pForm);
}

function m_USetValue(pObj, value) {
  if (pObj.innerText) {
    pObj.innerText = value;
  } else {
    pObj.value = value;
  }
}
function SetMajDateTime(sDate,sTime,sName,bTestDate,bTestTime,sFormName) {
  if (!sFormName) sFormName = 'F1_MODULE';
  if (bTestDate) {
    if (sDate != '' && !TestDate(sDate)) {
      alert('Cette date a un format incorrect.');
      eval('document.'+sFormName+'.speDATE_'+sName+'.focus();');
      return;
    }
  }
  re1 = /^(\d\d)$/;
  MyArray1 = re1.exec(sTime);
  if (MyArray1) sTime += ':00:00';
  else {
    re1 = /^(\d\d)(:|h)(\d\d)$/i;
    MyArray1 = re1.exec(sTime);
    if (MyArray1) sTime = MyArray1[1]+':'+MyArray1[3]+':00';
  }
  if (bTestTime) {
    if (sTime != '' &&  !TestTime(sTime)) {
      alert('Cette heure a un format incorrect.');
      eval('document.'+sFormName+'.speTIME_'+sName+'.focus();');
      return;
    }
  }
  else {
    if (!TestTime(sTime)) sTime = '00:00:00';
  }
  re1 = /^(\d{1,2})[- \/](\d{1,2})[- \/](\d{2}|\d{4})$/;
  MyArray = re1.exec(sDate);
  var sSQLDate = '';
  if (MyArray) {
    iYear = Number(MyArray[3]);
    if (iYear < 100) iYear+=2000;
    iMonth = Number(MyArray[2]);
    sMonth = (iMonth < 10) ? "0"+iMonth : String(iMonth);
    iDay = Number(MyArray[1]);
    sDay = (iDay < 10) ? "0"+iDay : String(iDay);
    sSQLDate = (sTime.length < 8) ? String(iYear)+"-"+sMonth+"-"+sDay+" "+sTime+":00":String(iYear)+"-"+sMonth+"-"+sDay+" "+sTime;
  }
  if (sDate == '' && sTime == '') sSQLDate = '';
  eval('document.'+sFormName+'.'+sName+'_STRINFO.value = sSQLDate;');
  eval('document.'+sFormName+'.'+sName+'_STRINFO_M.value = 1;');
}

//*******************************************************************************
// TOOLTIP.JS
//*******************************************************************************
function TT_SetToolTip(sLayName, bOff, e, dx, dy) {
  var pObj = getLayer(sLayName);
  if (!pObj) return false;
  if (!bOff) {
    if (!e) return false;
    if (isNaN(dx)) dx = 0;
    if (isNaN(dy)) dy = 0;
    iCx = getPageX(e) + dx;
    iCy = getPageY(e) + dy;
    moveLayerToInScreen(pObj, iCx, iCy);
    showLayer(pObj);
  } else hideLayer(pObj);
  return false;
}
function TT_create(Id, sMesg, sTitle, iWidth) {
  if (sTitle == null) sTitle = "Aide" ;
  if (iWidth == null) iWidth = 180 ;
  var ContentToolTip ="<TABLE WIDTH="+iWidth+" BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=#006666><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><CENTER><FONT FACE=TAHOMA COLOR=#FFFFFF SIZE=1><B>"+sTitle+"</B></FONT></CENTER></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR=lightblue><TR><TD><FONT FACE=TAHOMA COLOR=#000000 SIZE=1>"+sMesg+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
  document.write("<div id='"+Id+"' style='position:absolute;visibility:hidden'>"+ContentToolTip+"</div>");
  return false;
}
function TT_show(Id, e, dx ,dy) {
  if (isNaN(dx)) dx = 15 ;
  if (isNaN(dy)) dy = 10 ;
  return TT_SetToolTip(Id, 0, e, dx, dy);
}
function TT_hide(Id, e) {
  return TT_SetToolTip(Id, 1, e);
}
var nav = (document.layers); 
var iex = (document.all);
var skn;
//FONCTIONS POUR L'AIDE EN DIV
function pop(msg, titre, largeur, dx, dy, bAbsolutePos, bgColorTitre, bgColorCorps, ColorTitre, ColorCorps, e) {
	// modif GL - 22/08/2003 ajout des params de couleur
  if (!e) e = event;
  skn = getLayer("topdeck");
  if (!skn) return;
//  skn = (nav) ? skn : skn.style;
  if (titre == null) titre = "Aide" ;
  if (largeur == null) largeur = 180 ;
  if (!dx) dx = -60;
  if (!dy) dy = 20;
  if (bgColorTitre == null) bgColorTitre = '#006666';
  if (bgColorCorps == null) bgColorCorps = 'lightblue';
  if (ColorTitre == null) ColorTitre = '#FFFFFF';
  if (ColorCorps == null) ColorCorps = '#000000';
  var ContentToolTip ="<TABLE WIDTH="+largeur+" BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="+bgColorTitre+"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><CENTER><FONT FACE=TAHOMA COLOR="+ColorTitre+" SIZE=1><B>"+titre+"</B></FONT></CENTER></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="+bgColorCorps+"><TR><TD><FONT FACE=TAHOMA COLOR="+ColorCorps+" SIZE=1>"+msg+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
  writeLayer(skn, ContentToolTip); 
  moveLayerToEvent(skn, e, dx, dy, true);
//  alert("x="+(getPageX(e)+dx)+" y="+(getPageY(e)+dy) );
  showLayer(skn);
}
function kill() {
  hideLayer(skn);
}

//FONCTIONS POUR L'AIDE EN DIV POS 00
function pop2(msg, titre, largeur, bAbsolutePos, bgColorTitre, bgColorCorps, ColorTitre, ColorCorps) {
	// modif GL - 22/08/2003 ajout des params de couleur
  skn = getLayer("topdeck");
  if (!skn) return;
//  skn = (nav) ? skn : skn.style;
  if (titre == null) titre = "Aide" ;
  if (largeur == null) largeur = 180 ;
  if (bgColorTitre == null) bgColorTitre = '#006666';
  if (bgColorCorps == null) bgColorCorps = 'lightblue';
  if (ColorTitre == null) ColorTitre = '#FFFFFF';
  if (ColorCorps == null) ColorCorps = '#000000';
  var ContentToolTip ="<TABLE WIDTH="+largeur+" BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="+bgColorTitre+"><TR><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD><CENTER><FONT FACE=TAHOMA COLOR="+ColorTitre+" SIZE=1><B>"+titre+"</B></FONT></CENTER></TD></TR></TABLE><TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="+bgColorCorps+"><TR><TD><FONT FACE=TAHOMA COLOR="+ColorCorps+" SIZE=1>"+msg+"</FONT></TD></TR></TABLE></TD></TR></TABLE>";
  writeLayer(skn, ContentToolTip); 
//  alert("x="+(getPageX(event)+dx)+" y="+(getPageY(event)+dy) );
  showLayer(skn);
}

function getProperties(obj) 
{   
  var result = "";
  for (var i in obj)      
    result += i + ": " + obj[i] + ", ";
  return result;
}

function popscroll(msg, titre, largeur, dx, dy, bAbsolutePos, bgColorTitre, bgColorCorps, ColorTitre, ColorCorps, e) {
	// modif GL - 22/08/2003 ajout des params de couleur
  if (!e) e = event;
  skn = getLayer("topdeck");
  if (!skn) return;
//  skn = (nav) ? skn : skn.style;
  if (titre == null) titre = "Aide" ;
  if (largeur == null) largeur = 180 ;
  if (!dx) dx = -60;
  if (!dy) dy = 20;
  if (bgColorTitre == null) bgColorTitre = '#006666';
  if (bgColorCorps == null) bgColorCorps = 'lightblue';
  if (ColorTitre == null) ColorTitre = '#FFFFFF';
  if (ColorCorps == null) ColorCorps = '#000000';
  var ContentToolTip = " <TABLE WIDTH=100% HEIGHT=100% style='border:2px solid "+bgColorTitre+"' BORDER=0 CELLPADDING=0 CELLSPACING=0> \
        <TR> \
          <TD BGCOLOR="+bgColorTitre+"><CENTER><FONT FACE=TAHOMA COLOR="+ColorTitre+" SIZE=1><B>"+titre+"</B></FONT></CENTER></TD> \
        </TR> \
        <TR> \
           <TD BGCOLOR="+bgColorCorps+"><FONT FACE=TAHOMA COLOR="+ColorCorps+" SIZE=1>"+msg+"</FONT></TD> \
         </TR> \
      </TABLE> ";
  ContentToolTipContent = ContentToolTip;
  ContentToolTip = '<iframe src="" name="topdeckfr" id="topdeckfr" width="'+largeur+'" border="0"></iframe>';
  writeLayer(skn, ContentToolTip); 
  setTimeout("l = document.frames.item('topdeckfr');l.document.body.style.margin='0px 0px 0px 0px';l.document.body.innerHTML = ContentToolTipContent;",100);
  moveLayerToEvent(skn, e, dx, dy, true);
//  alert("x="+(getPageX(e)+dx)+" y="+(getPageY(e)+dy) );
  showLayer(skn);
}

function bi_frame_filterHTML(str, bAll) {
  // Traitement des marques de paragraphe
  str=str.replace(/<p[^>]*>/ig,'');
  str=str.replace(/<\/p[^>]*>/ig,'<br>');
  // Traitement des espaces multiples
  // str=str.replace(/\s\s/ig, ' ');
  // Traitement des apostrophes
  str=str.replace(/'/g,"'");
	str=str.replace(/’/g,"'");
	str=str.replace(/…/g,"'");
  // Traitement de caractères spéciaux
	str=str.replace(/œ/g,"oe");
	str=str.replace(/€/g,"&#128;");
  if (bAll) {
  // Traitement des éventuels tags ASP
    str=str.replace(/<\%[^\>]*\%\>/gi,"");
  // Traitement des éventuels tags PHP
    str=str.replace(/<\?[^\>]*\?\>/gi,"");
  // Traitement des éventuels scripts
    str=str.replace(/<script[^\/]*>.*\/script>/gi,"");
  // Traitement des éventuels styles
    str=str.replace(/<style[^\/]*>.*\/style>/gi,"");
  // Traitement des éventuels commentaires
    str=str.replace(/<\!--[^\>]*--\>/gi,"");
  // Traitement des balises HTML
    tags=[ "[^\\w\\/]",                  // par un symbole non-alphanumérique ou
           "\\d",                        // par un chiffre                    ou
           "[c-df-rtu-z]",                // par une lettre sauf A, B, E, S, T ou
           "a[^(>\\shref=)]",            // par A mais n'est pas A HREF=      ou
           "b[^r>]",                     // par B mais n'est pas B ni BR      ou
           "e[^m]",                      // par E mais n'est pas EM           ou
           "i[^>]",                      // par I mais n'est pas I            ou
           "strike",                     // par STRIKE                        ou
           "s[^(trong)]",                // par S mais n'est pas STRONG       ou
           "tt" ]                        // par TT
    re="/<\\/?"+tags[0]+"[^>]*>";
    for (i=1 ; i<tags.length ; i++) re+="|<\\/?"+tags[i]+"[^>]*>";
    eval("re="+re+"/gi");
    str=str.replace(re, "");
  // Traitement des "pseudo-balises HTML"
    str=str.replace(/&lt;([a-zA-Z!])/gi, "&lt; $1");
  // Traitement du '<' final
    str=str.replace(/&lt;$/gi,"&lt; ");
  }
  return str;
}

function getEventButton(e) {
  var button = e.button;
  
  if ( e.button != 0 && e.button != 2 && ( typeof(e.which) == 'undefined' || e.which > 0 ) ) 
  {
    /* Mozilla, Safari et Opera */
    if( typeof(e.which) != 'undefined' ) { button = e.which; }
    button--;
    /* Correction Opera et MS */
    if( button == 2 || button == 3) { button = 1; }
  }
  return button;
}
