function getElementsByClassName(clsName) 
{ 
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for ( var cls, i = 0; ( elem = elems[i] ); i++ )
	{
		if ( elem.className == clsName )
		{
			arr[arr.length] = elem;
		}
	}
	return arr;
}

var pictureMenuItems;
var deltimer;
function initialisePictureMenu()
 {
    if (!document.getElementById) {
        return;
    }
    pictureMenuItems = getElementsByClassName('banfader');
	setTimeout("initDelay()",4000);
	
}         
var fadi = 0;
function initDelay() {
	// Attach event handlers to the menu items:
	pictureMenuItems[fadi].onmouseover = function() { fadez(this,100); }
	pictureMenuItems[fadi].onmouseout = function() { fadez(this,20); }
	pictureMenuItems[fadi].opac = 100;
	pictureMenuItems[fadi].timer = '';
	// Apply initial opacity value to all menu objects:
	fadez(pictureMenuItems[fadi], 20);
	deltimer = setTimeout("initDelay()", (100));	
	fadi++;	
	if (fadi >= pictureMenuItems.length) clearTimeout(deltimer);
 }

 
 function setOpacity(obj, opacity)
 {
        // IE filter opacity:
        obj.style.filter = "alpha(opacity:" + opacity + ")";
        // Safari and Konqueror:
        obj.style.KHTMLOpacity = opacity / 100;
        // Old Mozilla and Firefox:
        obj.style.MozOpacity = opacity / 100;
        // CSS3 opacity for browsers that support it:
        obj.style.opacity = opacity / 100;
		obj.opac = parseInt(opacity);
		
 }

 function fadez(obj, destOp)
 {
 		clearTimeout(obj.timer);
 		var opacity = obj.opac;
		var delta = 8;
		if (opacity == destOp) return;
		
		var diff = destOp-opacity;
	    var direction = 1;
		if (opacity > destOp){
			direction = -1;
		}
		delta=Math.min(direction*diff,delta);
		opacity+=direction*delta;
		
        setOpacity(obj, opacity);
        obj.timer=setTimeout(function() { fadez(obj, destOp) }, 20);
 }

//window.onload = initialisePictureMenu;
// non IE
if (window.addEventListener)
	window.addEventListener("load", initialisePictureMenu, false); //invoke function
// IE
if (window.attachEvent)
	window.attachEvent("onload", initialisePictureMenu); //invoke function 

