refreshLatestResults = function()
        { 
            jQuery.getJSON("/Results/GetLatestResults",
            function(json)
            {
                loading= jQuery("#latestResultsList #divLoadingLatestResults");
                contents = jQuery("#latestResultsList #divContentsLatestResults")

                // Abort if there is no ranking list on the page to update.
                if (contents.length==0)
                {
                    return;
                }

                loading.fadeIn(1000);
                contents.fadeOut(1000);
                
                // If no response was given, the compared ranking was not yet available.
                // Ask again in two seconds!
                if (json == "")
                {
                    setTimeout(refreshLatestResults, 2*1000);
                    return;
                }                
                
                loading.fadeOut(1000);

                contents = jQuery("#latestResultsList #divContentsLatestResults")

                while (contents[0].childNodes[0]) {
                    contents[0].removeChild(contents[0].childNodes[0]);
                }

                var table1=document.createElement("table");
                table1.id="tableRanking";
                table1.setAttribute("className","latestResultsList");

                table1body = document.createElement("tbody");
                table1.appendChild(table1body);

                headerRow = document.createElement("tr");
                table1body.appendChild(headerRow);

                cell= document.createElement("td");
                cell.appendChild( document.createTextNode( "Dato"));
                headerRow.appendChild(cell);

                cell= document.createElement("td"); 
                cell.appendChild( document.createTextNode("Antal"));
                headerRow.appendChild(cell);

                cell= document.createElement("td"); 
                cell.appendChild( document.createTextNode("Spillere"));
                headerRow.appendChild(cell);
                                
                jQuery.each(json, function(i, item)
                {
                    tmpRow= document.createElement("tr");
                    table1body.appendChild(tmpRow);

                    tmpCell= document.createElement("td");
                    tmpCell.setAttribute("align", "left");                                       
                    link = document.createElement("A");
                    link.setAttribute("id","resultsetOverview" + item.Id);
                    link.appendChild( document.createTextNode( item.DateOfResultSet));
                    actionLink = "/Results/ShowResultSetDetailList/"+  item.Id;
                    link.setAttribute("href", actionLink);
                    tmpCell.appendChild(link);
                    tmpRow.appendChild(tmpCell);

                    

                    tmpCell= document.createElement("td");
                    tmpCell.appendChild( document.createTextNode(item.NumberOfGames));
                    tmpCell.setAttribute("align", "right");
                    tmpRow.appendChild(tmpCell);

                    tmpCell= document.createElement("td");
                    tmpCell.appendChild( document.createTextNode(item.Users));
                    tmpCell.setAttribute("align", "left");
                    tmpRow.appendChild(tmpCell);
                });

                contents[0].appendChild(table1);
                
                jQuery(contents).fadeIn(1000);
            });         
        }
jQuery("latestResultsList").ready( refreshLatestResults )