function WInfoInit() {
    var wInfoElm = null;
    var wInfoMsgs = new Array();
	var wInfoLinks = new Array();
	var wIndex = 0;
	var wOldIndex = 0;
	var wNewIndex = 0;
	var wInfoFadeElm = null;
	var xtimerskip = 0;
	var xtimer;
	var xfadetimer;
	var wFadeState = 0;
	var wFadeCnt = 0;
    if (document.getElementById) {
        wInfoElm = document.getElementById('winfo');
    }
    if (wInfoElm) {
		var elmsearch = true;
		var elmIndex = 1;
		while (elmsearch) {
			if (document.getElementById('wi'+zeroPad(elmIndex,2))) {
				wInfoMsgs[elmIndex-1] = document.getElementById('wi'+zeroPad(elmIndex,2));
				elmIndex++;
			} else {
				elmsearch = false;
			}
		}
		if (wInfoMsgs.length > 1) {			
			for (var i =0; i<wInfoMsgs.length;i++) {
				wInfoLinks[i] = xCreateElement('a');
				wInfoLinks[i].style.display = 'block';
				wInfoLinks[i].style.position = 'absolute';
				wInfoLinks[i].style.top = '12px';
				wInfoLinks[i].style.right = (((wInfoMsgs.length-1-i)*24)+22)+'px';
				wInfoLinks[i].style.width = '16px';
				wInfoLinks[i].style.height = '16px';
				wInfoLinks[i].style.border = '1px solid #1e1e1f';
				wInfoLinks[i].style.background = '#660044';
				wInfoLinks[i].style.zIndex = '10';
				wInfoLinks[i].style.cursor = 'pointer';
				wInfoLinks[i].onmouseover = function() { wInfoSwitch(this); }
				wInfoLinks[i].windex = i;
    			wInfoElm.appendChild(wInfoLinks[i]);
			}
			wInfoLinks[0].style.background = '#11cc00';
			wInfoFadeElm = xCreateElement('div');
			wInfoFadeElm.style.zIndex = '9';
			wInfoFadeElm.style.background = '#000000';
			wInfoFadeElm.style.width = '100%';
			wInfoFadeElm.style.height = wInfoElm.clientHeight+'px';
			wInfoFadeElm.style.position = 'absolute';
			wInfoFadeElm.style.top = '0';
			wInfoFadeElm.style.left = '0';
			wInfoFadeElm.style.visibility = 'hidden';
			wInfoElm.appendChild(wInfoFadeElm);
			xtimer = window.setInterval(wInfoChange,10000);
		}
    }

	function wInfoSwitch(elm) {
		xtimerskip = 2;
		window.clearInterval(xfadetimer);		
		wOldIndex = wIndex;
		wIndex = elm.windex;
		wNewIndex = wIndex;
		for (i=0;i<wInfoMsgs.length;i++) {
		    if (i != wNewIndex) {
				wInfoLinks[i].style.background = '#660044';
			}
		}
		wInfoLinks[wNewIndex].style.background = '#11cc00';
		wFadeState = 0;
		xfadetimer = window.setInterval(wInfoFade,1);
	}

	function wInfoChange() {
		if (xtimerskip == 0) {
			window.clearInterval(xfadetimer);
			wOldIndex = wIndex;	
			wIndex++;
			if (wIndex >= wInfoMsgs.length)	{ wIndex = 0; }	
			wNewIndex = wIndex;
			for (i=0;i<wInfoMsgs.length;i++) {
			    if (i != wNewIndex) {
			        wInfoLinks[i].style.background = '#660044';
	    		    }
			}
    		        wInfoLinks[wNewIndex].style.background = '#11cc00';
			wFadeState = 0;
			xfadetimer = window.setInterval(wInfoFade,1);
		} else {
			xtimerskip--;
		}
    }

	function wInfoFade() {
		if (wFadeState == 0) {
			wInfoFadeElm.style.opacity = (0)
            wInfoFadeElm.style.filter = 'alpha(opacity=0)';
			wInfoFadeElm.style.visibility = 'visible';
			wFadeCnt = 0;
			wFadeState = 1;
		}
		else if (wFadeState == 1) {
			if (wFadeCnt <= 30) {
				var opacity = Math.floor(wFadeCnt*(100/30));
                wInfoFadeElm.style.opacity = (opacity/100)
                wInfoFadeElm.style.filter = 'alpha(opacity='+opacity+')';
				wFadeCnt++;				
			} else {
			    for (i=0;i<wInfoMsgs.length;i++) {
		    		if (i != wNewIndex) {
						wInfoMsgs[i].style.visibility = 'hidden';
					}
				}
				wInfoElm.className='wi'+zeroPad((wNewIndex+1),2);
				wInfoMsgs[wNewIndex].style.visibility = 'visible';
				wFadeState = 2;
				wFadeCnt = 0;
			}
		} 
		else if (wFadeState == 2) {
			if (wFadeCnt <= 30) {
				var opacity = 100-Math.floor(wFadeCnt*(100/30));
                wInfoFadeElm.style.opacity = (opacity/100)
                wInfoFadeElm.style.filter = 'alpha(opacity='+opacity+')';
				wFadeCnt++;				
			} else {
				wInfoFadeElm.style.opacity = (0)
            	wInfoFadeElm.style.filter = 'alpha(opacity=0)';
				wInfoFadeElm.style.visibility = 'hidden';
				wFadeCnt = 0;
				wFadeState = 1;
				window.clearInterval(xfadetimer);
			}
		}		
	}    
        
    
}

function zeroPad(num,count) {
    var result = num + '';
    while(result.length < count) {
		result = '0'+result;
    }
    return result;
}


function xCreateElement(type) {
    var result = false;
    if (document.createElementNS) {
        result = document.createElementNS('http://www.w3.org/1999/xhtml','html:'+type);
    } else {
        result = document.createElement(type);
    }
    return result;
}

function addEvent(obj, evType, fn){
    if (obj.addEventListener){
        obj.addEventListener(evType, fn, false);
        return true;
    } else if (obj.attachEvent){
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    } else {
        return false;
    }
}

addEvent(window,'load',WInfoInit);

