var lastLink
var linksNo
var cott = {
    timeout: 750,
    maxLink: 0,
    init: function() {
        var topLink = document.getElementById("toplink");
        var links = topLink.getElementsByTagName("A");
        cott.maxLink = links.length-1;
		
        if (links.length == 0) { return; }
        for(var i=0;i<links.length;i++) {
			
            links[i].style.zoom = 1;
            links[i].style.display = 'none';
        }
        setTimeout("cott.rotateLink(1)", cott.timeout); 
    },
    fadeTo: function(obj, lvl) {
        obj.style.filter = 'alpha(opacity=' + lvl*10 + ')';
        obj.style.opacity = lvl/10;
    },
    rotateLink: function (linkNo) {
		
        cott.displayNextLink(linkNo);
        var nextLink = linkNo + 1;
        if (nextLink > cott.maxLink) {
			
            nextLink = 0;
        }
        var t = setTimeout("cott.rotateLink(" + nextLink + ")", cott.timeout);
    },
    displayNextLink: function(linkNo) {
		linksNo=linkNo
         lastLink = linkNo-1;
        if (lastLink < 0) {
            lastLink = cott.maxLink;
        }
		cott.fade(-9.9);
    },
    fade: function(stage) {
			if (!document.getElementById("toplink").getElementsByTagName("a")[lastLink]) { return; }
			 fobj = document.getElementById("toplink").getElementsByTagName("a")[lastLink];
			if (!document.getElementById("toplink").getElementsByTagName("a")[linksNo]) { return; }
			tobj =  document.getElementById("toplink").getElementsByTagName("a")[linksNo];
			
		
		
				if (stage < 0) {
					
					cott.fadeTo(fobj, Math.abs(stage));
				} else if (stage == 10) {
					cott.fadeTo(tobj, 9.9);
				} else if (stage == 0) {
					fobj.style.display = 'none';
					cott.fadeTo(tobj, 1);
					tobj.style.display = 'inline';
				} else {
					cott.fadeTo(tobj, stage);
				}
				if (stage != 10) { 
				var b = setTimeout("cott.fade(" + parseInt(stage+1) + ")", 40);
				}
    }
};

