// site specific javascript

$(function(){
		   

	
	//CALLS THE BIND BEHAVIOR FUNCTION
	behavior_binder();
	
});

/*
Binds behaviors
** can be re-run whenever there are DOM changes
*/
function behavior_binder(){

/* ADD FIRST/LAST TO LI
		adds a class 'first' to the first LI, and a 'last' to the last LI and 'first last' to a single LI
	*/
	$('ul').each(function(i){
		$(this).children('li:first').addClass('first');
		$(this).children('li:last').addClass('last');
	});
// END ADD FIRST/LAST TO LI

// give checkbox/radio button sn_form_elementDiv a class
	$(':checkbox').each(function(){
		$(this).parent('.sn_form_elementDiv').addClass('sn_form_elementDiv_checkbox');
	});
	$(':radio').each(function(){
		$(this).parent('.sn_form_elementDiv').addClass('sn_form_elementDiv_radio');
	});
	
	

}

/*
 * tickerMove() -- DISPLAY TICKER (FEED)
 * displays header feed in game header, tickerWidth needs to be set on a 
 * per game basis.
 */
 
var numTickerItemsToMove = 1;
var tickerWidth = 260;
var tickerDistanceToMove = tickerWidth * numTickerItemsToMove;
//var rightMostTickerPosition = ((tickerWidth * totalNumTickerItems) - tickerWidth) * -1;
var numTimesYouCanMoveTicker = Math.ceil(totalNumTickerItems / numTickerItemsToMove) - 1;
var rightMostTickerPosition = tickerDistanceToMove*numTimesYouCanMoveTicker * -1;
function tickerMove(direction)
{
	var element = document.getElementById("tickerList");
	currPosition = element.offsetLeft;
	if (direction == "previous")
	{
		var newPosition = currPosition + tickerDistanceToMove;
		if (newPosition > 0) newPosition = rightMostTickerPosition;
	}
	if (direction == "next")
	{
		var newPosition = currPosition - tickerDistanceToMove;
		if (newPosition < rightMostTickerPosition)  
			newPosition = 0;
	}
	$("#tickerList").css("left", newPosition+"px");
}