﻿function FormatTop10Item(obj) { 
var link = $(obj).find("a");
var title = $(link).text();$(link).remove();
var url = ""; url = $(obj).attr("class");
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="nB(\'/link/' + 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+='</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></tr></table>').remove();

var i=0;
$(MyItems).each(function() {

var DestinationCell = "cellA";

$("#"+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();

$("#newsletter div").html("Click here to receive Live Sports Direct's regular newsletter for information on promotional offers and special deals for fans of the sportsbook written in the trademarked LSPD style. <span style='color:#2b7abf;font-weight:bold;'>[coming soon]</span>");
$(".newsletter").find("a").prepend('<span class="nlsb" title="Click here for more details on subscribing to our newsletter"></span>')
$("#newsletter div").hover(function() { $(this).addClass("over");}, function() { $(this).removeClass("over"); }); 
$("#newsletter div").click(function() { n('/newsletter/'); }); 
});

