	var image_index=0;

	var interval = 5; // delay between rotating images (in seconds)
	interval *= 1000;


	function addLoadEvent(func) {

	    var oldonload = window.onload;

	    if (typeof window.onload != 'function') {

	        window.onload = func;

	    } else {

	        window.onload = function() {

	            if (oldonload) {

	                oldonload();

	            }

	            func();

	        }

	    }

	} 


	
	function imageItem(image_location) {
		this.image_item = new Image();
		this.image_item.src = image_location;

	}
		
	function startRotating (place, fileName)
	{
		rotateImage(place);
	}
	
	function rotateImage(place) {
		var divParent = document.getElementById(place).parentNode;

		image_index = (image_index) % image_list.length;
		changeOpac(99,place);
		changeOpac(99,divParent.id);
		document.getElementById(place).style.backgroundImage = "url(" + image_list[image_index].image_item.src + ")"; 

		image_index += 1;	
		if (image_index==image_list.length)
			{image_index=0;
			}
			
		document.getElementById(divParent.id).style.backgroundImage = "url(" + image_list[image_index].image_item.src + ")"; 
			
							
		var recur_call = "rotateImage('"+place+"')";
		var timed_call = "timedopacity('"+place+"')";

		setTimeout(recur_call, 10000);
		setTimeout(timed_call, 8000);
		
	}
	function timedopacity(place)
	{
	opacity(place,50,1,2000);
	}
	
	function opacity(id, opacStart, opacEnd, millisec) { 
		//speed for each frame 
		var speed = Math.round(millisec / 100); 
		var timer = 0; 

		//determine the direction for the blending, if start and end are the same nothing happens 
		if(opacStart > opacEnd) { 
			for(i = opacStart; i >= opacEnd; i--) { 
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
				timer++; 
			} 
		} else if(opacStart < opacEnd) { 
			for(i = opacStart; i <= opacEnd; i++) 
				{ 
				setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
				timer++; 
			} 
		} 
	} 

	//change the opacity for different browsers 
	function changeOpac(opacity, id) { 
		var object = document.getElementById(id).style; 
		object.opacity = (opacity / 100); 
		object.MozOpacity = (opacity / 100); 
		object.KhtmlOpacity = (opacity / 100); 
		object.filter = "alpha(opacity=" + opacity + ")"; 
		
	} 

	



