// ---------------------------------------------------------------------------
// this script is copyright (c) 2001 by Michael Wallner!
// http://www.wallner-software.com
// mail:"info - dhtml @ wallner - software . com" (remove Blanks)
//
// you may use this script on web pages of your own
// you must not remove this copyright note!
//
// Sie dürfen dieses Script auf Ihren Webseiten verwenden
// Sie dürfen diesen Copyright Hinweis jedoch nicht entfernen!
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
//                   text fade-in / -out effect version 1.0
//
// supported browsers:  IE4, IE5, NS4, NS6, MOZ, OP5
// needed script files: crossbrowser.js
// ---------------------------------------------------------------------------


//info effect for all browsers
//fade out last info  and fade in actual info at the same time
//Info Effekt für alle Browser
//Gleichzeitiges Ein- und Ausblenden der Layer
function b_effektInfo(){
  if (this.visible) {
    this.show();
    if (this.actColor < this.colors.length) {
      if (bt.ns4)
        this.writeText(this.text,this.cl,this.colors[this.actColor]);
      else
        this.css.color=this.colors[this.actColor];
      this.actColor++;
    }
  }
  else {
    if (this.actColor > 0) {
      this.actColor--;
      if (bt.ns4)
        this.writeText(this.text,this.cl,this.colors[this.actColor]);
      else
        this.css.color=this.colors[this.actColor];
      if (this.actColor==0) {
        this.hide();
      }
    }
  }
}


//why use the <FONT> tag and not the 'style=' attribute to set text color?
//ns4 doese not support document.write('<xx style="yy">'); for more than one
//layer per page!

//Warum wird der <FONT> Tag und nicht das 'style=' Attribut verwendet um die
//Textfarbe zu setzen?
//Weil der NS4 nur bei einem Layer pro Seite ein
//document.write('<xx style="yy">'); unterstützt!

//write text to layer (ns4)
//Screibe Text in einen Layer (ns4)
//text:  text to write
//cl:    css class to format text
//color: text color
function b_writeText(text,cl,color){
  var t
   t='<span class="'+cl+'"><FONT color="'+color+'">'+text+'</FONT></span>';
   if (bt.ns4) {
     this.obj.document.write(t);
     this.obj.document.close();
   }
}

//This function creates one infoLayer
//Diese Funktion erstellt einen infoLayer
//name: id of the layer
//x,y:	screen position of the info
//text: the info text
//cl:   css class name
function createInfo(name,x,y,text,cl) {

  if (bt.ns4)
    document.write("<LAYER class='"+cl+"' visibility='hide' name='"+name+"'>"+text+"</LAYER>");
  else
    document.write("<DIV class='"+cl+"' id='"+name+"' style='visibility:hidden;'>"+text+"</DIV>");

  this.colors= new Array('#ffffff','#EEEEEE','#CCCCCC','#AAAAAA','#999999',
                         '#333333','#000000')

  this.visible=false;                                //set this true to fade in
  this.text=text;
  this.cl=cl;
  this.actColor=0;
  this.name=name;
  this.obj=getObj(name);
  this.css=(bt.ns4)?this.obj:this.obj.style;
  this.visbility='visible'               //remeber current visibility (op5 bug)
  this.hide=b_hide;
  this.show=b_show;
  this.moveTo=b_moveTo;
  this.moveBy=b_moveBy;
  this.writeText=b_writeText;	      //function to write text into a layer/div
  this.effekt=b_effektInfo;	                              //fade in and out
  this.x=0;
  this.y=0;
  this.moveTo(x,y);
  this.hide();

  return this;
}

//------------------------------------------------------------------------------

//Add one Info to the info Array
//Einen infoLayer hinzufügen
function b_addInfo(nr,text,cl,x,y) {
  this.infos[nr] = new createInfo(this.name+nr,x,y,text,cl);
}

//show or hide one infoLayer (fade in/out)
//einen infoLayer anzeigen oder verstecken (fade in/out)
function b_showInfo(nr,vis) {
  if (this.infos[nr]) this.infos[nr].visible = vis;
}

//manage the infoEffekt every 150ms
//den infoEffekt alle 150ms verwalten
function b_infoArrayEffekt() {
  var i;
  if (this.rotate>0 && !this.inRotate) {
    this.inRotate=true;
    this.effektRotate();
  }

  for (i=0; i<this.infos.length; i++) {
    if (this.infos[i]) this.infos[i].effekt();
  }
  setTimeout(this.v+'.effekt()',150);
}

//set layer position an visibility after page resize (op5 bug!)
//setzen der Layer Position und der Sichtbarkeit nach einer Größenänderung
//des Fensters (op5 bug!)
function b_infoRefresh() {
  var i;
  for (i=0; i< this.infos.length; i++) {
    if (this.infos[i]) {
      this.infos[i].moveTo(this.infos[i].x,this.infos[i].y);
      this.infos[i].css.visibility=this.infos[i].visibility;
    }
  }
}

function b_infoRotate() {
  if (this.infos[this.actInfo])
    this.showInfo(this.actInfo,false);

  this.actInfo++;
  while (!this.infos[this.actInfo]) {
    if (this.actInfo > this.infos.length)
      this.actInfo=0;
    else
      this.actInfo++;
  }
  this.showInfo(this.actInfo,true);
  if (this.rotate>0)
    setTimeout(this.v+'.effektRotate()',this.rotate);
  else
    this.inRotate=false;
}


//test window resize in opera 5
//Teste Größenänderung des Fensters im Opera 5
function b_resize(e) {
  if (bt.op5) {
    var s = new createPageSize();
    if ((screenSize.width!=s.width) || (screenSize.height!=s.height)) {
      screenSize = new createPageSize();
      this.refresh();
      eval(e);
    }
    setTimeout(this.v+".resize('"+e+"')",500);
  }
}


//you need one infoArray per page to manage the infolayers
//Sie benötigen ein infoArray pro Seite zum Verwalten der infoLayers
function createInfoArray(name) {
  this.infos = new Array();
  this.name=name;
  this.addInfo=b_addInfo;
  this.showInfo=b_showInfo;
  this.effekt=b_infoArrayEffekt;
  this.effektRotate=b_infoRotate;
  this.refresh=b_infoRefresh;
  this.rotate=0;
  this.inRotate=false;
  this.actInfo=0
  this.resize=b_resize;

  this.v = name + "var";
  eval(this.v + "=this");

  this.effekt();	       //init the effect
  return this
}


