function Get_indexColor (aColorVon, aColorBis)
{ alert ('aColor :' + aColorVon +
         ";\n 100% : "+ fadeColor (1, aColorVon, aColorBis) +
         ";\n 90% : " + fadeColor (0.9, aColorVon, aColorBis) +
         ";\n 80% : " + fadeColor (0.8, aColorVon, aColorBis) +
         ";\n 70% : " + fadeColor (0.7, aColorVon, aColorBis) +
         ";\n 60% : " + fadeColor (0.6, aColorVon, aColorBis) +
         ";\n 50% : " + fadeColor (0.5, aColorVon, aColorBis) +
         ";\n 40% : " + fadeColor (0.4, aColorVon, aColorBis) +
         ";\n 30% : " + fadeColor (0.3, aColorVon, aColorBis) +
         ";\n 20% : " + fadeColor (0.2, aColorVon, aColorBis) +
         ";\n 10% : " + fadeColor (0.1, aColorVon, aColorBis) +
         ";\n  0% : " + fadeColor (0, aColorVon, aColorBis));
 }

 // Get_indexColor ("#FFE1B7", "#4682B4");

function fadeColor (aFaktor, aStrColorVon, aStrColorBis)
{ if (aFaktor>1) {aFaktor=1};
  if (aFaktor<0) {aFaktor=0}
  nRVon=parseInt (aStrColorVon.slice (1,3),16);
  nGVon=parseInt (aStrColorVon.slice (3,5),16);
  nBVon=parseInt (aStrColorVon.slice (5,7),16);
  nRBis=parseInt (aStrColorBis.slice (1,3),16);
  nGBis=parseInt (aStrColorBis.slice (3,5),16);
  nBBis=parseInt (aStrColorBis.slice (5,7),16);
  StrR=(Math.round ((nRBis-nRVon)*aFaktor)+ nRVon).toString(16).replace (/(\b[0-9,A-F,a-f]\b)/, "0$1");
  StrG=(Math.round ((nGBis-nGVon)*aFaktor)+ nGVon).toString(16).replace (/(\b[0-9,A-F,a-f]\b)/, "0$1");
  StrB=(Math.round ((nBBis-nBVon)*aFaktor)+ nBVon).toString(16).replace (/(\b[0-9,A-F,a-f]\b)/, "0$1");
  return ('#'+StrR+StrG+StrB).toUpperCase();
}



/*****************************************************************************
                    Object LinkLayerObj
*****************************************************************************/
var glo_BlankImg = new Image();
glo_BlankImg.src                     = 'pics/blank.gif';

function LinkLayerObj(aLink)
{ this.Link                 = aLink;
  this.insertLink           = L_insertLink;
  this.setLinkColor         = L_setLinkColor;
  this.base_layer           = this.createLayerObj_absolute(0,0, this.width, this.height)
  if (this.Link["activeLink"])
  { this.active_layer         = this.createLayerObj_absolute(0,0, this.width, this.height)
    this.active_layer.setzIndex (this.base_layer.getzIndex()+1);
    this.active_layer.hideLayer();
  }
  this.link_layer           = this.createLayerObj_absolute(0,0, this.width, this.height)
  this.link_layer.insertImage (glo_BlankImg.src, this.Link["text"], null, null, aLink["link"], null);
  this.link_layer.setzIndex (this.base_layer.getzIndex()+1);
  this.old_L_do_onmouseover = this.do_onmouseover;
  this.old_L_do_onmouseout  = this.do_onmouseout;
  this.do_onmouseover       = L_do_onmouseover;
  this.do_onmouseout        = L_do_onmouseout;
  //eval ('this.layer.captureEvents(Event.'+aEventname.toUpperCase().replace (/ON(.*)/, "$1")+')');
  eval(this.obj + "=this");
  return this;
  }

function L_insertLink ()
{ if (this.Link["image"])
  { if (this.Link["alphaimage"])
     this.base_layer.insertImage (this.Link["image"],"",50,this.Link["alphaimage"])
    else
      this.base_layer.insertImage (this.Link["image"],"")
   }
  else if (this.Link["style"])
  { if (this.Link["style"].ticker_backgroundColor)
      this.base_layer.setBgColor (this.Link["style"].ticker_backgroundColor);
    if (this.Link["text"])
      this.base_layer.insertCenterText (this.Link["text"], this.Link["style"].classname)
  }
  if (this.active_layer)
  { if (this.Link["activeLink"]["image"])
    { if (this.Link["activeLink"]["alphaimage"])
      this.active_layer.insertImage (this.Link["activeLink"]["image"],"",50,this.Link["activeLink"]["alphaimage"])
      else
        this.active_layer.insertImage (this.Link["activeLink"]["image"],"")
     }
    else if (this.Link["activeLink"]["style"])
    { if (this.Link["activeLink"]["style"].ticker_backgroundColor)
        this.active_layer.setBgColor (this.Link["activeLink"]["style"].ticker_backgroundColor);
      if (this.Link["activeLink"]["text"])
        this.active_layer.insertCenterText (this.Link["activeLink"]["text"], this.Link["activeLink"]["style"].classname)
    }
  }
}

function L_do_onmouseover ()
{ if (this.do_pause) this.do_pause();
  if (this.active_layer) this.active_layer.showLayer();
  //if (this.old_L_do_onmouseover) this.old_L_do_onmouseover();

}

function L_do_onmouseout ()
{ if (this.active_layer) this.active_layer.hideLayer();
  if (this.do_continue) this.do_continue();
  //if (this.old_L_do_onmouseout) this.old_L_do_onmouseout();
}

function L_setLinkColor (aColor)
{ if (!this.Link["image"])
  { if (bw.ns4)
    { eval ('document.ids.'+this.Link["style"].classname+'fadecolor.color="'+aColor+'"');
       this.insertLink ()
    }
    if (bw.ie4||bw.dom)
    {  this.base_layer.layer.getElementsByTagName("td")[0].style.color=aColor;
    }
  }
}


/*****************************************************************************
                    Object AnimationObj_fade
*****************************************************************************/

function AnimationObj_fade (aColorFrom, aColorTo)
{ this.colorFrom             = (aColorFrom)?aColorFrom:'#000000';
  this.colorTo               = (aColorTo)?aColorTo:'#FF0000';
  this.do_animation_step     = f_do_animation_step;
  this.do_animation_laststep = f_do_animation_laststep;
  if (this.param=="ticker_from_parent_bottom")
  { this.reset_after_fade=1;
    this.hide_after_fade=1;
  }
  else
  { this.reset_after_fade      = 0;
    this.hide_after_fade       = 0;
  }
  return this;
 }

function f_do_animation_step (aLayerObj, aFaktor)
{ aLayerObj.setLinkColor (fadeColor (aFaktor, this.colorFrom, this.colorTo))
}

function f_do_animation_laststep (aLayerObj)
{   aLayerObj.setLinkColor (this.colorTo)
  if (this.hide_after_fade==1)
    aLayerObj.hideLayer();
  if (this.reset_after_fade==1)
    aLayerObj.setLinkColor (this.colorFrom)
}


/*****************************************************************************
                    Object Animation_Obj_slide
*****************************************************************************/

function AnimationObj_slide (aToX, aToY)
{  this.ToX=(aToX)?aToX:null;
   this.ToY=(aToY)?aToY:null;
   this.StartX=null;
   this.StartY=null;
   this.do_level_start        = s_do_level_start;
   this.do_transaction_start  = s_do_transaction_start;
   this.do_animation_step     = s_do_animation_step;
   this.do_animation_laststep = s_do_animation_laststep;
 return this;
}

function s_do_transaction_start (aLayerObj, aStartZeit)
{ //alert(aLayerObj.layername);
  if (this.param=='slide_back_from_parent_random')
  { this.ToX=(this.ToX)?this.ToX:aLayerObj.x;
    this.ToY=(this.ToY)?this.ToY:aLayerObj.y;
    aLayerObj.move_behind_parent_border ('random')
  }
  else if (this.param=='slide_back_from_parent_left')
  { this.ToX=(this.ToX)?this.ToX:aLayerObj.x;
    this.ToY=(this.ToY)?this.ToY:aLayerObj.y;
    aLayerObj.move_behind_parent_border ('left')
  }
  else if (this.param=='slide_back_from_parent_bottom')
  { this.ToX=(this.ToX)?this.ToX:aLayerObj.x;
    this.ToY=(this.ToY)?this.ToY:aLayerObj.y;
    aLayerObj.move_behind_parent_border ('bottom')
  }
  else if (this.param=='ticker_from_parent_bottom')
  { this.ToX=(this.ToX)?this.ToX:aLayerObj.x;
    this.ToY=(this.ToY)?this.ToY:aLayerObj.y;
    aLayerObj.move_behind_parent_border ('bottom')
    aLayerObj.showLayer();
    aLayerObj.setzIndex (0); // netscape 4 brauchts ...
  }
this.StartX=aLayerObj.x;
this.StartY=aLayerObj.y;
}

function s_do_level_start(aLayerObj, aStartzeit)
{ if (this.param=='ticker_from_parent_bottom')
  { aLayerObj.move_behind_parent_border ('bottom')
    aLayerObj.showLayer();
  }
}


function s_do_animation_step(aLayerObj, aFaktor)
{  aLayerObj.moveLayerTo (this.StartX+((this.ToX-this.StartX)*aFaktor),
                          this.StartY+((this.ToY-this.StartY)*aFaktor));
}

function s_do_animation_laststep (aLayerObj)
{ aLayerObj.moveLayerTo (this.ToX, this.ToY);
}

/*****************************************************************************
                    Object AnimationObj
*****************************************************************************/

function AnimationObj (aDauer, aParam)
{  this.Dauer                       = aDauer;
   this.orgDauer                    = aDauer;
   this.param                       = aParam;
   this.StartZeit                   = null;
   this.PauseStartZeit              = null;
   this.finished                    = 0;
   this.fPause                      = false;
   this.doLevelStart                = A_doLevelStart;
   this.doTransactionStart          = A_doTransactionStart;
   this.doAnimationStep             = A_doAnimationStep;
   this.doPause                     = A_doPause;
   this.doContinue                  = A_doContinue;
return this;
}

function A_doTransactionStart (aLayerObj, aStartZeit)
{ if (this.do_transaction_start) this.do_transaction_start (aLayerObj);
}

function A_doLevelStart (aLayerObj, aStartZeit)
{ this.Dauer = this.orgDauer;
  this.StartZeit = aStartZeit;
  this.finished=0;
  if (this.do_level_start) this.do_level_start (aLayerObj, aStartZeit);
}

function A_doPause (aLayerObj, aNowZeit)
{ this.PauseStartZeit=aNowZeit;
  this.fPause =true;
}

function A_doContinue (aLayerObj, aNowZeit)
{ if (this.fPause)
  { this.StartZeit=Math.max(aNowZeit-this.PauseStartZeit+this.StartZeit, 0);
    this.fPause=false;
  }
}

function A_doAnimationStep(aLayerObj, aNowZeit)
{
  if (!this.fPause)
  { var aFaktor=(aNowZeit-this.StartZeit)/this.Dauer;
    //window.status= aFaktor;

    if (aFaktor<1)
    { if (this.do_animation_step) this.do_animation_step(aLayerObj, aFaktor);
    }
    else
    { if (this.do_animation_laststep) this.do_animation_laststep(aLayerObj);
      this.finished=1;
    }
  }
}

/*****************************************************************************
                    Object AnimationLayerObj
*****************************************************************************/

function AnimationLayerObj ()
{  this.AnimationObjs           = new Array();
   this.add_AninmationObj_slide = a_add_AninmationObj_slide;
   this.add_AninmationObj_fade  = a_add_AninmationObj_fade;
   this.add_AninmationObj_pause = a_add_AninmationObj_pause;
   this.do_level_start          = a_do_level_start;
   this.do_transaction_start    = a_do_transaction_start;
   this.do_animation_step       = a_do_animation_step;
   this.fpause                  = false;
   this.do_pause                = a_do_pause;
   this.do_continue             = a_do_continue;
   this.finished                = 0;
   this.level_finished          = 0;
   this.get_max_level           = a_get_max_level;
   this.aktlevel                = 0;
   this.maxlevel                = 0;
   eval(this.obj + "=this");
 }

function a_add_AninmationObj_slide (aDauer, aParam, aLevel, aToX, aToY)
{ AnimationObj_slide.prototype= new AnimationObj (aDauer, aParam);
  if (!this.AnimationObjs [aLevel])
    this.AnimationObjs [aLevel] = new Array ();

  this.AnimationObjs [aLevel][this.AnimationObjs[aLevel].length] = new AnimationObj_slide (aToX, aToY);
  this.maxlevel = Math.max (aLevel, this.maxlevel);
}

function a_add_AninmationObj_fade (aDauer, aParam, aLevel, aColorFrom ,aColorTo)
{ AnimationObj_fade.prototype= new AnimationObj (aDauer, aParam);
  if (!this.AnimationObjs [aLevel])
    this.AnimationObjs [aLevel] = new Array ();
  this.AnimationObjs [aLevel][this.AnimationObjs[aLevel].length] = new AnimationObj_fade (aColorFrom ,aColorTo);
  this.maxlevel = Math.max (aLevel, this.maxlevel);
}

function a_add_AninmationObj_pause (aDauer, aParam, aLevel)
{  if (!this.AnimationObjs [aLevel])
    this.AnimationObjs [aLevel] = new Array ();
  this.AnimationObjs [aLevel][this.AnimationObjs[aLevel].length] = new AnimationObj (aDauer, aParam);
  this.maxlevel = Math.max (aLevel, this.maxlevel);
}

function a_get_max_level ()
{ return (this.maxlevel);
}

function a_do_transaction_start (aStartZeit)
{ this.finished=0;
 this.aktlevel=0;
  for (var i=0; i<=this.maxlevel; i++ )
  { if (this.AnimationObjs[i]) // level mu&szlig; nicht existieren, d.h er kann bei 1 anfangen ...
    {for (var j=0; j<this.AnimationObjs[i].length; j++ )
      { this.AnimationObjs [i][j].doTransactionStart (this, aStartZeit)
      }
    }
  }
}

function a_do_level_start (aStartZeit, aLevel)
{ this.aktlevel = aLevel;
  if (this.AnimationObjs [this.aktlevel])
  { this.level_finished=0;
    for (var i=0; i<this.AnimationObjs [this.aktlevel].length; i++ )
    { this.AnimationObjs [this.aktlevel][i].doLevelStart (this, aStartZeit)
    }
   }
}

function a_do_pause ()
{ var JetzZeit = new Date()
  if (this.AnimationObjs [this.aktlevel])
  { for (var i=0; i<this.AnimationObjs [this.aktlevel].length; i++ )
       this.AnimationObjs [this.aktlevel][i].doPause (this, JetzZeit.getTime())
  }
}

function a_do_continue ()
{ var JetzZeit = new Date()
  if ( this.AnimationObjs [this.aktlevel])
  { for (var i=0; i<this.AnimationObjs [this.aktlevel].length; i++ )
      this.AnimationObjs [this.aktlevel][i].doContinue (this, JetzZeit.getTime())
  }
}

function a_do_animation_step (aNowZeit)
{ var tmpfinished=1;
  if (this.AnimationObjs[this.aktlevel])
  { for (var i=0; i<this.AnimationObjs[this.aktlevel].length; i++)
    { this.AnimationObjs[this.aktlevel][i].doAnimationStep (this, aNowZeit)
      tmpfinished=tmpfinished&&this.AnimationObjs[this.aktlevel][i].finished;
    }
    this.level_finished=tmpfinished;
    this.finished=tmpfinished&&(this.maxlevel==this.aktlevel);
    if (!this.finished )
    { //alert (this..layername+ ":"+this.maxlevel+ ":"+this.aktlevel);
    }
  }
  else
  { //alert (this..layername+ ":"+this.maxlevel+ ":"+this.aktlevel);
    this.level_finished=1;
    this.finished=0;
  }
}

/*****************************************************************************
                    Object Animation_TransactionObj
*****************************************************************************/

function Animation_TransactionObj (aName, aRepeat)
{   this.name                    = aName;
    this.IntervallHandle         = null;
    this.AnimationLayerObjs      = new Array();
    this.add_Aninmation_LayerObj = t_add_Aninmation_LayerObj;
    this.start_animation         = t_start_animation;
    this.start_level             = t_start_level;
    this.do_animation_step       = t_do_animation_step;
    this.get_max_level           = t_get_max_level;
    this.repeat                  = (aRepeat)?aRepeat:"no_repeat";
    this.maxlevel                = 0;
    this.aktlevel                = 0;
    // fading
    this.obj = "AnimTrans_" + aName;
    eval(this.obj + "=this");
    //this.obj=eval(this);

    // initialize Layers, but not for Netscape4
return this;
}

function t_get_max_level()
{ for (var i=0;i<this.AnimationLayerObjs.length;i++)
   this.maxlevel=Math.max(this.maxlevel, this.AnimationLayerObjs[i].get_max_level ())
  return (this.maxlevel);
}

function t_add_Aninmation_LayerObj (aLayerObj)
{ this.AnimationLayerObjs[this.AnimationLayerObjs.length] = aLayerObj;
  return aLayerObj;
}

function t_start_animation()
{ var StartDate=new Date();
  var StartZeit=StartDate.getTime();
  this.max_level=this.get_max_level()
  this.aktlevel = 0;
  for (var i=0; i<this.AnimationLayerObjs.length;i++)
       this.AnimationLayerObjs[i].do_transaction_start (StartZeit, this.aktlevel);
  this.start_level (StartZeit, this.aktlevel);
  this.IntervallHandle=setInterval(this.obj+'.do_animation_step()',10);
}

function t_start_level(aStartZeit, aLevel)
{ for (var i=0; i<this.AnimationLayerObjs.length;i++)
  { if (this.AnimationLayerObjs[i].maxlevel>=aLevel )
     this.AnimationLayerObjs[i].do_level_start (aStartZeit, aLevel );
  }
 }

function t_do_animation_step(aParam)
{ var level_finished = null;
  var transaction_finished = null;
  var NowDate=new Date();
  var NowZeit=NowDate.getTime();
  level_finished=true;
  for (var i=0; i<this.AnimationLayerObjs.length; i++)
  { if (!this.AnimationLayerObjs[i].level_finished) // wenn z.B. Level 0 in diesem Layer nicht vorhanden...
    { this.AnimationLayerObjs[i].do_animation_step(NowZeit);
      level_finished = level_finished&&(this.AnimationLayerObjs[i].level_finished);
     }
  }
  if (level_finished)
  { this.aktlevel++;
    if (this.aktlevel > this.maxlevel)
      transaction_finished=1
    else
      this.start_level(NowZeit, this.aktlevel);
  }
  if (transaction_finished)
  { clearInterval (this.IntervallHandle);
    this.aktlevel=0;
    if (this.repeat=="repeat")
    { this.start_animation();
    }
  }
}

