$(document).ready(function(){ 
	
	var settings = {
		target:'.sd-sections',
		items:'li',
		prev:'a.sd-prev',
		next:'a.sd-next',
		//navigation:'.sd-navigation a',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		step:1,
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them !!!!!
		,max:5
		,onBefore:function( e, elem, $pane, $items, pos ){
			/*
			$('.sd-navigation a').each(function() {
					$(this).removeClass('active');					
					if($(this).attr('href')=='#'+elem.id) $(this).addClass('active');
				});
			*/
		}
	};
	
	var settings2 = {
		target:'.sd-sections',
		items:'li',
		prev:'a.sd-prev',
		next:'a.sd-next',
		//navigation:'.sd-navigation a',
		offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
		step:1,
		start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		jump: false //click on the images to scroll to them !!!!!
		,max:1
		,onBefore:function( e, elem, $pane, $items, pos ){
			/*
			$('.sd-navigation a').each(function() {
					$(this).removeClass('active');					
					if($(this).attr('href')=='#'+elem.id) $(this).addClass('active');
				});
			*/
		}
	};
	
		$('#sd-index #item1').serialScroll(settings);
		$('#sd-index #item2').serialScroll(settings2);
		//$('#sd-index #item2').serialScroll(settings2);
		$('#sd-index #item3').serialScroll(settings);
		
		var menu_id = '#sd-index .sd-navigation a';
		//if ($(selector).exists()) {}
		$(menu_id).click(function () {
			var href1 = $(this).attr('href');
			var idx = $(menu_id).index(this);
			//Показываем активное меню
			$(menu_id).each(function() {
				//alert(idx+' '+$(this).index());
				if(idx == $(this).index()) $(this).addClass('active');
				else $(this).removeClass('active');
			});
			$('#sd-index .sd-items').each(function() {
				//alert(href + '  #'+$(this).attr('id'));
				if(href1 == '#'+$(this).attr('id')) $(this).removeClass('hide');
				else $(this).addClass('hide');
			});
			return false;
		});
	//}
	//jQuery.fn.exists = function(){return ($(this).length > 0);}

}); 
