////////////////////// ROLLOVER - DREAMWEAVER //////////////////////

<!--
function openwin(url, name, options) {
      var win = window.open(url, name, options);}
//-->

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

////////////////////// EXPANDABLE ITEM scripts//////////////////////
if (document.getElementById){
document.write('<style type="text/css">\n')
document.write('.sub{display: none;}\n ')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var ar = document.getElementById("expDiv").getElementsByTagName("div");
		var ex = document.getElementById("ex"+(obj));
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="sub")
				ar[i].style.display = "none";
				ex.value = "[+]";
			}
			el.style.display = "block";
			document.getElementById("ex"+(obj)).value = "[—]";
		}else{
			el.style.display = "none";
			document.getElementById("ex"+(obj)).value = "[+]";
		}
	}
}

if(document.getElementById){
	document.write('<style type="text/css">\n')
	document.write('.submenu{display: none;}\n')
	document.write('</style>\n')	
}
function expandGames(obj){
	if(document.getElementById){
		var el = document.getElementById(obj);
		var ar = document.getElementById("menuMaster").getElementsByTagName("span");
		if(el.style.display != "block"){
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function setcookie(cookieName,cookieValue,days,nPath){
	var today = new Date();
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*60*60*24*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = cookieName+"="+escape(cookieValue) + expires + "; path=" + nPath;
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

/////////////////////////////////////////

/********** Used by createWager.jsp **********************/
/********** and by createTeaser.jsp **********************/

var multiSingle = false;

function initCreateWager(){
    // initialize calculator
	if (multiSingle) {
		initCreateWagerMultiSingle();
		return;
	}
	
    if (document.createWager) { 
	    if (currentRiskAmount != null){
			document.createWager.riskAmount.value = currentRiskAmount; // set selected risk if true
		} else if (wagerMin < lastRiskAmount ) {
            document.createWager.riskAmount.value = lastRiskAmount; // set min bet
        } else {
            document.createWager.riskAmount.value = wagerMin; // set min bet
        }
        document.createWager.riskAmount.focus();
        wagerWin = document.createWager.riskAmount.value * wAmount / rAmount;
        wagerWin = Math.round( wagerWin * 100 ) / 100;
        document.createWager.winAmount.value = dollarize(wagerWin);
        defineEvents();
    }
}

function initCreateWagerMultiSingle(setManually) {
	var wagerCount = arrCurrentRiskAmount.length;
	
	if (document.createWager) { 
		for (var w=0;w<wagerCount;w++) {
			if (!setManually) {
				if (arrCurrentRiskAmount[w] != null) {
					document.createWager['riskAmount' + w].value = arrCurrentRiskAmount[w];
				} else if (arrWagerMin[w] < arrLastRiskAmount[w] ) {
		            document.createWager['riskAmount' + w].value = arrLastRiskAmount[w]; // set min bet
		        } else {
		            document.createWager['riskAmount' + w].value = arrWagerMin[w]; // set min bet
		        }
			}
			wagerWin = document.createWager['riskAmount' + w].value * arrWAmount[w] / arrRAmount[w];
	        wagerWin = Math.round( wagerWin * 100 ) / 100;
	        document.createWager['winAmount' + w].value = dollarize(wagerWin);
		}
		defineMultiSingleEvents();
		setMultiSingleRiskTotals();
	}
}

function setMultiSingleRiskTotals() {

	var wagerCount = arrCurrentRiskAmount.length;
	var objRiskTotal = document.getElementById('total-risk');
	var objWinTotal = document.getElementById('total-towin');
	var riskAmount = 0;
	var winAmount = 0;
	var objRisk;
	var objWin;
	var r, w;
	
	if (document.createWager) {
		for (var w=0;w<wagerCount;w++) {
			objRisk = document.getElementById('riskAmount'+w);
			riskAmount += parseFloat(objRisk.value);
			objWin = document.getElementById('winAmount'+w);
			winAmount += parseFloat(objWin.value);
		}
		
		r = new Number(riskAmount).toString();
		w = new Number(winAmount).toString();

		if (riskAmount < 0 || r == 'NaN')	{
			objRiskTotal.innerHTML = '0';
		} else {
			objRiskTotal.innerHTML = dollarize(riskAmount);
		}
		
		if (winAmount < 0 || w == 'NaN')	{
			objWinTotal.innerHTML = '0';
		} else {
			objWinTotal.innerHTML = dollarize(winAmount);	
		}
	}
	
}


/********** Used by updateWager.jsp **********************/
function initUpdateWager(){
    // focus the place bet button
    document.placeBetForm.placeBet.focus();
}


//*************** calculator *******************//

function defineEvents() {
	document.createWager.riskAmount.onkeyup=setWinAmount;
	document.createWager.winAmount.onkeyup=setRiskAmount;
}

function defineMultiSingleEvents() {
	var wagerCount = arrCurrentRiskAmount.length;
	var objRisk;
	var objWin;
	
	if (document.createWager) { 
		for (var w=0;w<wagerCount;w++) {
			objRisk = document.getElementById('riskAmount'+w);
			objWin = document.getElementById('winAmount'+w);
			objRisk.onkeyup=setMultiWinAmount;
			objWin.onkeyup=setMultiRiskAmount;
		}
	}
}


function setMultiWinAmount() {
	var riskAmount = this.value;
	var n = new Number(riskAmount).toString();
	var index = this.id.split('riskAmount')[1];
	var objWin = document.getElementById('winAmount'+index);
	
	stripAlpha(this);
	
	if (riskAmount < 0 || n == 'NaN')	{
		objWin.value = 0;
	} else {
		wagerWin = riskAmount * arrWAmount[index] / arrRAmount[index];
	    wagerWin = Math.round( wagerWin * 100 ) / 100;
		objWin.value = dollarize(wagerWin);
	}
	setMultiSingleRiskTotals();
}


function stripAlpha(field) {
	var val = field.value;
	//only allow numbers and decimal
	field.value = val.replace(/[^0-9.]/i,'');
}

function setMultiRiskAmount() {
	var winAmount = this.value;
	var n = new Number(winAmount).toString();
	var index = this.id.split('winAmount')[1];
	var objRisk = document.getElementById('riskAmount'+index);

	stripAlpha(this);
	
	if (winAmount < 0 || n == 'NaN')	{
		objRisk.value = 0;
	} else {
		wagerRisk = winAmount * arrRAmount[index] / arrWAmount[index];
	    wagerRisk = Math.round( wagerRisk * 100 ) / 100;
		objRisk.value = dollarize(wagerRisk);
	}
	setMultiSingleRiskTotals();
}


// turn incoming expression into a dollar value
function dollarize (expr) {
	return format(expr,2);
}

function setWinAmount() {
	var riskAmount = document.createWager.riskAmount.value;
	var n = new Number(riskAmount).toString();
	
	stripAlpha(this);
	
	if (riskAmount < 0 || n == 'NaN')	{
		document.createWager.winAmount.value = 0;
	} else {
	    wagerWin = document.createWager.riskAmount.value * wAmount / rAmount;
	    wagerWin = Math.round( wagerWin * 100 ) / 100;
	    document.createWager.winAmount.value = dollarize(wagerWin);
	}
}

function setRiskAmount() {
	var winAmount = document.createWager.winAmount.value;
	var n = new Number(winAmount).toString();
	
	stripAlpha(this);
	
	if (winAmount < 0 || n == 'NaN')	{
		document.createWager.riskAmount.value = 0;
	} else {
	    wagerRisk = document.createWager.winAmount.value * rAmount / wAmount;
	    wagerRisk = Math.round( wagerRisk * 100 ) / 100;
	    document.createWager.riskAmount.value = dollarize(wagerRisk);
	}
}

// This is set globally in checkWC so that I can see it's value to verify against the maximum number of multi-singles
var globalTotalNum = 0;

function verifyMultiSingles() {
	var MAX_SINGLES = 20;
	
	if (globalTotalNum > MAX_SINGLES) {
		alert('You may only place a maximum of ' + MAX_SINGLES + ' single bets at one time.\nYou have selected ' + globalTotalNum + ' single bets.\n\nPlease uncheck ' + (globalTotalNum-MAX_SINGLES) + ' of them and try again.');
		return false;
	} else {
		return true;
	}
}

// this function takes care of the decimal place formating
function format (expr, decplaces) {
	var str = "" + Math.round (eval(expr) * Math.pow(10,decplaces));
	while (str.length <= decplaces) {
    	str = "0" + str;
	}
	var decpoint = str.length - decplaces;
	return str.substring(0,decpoint) + "." + str.substring(decpoint,str.length);
}
// ******************* end calculator *************************//

/********** Disable Bet Button **********************/

function disableBetButton(){
document.placeBetForm.placeBet.disabled = true;
}

/***************** Bet functions *********************/
function cancel(targetURL) {
	document.location.href = targetURL;
}

function placeBet() {
    document.createWager.action = "UpdateWager";
    document.createWager.submit();
}

function switchPicks() {
    document.createWager.action = "SwitchPicks";
    document.createWager.submit();
}

function addPicks() {
    document.createWager.action = "AddPick";
    document.createWager.submit();
}

function addPicksOnly() {
    document.wagerLocation.action = "/sportsbook/app/AddPick";
    document.wagerLocation.submit();
}

function changeBuyPoints() {
    document.createWager.action = "CreateWager";
    document.createWager.submit();
}

function repostMultiSingle() {
    document.placeBetForm.action = "CreateWager";
    document.placeBetForm.submit();
}



function setTeaserOption( optionID ) {
    document.createWager.action = "CreateWager";
    document.createWager.teaserOption.value = optionID;
    document.createWager.submit();
}

// disable form buttons

function updateWagerButAction(){
document.placeBetForm.submit();
document.placeBetForm.placeBet.disabled=true; 
document.placeBetForm.Cancel.disabled=true; 
document.placeBetForm.reenter.disabled=true; 
}


// *******sports menu dropdown handler ************/
function formHandler(PICK){
		if (document.wagerLocation.selectSport.value == "#") {
		return;
		} else {
		document.location = PICK.options[PICK.selectedIndex].value;
	}
}

/*********Schedule Form Buttons Handler *******/
function doSomething(){
    alert('action');
}

var isProp = false; // used to check for futures/props
var isTeasable = false; // used to check for teasable events

function checkWC() {

	var checkBoxes = document.getElementsByName("lineID")
    var len = checkBoxes.length
    var checkedNum = 0;
     
    for( var i=0; i<len; i++ ) {
        if( checkBoxes[i].checked ) {
            checkedNum ++;
        }
    }
    
    var pickBoxes = document.getElementsByName("pickIndex")
    var picklen = pickBoxes.length
    var pickNum = 0;
     
    for( var i=0; i<picklen; i++ ) {
        if( pickBoxes[i].checked ){
            pickNum ++;
        }
    }

    var totalNum = checkedNum + pickNum;
	globalTotalNum = totalNum;

    // Disable all Buttons
    if( totalNum == 0 ) {
		deactivateButton( "toolbar-single" );
		deactivateButton( "toolbar-if-bet" );		
		deactivateButton( "toolbar-reverse" );
		deactivateButton( "toolbar-parlay" );			
		deactivateButton( "toolbar-teaser" );
		deactivateButton( "toolbar-round-robin" );

		/*		
        document.wagerLocation.single.disabled = true;
		//document.wagerLocation.single.value = 'Single'		
        document.wagerLocation.single.className = "toolbarButtonDis";
        document.wagerLocation.ifbet.disabled = true;
        document.wagerLocation.ifbet.className = "toolbarButtonDis";
        document.wagerLocation.reverse.disabled = true;
        document.wagerLocation.reverse.className = "toolbarButtonDis";
        document.wagerLocation.parlay.disabled = true;
        document.wagerLocation.parlay.className = "toolbarButtonDis";
        document.wagerLocation.teaser.disabled = true;
        document.wagerLocation.teaser.className = "toolbarButtonDis";
        document.wagerLocation.roundrobin.disabled = true;
        document.wagerLocation.roundrobin.className = "toolbarButtonDis";
		*/
    // Disable parlay/teaser wager buttons
    } else if( totalNum == 1 ) {
		activateButton( "toolbar-single" );
		deactivateButton( "toolbar-if-bet" );		
		deactivateButton( "toolbar-reverse" );
		deactivateButton( "toolbar-parlay" );			
		deactivateButton( "toolbar-teaser" );
		deactivateButton( "toolbar-round-robin" );
	
		/*
        document.wagerLocation.single.disabled = false;
		//document.wagerLocation.single.value = 'Single';
        document.wagerLocation.single.className = "toolbarButton";
        document.wagerLocation.ifbet.disabled = true;
        document.wagerLocation.ifbet.className = "toolbarButtonDis";
        document.wagerLocation.reverse.disabled = true;
        document.wagerLocation.reverse.className = "toolbarButtonDis";
        document.wagerLocation.parlay.disabled = true;
        document.wagerLocation.parlay.className = "toolbarButtonDis";
        document.wagerLocation.teaser.disabled = true;
        document.wagerLocation.teaser.className = "toolbarButtonDis";
        document.wagerLocation.roundrobin.disabled = true;
        document.wagerLocation.roundrobin.className = "toolbarButtonDis";
		*/
		
    // Disable Single Wager Button
    } else if( totalNum == 2 ) {
		activateButton( "toolbar-single" );
		activateButton( "toolbar-if-bet" );		
		activateButton( "toolbar-reverse" );		
		activateButton( "toolbar-parlay" );				
		deactivateButton( "toolbar-round-robin" );	
	
		/*
        document.wagerLocation.single.disabled = false;
		//document.wagerLocation.single.value = 'Multi';
        document.wagerLocation.single.className = "toolbarButton";
        document.wagerLocation.ifbet.disabled = false;
        document.wagerLocation.ifbet.className = "toolbarButton";
        document.wagerLocation.reverse.disabled = false;
        document.wagerLocation.reverse.className = "toolbarButton";
        document.wagerLocation.parlay.disabled = false;
        document.wagerLocation.parlay.className = "toolbarButton";
        document.wagerLocation.teaser.disabled = false;
        document.wagerLocation.teaser.className = "toolbarButton";
        document.wagerLocation.roundrobin.disabled = true;
        document.wagerLocation.roundrobin.className = "toolbarButton";
		*/
    } else {
		activateButton( "toolbar-single" );
		deactivateButton( "toolbar-if-bet" );		
		deactivateButton( "toolbar-reverse" );
		activateButton( "toolbar-parlay" );			
		activateButton( "toolbar-round-robin" );	
	
		/*
        document.wagerLocation.single.disabled = false;
		//document.wagerLocation.single.value = 'Multi';
        document.wagerLocation.single.className = "toolbarButtonDis";
        document.wagerLocation.ifbet.disabled = true;
        document.wagerLocation.ifbet.className = "toolbarButtonDis";
        document.wagerLocation.reverse.disabled = true;
        document.wagerLocation.reverse.className = "toolbarButtonDis";
        document.wagerLocation.parlay.disabled = false;
        document.wagerLocation.parlay.className = "toolbarButton";
        document.wagerLocation.teaser.disabled = false;
        document.wagerLocation.teaser.className = "toolbarButton";
        document.wagerLocation.roundrobin.disabled = false;
        document.wagerLocation.roundrobin.className = "toolbarButton";
		*/
    }

	if (isTeasable && totalNum >= 2 ){
		activateButton( "toolbar-teaser" );
	} else {
		deactivateButton( "toolbar-teaser" );		
	}	
	   
    if (checkedNum >= 1) {
	
//        document.wagerLocation.addtopicks.disabled = false;
//        document.wagerLocation.addtopicks.className = "toolbarButton";
    } else {
//        document.wagerLocation.addtopicks.disabled = true;
//        document.wagerLocation.addtopicks.className = "toolbarButtonDis";
    }
	
      
   // disable parlay and teaser buttons if only props
   if (isProp == true && checkedNum >= 1) { 
		activateButton( "toolbar-single" );
		deactivateButton( "toolbar-if-bet" );		
		deactivateButton( "toolbar-reverse" );
		deactivateButton( "toolbar-parlay" );			
		deactivateButton( "toolbar-teaser" );
		deactivateButton( "toolbar-round-robin" );   

		/*   
       document.wagerLocation.parlay.disabled = true;
       document.wagerLocation.parlay.className = "toolbarButtonDis";
       document.wagerLocation.teaser.disabled = true;
       document.wagerLocation.teaser.className = "toolbarButtonDis";
       document.wagerLocation.ifbet.disabled = true;
       document.wagerLocation.ifbet.className = "toolbarButtonDis";
       document.wagerLocation.reverse.disabled = true;
       document.wagerLocation.reverse.className = "toolbarButtonDis";
       document.wagerLocation.roundrobin.disabled = true;
       document.wagerLocation.roundrobin.className = "toolbarButtonDis";
	   */
   }
}

function activateButton( buttonName ) {
	var disabledTopButton = document.getElementById(buttonName + '-top-disabled');
	if (disabledTopButton) { disabledTopButton.style.display = 'none'; }	
	var activeTopButton = document.getElementById(buttonName + '-top-active');
	if (activeTopButton) { activeTopButton.style.display = 'block';	}

	var disabledBottomButton = document.getElementById(buttonName + '-bottom-disabled');
	if (disabledBottomButton) { disabledBottomButton.style.display = 'none'; }	
	var activeBottomButton = document.getElementById(buttonName + '-bottom-active');
	if (activeBottomButton) { activeBottomButton.style.display = 'block';	}
	
}

function deactivateButton (buttonName ) {
	var activeTopButton = document.getElementById(buttonName + '-top-active');
	if (activeTopButton) { activeTopButton.style.display = 'none';	}
	var disabledTopButton = document.getElementById(buttonName + '-top-disabled');
	if (disabledTopButton) { disabledTopButton.style.display = 'block'; }	

	var activeBottomButton = document.getElementById(buttonName + '-bottom-active');
	if (activeBottomButton) { activeBottomButton.style.display = 'none'; }
	var disabledBottomButton = document.getElementById(buttonName + '-bottom-disabled');
	if (disabledBottomButton) { disabledBottomButton.style.display = 'block';}
}

/************** used by Bet History ************/
function betHistoryHandler(x){
		var period = x;
		if (document.betHistoryForm.timePeriod.value == "#") {
		return;
		} else {
		document.location = '/sportsbook/app/ViewSettledWagers?period='+period;
	}
}

// *************** used by the reload lines button ************//

function reloadLines() {
var event = document.location;
	document.location.href = event;
}

// ************** used by createTeaser.jsp to show sweetheart teaser info //
function showTeaserInfo(){
if (!document.getElementById){
openHelp('sportsbook/wager-teaser.jsp');
} else {
document.getElementById('sweetheartInfo').style.display = 'block';
}
}

function hideTeaserInfo(){
document.getElementById('sweetheartInfo').style.display = 'none';
}

var timeoutID = null;

function markToolbarLocation() {
    var scheduleToolbar = document.getElementById('scheduleToolbar');

    if ( scheduleToolbar ) {
        if( timeoutID != null ) {
            clearTimeout( timeoutID );
        }
        scheduleToolbar.style.visibility = "hidden";
        timeoutID = setTimeout( "positionToolbar()", 300 );
    }
}

function positionToolbar() {
    var ie = (navigator.userAgent.indexOf("MSIE 6.") != -1);

    var scheduleToolbar = document.getElementById('scheduleToolbar');
    var masterBlock = document.getElementById('master-content-block');
    
    if( document.documentElement.scrollTop ){
        var viewTop = document.documentElement.scrollTop;
    } else {
        var viewTop = document.body.scrollTop;
    }
    var scheduleTop = masterBlock.offsetTop + 64;
    
    if( viewTop  > scheduleTop ) {
        var offsety = ( viewTop - scheduleTop ) + 64;

        if( ie ) {
            scheduleToolbar.style.visibility = "hidden";
        }
        
        scheduleToolbar.style.top = offsety + 'px';
        scheduleToolbar.style.left = '190px';
        
        if( ie ) {
            scheduleToolbar.filters[0].Apply();
        }
        
        scheduleToolbar.style.visibility = "visible";
        
        if( ie ) {
            scheduleToolbar.filters[0].Play();
        }
    } else {
        scheduleToolbar.style.top  = '64px';
        scheduleToolbar.style.left = '190px';
        scheduleToolbar.style.visibility = "visible";
    }
}


function ViewPreferences( strFilter, strSort, strPicksViewState ){
    this.eventFilter = strFilter;
    this.eventSort = strSort;
    this.picksViewState = strPicksViewState;
}

ViewPreferences.prototype.setFilter = function( strFilter ) {
    this.eventFilter = strFilter;
    this.setCookie();
    document.location.replace( document.location.href );
}

ViewPreferences.prototype.setSort = function( strSort ) {
    this.eventSort = strSort;
    this.setCookie();
    document.location.replace( document.location.href );
}

ViewPreferences.prototype.setPicksViewState = function( strPicksViewState ) {
    this.picksViewState = strPicksViewState;
    this.setCookie();
    //document.location.replace( document.location.href );
}


ViewPreferences.prototype.setCookie = function() {
    document.cookie = "ScheduleViewPrefs=filter:"+ this.eventFilter + "&sort:" + this.eventSort + "&picks:" + this.picksViewState + "; path=/";
}


function ScheduleMenu(){
    this.openBranches = new Array();
}

ScheduleMenu.prototype.toggleBranch = function( elmNode ){  
    var branch = elmNode.parentNode;
    if( branch.className == "branch-closed" ) {
        //closeOpenBranches();
        this.addOpenBranch( branch.id )
        branch.className = "branch-open";
    } else {
        this.removeOpenBranch( branch.id )
        branch.className = "branch-closed";
    }
    
	if (branch.id == "Football" && branch.className == "branch-open"){		
		this.setCookie( "football", "open" );
	} else	if (branch.id == "Football" && branch.className == "branch-closed"){		
		this.setCookie( "football", "closed" );
	} else {
	    this.setCookie();
	}
}

ScheduleMenu.prototype.addOpenBranch = function( strId) {
    this.openBranches[ this.openBranches.length ] = strId;
}

ScheduleMenu.prototype.removeOpenBranch = function( strId) {
    var newOpenBranches = new Array();
    
    var len = this.openBranches.length; 
    for( i=0; i<len; i++ ) {
        var currId = this.openBranches[i];
        if( strId != currId ){
            newOpenBranches[ newOpenBranches.length ] = currId;
        }
    }
    
    this.openBranches = newOpenBranches;
}

ScheduleMenu.prototype.closeOpenBranches = function() {
    var len = this.openBranches.length; 
    for( i=0; i<len; i++ ) {
        var branch = document.getElementById( openBranches[i] );
        branch.className = "branch-closed";
    }
    this.openBranches = new Array()
}

ScheduleMenu.prototype.setCookie = function( branchId , state ) {
    var cookieValue = "";
    var len = this.openBranches.length; 
    for( i=0; i<len; i++ ) {
        cookieValue += this.openBranches[i];
        if( i < ( len -1 ) ) {
            cookieValue += '&';
        }
    }
	
	if (branchId == "football"){
	    document.cookie = "ScheduleMenuFootballConfig="+ state +"; path=/";	
	} 

    document.cookie = "ScheduleMenuConfig="+cookieValue+"; path=/";


}

// used for date and time stamp in sportsbook toolbar
function writeTime() {
    var timeStamp = document.getElementById( "timestamp" );
    
    if( timeStamp == null || timeStamp.innerHTML == null ){
        return;
    }
    
    
    var d = new Array();
    var weekday = new Array( "Sun","Mon","Tue","Wed","Thu","Fri","Sat" );
    var monthname = new Array( "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" );
    
    var today = new Date( msStartTime );
    
    var dayname = weekday[ today.getUTCDay() ];
    var month = monthname[ today.getUTCMonth() ];
    var numdate = today.getUTCDate();
    var hours = today.getUTCHours();
    var minutes = today.getUTCMinutes();
    var seconds = today.getUTCSeconds();
    
    var ampm = ( hours >= 12 )?'p':'a';
    
    if ( hours > 12 ){
        hours -= 12;
    }
        
    minutes = fixTime( minutes );
    seconds = fixTime( seconds );

    var time = dayname + " " + month + ". " + numdate + ", " + hours + ":" + 
    minutes +  ":" + seconds + ampm + " ET";
    
    var currentStamp = timeStamp.innerHTML;

    if (currentStamp != time ){
        timeStamp.innerHTML = time;
    }
    
    msStartTime += 500;
    timeout= setTimeout( 'writeTime();',500 );
}

function fixTime( time ) {
    if (time < 10){
        time = "0" + time;
    }
    return time;
}

function submitWager(type){

	var wagerVar = document.getElementById("wagerType");
	wagerVar.value = type;
	if (type == 'Single' && verifyMultiSingles()){
		document.wagerLocation.submit();
	}
	
	if (type == 'Parlay'){
		document.wagerLocation.submit();		
	}
	
	if (type == 'Round Robin'){
		roundRobinParlay();
		document.wagerLocation.submit();			
	}
	
	if (type == 'If Bet'){
		document.wagerLocation.submit();			
	}	

	if (type == 'Reverse'){
		document.wagerLocation.submit();			
	}			

	if (type == 'Teaser'){
		document.wagerLocation.submit();			
	}		
}

function pressButton(name,image)
{
	document[name].src='/images/sportsbook/' + image;
}	


function selectbillboard(id){

	if (selectedspotlight != id){
	
		if (selectedspotlight != ""){
			var oldspotlight = document.getElementById('spotlight-' + selectedspotlight);
			oldspotlight.style.background = 'url(/images/sportsbook/spotlight-off.gif)';

			var oldspotlightarrow = document.getElementById('spotlight-arrow-' + selectedspotlight);
			oldspotlightarrow.style.background = '#000';
			
			var oldpromoblock =  document.getElementById('promoblock-' + selectedspotlight);				

			if (oldpromoblock){
				oldpromoblock.style.display = 'none';			
			} else {
				oldpromoblock =  document.getElementById('promoblock-default-' + selectedspotlight);				
				oldpromoblock.style.display = 'none';								
			}
		}
				

				
		if (  ! document.getElementById('spotlight-' + id) ){
			return false;
		}
		
		
		var newspotlight = document.getElementById('spotlight-' + id);		
		newspotlight.style.background = 'url(/images/sportsbook/spotlight-selected.gif)';	

		var newspotlightarrow = document.getElementById('spotlight-arrow-' + id);
		newspotlightarrow.style.background = 'url(/images/sportsbook/spotlight-arrow.gif)';	

		var newpromoblock =  document.getElementById('promoblock-' + id);	
		
		if (newpromoblock){
			newpromoblock.style.display = 'block';				
		} else {
			newpromoblock =  document.getElementById('promoblock-default-' + id);				
			newpromoblock.style.display = 'block';										
		}

		selectedspotlight = id;		

		return true;
	}
}


function activatespotlight(id){
	// swap background image
	if (id != selectedspotlight){
		var spotlight = document.getElementById('spotlight-' + id);		
		spotlight.style.background = "url(/images/sportsbook/spotlight-on.gif)";
		spotlight.style.cursor = "pointer";
	}
}

function deactivatespotlight(id){
	// swap background image
	if (id != selectedspotlight){
		var spotlight = document.getElementById('spotlight-' + id);		
		spotlight.style.background = "url(/images/sportsbook/spotlight-off.gif)";
		spotlight.style.cursor = "default";		
	}
	
}

function onloadBillboard(  promoParameter, promoFirst ){

	var promofound = false;
	
	if (promoParameter != ''){
			promofound = selectbillboard( promoParameter );	
	}

	if (!promofound ){
		promofound = selectbillboard( promoFirst );		
	}

	if (!promofound){

		// hide the billboards
//		var billboards = document.getElementById('billboard');
//		billboards.style.display = 'none';
		
		// show default
	
	}				

}

function popUp(name, url){	
	newWin=window.open(url,name,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=1024,height=800');
	if(!newWin){
		popupDisabledMsg();
	}
	newWin.focus();
}


function popupDisabledMsg() {	
		var errorHTML = "";
		errorHTML += "<div class=\"no-script\">";
		errorHTML += "	<div id=\"error-icon\"><img src=/"/lib/images/spacer.gif/" align=\"left\" alt=\"Error\"/></div>";
		errorHTML += "	<div id=\"error-copy\">";
		errorHTML += "		<span id=\"error-copy-warning\" >It seems your browser's popup is blocked. You have to click the \"Live\" button again.<br/></span>";
		errorHTML += "	</div>";
		errorHTML += "</div>";	
		document.getElementById("popup-disabled-alert").innerHTML = errorHTML;	
} 