// JavaScript Document
	
	liArray = document.getElementById("ul_carousel").getElementsByTagName('li');
	if(array_length(liArray)>0){
		var y = 0;
		var cycle_aan = true;
		
		//Set het achtergrond plaatje
		big_img_path = liArray[0].getElementsByTagName('input')[0].value;
		newImage = "url("+big_img_path+")";

                link_active = liArray[0].getElementsByTagName('a')[0];
		document.getElementById("rm_view_media").onclick = function() {window.location.href = link_active.href;return false;}

                document.getElementById("rm_view_media").style.backgroundImage = newImage;
		
		init_Carousel();
	}
	function onmouse_out(index){
		y = index;
		
		cycle_aan = true; 
		//init_Carousel();
	}
	function init_Carousel(){
		if(cycle_aan){
			setTimeout('setItemActive(y)',5000);
		}
	}
	function mouse_init_Carousel(li_element){
 		r=0;
		cycle_aan = false;
		if(li_element.id != "active"){
			big_img_path = li_element.getElementsByTagName('input')[0].value;
			newImage = "url("+big_img_path+")";
			
			opacity('rm_view_media',newImage, 100, 0, 800);
			
		}
		while(liArray[r]){    
			liArray[r].id="";    
			r++;  
		}
		link_active = li_element.getElementsByTagName('a')[0];
                document.getElementById("rm_view_media").onclick = function() {window.location.href = link_active.href;return false;}
                
		li_element.id = "active";

	}
	function setItemActive(ii){
		if(cycle_aan){
			
			if(liArray[ii].id == "active"){liArray[ii].id = ""}
			y++; 
			if(array_length(liArray) <= y){	
				y = 0;
			}

			big_img_path = liArray[y].getElementsByTagName('input')[0].value;
			newImage = "url("+big_img_path+")";
			opacity('rm_view_media',newImage, 100, 0, 800);
			
			liArray[y].id = "active";

                        link_active = liArray[y].getElementsByTagName('a')[0];
			document.getElementById("rm_view_media").onclick = function() {window.location.href = link_active.href;return false;}
		
			init_Carousel();
		}
	}
	function array_length(arr) {
		var length = -1;
		for(val in arr) {
			length++;
			
		}
		//met het bovenste doet hij dus niets
		return arr.length;
	}
	function opacity(id,big_img_path, 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++; 
			} 
		opacity('rm_view_media',newImage, 0, 100, 800);
		changeOpac(0,id);
		} else if(opacStart < opacEnd) {
			document.getElementById("rm_view_media").style.backgroundImage = newImage;
			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 + ")"; 
	}
