

function createStatsLanding() {
	return createBothByClass("t_ibp");
}


function createBothByClass(type) {
	
	function sortByDisplayName(a,b) {
		if (a.display_name > b.display_name) return 1;
		else if (a.display_name < b.display_name) return -1;
		else return 0; 
	}

	var html = "<table width=\"100%\"><tr valign=\"top\">";
	for (var l=0; l < classes.length; l++) {
		
		var arrLeagues = new Array();        
		var i = 0;
		for (league in properties.leagues) {
		    if (properties.leagues[league].hidden != "0") continue;
		    if (properties.leagues[league].sport_code_display == classes[l].sport) {
		        arrLeagues[i] = properties.leagues[league];
		        i++;
		    }
		}
		
		arrLeagues.sort(sortByDisplayName);

		
		for (i = 0; i < arrLeagues.length; i++) {
			var objLeague = arrLeagues[i];
			if (objLeague.sport_code_display == classes[l].sport) {
				objLeague.clubs.sort(sortByDisplayName);
				html += "<td width=\"33%\">";
				html += "<div class=\"subHead\" align=\"center\">" + objLeague.display_name + "</div>";
				
				
				
				if (type == "t_ibp") {
					html += "<p style=\"text-align:center\">";
					html += "<a href=\"/milb/stats/stats.jsp?t=l_sco&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Scores</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"/milb/stats/stats.jsp?t=l_sta&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Standings</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"/mlb/events/winterleagues/schedule/?sid=" + objLeague.id + "\">Schedule</a>";
					html += "</p>";

					html += "<p style=\"text-align:center\">";
					html += "<a href=\"/milb/stats/stats.jsp?t=l_bat&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Batting leaders</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"/milb/stats/stats.jsp?t=l_pit&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Pitching leaders</a><br/>";
					html += "<a href=\"/milb/stats/stats.jsp?t=l_tba&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Team batting</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href=\"/milb/stats/stats.jsp?t=l_tpi&sid=" + objLeague.id + "&lid=" + objLeague.id.substring(1) + "\">Team pitching</a><br/>";
					
					html += "</p>";
				}

				
				
				html += "<ul>";
				
				for (club in objLeague.clubs) {
					
					if (objLeague.clubs[club].hidden != "0") continue;
					
					if (type == "t_sch" && (objLeague.clubs[club].id in _oc(hostedSites))) html += "<li><a href=\"/schedule/index.jsp?sid=" + objLeague.clubs[club].id +"\">" + objLeague.clubs[club].display_name + "</a></li>";
					
					else {  
						if (objLeague.clubs[club].id) html += "<li><a href=\"/milb/stats/stats.jsp?sid=" + objLeague.clubs[club].league_id + "&t=" + type + "&cid=" + objLeague.clubs[club].id.substring(1) +"\">" + objLeague.clubs[club].display_name + "</a></li>"; 
						else html += ""; 
					} 
				}
				html += "</ul><br/></td>";

				
				if (((i+1) % 3) == 0) html += "</tr><tr valign=\"top\">";
			}
		}
		html += "</tr>";
	}
	html += "</table>";
	
	return html;
}