// Suckerfish Dropdown, only for IE6 needed 
startList = function() {
    if (document.all&&document.getElementById) {
        navRoot = document.getElementById("main_nav");
        for (i=0; i<navRoot.childNodes.length; i++) {
            node = navRoot.childNodes[i];
            if (node.nodeName=="LI") {
                node.onmouseover=function() {
                    this.className+=" over";
                }
                node.onmouseout=function() {
                    this.className=this.className.replace(" over", "");
                }
            }
        }
    }
}

// slideshow
function Fader(id, fadetime) {
    this.id = id;
    this.fadetime = fadetime;
    
    this.images = document.getElementById(this.id).getElementsByTagName("img");
    this.counter = 0;

    this.fade = function(step) {
        var fader = this;

        step = step || 0;

        this.images[this.counter].style.opacity = step/100;
        this.images[this.counter].style.filter = "alpha(opacity=" + step + ")"; // IE?

        step = step + 2;

        if (step <= 100) {
            window.setTimeout(function() { fader.fade(step); }, 1);
        } else {
            window.setTimeout(function() { fader.next(); }, this.fadetime);
        }
    };
	
    this.fadeOut = function(step) {
        var fader = this;

        step = step || 100;

        this.images[this.counter].style.opacity = step/100;
        this.images[this.counter].style.filter = "alpha(opacity=" + step + ")"; // IE?

        step = step - 2;

        if (step > 0) {
            window.setTimeout(function() { fader.fadeOut(step); }, 1);
        } else {
            window.setTimeout(function() {
				fader.counter = 0;
				fader.next(); 
			}, this.fadetime);
        }
    };

    this.next = function() {
	    if (this.images.length > 1) {
	        if (this.counter+1 < this.images.length) {
				this.counter++;
				this.fade();
			} else {			
				for (var i=1; i<this.images.length-1; i++) {
	        		this.images[i].style.opacity = 0;
	        		this.images[i].style.filter = "alpha(opacity=0)"; // IE?
				}
				
				this.fadeOut();
	        }
	    }
    }
    
    this.start = function() {
        var fader = this;
        window.setTimeout(function() { fader.next(); }, this.fadetime);
    }
}

// init scripts
function init() {
    // Suckerfish Dropdown
    startList();
    
    // Fader 
    Fader = new Fader('branding', 5000);
    Fader.start();
}

window.onload = init;