var player;
////////////////////////////////////////////
// showPlayer()
// Description : Open the player
// Param : 
//		none
////////////////////////////////////////////
function showPlayer(){
	if (!checkPlayerOpen()){
	    player = window.open(g_SSLRoot + "/Common/Popup/NowPlaying.aspx", "_mg_now_playing", "height=640,width=245,scrollbars=no,menubar=no,toolbar=no,status=no,resizable=no");
	}
	return true;
}
////////////////////////////////////////////
// checkPlayerOpen()
// Description : The player updates the "_mn_player_poll" every couple seconds.
//  If the player hasnt updated the cookie then it aint open.
// Param : 
//		none
////////////////////////////////////////////
function checkPlayerOpen(){
	var s = getCookieValue("_mn_player_poll");
	if (s == false){
		return false;
	}
	else{
		var d = new Date(s);
		var now = new Date();
		
		if (dateDiff("s", s, now.toString()) > 3)
			return false;
		else
			return true;
	}
}
////////////////////////////////////////////
// alertTempItem()
// Description : Temp function to for top 1000 items
// Param : 
//		none
////////////////////////////////////////////
function alertTempItem(){
	alert('This is a MusicGremlin temporary item and is not available.');
	return false;
}
////////////////////////////////////////////
// a()
// Description : Adds an item to the add cookie so that the player can pick it up.
// Param : 
//		id = an item id that is to be added to the player.
//		typ = track, album, playlist, gremlist
//		action = playnow or add to playlist
////////////////////////////////////////////
function a(id, typ, action){
	try{
		showPlayer();	// show the player
		
		//format the item and add it to the add cookie
		var newItem = id.toString() + "," + typ.toString() + "," + action.toString();
		var s = getCookieValue("_mn_player_queue");
		if (s == false || s == ""){
			writeNowPlayingPlayerCookie("_mn_player_queue", newItem);
			s = getCookieValue("_mn_player_queue");
		}	
		else
			writeNowPlayingPlayerCookie("_mn_player_queue", s + "|" + newItem);
	}
	catch(e){ // unhandled
		jsError("NowPlayingUtil.js::a()", e.message, true);
	}
	return false;
}

function closePlayer(){
}