var CurImgSld = 0;
var MaxImgSld = 6; // $('.sliderPage').length - 1;
var SldInt;

$(function() {

	$('#homeSlider').cycle({
		fx: 'scrollLeft',
		timeout: 0,
		speed: 700,
		startingSlide: 0
	});

	$('.selectSlide').click( function() {
	
		clearInterval(SldInt);
	
		$(".homeSlideSelect .active").each(function(){
			$(this).removeClass('active');
		});
	
		$('#homeSlider').cycle({
			fx: 'scrollLeft',
			timeout: 0,
			speed: 700,
			startingSlide: CurImgSld
		});
	
		CurImgSld = parseFloat($(this).attr("id"));
		
		$('#'+CurImgSld).addClass('active');
		
		$('#homeSlider').cycle( CurImgSld );
		
		return false;
	
	});

	SldInt = setInterval("nextSlide()", 2000);

});

function nextSlide () {

	$(".homeSlideSelect .active").each(function(){
		$(this).removeClass('active');
	});

	$('#homeSlider').cycle({
			fx: 'scrollLeft',
			timeout: 0,
			speed: 700,
			startingSlide: CurImgSld
	});

	CurImgSld++;

	if (CurImgSld > MaxImgSld) { CurImgSld = 0; }

	//alert('#'+CurImgSld);

	$('#'+CurImgSld).addClass('active');

	$('#homeSlider').cycle( CurImgSld );

}
