var ajaxOdds = new Ajaxer();
var interval;


function showOdds_response()
{
	$oddsData = eval('(' + ajaxOdds.getResponseText() + ')');
	
	document.getElementById('oddsContent').innerHTML = $oddsData['odds'];
	document.getElementById('lastUpdate').innerHTML = $oddsData['lastUpdate'];
} // showGameOdds_response


function showOdds()
{
	ajaxOdds.setURL("/engine/actionUpdateOdds.ajax.php");
	
	ajaxOdds.setParameter("sportName", document.getElementById('sport').value );
	ajaxOdds.setParameter("foldername", document.getElementById('division').value );
	ajaxOdds.setParameter("id_schedule", document.getElementById('id_schedule').value );
	ajaxOdds.setParameter("headerType", "BANNER");

	ajaxOdds.setComplete(showOdds_response);
	ajaxOdds.execute();
} // showGameOdds


function setOddsInterval()
{
	interval = setInterval('showOdds()', 60*1000);
}  // setOddsInterval


function setCookie( value )
{
	var expireDate = new Date();
	expireDate.setDate(expireDate.getDate() + 7);
	document.cookie = "updateOdds="+value+";expires="+expireDate.toGMTString()+";path=/";
}  // setCookie


function setUpdateOption()
{
	var updateOn = document.getElementById('updateOn');
	var updateOff = document.getElementById('updateOff');
	
	if ( updateOn.className=='updateOption' )
	{
		clearInterval(interval);
		var selected = updateOff;
		var unselected = updateOn;
		setCookie("Off");
	}
	else
	{
		setOddsInterval();
		var selected = updateOn;
		var unselected = updateOff;
		setCookie("On");
	}  // if

	selected.className = 'updateOption';
	selected.removeAttribute("href");
	selected.removeAttribute("onclick");
	selected.onclick = null;

	unselected.onclick = setUpdateOption;
	unselected.className = '';
	unselected.href = '#';
}  // setUpdateOption

