// Reno - 2003-03-13 09:27:07 - V1.0.0
//*******************************************************************************
//-------------------------------------------------------------------------------
// DHTMLLIB.JS
//-------------------------------------------------------------------------------
//*******************************************************************************
/******************************************************************************
* dhtmllib.js                                                                 *
*                                                                             *
* Copyright 1999 by Mike Hall.                                                *
* Web address: http://www.brainjar.com                                        *
* Last update: February 26, 2000.                                             *
*                                                                             *
* Provides basic functions for DHTML positioned elements which will work on   *
* both Netscape Communicator and Internet Explorer browsers (version 4.0 and  *
* up).                                                                        *
******************************************************************************/

// requiert detect.js
// Compatible NS6 - Nicolas - last modified : 10/12/01 
//-----------------------------------------------------------------------------
// Global var
//-----------------------------------------------------------------------------
var bDHTMLDebug = false;	// show debug (object not found)

//-----------------------------------------------------------------------------
// Common function
//-----------------------------------------------------------------------------
function isNullLayer(layer,strFunc)
{
	if (strFunc == null) strFunc = "";

	if (layer == null)
	{
  	if (bDHTMLDebug) alert(strFunc+" : layer is null");
		return true;
	}
	return false;
} // function isNullLayer

//-----------------------------------------------------------------------------
// Layer visibility.
//-----------------------------------------------------------------------------
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 inheritLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"inherit")) return;
  if (layer.visibility != null) layer.visibility = "inherit";
  if (layer.style && layer.style.visibility != null) layer.style.visibility = "inherit";
  return;
} // function inheritLayer

function getVisibility(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"visibility")) return;

  if (layer.visibility != null) {
    if (layer.visibility == "show") return "visible";
    if (layer.visibility == "hide")  return "hidden";
    return layer.visibility;
  }
  if (layer.style && layer.style.visibility != null) return layer.style.visibility;
  return;
} // function getVisibility

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

// keep for compatibility
function writeILayer(layer,txt){  
  if (typeof(layer) == "string") layer = getLayer(layer);
  writeLayer(layer,txt);
  return;
} // function writeILayer

function writeILayerOuter(layer,txt)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"writeILayer")) return;
  if (isMinNS4)	writeLayer(layer,txt); // pas supporté par NS4
  if (isIENS6) layer.document.body.outerHTML = txt;
  return;
} // function writeILayerOuter

//-----------------------------------------------------------------------------
// visibility + positionning.
//-----------------------------------------------------------------------------
function SetOff() {
  var a=SetOff.arguments;
  for (i = 0; i < a.length; i++) {
    hideLayer(a[i]);
  }
} // function SetOff

function SetLayer(IdOn, IdOff, cx, cy) {
  if (IdOn) {
    if (isMinNS4) { cx-=0; cy-=0; }
//    if (isIENS6) {
      cx += getPageScrollX(); 
      cy += getPageScrollY(); 
//    }
  	moveLayerTo(IdOn, cx, cy);
    showLayer(IdOn);
  }
  if (IdOff){
    hideLayer(IdOff);
  }
} // function SetLayer

var SL_pull_Int = false;
var SL_pull_To = 30;
var SL_pull_Pad = 15;
var SL_pull_IdOn = false;
var SL_pull_Cy = 0;
var SL_pull_Cx = 0;
function SetLayer_pullengine(IdOn, cy){
  pObj = IdOn;
  if (getClipHeight(pObj) < cy) {
    clipLayer(pObj, 0, 0, getClipRight(pObj), getClipBottom(pObj)+SL_pull_Pad);
  } else {
    clearInterval(SL_pull_Int);
    SL_pull_Int = false;
    SL_pull_IdOn = false;
  }
} // function SetLayer_pullengine

function SetLayer_pull(IdOn, IdOff, cx, cy, bNotPull) {
  if (SL_pull_IdOn) {
    if (SL_pull_Int) clearInterval(SL_pull_Int);
    objOn = getLayer(SL_pull_IdOn);
    clipLayer(objOn, 0, 0, getWidth(objOn)+10, SL_pull_Cy);
  }
  if (bNotPull) return SetLayer(IdOn, IdOff, cx, cy);
  if (IdOff){
    objOff = getLayer(IdOff);
    hideLayer(objOff);
  }
  if (IdOn) {
    SL_pull_IdOn = IdOn;
    objOn = getLayer(IdOn);
    if (isMinNS4) { cx-=0; cy-=0; }
  	 moveLayerTo(objOn, cx, cy);
    SL_pull_Cy = getHeight(objOn);
    clipLayer(objOn, 0, 0, getWidth(objOn)+10, 15);
    showLayer(objOn);
    SL_pull_Int = setInterval("SetLayer_pullengine('"+IdOn+"', "+SL_pull_Cy+")", SL_pull_To);
  }
} // function SetLayer_pull

function SetLayer_pullengineW(IdOn, cx){
  pObj = IdOn;
  if (getClipWidth(pObj) < cx) {
    clipLayer(pObj, 0, 0, getClipRight(pObj)+SL_pull_Pad, getClipBottom(pObj));
  } else {
    clearInterval(SL_pull_Int);
    SL_pull_Int = false;
    SL_pull_IdOn = false;
  }
} // function SetLayer_pullengineW

function SetLayer_pullW(IdOn, IdOff, cx, cy, bNotPull) {
  if (bNotPull) return SetLayer(IdOn, IdOff, cx, cy);
  if (IdOff){
    objOff = getLayer(IdOff);
    hideLayer(objOff);
  }
  if (IdOn) {
    SL_pull_IdOn = IdOn;
    objOn = getLayer(IdOn);
    if (isMinNS4) { cx-=0; cy-=0; }
  	moveLayerTo(objOn, cx, cy);
    SL_pull_Cx = getWidth(objOn);
    clipLayer(objOn, 0, 0, 10, getHeight(objOn)+10);
    showLayer(objOn);
    SL_pull_Int = setInterval("SetLayer_pullengineW('"+IdOn+"', "+SL_pull_Cx+")", SL_pull_To);
  }
} // function SetLayer_pullW

//-----------------------------------------------------------------------------
// Layer properties.
//-----------------------------------------------------------------------------
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 getLeft

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 getTop

function getRight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"right")) return;
  return getLeft(layer) + getWidth(layer);
} // function getRight

function getBottom(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bottom")) return;
  return getTop(layer) + getHeight(layer);
} // function getBottom

function getPageLeft(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"left")) return 0;
  if (layer.pageX) return layer.pageX;
  if (isIENS6) {
    x = 0;
    while (layer.offsetParent != null) {
      x += layer.offsetLeft;
      layer = layer.offsetParent;
    }
    x += layer.offsetLeft;
    return x;
  }
  return 0;
} // function getPageLeft

function getPageRight(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"right")) return;
	return getPageLeft(layer)+getWidth(layer);
} // function getPageRight

function getPageTop(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"top")) return 0;
  if (layer.pageY) return layer.pageY;
  if (isIENS6) 	{
    y = 0;
    while (layer.offsetParent != null) 		{
      y += layer.offsetTop;
      layer = layer.offsetParent;
    }
    y += layer.offsetTop;
    return y;
  }
  return 0;
} // function getPageTop

function getPageBottom(layer) 
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bottom")) return;
	return getPageTop(layer)+getHeight(layer);
} // function getPageBottom

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)) return parseInt(layer.offsetHeight);
  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 getHeight

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)) return parseInt(layer.offsetWidth);
  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 getWidth

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 setWidth

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 setHeight

function getContentHeight(layer) { 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"height")) return;
  if (parseInt(layer.scrollHeight)) return parseInt(layer.scrollHeight);
  if (layer.document.height) return layer.document.height;
  if (layer.clip) return layer.clip.bottom - layer.clip.top;
  return 0;
} // function getContentHeight

function getContentWidth(layer) { 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"width")) return;
  if (parseInt(layer.scrollWidth)) return parseInt(layer.scrollWidth);
  if (layer.document.width) return layer.document.width;
  if (layer.clip) return layer.clip.right - layer.clip.left;
  return 0;
} // function getContentWidth

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 resizeLayerTo

//-----------------------------------------------------------------------------
// Move Layer
//-----------------------------------------------------------------------------
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), parseInt(y));

  if (isIENS6) {
    var obj = layer.offsetParent;
    while (obj != null) {
      x -= parseInt(obj.offsetLeft, 10);
      y -= parseInt(obj.offsetTop, 10);
      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;
  }
  
  iLeft = x+dx ;
  iRight = iLeft + getWidth(layer);
  iTop = y+dy;
  iBottom = iTop + getHeight(layer);
  
  iLeftwin = getPageScrollX();
  iRightwin = iLeftwin+getWindowWidth();
  
  iTopwin = getPageScrollY();
  iBottomwin = iTopwin+getWindowHeight();

	ix = (iRight > iRightwin) ? iRightwin - getWidth(layer) : iLeft;
	iy = (iBottom > iBottomwin) ? iBottomwin - getHeight(layer) : iTop;

	if (ix < iLeftwin) ix = iLeftwin;
	if (iy < iTopwin) iy = iTopwin;
	
  return moveLayerTo(layer, ix, iy, 0);
} // function moveLayerToInScreen

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));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), 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) + dx+"px";
    layer.style.top  = parseInt(layer.style.top) + dy+"px";
  }
  return;
} // function moveLayerBy

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 moveLayerToLayerMv(player,pilayer,distx,disty)
{
  if (typeof(player) == "string") player = getLayer(player);
  if (typeof(pilayer) == "string") pilayer = getLayer(pilayer);

	if (isNullLayer(layer,"movelayertolayer : layer") || isNullLayer(ilayer,"movelayertolayer :ilayer")) return;

	if (!distx && !disty)
	{
		distx = getPageLeft(ilayer) - getPageLeft(layer);
		disty = getPageTop(ilayer) - getPageTop(layer);
	}
	if (distx == 0)	signex = 1;
	else signex = parseInt(Math.abs(distx)/distx);
	if (disty == 0)	signey = 1;
	else signey = parseInt(Math.abs(disty)/disty);
	jx=parseInt(signex*Math.abs(distx)/50);
	jy=parseInt(signey*Math.abs(disty)/50);
	
	while (Math.abs(getPageLeft(layer) - getPageLeft(ilayer)) > Math.abs(jx) ||  Math.abs(getPageTop(layer)- getPageTop(ilayer)) > Math.abs(jy))
	{
		if (Math.abs(getPageLeft(layer) - getPageLeft(ilayer)) <  Math.abs(jx)) jx = 0;
		if (Math.abs(getPageTop(layer) - getPageTop(ilayer)) <  Math.abs(jy)) jy = 0;
		moveLayerBy(layer, jx, jy);
		setTimeout("moveLayerToLayerMv(\""+player+"\",\""+pilayer+"\","+distx+","+disty+")",1);
		return;
	}	
	moveLayerToLayer(player,pilayer);
	return;
} // function moveLayerToLayerMv

function centerLayerW(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"centerw")) return;
	var x = (getPageWidth()-getWidth(layer)) / 2;
	moveLayerTo(layer,x,0);
  return;
} // function centerLayerW

function centerLayerH(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"centerh")) return;
	var y = (getPageHeight()-getHeight(layer)) / 2;
	moveLayerTo(layer,0,y);
  return;
} // function centerLayerH

function centerLayer(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"center")) return;
	var x = (getPageWidth()-getWidth(layer)) / 2;
	var y = (getPageHeight()-getHeight(layer)) / 2;
	moveLayerTo(layer,x,y);
  return;
} // function centerLayer

//-----------------------------------------------------------------------------
// Z-Index
//-----------------------------------------------------------------------------
function getzIndex(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"z-index")) return;
	if (layer.zIndex) return layer.zIndex;
  if (layer.style) return layer.style.zIndex;
  return 0;
} // function getzIndex

function setzIndex(layer, z) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"z-index")) return;
  if (layer.zIndex != null) layer.zIndex = z;
  if (layer.style) layer.style.zIndex = z;
  return;
} // function setzIndex

function moveAbove(layer,win)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	var max=0;
	if (!win) win =window;
  if (isIE) tab = win.document.all.tags("DIV");
  else tab = document.layers;
  
  if (tab)
  {
  	for (i=0;i<tab.length;i++)
  		if (getzIndex(tab[i]) > max) max = getzIndex(tab[i]);
  }
  	
  if (isNS6) layer.moveAbove();  
	else setzIndex(layer, max+1)
  return;
} // function moveAbove

function moveBelow(layer,win)
{
  if (typeof(layer) == "string") layer = getLayer(layer);
	var min=0;
	if (!win) win =window;
	if (isIE) tab = win.document.all.tags("DIV");
  else tab = document.layers;
	for (i=0;i<tab.length;i++)
		if (getzIndex(tab[i]) < min) min = getzIndex(tab[i]);
	
	if (isNS6) layer.moveAbove();  
  else setzIndex(layer, min-1)
  return;
} // function moveBelow


//-----------------------------------------------------------------------------
// Layer clipping.
//-----------------------------------------------------------------------------
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 clipLayer

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 getClipLeft

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 getClipTop

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 getClipRight

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 getClipBottom

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 getClipWidth

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 getClipHeight

function getIEClipValues(str) {
  var clip = new Array();
  var i;

  // Parse out the clipping values for IE layers.

  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 getIEClipValues

//-----------------------------------------------------------------------------
// Layer scrolling.
//-----------------------------------------------------------------------------
function scrollLayerTo(layer, x, y, bound) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"scroll")) return;

  var dx = getClipLeft(layer) - x;
  var dy = getClipTop(layer) - y;

  scrollLayerBy(layer, -dx, -dy, bound);
  return;
} // function scrollLayerTo

function scrollLayerBy(layer, dx, dy, bound) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"scrollby")) return;

  var cl = getClipLeft(layer);
  var ct = getClipTop(layer);
  var cr = getClipRight(layer);
  var cb = getClipBottom(layer);

  if (bound) {
    if (cl + dx < 0)
      dx = -cl;
    else if (cr + dx > getWidth(layer))
      dx = getWidth(layer) - cr;
    if (ct + dy < 0)
      dy = -ct;
    else if (cb + dy > getHeight(layer))
      dy = getHeight(layer) - cb;
  }
	
	if (getClipHeight(layer) >= layer.document.height)
		dy = 0;
	if (getClipWidth(layer) >= layer.document.width)
		dx = 0;

  clipLayer(layer, cl + dx, ct + dy, cr + dx, cb + dy);
  moveLayerBy(layer, -dx, -dy);
  return;
} // function scrollLayerBy

//-----------------------------------------------------------------------------
// Layer background.
//-----------------------------------------------------------------------------
function getBgColor(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bgcolor")) return;
  if (isMinNS4)  return layer.bgColor;
  if (isIENS6) return layer.style.backgroundColor;
} // function getBgColor

function getForeColor(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"color")) return;
  if (isMinNS4) return layer.color;
  if (isIENS6)	return layer.style.color;
} // function getForeColor

function getBorderColor(layer) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bordercolor")) return;
  if (isMinNS4) return layer.bordercolor;
 	if (isIENS6) return layer.style.borderColor;
} // function getBorderColor

function setBgColor(layer, color) {
  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 setBgColor

function setForeColor(layer, color) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"color")) return;
  if (isMinNS4) layer.color = color;
	if (isIENS6) layer.style.color = color;
  return;
} // function setForeColor

function setBorderColor(layer,color)
{
  if (!color.match(/^(\d|[a-fA-F]){6}$/)) return; 
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bordercolor")) return;
  if (isMinNS4) layer.bordercolor = color;
	if (isIENS6) layer.style.borderColor = color;
  return;
} // function setBorderColor

function setBgImage(layer, src) {
  if (typeof(layer) == "string") layer = getLayer(layer);
	if (isNullLayer(layer,"bgimage")) return;
  if (isMinNS4) layer.background.src = src;
  if (isIENS6) layer.style.backgroundImage = "url(" + src + ")";
} // function setBgImag

//-----------------------------------------------------------------------------
// Layer creation.
//-----------------------------------------------------------------------------
// Compatible IE & NS
function createLayer(p_name,p_style,p_action,p_src)
{
	if (!p_style) p_style="";
	if (!p_action) p_action="";
	if (!p_src)	p_src="#";
	
	if (isMinNS4 || isMinNS6)
	{
		if (p_style) p_style = styleToNS(p_style);
		document.write("<layer "+p_style+" name=\""+p_name+"\" id=\""+p_name+"\" "+p_action+">"+p_src+"</layer>");
	}
	
  if (isMinIE4)	document.write("<div name=\""+p_name+"\" id=\""+p_name+"\" style='"+p_style+"' "+p_action+" >"+p_src+"</div>");

	l_lay = getLayer(p_name);
	if (isMinNS4)	l_lay.innerHTML = p_src;

	return l_lay;
} // function createLayer

function styleToNS(p_style)
{
	aTab=p_style.split(";");
	for (i=0;i<aTab.length;i++)
		aTab[i]=aTab[i].replace(/:/g,"='")+"'";

	p_style = aTab.toString();
	p_style = p_style.replace(/,/g," ");
	p_style = p_style.replace(/background-color/g,"bgcolor");
	p_style = p_style.replace(/border='[^']*'/,"border=1");
	return p_style;
} // function styleToNS

function createILayer(p_name,p_style,p_action,p_src)
{
	if (!p_style) p_style="";
	if (!p_src) p_src="#";
	if (!p_action) p_action="";	

	if (isMinNS4 || isMinNS6) 
	{
		if (p_style) p_style = styleToNS(p_style);		
		document.write("<ilayer src=\""+p_src+"\" "+p_style+" name=\""+p_name+"\" id=\""+p_name+"\" "+p_action+"></ilayer>");
	}
  if (isMinIE4){
		document.write("<iframe style='"+p_style+"' name=\""+p_name+"\" id=\""+p_name+"\" "+p_action+" src=\""+p_src+"\"></iframe>");
	}
	return;
} // function createILayer


//-----------------------------------------------------------------------------
// Find Layer
//-----------------------------------------------------------------------------
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 getFrame

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 findLayer

//-----------------------------------------------------------------------------
// Page & Window properties.
//-----------------------------------------------------------------------------
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 getPageWidth

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 getPageHeight

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

//-----------------------------------------------------------------------------
// Event properties.
//-----------------------------------------------------------------------------
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;
}

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 getElement

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;
}
