$(document).ready(function(){   
	var windowWidth = $(window).width();
	var slinIndex = $('.slideMe').length;
	var panelWidth = windowWidth * slinIndex;
	var count = 0;           
	var countReset = count;		
	var newPosition = (count*windowWidth);
	$('.panelA').width(panelWidth);
	$('.slideMe').width(windowWidth);

resetVar = function(){ 
	windowWidth = $(window).width();
	slinIndex = $('.slideMe').length;
	panelWidth = windowWidth * slinIndex;
	newPosition = (count*windowWidth); 
};	

slideIt = function(){ 
	resetVar();
	$('.panelA').animate({'left':- Math.round(newPosition)}, 800);		
	$('.slideNav span').removeClass('active').eq(count).addClass('active');
};

setMe = function(){ 
	intervalID = setInterval(function() {	 
		if(count == slinIndex - 1) {count = countReset}
		else {var countKeep = (count++);}
		slideIt();
	}, 18000);
};
setMe();
	
$('.slideNav span').each(function(i){
	$(this).click(function(){
		var indexSpan = $('.slideNav span').index(this);
		count = indexSpan
		clearInterval(intervalID);
		slideIt();
		setMe();
	});
});

$('.callOut').each(function(i){
	$(this).click(function(){
		clearInterval(intervalID);
		setMe();
	});
});

$(window).resize(function() {
	resetVar();		
	$('.slideMe').stop().width(windowWidth);
	$('.panelA').stop().width(panelWidth).css({'left':- newPosition});		
});

});
