




function rerouteClubsAndStatsTargets() {
	var linkObj, i=0;
	while ( linkObj = document.links[i++] ) {
		// replace stats.jsp with winterleagues-hosted
		if ( linkObj.href.indexOf('minorleaguebaseball.com/milb/stats/') > -1 || linkObj.href.indexOf('minorleaguebaseball.com/clubs/') > -1 || linkObj.href.indexOf('minorleaguebaseball.com/leagues/') > -1 ) {
			var new_path = linkObj.href.replace(/http:\/\/[^\/]*\/|https:\/\/[^\/]*\//,top.location.protocol+'//'+top.location.host+'/');
			linkObj.href = new_path;
		}
	}
}

function getImagesWithinDiv(divId) {
	var out = null;
	var divContainer = document.getElementById(divId);
	if (divContainer != null) out = divContainer.getElementsByTagName("img");
	return out;
}

function rerouteImageSrc(divId) {
	var out = getImagesWithinDiv(divId);
	if ( out != null && out.length > 0 ) {
		var out_length = out.length - 1;
		var imgObj, new_src;
		do {
			imgObj = out[out_length];
			new_src = imgObj.src.replace(/http:\/\/[^\/]*\/|https:\/\/[^\/]*\//,top.location.protocol+'//web.minorleaguebaseball.com/');
			imgObj.src = new_src;
		} while (out_length--);
	}
}

function overwriteMinimums(type, value, season_state) {
	var label = (type == 'l_pit') ? " innings pitched" : " plate appearances";
	var team_or_league = (season_state == 'offseason') ? "league" : "team";
	try {
		document.getElementById("minimums").innerHTML = "<br/><span class=\"textSm\">(minimum " + value + label + " per " + team_or_league + " game)</span>";
	} catch (e) {}
}

function copyArray(a) {
    if ( a==null ) return null;
    var ret = [];
    for (var i=0; i < a.length; i++) ret[i] = a[i];
    return ret;
}