var     ns  = (document.layers) ? true : false;                // ns4x
var     dom = (document.getElementById) ? true : false;        // DOM compatible browser (ie6+, ns6+, mozilla...)
var     ie  = (document.all) ? true : false;                   // ie4x

function        menuCss(id, cls)
{
  if (dom)
    {      
      var m = document.getElementById(id);
      if (m)
        m.className = cls;
    }
}

function	changeCss(e, cls)
{
  if (dom && e && e.className)
    e.className = cls;
}

function	cssShow(id, v)
{
  var e = document.getElementById(id);
  if (e && e.style) {
    var s = v ? '' : 'none';
    e.style.display = s;
  }
}

function	getCoordsOfElement(e)
{
  if (!e)
    return new coords(0, 0);

  var r = new coords(e.offsetLeft, e.offsetTop);
  var l = null
  for (e = e.offsetParent; e; e = e.offsetParent) {
    //alert(e.tagName+'='+e.id);
    r.add(e.offsetLeft, e.offsetTop);
    if (e.offsetTop != 0)
     l = e;
  }
  return r;
}
function	coords(ex, ey)
{
  if (!ex)
    this.x = 0;
  else
    this.x = ex;
  if (!ey)
    this.y = 0;
  else
    this.y = ey;
  
  this.addC = function(c) { this.x += c.x; this.y += c.y; };
  this.add = function(nx, ny) {this.x += nx; this.y += ny; }
  this.addX = function(nx) { this.x += nx; };
  this.addY = function(ny) { this.y += ny; };
}


function	showHideFolder(id)
{
  var e = document.getElementById(id);
  if (!e)
    return;
  if (!e.style)
    return;
  var v = (e.style.display == '');
  e.style.display = v ? 'none' : '';
  var i = document.getElementById(id+'-img');
  if (!i)
    return;
  // folder-closed.gif
  i.src = './images/' + (v ? 'folder-closed.gif' : 'folder-opened.gif');
}

// quelques fonctions bien pratiques
// merci a :
// http://www.crockford.com/javascript/remedial.html

function isArray(a) {
    return isObject(a) && a.constructor == Array;
}
function isBoolean(a) {
    return typeof a == 'boolean';
}
function isEmpty(o) {
    var i, v;
    if (isObject(o)) {
        for (i in o) {
            v = o[i];
            if (isUndefined(v) && isFunction(v)) {
                return false;
            }
        }
    }
    return true;
}
function isFunction(a) {
    return typeof a == 'function';
}
function isNull(a) {
    return typeof a == 'object' && !a;
}
function isNumber(a) {
    return typeof a == 'number' && isFinite(a);
}
function isObject(a) {
    return (a && typeof a == 'object') || isFunction(a);
}
function isString(a) {
    return typeof a == 'string';
}
function isUndefined(a) {
    return typeof a == 'undefined';
} 

