//embeds the flash player with the specified video
var espnPromoReel = new function() {
	
	this.vids = [];
	
	this.embedVideo = function(id, container){
		var flashvars = {};
			flashvars.autostart = "false";
			flashvars.id = id;
			flashvars.height = "324";
			flashvars.width = "576";
			flashvars.adminOver = "3805638";
			flashvars.player = "videoHub09";
		
		var params = {};
			params.wmode = "opaque";
			params.allowScriptAccess = "always";
			params.allowFullScreen = "true";
			params.quality = "high";
			params.bgcolor = "#000000";
		
		var attributes = {};
		
		var swfLocation = "http://assets.espn.go.com/espnvideo/mpf32/prod/r_3_2_0_14/ESPN_Player.swf?id=" + id + "&autostart=false&playerType=videoHub09";
		
//		prompt("tocheck", swfLocation);
		
		// Embed that flash
		swfobject.embedSWF( swfLocation, container, "576", "324", "9.0.45", false, flashvars, params, attributes);
	};
	
	this.showcasePlugin = function(obj, rank) {
		rank++;
		
		// analyze obj to figure out its container / section_id
		var section_id = parseInt(obj.context.parentNode.parentNode.id.match(/\d+/));
		
//		alert("showcasePlugin: "+ section_id +", "+rank);
		this.checkVideo(section_id, rank);
		
	};
	
	this.checkVideo = function(section_id, rank) {
//		alert("checkVideo: "+section_id + " , " + rank + ", " + this.vids[section_id][rank]);
		// figure out what one it is in the order
		if(this.vids[section_id] == undefined || this.vids[section_id][rank] == undefined) return false;
		else if(this.vids[section_id][rank] > 0) {
			var tim = setTimeout('espnPromoReel.embedVideo(' + this.vids[section_id][rank] + ', "espn_promoreel_media_' + section_id + '_' + rank + '");', 100);
		} else return false;
		
	};
	
	this.addVideo = function(section_id, rank, id) {
		// id
		if (this.vids[section_id] == undefined) this.vids[section_id] = [];
		if (this.vids[section_id][rank] == undefined) this.vids[section_id][rank] = id;
	};

}

