﻿
// ------------------------------------------------------------------------------------------
// MJB - Functions to display the picks of a Given Player
// ------------------------------------------------------------------------------------------
    function LoadWagersForUser(iRowIndex) {

        if (TogglePlusMinus(iRowIndex, PlayersGrid.getTotalNumberOfRecords()) == "MinusClicked")
        {
            $get('divWagers').innerHTML = "Loading..."; 
            PlayersGrid.cancel();
        }
        else
        {
            $get('divWagers').innerHTML = "Loading..."; 
            PlayersGrid.editRecord(iRowIndex);
            $get('LegendTitle').innerHTML = 'Picks for ' + PlayersGrid.Rows[iRowIndex].Cells['Name'].Value + ':&nbsp;';
            YAF.Pages.BGG_WagersForUser.ShowWagersForUser(PlayersGrid.Rows[iRowIndex].Cells['UserID'].Value, OnUsersWagersSucceeded, OnUsersWagersFailed); 
        }
    }

    function OnUsersWagersSucceeded(result, userContext, methodName) {
    $get('divWagers').innerHTML = result; 
    }

    function OnUsersWagersFailed(error, userContext, methodName) {
    $get('divWagers').innerHTML = "An error occured.";
    }



// ------------------------------------------------------------------------------------------


// ------------------------------------------------------------------------------------------
// MJB - Generic functions 
// ------------------------------------------------------------------------------------------
    function TogglePlusMinus(iRowIndex, iTotalRows) {
        
        strDirStructure = $get('divCurrentTheme').innerHTML;
        strCurrentIconSrc = $get('plusRow' + iRowIndex).src;
        if (strCurrentIconSrc.substr(strCurrentIconSrc.length - 9,9) == "minus.gif")
        {
            $get('plusRow' + iRowIndex).src = strDirStructure + "/plus.gif";           
            return "MinusClicked";
        }
        else
        {
            $get('plusRow' + iRowIndex).src = strDirStructure + "/minus.gif"; 
        //    ResetPlusIcons(iRowIndex, iTotalRows);
            return "PlusClicked"
        }
    }

    function ResetPlusIcons(iNotMe, iTotalRows)
    {
        count = 0;
        strTemp = "";
        rows = iTotalRows;
        
        while (count < rows) {
            if (count != iNotMe){
                strTemp = $get('divCurrentTheme').innerHTML + "/plus.gif";
                $get('plusRow' + count).src = strTemp 
            }
            count ++;
        }
    }
// ------------------------------------------------------------------------------------------

