function tombstoneToggle(ctrl)
{
	var tId=$(ctrl).attr("id");
	$(".tombstoneItem").css({"display":"none"});
	$("#tombstone_" + tId).css({"display":"block"});
}
var tombStoneInterval=null;
function scroll(speed,rev)
{
	
	 

	 
	if (!speed) speed=8000;
	var inc=400;
	if (rev) 
		inc*=-1;
	else
		rev=0;
		
		
	
			
	var leftNext=parseInt($("#tombstones").css("left"))-inc;
	
 
	 
	//clearInterval(tombStoneInterval);
	//tombStoneInterval=setInterval(function(){checkTombstoneScroll();},500);
	
	var width=parseInt($("#tombstones").css("width"))-parseInt($("#tombstones").parent().parent().css("width"));
	
	
	if (Math.abs(leftNext)>width)
	{
		//speed=(speed/inc) * parseInt(Math.abs(parseInt($("#tombstones").css("left"))+width ));
		leftNext=width*-1;
	}
	
	if (leftNext>0) 
	{
		//speed=(speed/inc) * parseInt(parseInt($("#tombstones").css("left")));
		leftNext=0;
	}
	
	
	
	$("#tombstones").animate({left:leftNext + "px"}, speed,'linear',function(){scroll(speed,rev);} );
}
function checkTombstoneScroll()
{



	var tL=parseInt($("#tombstones").css("left"));
	
	$("#txtStatus").html(tL + "," + $("#tombstones").css("width"));
	 
	if (tL>0) 
	{
		$("#tombstones>img:last").insertBefore("#tombstones>img:first");
	}
	 
	
}
function setScroll(ev)
{
	var offset=$("#tombstones").parent().parent().offset();
	var posX=ev.pageX-offset.left;
	var w=parseInt($("#tombstones").parent().parent().css("width"));
	
	
	var regionW=w/5;
	
	var region=Math.ceil(posX/regionW);
	$(".status").html(region);
	
	
	
	$("#tombstones").stop();
	var rev=0;
	speed=8000;
	if (region<3) rev=1;
	if (region>=5 || region<=1)
	{
		speed=3200;
	}
	
	if (region!=3)
	{
		scroll(speed,rev);
	}	
	
	
	
	
}