var countNode = document.getElementById("knoten").childNodes.length;
if(!window.WDHG)WDHG = new Object();
var start =(document.all)?0:1; // muss bei NS mit 1 beginnen
var BGFadeInStep=5;
var BGFadeOutStep=5;
var BGEndColor="e6e7f9";
var BGStartColor="CCCCFF";
var BGFadeRunning=false;
//*******************Evend-Handler***************************
document.onmouseover = theOnOver;
document.onmouseout  = theOnOut;
if(document.captureEvents)
    document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
//***********************************************************
WDHG.obj = Array();
for (var i=start; i<countNode ; i++ ) {
// es werden nur die TD-Knoten im Array gespeichert
o=document.getElementById("knoten").childNodes[i].firstChild;
  if(o !="#text") {
    WDHG.obj[i]=o;
  }
}
//alert(WDHG.obj.length+" Knoten wurden gez&auml;hlt."); //anzahl der Knoten
//*****************Knoten ausgeben*******************************
//document.write("folgende Knoten sind gespeichert:<br>");
//for (var i=start; i<countNode ; i++ ) {
//if(WDHG.obj[i]) {
//document.write("Knoten "+i+" mit dem Namen <b>" + WDHG.obj[i].nodeName + "<\/b><br>");
//}

//}
//************************************************************
WDHG.ElName = "";
WDHG.hexDec = function (hex){return(parseInt(hex,16));}
WDHG.decHex = function (dec){return (dec < 16 ? "0" : "") + dec.toString(16);}
/************************************************************
*
* Function    : WDHG.getColor
* @params     : start   - the start color (in the form "RRGGBB")
*             : end     - the end color (in the form "RRGGBB" )
*             : percent - the percent (0-100) of the fade between start & end
* returns     : color in the form "#RRGGBB"
*
*************************************************/
WDHG.getColor = function (start, end, percent)
{

        var rStart=WDHG.hexDec(start.slice(0,2));
        var gStart=WDHG.hexDec(start.slice(2,4));
        var bStart=WDHG.hexDec(start.slice(4,6));

        var rEnd=WDHG.hexDec(end.slice(0,2));
        var gEnd=WDHG.hexDec(end.slice(2,4));
        var bEnd=WDHG.hexDec(end.slice(4,6));

        var pc=percent/100;

        var r=Math.round(rStart+(pc*(rEnd-rStart)));
        var g=Math.round(gStart+(pc*(gEnd-gStart)));
        var b=Math.round(bStart+(pc*(bEnd-bStart)));

        return("#" + WDHG.decHex(r) + WDHG.decHex(g) + WDHG.decHex(b));
}
/************************************************/


// 001______________________________________________
function theOnOver(e)
{
var obj;
        if(window.event){
                obj=event.srcElement;

        }else
                obj=e.target;

        if(obj.nodeName!='OPTION'){
       //alert(" Knoten: "+obj.nodeName+" Gespeichert: "+countNode);
                WDHG.linkFadeUp(obj);
}
}
// 002______________________________________________
WDHG.linkFadeUp = function(obj)
{
        if(obj.state == null)
        {
                obj.state = "OFF";
                obj.index = 0;
                obj.startColor = BGStartColor;
                obj.endColor = BGEndColor;
        }

        if(obj.state == "OFF")
        {
                obj.state = "FADE_UP";

                WDHG.startBGFader();
        }
        else if( obj.state == "FADE_UP_DOWN"
                || obj.state == "FADE_DOWN")
        {
                obj.state = "FADE_UP";
        }
}
// 003______________________________________________
function theOnOut(e)
{
var obj;
if(window.event)
                obj=event.srcElement;
        else
                obj=e.target;

                WDHG.linkFadeDown(obj);

}
// 004_______________________________________________
WDHG.linkFadeDown = function(obj)
{
        if(obj.state=="ON")
        {
                obj.state="FADE_DOWN";
                WDHG.startBGFader();
        }
        else if(obj.state == "FADE_UP")
        {
                obj.state="FADE_UP_DOWN";
        }
}
// 005_________________________________________________
WDHG.startBGFader = function()
{
        if(!BGFadeRunning ){

                WDHG.BGFadeAnimation();}
}
// 006*********************************************
WDHG.BGFadeAnimation = function(){
        BGFadeRunning = false;

        for (i=start; i<countNode ; i++ ) {
// Da bei NS die #text-Knoten nicht im Array gespeichert wurden
// muss hier eine Pr&uuml;fung erfolgen
 if(WDHG.obj[i]) {
    var obj = WDHG.obj[i];
//nur Knoten mit href animieren
    if(obj.state && obj.nodeName=="A"){
   // window.status=obj.state+" Index: "+obj.index+" Knoten: "+countNode;
         if(obj.state == "FADE_UP")
         {
           obj.index+=BGFadeInStep;
           if(obj.index > 100)
             obj.index = 100;
obj.style.background=WDHG.getColor(obj.startColor, obj.endColor, obj.index);

           if(obj.index == 100)
              obj.state="ON";
           else
             BGFadeRunning = true;
         }
         else if(obj.state == "FADE_UP_DOWN")
         {
            obj.index+=BGFadeOutStep;
            if(obj.index>100)
            obj.index = 100;

obj.style.background=WDHG.getColor(obj.startColor, obj.endColor, obj.index);

                                if(obj.index == 100)
                                        obj.state="FADE_DOWN";
                                BGFadeRunning = true;
                        }
                        else if(obj.state == "FADE_DOWN")
                        {
                                obj.index-=BGFadeOutStep;
                                if(obj.index<0)
                                        obj.index = 0;
obj.style.background=WDHG.getColor(obj.startColor, obj.endColor, obj.index);

                                if(obj.index == 0)
                                        obj.state="OFF";
                                else
                                        BGFadeRunning = true;
                        }
                }
}
}

        /*** Check to see if we need to animate any more frames. ***/
        if(BGFadeRunning)
                setTimeout("WDHG.BGFadeAnimation()", 10);
}

for (var i=start; i<countNode ; i++ ) {
if(WDHG.obj[i]) {
WDHG.linkFadeUp(WDHG.obj[i]);
//WDHG.obj[i].state="FADE_UP_DOWN";
//WDHG.linkFadeDown(WDHG.obj[i]);
}

}
for (var i=start; i<countNode ; i++ ) {
if(WDHG.obj[i]) {
WDHG.linkFadeDown(WDHG.obj[i]);
}

}