var boxLocation = 0;
var orderArray=[4,5,2,3,6,1];

$(function() {

	switch ($('.box').size())
	{
		case 3:
			orderArray=[2,3,1];
		  break;
		case 4:
			orderArray=[2,5,4,1];
		  break;
		case 5:
			orderArray=[4,5,2,3,1];
			$('#nav6').remove();
		  break;
		case 8:
			orderArray=[5,6,2,3,7,8,4,3,7,6,2,1];
		  break;
		default:
			orderArray=[4,5,2,3,6,1];
  }

    autoScroll = setTimeout(scrollToNext,7000);

});

function scrollToNext(){



	$('#nav1,#nav2,#nav3,#nav4,#nav5,#nav6').unbind('mousedown');
	$(".navItem").css("backgroundColor","");
	$(".navItem").css("color","");
	$('#videoBox').scrollTo(  $('#box'+orderArray[boxLocation]) , {duration: theSpeed, queue:true, onAfter:function(){bindNav();}});
	$('#nav'+orderArray[boxLocation]).css("backgroundColor","white");
	$('#nav'+orderArray[boxLocation]).css("color","black");
	boxLocation++;
	if(boxLocation==orderArray.length){boxLocation=0;}
	autoScroll = setTimeout(scrollToNext,4000);

}

