MyPlayer = Player.getPlayerById("espnvideo"); //("player0");
var playerInst0 = new Object();
jQuery(document).ready(function(){ 
	jQuery("#fullTextLink").bind("click", function(){ EVERYZING.playerControls.openTranscript(); })

	/* How much of this should I set?
	playerInst0.playPlayer = function(event){};
	playerInst0.showHideSnippetArrow = function(show, snippetToShow){};
	playerInst0.pausePlayer = function(){document.getElementById('playerInst0_frame').src = 'about:blank';};
	playerInst0.showPlayer = function(){
				if(document.getElementById('playerInst0_frame').src == 'about:blank')
					document.getElementById('playerInst0_frame').src = document.getElementById('playerInst0_frame').getAttribute('savesrc');
			};
	playerInst0.stkw = eval('<xsl:value-of select="$stkw"/>');
	Player.snippetHandleMouseEv = function(ev, index, isClick,isViewMedia,srpindex){}; yes, capital P
	*/
	
	// Timing issue: player function may not be visible even though page is "ready"
	// TODO Does/can the player send a "ready" event or callback?
	playerInst0.seek = function(time) {
		if (typeof MyPlayer == "undefined") {
			MyPlayer = Player.getPlayerById("espnvideo");
		}
		if (typeof MyPlayer.playPlayer == "function") {
			// Custom player api doesn't include "seek"
			// Moving back 5 seconds is a pseudo-sync hack 
			// for keyframe seek problem
			MyPlayer.playPlayer(Math.max(0, Math.round(time) - 5)); 
		}
	};
	
	// The ESPN player seems to clash with this in settings.js. 
	// It probably has its own "customSettings" object, although this problem 
	// only occurs in IE. Go figure.   	
	jQuery(".ez-tagcloudMod-tagcloud .tagcloud-wrapper").gradient({from: 'CA1818', 
            		    										   to:   '8A0000', 
                												   direction: "horizontal"});
});

EVERYZING = EVERYZING || {};
EVERYZING.util = EVERYZING.util || {};
EVERYZING.playerControls = EVERYZING.playerControls || {};
EVERYZING.social = EVERYZING.social || {};

EVERYZING.util.Logger = function (message){
  if(window.console) console.log(message)
  else alert(message);
}

EVERYZING.playerControls.jumpPlayerTo = function(time){
	playerInst0.seek(time);
}


EVERYZING.playerControls.openTranscript = function(){
	var win = window.open(location.href.replace("/m/","/transcript/"), "Transcript", "left=100,screenX=200,width=520,height=480,resizable,scrollbars");
}

// These turned out to be unnecessary because the
// custom player has the functionality built in.
EVERYZING.social.email = function() {
	//alert("Email not implemented");	
}

EVERYZING.social.embed = function() {
	//alert("Embedding not implemented");
}




