<!--
//#############################################################################
//#############################################################################
//#############################################################################

// Night Rider effect of the nav links on the main page. HA!


var conMultiplier = 1.08;
var conTop = 300;
var conBottom = 50;

var iChangeRate = conTop;   // set in nightRider().  Based on the number of iCrossRate/iLies.
var iLies;                  // <li> count
var iCurrentLI = 0;         // currently lit <li>   
var bRight = 1;             // direction of 'light'
var sLID = 'nightRider';    // default home page selections
var bGoFaster = 1;
var iTimeoutActive = 0;
var iMode = 0;
var bGoNightRider = true;
var bAtHome = false;
var bAtSub = false;
var hColor = 'ffffff';
//var bRandomize = true;

function nightRider(){
    var sURL = document.location.toString();   //convert to string rather than pass object.
    var aURL = sURL.split('/');
    if (aURL.length == 4){  // At home.
        calculateLies('navUL');
        bAtHome = true;
        nightRiderMove();
    } else {         
        if (((sURL.indexOf('/software/') > 0 ) | (sURL.indexOf('/links/') > 0 )) && (aURL.length == 5)) {  //do night rider to sub navigations
            calculateLies('subUL');
            sLID = 'subNightRider'
            bAtSub = true;
            restartNightRider();
        }
    }
}
function nightRiderMove(){
    if (bGoNightRider){
        iTimeoutActive = 1
        if (iMode == 0){
            gbid(sLID + iCurrentLI).className = '';
        } else {
            gbid(sLID + iCurrentLI).className = 'liCurrent';          
        }
        if (bRight){
            if (iCurrentLI == iLies) {  //  at last right, now moving left
                iCurrentLI--;
                bRight = 0;
                changeColor();
            } else {                    // moving right
                iCurrentLI++ 
            }
        } else {
            if (iCurrentLI == 0) {      // at first left, now moving right
                iCurrentLI++;
                bRight = 1;
                changeColor();
                if (bGoFaster) {
                    if (iChangeRate > conBottom){
                        iChangeRate = iChangeRate / conMultiplier; // go faster and faster!!
                    } else {
                        bGoFaster = 0;
                        //iMode = (iMode == 1)? 0 : 1;  // switch default lighting to: off/on or on/off
                    }
                } else {    // go slower
                    if (iChangeRate < conTop){
                        iChangeRate = iChangeRate * conMultiplier; //go slower and slower!!
                    } else {
                        bGoFaster = 1;  //start going faster now
                    }
                } 
            } else {                    // moving left
                iCurrentLI--;       
            }       
        }
        //iCurrentLI = (bRandomize)? Math.round(iLies*Math.random()) : iCurrentLI;
        if (iMode == 0){
            gbid(sLID + iCurrentLI).className = 'liCurrent';     
        } else {
            gbid(sLID + iCurrentLI).className = '';     
        }
        //gbid('info').innerHTML = iCurrentLI+' | '+bRight+" | "+bGoFaster+" | "+iMode+" | "+hColor+" | "+iChangeRate;
        //gbid('kc').style.color = '#' + hColor;
        setTimeout('nightRiderMove()', iChangeRate);  //loop
    }
}
var iHue = 0;
var hexColor = 0;
function changeColor(){
    var iHue = (Math.round(3*Math.random())* 2) - 2;
    //var hexColor = Math.round(15*Math.random())
    //iHue = (iHue == 4)? 0 : iHue+2;
    hexColor = (hexColor == 15)? 0 : hexColor + 3;
    hColor = hColor.replace(hColor.substr(iHue,2) ,d2h(hexColor).toString() + d2h(hexColor).toString());
}
var hD="0123456789ABCDEF";
function d2h(d) {
    var h = hD.substr(d&15,1);
    while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
    return h;
}
function h2d(h){
    return parseInt(h,16);
}
function stopNightRider(i){
    bGoNightRider=false;
    iCurrentLI = i;     // Save position so we can resume when user onMouseOut.
    iChangeRate = conTop;  //reset.
    iGoFaster = 1;
    for (var i = 0; i <= iLies; i++){
        gbid(sLID + i).className = '';
    } 
    iTimeoutActive = 0;
}
function restartNightRider() {
    if(!iTimeoutActive){
        if (bAtHome || bAtSub){
            bGoNightRider=true;
            if (iCurrentLI > iLies){iCurrentLI = iLies;}//if user hovers main cats prevent bug.
            nightRiderMove();
        }
    }
}
function calculateLies(sParentNode){
    var oLies = gbid(sParentNode).childNodes;
    iLies = oLies.length;       
    if (navigator.appName == 'Netscape'){ // DOM tree in Netscape is different than IE
        iLies = (((iLies-1)/2)-1); 
    } else {
        iLies--;    
    }
    bGoNightRider = true;
}
//#############################################################################
//#############################################################################
//#############################################################################
//-->
