var slides = Array('#solar','#energy-audits','#heating','#insulation');
var counter = 0;
var settings = {
	easing : 'swing',
	axis : 'x',
	duration : 500
}
var $selected;
function autoPlay()  {
	if(counter == (slides.length)) counter = 0;
	if($selected) $selected.removeClass('selected');
	$('.scroll').scrollTo(slides[counter], settings);
	$('#scrollnav'+(counter+1)+' a').addClass('selected');
	$selected = $('#scrollnav'+(counter+1)+' a');
	counter++;
	setTimeout("autoPlay()", 3000);
}


$(document).ready(function () {
			
	var $panels = $('#slider .scrollContainer > div');
	var $container = $('#slider .scrollContainer');
	
	// if false, we'll float all the panels left and fix the width 
	// of the container
	var horizontal = true;
	
	// float the panels left if we're going horizontal
	if (horizontal) {
	  $panels.css({
	    'float' : 'left',
	    'position' : 'relative' // IE fix to ensure overflow is hidden
	  });
	  
	  // calculate a new width for the container (so it holds all panels)
	  $container.css('width', $panels[0].offsetWidth * $panels.length);
	}
	
	// collect the scroll object, at the same time apply the hidden overflow
	// to remove the default scrollbars that will appear
	var $scroll = $('#slider .scroll').css('overflow', 'hidden');
	
	autoPlay();
	
});