$(document).ready(function(){
						   
						   
//-----------------------------------
//-----------------------------------
//-----------------------------------


	var totWidth=0;
	var positions = new Array();
	
	$('#slides .slide').each(function(i){
		
		/* Traverse through all the slides and store their accumulative widths in totWidth */
		
		positions[i]= totWidth;
		totWidth += $(this).width();
		
		/* The positions array contains each slide's commulutative offset from the left part of the container */
		
		if(!$(this).width())
		{
			alert("Please, fill in width & height for all your images!");
			return false;
		}
		
	});
	
	$('#slides').width(totWidth);

	/* Change the cotnainer div's width to the exact width of all the slides combined */

	$('#menu_banner_selector ul li a').click(function(e,keepScroll){

			/* On a thumbnail click */

			$('li.menuItem').removeClass('act').addClass('inact');
			$(this).parent().addClass('act');
			
			var pos = $(this).parent().prevAll('.menuItem').length;
			
			$('#slides').stop().animate({marginLeft:-positions[pos]+'px'},450);
			/* Start the sliding animation */
			
			e.preventDefault();
			/* Prevent the default action of the link */
			
			
			// Stopping the auto-advance if an icon has been clicked:
			if(!keepScroll) clearInterval(itvl);
	});
	
	$('#menu_banner_selector ul li.menuItem:first').addClass('act').siblings().addClass('inact');
	/* On page load, mark the first thumbnail as active */
	
	
	
	/*****
	 *
	 *	Enabling auto-advance.
	 *
	 ****/
	 
	var current=1;
	function autoAdvance()
	{
		if(current==-1) return false;
		
		$('#menu_banner_selector ul li a').eq(current%$('#menu_banner_selector ul li a').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
		current++;
	}

	// The number of seconds that the slider will auto-advance in:
	
	var changeEvery = 10;

	var itvl = setInterval(function(){autoAdvance()},changeEvery*1000);

//-----------------------------------
//-----------------------------------
//-----------------------------------
/*
	var totWidth_1=0;
	var positions_1 = new Array();
	
	$('#slides_1 .slide_1').each(function(i){
		positions_1[i]= totWidth_1;
		totWidth_1 += $(this).width(); 
			if(!$(this).width())
			{
				alert("Please, fill in width & height for all your images!");
				return false;
			}
	});
	
	$('#slides_1').width(totWidth_1);
	
	$('#menu_banner_selector_1 ul li a').click(function(e_1,keepScroll_1){

			$('li.menuItem_1').removeClass('act').addClass('inact');
			$(this).parent().addClass('act');
			var pos_1 = $(this).parent().prevAll('.menuItem_1').length;
			$('#slides_1').stop().animate({marginLeft:-positions_1[pos_1]+'px'},450);
			e_1.preventDefault();
			if(!keepScroll_1) clearInterval(itvl_1);
	});

	$('#menu_banner_selector_1 ul li.menuItem_1:first').addClass('act').siblings().addClass('inact');
	


	var current_1=1;
	function autoAdvance_1()
	{
		if(current_1==-1) return false;
		$('#menu_banner_selector_1 ul li a').eq(current_1%$('#menu_banner_selector_1 ul li a').length).trigger('click',[true]); 
		current_1++;
	}

	var changeEvery_1 = 10;
	var itvl_1 = setInterval(function(){autoAdvance_1()},changeEvery_1*1000);

*/
//-----------------------------------
//-----------------------------------
//-----------------------------------
/*

	var totWidth_2=0;
	var positions_2 = new Array();
	
	$('#slides_2 .slide_2').each(function(i){
		positions_2[i]= totWidth_2;
		totWidth_2 += $(this).width(); 
			if(!$(this).width())
			{
				alert("Please, fill in width & height for all your images!");
				return false;
			}
	});
	
	$('#slides_2').width(totWidth_2);
	
	$('#menu_banner_selector_2 ul li a').click(function(e_2,keepScroll_2){

			$('li.menuItem_2').removeClass('act').addClass('inact');
			$(this).parent().addClass('act');
			var pos_2 = $(this).parent().prevAll('.menuItem_2').length;
			$('#slides_2').stop().animate({marginLeft:-positions_2[pos_2]+'px'},450);
			e_2.preventDefault();
			if(!keepScroll_2) clearInterval(itvl_2);
	});

	$('#menu_banner_selector_2 ul li.menuItem_2:first').addClass('act').siblings().addClass('inact');
	


	var current_2=1;
	function autoAdvance_2()
	{
		if(current_2==-1) return false;
		$('#menu_banner_selector_2 ul li a').eq(current_2%$('#menu_banner_selector_2 ul li a').length).trigger('click',[true]); 
		current_2++;
	}

	var changeEvery_2 = 10;
	var itvl_2 = setInterval(function(){autoAdvance_2()},changeEvery_2*1000);


*/
//-----------------------------------
//-----------------------------------
//-----------------------------------
	
	
	
	
	
});
























