var intID;

var leftPos=0;

var liWidth = 160;



$(document).ready(function() {

startMove();

});



function startMove(){

	$('.postLinks a').click(function(){

		selCont($('.postLinks a').index(this));								 

	});

	intID=setInterval('runMove()',5000);	

}





function runMove(){

	leftPos=leftPos-liWidth;

	Moving();

}



function Moving(){

	var total=$("#featuredPostBox ul li").length;

	var width=total*liWidth;

	

	if(-width == leftPos)

		leftPos=0;



	$("#featuredPostBox").animate({ 

        left: leftPos+"px"

      }, 500 );	

}





function selCont(id){

	clearInterval(intID);

	leftPos=-(id*liWidth);

	Moving();

	//alert(leftPos)

	intID=setInterval('runMove()',2000);

}