var $jUBT = jQuery.noConflict();

$jUBT(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */
	
	var totWidth=0;
	var positions = new Array();
	var pos = 0;
	var plenght;
	
	$jUBT('#slides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		
		positions[i]= totWidth;
		totWidth += $jUBT(this).width();
		plenght = i;
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		
		if(!$jUBT(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
var pos = $jUBT(this).parent().prevAll('.menuItem').length;
var sz = $jUBT('.menuItem').size();
	
		setInterval(function(e){
						 
			
			pos=pos+1;	
				
			if(pos>=sz){
				$jUBT("#page_"+sz).removeClass('active');
				pos=0;
				
			}	
			
			$jUBT("#page_"+pos).removeClass('active');
			$jUBT("#page_"+(pos+1)).addClass('active');
			
			

$jUBT('#slides').stop().animate({left:-positions[pos]},450);
			
			
			
				

			
			
			/* Start the sliding animation */
			
			e.preventDefault();
			/* Prevent the default action of the link */
	}, 5000);
	
	
	/* next event */
	
	
	
});


