var mac=false;

function show(id) {

  if (ns4){document.layers[id].visibility = "show";}
  else if (ie4){document.all[id].style.visibility = "visible";}
}
function hide(id) {
  if (ns4) document.layers[id].visibility = "hide";
  else if (ie4) document.all[id].style.visibility = "hidden";
}

function showL(id) {
  if(ie4){
    tmpClientX = window.event.clientX;
    tmpOffsetX = window.event.offsetX;
    newPosX = parseInt(tmpClientX) - parseInt(tmpOffsetX);
    if (newPosX < parseInt(divCont.style.left)) newPosX = divCont.style.left;
    
    id.style.visibility = "visible";
    id.style.left = newPosX;
  }
  else if (ns4){
    newPosX = parseInt(tmpPosX) - 25;
    id.visibility = "show";
    id.left = newPosX
  }
}
function hideL(id) {
  if (ns4) id.visibility = "hide";
  else if (ie4) id.style.visibility = "hidden";
}

//////////////////////////
//// SMART SLIDE SHOW ////
function smartSlide(name) {
  //Eigenschaften
  this.name = name;
  this.lays = new Array();
  this.times = new Array();
  this.Evnts = new Array();
  this.started = false;
  this.current = 0;
  this.slides = 0
  this.i = 0
  //Methoden
  this.Add = smartSlideAdd
  this.Start = smartSlideStart
  this.GoOn = smartSlideGoOn
  this.Stop = smartSlideStop
  this.Switch = smartSlideSwitch
  this.Clicked = smartSlideClick
  this.AddEvent = smartSlideAddEvent
  this.ExecEvent = smartSlideExecEvent
  //Objects
  this.control = null
}
function smartSlideAdd (ID,time) {
  if (ns4) {
    this.lays[this.slides] = document.layers[ID];
  }
  if (ie4) {
    this.lays[this.slides] = document.all[ID];
  }
  this.times[this.slides] = time;
  this.slides++
  return true;
}
function smartSlideStart() {
  if (!this.started) this.started = true;
  if (this.slides <= 0) return false;
  if (this.control) this.control.Check()
  this.GoOn()
  return false;
}
function smartSlideGoOn() {
  if (!this.started) return true;
  for (this.i=0 ; this.i< this.slides; this.i++) {
    if (this.i == this.current) {
      showL(this.lays[this.i]);
      time=this.times[this.i];
    }
    else hideL(this.lays[this.i])
  }
  this.current ++
  if (this.current >= this.slides) this.current=0
  if (time > 0) eval(this.name+ "TO = setTimeout('"+this.name+".GoOn()',time)")
  return true;
}
function smartSlideStop() {
  this.started = false
  eval ("clearTimeout("+this.name+"TO)")
  if (this.control) this.control.Check()
  return true;
}
function smartSlideSwitch() {
  if (this.started) this.Stop()
  else { this.started = true ; this.GoOn() ; }
  if (this.control) this.control.Check()
  return true
}
function smartSlideClick(e) {
  if (ns4) alert(e.type +" -- "+ e.target)
  if (ie4) alert(window.event.type +" -- "+ window.event.srcElement.name)
  return true;
}
function smartSlideAddEvent(name,type,exec) {
  this.Evnts[this.Evnts.length] = new Evntsobj(name,type,exec)
}
function smartSlideExecEvent(e) {
  alert(e)
  window.status=e.type + "--" + e.target.name
  if (e.type == "mouseup") alert("click "+ e.target.name)
  if (e.type == "mouseover") alert("mouseover "+ e.target.name)
  return true;
}
//// SMART SLIDE SHOW ////
//////////////////////////

/////////////////////////
//// SMART TIMELINER ////
function TimeLiner(name) {
  //Eigenschaften
  this.name = name;
  this.Lines = 0
  this.Line1 = new Array();
  this.Line2 = new Array();
  this.Line3 = new Array();
  this.times = new Array();
  this.started = false;
  this.current = 0;
  this.i = 0;
  //Methoden
  this.Add = TimeLinerAdd
  this.Start = TimeLinerStart
  this.GoOn = TimeLinerGoOn
  this.Stop = TimeLinerStop
  this.Switch = TimeLinerSwitch
  this.Reset = TimeLinerSwitch
  //Objekte
  this.control = null
}
function TimeLinerAdd (Exe1,Exe2,Exe3,time) {
  if (ns4) {
    this.Line1.push(Exe1);
    this.Line2.push(Exe2);
    this.Line3.push(Exe3);
    this.times.push(time);
  } else if (ie4) {
    this.Line1[this.Lines] = Exe1;
    this.Line2[this.Lines] = Exe2;
    this.Line3[this.Lines] = Exe3;
    this.times[this.Lines] = time;
  }
  this.Lines++
  return true;
}
function TimeLinerStart() {
  if (!this.started) this.started = true;
  if (this.Lines <= 0) return false;
  this.GoOn()
  if (this.control) this.control.Check()
  return true;
}
function TimeLinerGoOn() {
  if (!this.started) return true;
  for (this.i=0 ; this.i< this.Lines; this.i++) {
    if (this.i == this.current) {
      if (this.Line1[this.i] != "wait" && this.Line1[this.i] != "") eval (this.Line1[this.i]);
      if (this.Line2[this.i] != "wait" && this.Line2[this.i] != "") eval (this.Line2[this.i]);
      if (this.Line3[this.i] != "wait" && this.Line3[this.i] != "") eval (this.Line3[this.i]);
      time=this.times[this.i];
    }
  }
  this.current ++
  if (this.current >= this.Lines) this.current=0
  //if (time > 0) eval(this.name+ "TO = setTimeout('"+this.name+".GoOn()',time)")
  if (time > 0) this.timeout = setTimeout(this.name+'.GoOn()',time)
  if (this.control) this.control.Check()
  return true;
}
function TimeLinerStop() {
  this.started = false
  if (this.control) this.control.Check()
  //eval ("clearTimeout("+this.name+"TO)")
  clearTimeout(this.timeout)
  return true;
}
function TimeLinerSwitch() {
//alert("switched")
  if (this.started) this.Stop()
  else { this.started = true ; this.GoOn(); }
  if (this.control) this.control.Check()
}
//function TimeLinerSwitch() {
//  this.Stop()
//  this.current = 0
//}
//// SMART TIMELINER ////
/////////////////////////

///////////////////////
//// StopGo Button ////
function stopGoBttn (ID,Remote,top,left, mup) {
  //if (mac && ns4) top = top *.82
  //if (mac && ie4) top = top *.78
  this.ID = ID
  this.picgo = new Image ()
  this.picstop = new Image ()
  this.picgo.src = "/grafiken/play/go.gif"
  this.picstop.src = "/grafiken/play/stop.gif"
  this.Go = stopGoGo
  this.Stop = stopGoStop
  this.Check = stopGoCheck
  this.imgID = "B"+ID
  this.Remote = Remote
  this.mouseup = mup
  if (ns4) {
    this.layer = document.layers[ID] = new Layer(7)
    this.layer.top = top
    this.layer.left = left
    this.layer.height = 12
    this.layer.visibility = "show"
    this.layer.document.open()
    this.layer.document.write("<a href=\"javascript:void(null)\" onMouseup=\""+this.mouseup+";\"><img name='b"+ID+"' src='"+this.picstop.src+"' width=7 height=12 border=0></a>")
    this.layer.document.close()
    this.picture = document.layers[ID].document.images["b"+ID]
  }
  if (ie4) {
    this.layer = document.all[ID]
    tempstr = "<div id='"+ID+"' style='position: absolute; width: 7; height: 12; left: "+left+"; top: "+top+";'><img name='b"+ID+"' src='"+this.picstop.src+"' width=7 height=12 onClick=\""+this.mouseup+"\"></div>"
    document.body.insertAdjacentHTML("BeforeEnd",tempstr)
    this.picture = document.images["b"+ID]
  }
  Remote.control = this
  this.Check()
  return true;
}
function stopGoGo () {
  this.picture.src = this.picgo.src
  return true
}
function stopGoStop () {
  this.picture.src = this.picstop.src
  return true
}
function stopGoCheck () {
  if (this.Remote.started) this.Go()
  else this.Stop()
  return true
}
//// StopGo Button ////
///////////////////////


///////////////////
//// BIG LAYER ////
///////////////////
// BigLayer soll es ermöglichen, Layers für hervorhebungen zu verwenden
// BigLayer kann Layers dynamisch erstellen (ifloaded()) oder bestehende übernehmen (Assign())
function BigLayer(name) {
  //Standard Werte
  this.name = name
  this.layer = null
  this.HTML = ""
  this.top = 0
  this.left = 0
  this.width = 0
  this.height = 0
  this.mouseup = ""
  this.mouseover = ""
  this.mouseout = ""
  this.link = ""
  
  //Clipping Werte
  this.clipped = false
  this.clipwid = false
  this.clipTop = false
  this.cilpBot = false
  this.cliplef = false
  
  // Methoden
  this.Write = BigLayerWrite
  this.Create = BigLayerCreate
  this.Assign = BigLayerAssign
  this.Show = BigLayerShow
  this.Hide = BigLayerHide
  this.Destroy = BigLayerDestroy
  this.Setup = BigLayerSetup
  this.Clip = BigLayerClip
  this.Move = BigLayerMove
  
  //Spezial Methoden
  this.SetClipAni = BigLayerSetClipAni
//  this.SetPathAni = BigLayerSetPathAni
//  this.SetAniSeq = BigLayerSetAniSeq
  this.InsertImage = BigLayerInsertImage
}
// --- BIG LAYER - Assign -------------------------------------------------------------
  function BigLayerAssign(name) {
    if (ns4) {
      this.layer = document.layers[name]
      this.style = this.layer
    }
    if (ie4) {
      this.layer = document.all[name]
      this.style = this.layer.style
    }
  }
// --- BIG LAYER - Write -------------------------------------------------------------
  function BigLayerWrite () {
    if (!this.layer) return false
    if (ns4) {
      this.layer.document.open()
      this.layer.document.write(this.HTML)
      this.layer.document.close()
    }
    if (ie4) this.layer.innerHTML = this.HTML
    if (ie4 && mac) {
    //  this.layer.onmouseout = 
    }
    return true
  }
// --- BIG LAYER - Create -------------------------------------------------------------
  function BigLayerCreate (top,left,width,height, visible) {
    if (this.layer) this.Destroy()
    this.top = top
    this.left = left
    this.width = width
    this.height = height
    ID = "LAY"+this.name
    if (ns4) {
      this.layer = document.layers[ID] = new Layer(width)
      if (visible == true) this.layer.visibility = "show"
      else this.layer.visibility = "hide"
      this.layer.top = top
      this.layer.left = left 
      this.layer.height = height
      this.style= this.layer
    }
    if (ie4) {
      if (visible == true) visibility = "visible"
      else visibility = "hidden"
      document.body.insertAdjacentHTML('BeforeEnd','<div id="'+ID+'" style="position: absolute; visibility: '+visibility+'; width: '+width+'; height: '+height+'; top: '+top+'; left: '+left+';">&nbsp;</div>')
      this.layer = document.all[ID]
      this.style = this.layer.style
    }
    return true
  }
// --- BIG LAYER - Show -------------------------------------------------------------
  function BigLayerShow () {
    if (this.layer == null) {return false}
    showL(this.layer)
    return true
  }
// --- BIG LAYER - Hide -------------------------------------------------------------
  function BigLayerHide () {
    if (this.layer == null) return false
    hideL(this.layer)
    return true
  }
// --- BIG LAYER - Destroy -------------------------------------------------------------
  function BigLayerDestroy() {
    this.Hide()
    if (ns4) delete this.layer
    if (ie4) {
      this.layer.innerHTML = ""
      this.layer.outerHTML = ""
    }
    return true
  }
// --- BIG LAYER - Setup -------------------------------------------------------------
  function BigLayerSetup(top,left,height,width) {
    if (top) this.style.top = top
    if (left) this.style.left = left
    if (height) this.style.height = height
    if (width) this.style.width = width
    return true
  }
// --- BIG LAYER - Clip -------------------------------------------------------------
  function BigLayerClip (top,wid,bot,lef) {
    if (ie4 && !this.clipped) {
      this.style.clip = "rect(0px "+this.layer.w+"px "+this.layer.h+"px 0px)"
      this.cliptop = 0
      this.clipwid = this.layer.w
      this.clipbot = this.layer.h
      this.cliplef = 0
    }
    if (top==null) top = this.cliptop
    if (wid==null) wid = this.clipwid
    if (bot==null) bot = this.clipbot
    if (lef==null) lef = this.cliplef
    this.clipped = true
    if (ns4) {
      this.style.clip.top = top
      this.style.clip.right = wid
      this.style.clip.bottom = bot
      this.style.clip.left = lef
    }
    if (ie4) {
      this.style.clip = "rect("+top+"px "+wid+"px "+bot+"px "+lef+"px)"
    }
    return true
  }
function BigLayerSetClipAni (steps, delay, fromtop, fromright, frombottom, fromleft)  {
  this.ClipAni = new ClipAni(this, this.width, this.height)
  this.ClipAni.Calc(steps, delay, fromtop, fromright, frombottom, fromleft) 
  return true
}
//function BigLayerSetPathAni (PAobject) {
//  this.PathAni = PAobject
//  this.PathAni.

//}
function BigLayerInsertImage (imgURL,width,height) {
  this.image = new Image
  this.image.src = imgURL
  this.image.bez = "IMG"+this.name
  this.HTML = ''
  if (this.link || this.mouseover || this.mouseout || this.mouseup) {
    this.HTML += '<a ' // </a>
    if (this.link) this.HTML += 'href="'+this.link+'"'
    else this.HTML += 'href="javascript:void(null);"'
    
    if (this.mouseover) this.HTML += ' onmouseover="'+this.mouseover+'"'
    if (this.mouseout) this.HTML += ' onMouseout="'+this.mouseout+'"'
    if (this.mouseup) this.HTML += ' onmouseup="'+this.mouseup+'"'
    
    this.HTML += '>'
  }
  this.HTML += '<IMG name="'+this.image.bez+'" SRC="'+this.image.src+'" WIDTH='+width+' HEIGHT='+height+' ALT="" border=0>'
  if (this.link || this.mouseover || this.mouseout || this.mouseup) {
    this.HTML += '</a>'
  }
  return true
}


function BigLayerMove (x,y) {
  if (x.indexOf("-") || y.indexOf("+")) xpos = parseInt(this.style.left) + parseInt(x)
  else xpos = parseInt(x)
  if (y.indexOf("+") || y.indexOf("+")) ypos = parseInt(this.style.top) + parseInt(y)
  else ypos = parseInt(y)
  if (x != null) this.style.left = xpos
  if (y != null) this.style.top = ypos
  
  return true
}
//// BIG LAYER ////
///////////////////


/////////////////////////
//// CLIP ANImation  ////
/////////////////////////
// Animiert ein Object über dessen Clipping Eigenschaft
// Open und Close Efekte sind dadurch möglich
function ClipAni (iniObj, width, height) {
  this.width = width
  this.height = height
  this.iniObj = iniObj
  this.current = 0
  this.name = "test"
  
  this.status = "not calculated"
  
  this.Calc = ClipAniCalc
  this.Open = ClipAniOpen
  this.Close = ClipAniClose
  this.Turn = ClipAniTurn
  return true
}
function ClipAniCalc (steps, delay, fromtop, fromright, frombottom, fromleft) {
  this.steps = steps
  this.delay = delay
  if (fromtop) this.fromtop = fromtop
    else this.fromtop = (this.height/2)
  if (frombottom) this.frombot = frombottom
    else this.frombot = (this.height/2)
  if (fromleft) this.fromleft = fromleft
    else this.fromleft = (this.width/2)
  if (fromright) this.fromright = fromright
    else this.fromright = (this.width/2)
  
  this.Stepstop = new Array()
  this.Stepswid = new Array()
  this.Stepsbot = new Array()
  this.Stepslef = new Array()
  for (i=0 ; i<=this.steps ; i++) { 
    this.Stepstop[i] = this.fromtop/this.steps * i
    this.Stepswid[i] = this.width - ((this.width - this.fromright)/this.steps *i)
    this.Stepsbot[i] = this.height - ((this.height - this.frombot)/this.steps *i)
    this.Stepslef[i] = this.fromleft/this.steps *i
  }
  this.status = "calculated"
  return true
}
function ClipAniOpen () {
  if (this.status == "opened") return true
  if (this.status == "closing") { this.Turn(); return true }
  if (this.status != "opening") {this.current = this.steps ; this.iniObj.Show()}
  this.status = "opening"
  this.iniObj.Clip(this.Stepstop[this.current],this.Stepswid[this.current],this.Stepsbot[this.current],this.Stepslef[this.current])
  this.current--
  if (this.current < 0 ) {this.status = "opened" ; return true}
  //window.status= this.Stepstop[this.current]+"-"+this.Stepswid[this.current]+"-"+this.Stepsbot[this.current]+"-"+this.Stepslef[this.current]
  eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Open()',"+this.delay+")")
  return true
}
function ClipAniClose() {
  if (this.status == "closed") return true
  if (this.status == "opening") { this.Turn(); return true }
  if (this.status == "stoped" || this.status == "opened") this.current = 0
  this.status = "closing"
  this.iniObj.Clip(this.Stepstop[this.current],this.Stepswid[this.current],this.Stepsbot[this.current],this.Stepslef[this.current])
  this.current++
  if (this.current > this.steps) {this.status = "closed" ; this.iniObj.Hide(); return true}
  eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Close()',"+this.delay+")")
  return true
}
function ClipAniTurn() {
  if (this.status == "closed") this.Open()
  if (this.status == "closing") {
    this.status = "opening"
    eval("clearTimeout(CATO"+this.iniObj.name+")")
    eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Open()',"+this.delay+")")
  }
  if (this.status == "opened") this.Close()
  if (this.status == "opening") {
    this.status = "closing"
    eval("clearTimeout(CATO"+this.iniObj.name+")")
    eval("CATO"+this.iniObj.name+"=setTimeout('"+this.iniObj.name+".ClipAni.Close()',"+this.delay+")")
  }
  return true
}
//// CLIP ANImation  ////
/////////////////////////


