// Part of this code use public GNU library from Dan Steinman work. http://www.dansteinman.com/dynapi/

function DynLayer(id,nestref,frame) {
  if (!is.ns5 && !DynLayer.set && !frame) DynLayerInit()
  this.frame = frame || self
  if (is.ns) {
    if (is.ns4) {
      if (!frame) {
        if (!nestref) var nestref = DynLayer.nestRefArray[id]
        if (!DynLayerTest(id,nestref)) return
        this.css = (nestref)? eval("document."+nestref+".document."+id) : document.layers[id]
      }
      else this.css = (nestref)? eval("frame.document."+nestref+".document."+id) : frame.document.layers[id]
      this.elm = this.event = this.css
      this.doc = this.css.document
    }
    else if (is.ns5) {
      this.elm = document.getElementById(id)
      this.css = this.elm.style
      this.doc = document
    }
    this.x = this.css.left
    this.y = this.css.top
    this.w = this.css.clip.width
    this.h = this.css.clip.height
  }
  else if (is.ie) {
    if ((is.ie5up)|| (is.ie6)) {
    //alert("IE 5.5 ou 6.0");
      this.elm = document.getElementById(id)
      this.css = this.elm.style
      this.doc = document
      this.x = this.elm.offsetLeft
      this.y = this.elm.offsetTop
      this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
      this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
    }
    else
    {
      this.elm = document.all[id]
      this.css = this.elm.style
      this.doc = document
      this.x = this.elm.offsetLeft
      this.y = this.elm.offsetTop
      this.w = (is.ie4)? this.css.pixelWidth : this.elm.offsetWidth
      this.h = (is.ie4)? this.css.pixelHeight : this.elm.offsetHeight
    }
  }

  this.id = id
  this.nestref = nestref
  this.obj = id + "DynLayer"
  eval(this.obj + "=this")
}

function DynLayerMoveTo(x,y) {
  if (x!=null) {
    this.x = x
    if (is.ns) this.css.left = this.x
    else this.css.pixelLeft = this.x
  }
  if (y!=null) {
    this.y = y
    if (is.ns) this.css.top = this.y
    else this.css.pixelTop = this.y
  }
}

function DynLayerShow() {
  this.css.visibility = (is.ns4)? "show" : "visible"
}
function DynLayerHide() {
  this.css.visibility = (is.ns4)? "hide" : "hidden"
}
DynLayer.prototype.moveTo = DynLayerMoveTo
DynLayer.prototype.show = DynLayerShow
DynLayer.prototype.hide = DynLayerHide
DynLayerTest = new Function('return true')

function DynLayerInit(nestref) {
  if (!DynLayer.set) DynLayer.set = true
  if (is.ns) {
    if (nestref) ref = eval('document.'+nestref+'.document')
    else {nestref = ''; ref = document;}
    for (var i=0; i<ref.layers.length; i++) {
      var divname = ref.layers[i].name
      DynLayer.nestRefArray[divname] = nestref
      var index = divname.indexOf("Div")
      if (index > 0) {
        eval(divname.substr(0,index)+' = new DynLayer("'+divname+'","'+nestref+'")')
      }
      if (ref.layers[i].document.layers.length > 0) {
        DynLayer.refArray[DynLayer.refArray.length] = (nestref=='')? ref.layers[i].name : nestref+'.document.'+ref.layers[i].name
      }
    }
    if (DynLayer.refArray.i < DynLayer.refArray.length) {
      DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
    }
  }
  else if (is.ie) {
    for (var i=0; i<document.all.tags("DIV").length; i++) {
      var divname = document.all.tags("DIV")[i].id
      var index = divname.indexOf("Div")
      if (index > 0) {
        eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
      }
    }
  }
  return true
}
DynLayer.nestRefArray = new Array()
DynLayer.refArray = new Array()
DynLayer.refArray.i = 0
DynLayer.set = false

this.ua = navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
function BrowserCheck() {
  var b = navigator.appName
  if (b=="Netscape") this.b = "ns"
  else if (b=="Microsoft Internet Explorer") this.b = "ie"
  else this.b = b
  this.version = navigator.appVersion
  this.v = parseInt(this.version)
  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 = (this.version.indexOf('MSIE 4')>0)
  this.ie5up = !this.ie4;
  this.ie6 = (this.major == 4 && this.ua.indexOf('msie 6.0') != -1);
  this.min = (this.ns||this.ie)
}
is = new BrowserCheck()

function init() {
  menu1 = new DynLayer('menu1Div')  
  menu2 = new DynLayer('menu2Div')  
  corporate = new DynLayer('corporateDiv')
  business = new DynLayer('businessDiv')
  }