var SortType = {
    'Application': 0,
    'Developer': 1,
    'EarningsAllTime': 2
};

var SortOrder = {
    'Ascending': 0,
    'Descending': 1
}

function LeaderboardRow(appCellObj, developerCellObj, allTimeCellObj)
{
    this.Application = new ApplicationCell(appCellObj.Data, appCellObj.MarkupObj);
    this.Developer = new DeveloperCell(developerCellObj.Data, developerCellObj.MarkupObj);
    this.AllTimeEarnings = new EarningsCell(allTimeCellObj.Data, allTimeCellObj.MarkupObj);
 
    this.Render = function(rank)
    {
        var tr = document.createElement("tr");
        var td = document.createElement("td");
        td.className = 'rankvalue';
        td.innerHTML = rank;
        
        tr.appendChild(td);
        tr.appendChild( this.Application.Render() );
        tr.appendChild( this.Developer.Render() );
        tr.appendChild( this.AllTimeEarnings.Render() );
        return tr;
    };
    
    /*
        Compares the current row with otherRow based on the sortType.
        This function returns the following:
             -1 if this row is smaller than otherRow
             0 if this row is equal to otherRow
             1 if this row is greater than otherRow
    */
    this.Compare = function (otherRow, sortType)
    {
        switch (sortType)
        {
            case SortType.Application:
                return this.Application.Compare(otherRow.Application);
            case SortType.Developer:
                return this.Developer.Compare(otherRow.Developer);
                break;
            case SortType.EarningsAllTime:
                return this.AllTimeEarnings.Compare(otherRow.AllTimeEarnings);
                break;
        }
    };
}
