﻿function FormatTop10Item(obj) { 
var link = $(obj).find("a");
var title = $(link).text();$(link).remove();
var url = ""; url = $(link).attr("href");
var img = ""; img = $(obj).find("img");
var text = $.trim($(obj).text());

var html = "";
html+= '<table width="100%" border="0" cellpadding="0" cellspacing="0" class="listingitem" title="' + title + '" onclick="n(\'' + url + '\');">';
html+= '<tr>';
html+= '<td valign="top" class="listingitemcell">';

if ((img != null) && (img != "")) { var src = img.attr("src");if ((src != null) && (src != "")) { 
html+= '<table width="100" border="0" align="left" cellpadding="0" cellspacing="0" class="itemlogo"><tr><td align="center" valign="middle" style="background:#fff;"><img src="' + src + '" alt="' + title + '" /></td></tr></table>';
} else { 
html+= '<table width="100" border="0" align="left" cellpadding="0" cellspacing="0" class="itemlogo"><tr><td align="center" valign="middle">' + title + '</td></tr></table>';
}}
html+= '<table><tr><td class="listingitemtext" valign="middle" align="left">' + text + '</td></tr></table>';
//html+= $(obj).html();
html+='</td>';
html+= '</tr>';
html+= '</table>';

return html;

}

function RenderDirectoryItems() { 
var MyItems = $("#directory ul li")
$("#directory ul").after('<table width="100%" border="0" cellpadding="5" id="sportsbooklistingitems"><tr><td width="33%" id="cellA" valign="top"></td><td width="33%" id="cellB" valign="top"></td><td width="33%" id="cellC" valign="top"></td></tr></table>').remove();

var i=0;
$(MyItems).each(function() {

var DestinationCell = "cellA";
if (i % 2 == 0) { DestinationCell = "cellB" }
if (i % 3 == 0) { DestinationCell = "cellC" }

$("#"+DestinationCell).html($("#"+DestinationCell).html() + FormatTop10Item($(this)));

i++;

});

$(".listingitem").hover(function() { $(this).removeClass("listingitem"); $(this).addClass("listingitemover"); }, function() { $(this).removeClass("listingitemover"); $(this).addClass("listingitem"); }); 

}

$(function() {
RenderDirectoryItems();
});

