	  var vCarousel;
	  var interaction = 0;
     
	 function runTest() {


		if (document.getElementById('vertical_carousel')) {	
		 vCarousel = new UI.Carousel("vertical_carousel", {direction: "vertical"});	
		 if (userscroll > 0){
	        interactiontest();
			}else{
		  setTimeout('interactiontest();', delay);	
		  }
		   //testif users has rolled over the carosell
	    Event.observe($("vertical_carousel"), 'mouseover', function() {
	   	interaction = 1;//  alert(interaction);
		  });}
			
				if (document.getElementById('horizontal_carousel')) {	
		 vCarousel = new UI.Carousel("horizontal_carousel", {direction: "horizontal"});	
		 if (userscroll > 0){
	        interactiontest();
			}else{
		  setTimeout('interactiontest();', delay);	
		  }
		   //testif users has rolled over the carosell
	    Event.observe($("horizontal_carousel"), 'mouseover', function() {
	   	interaction = 1;//  alert(interaction);
		  });}
			
    }

		 
	 //auto scroll if user has not interacted with carosell
	  function autoscroll() {
	 	 currentpoz = vCarousel.currentIndex();
		 maxscroll =  vCarousel.elements.length-3;
		 vCarousel.scrollTo(currentpoz+3);
		 setTimeout('interactiontest();', delay);
	  }
	  
		
		//scroll controll logic
	   function interactiontest(){
	   currentpoz = vCarousel.currentIndex();
		 maxscroll =  vCarousel.elements.length-3;
		// alert('current'+ currentpoz +' maxscroll'+ maxscroll);
	   if (interaction == 0){
	    if (userscroll > 0){
	        vCarousel.scrollTo(userscroll);
			}else if(maxscroll <= currentpoz){
		     vCarousel.scrollTo(0);autoscroll();
		    }else{
			autoscroll();
			}
	    }
	   }
	   Event.observe(window, "load", runTest);
			
			