////////////////////////////////////////////////////////////////////
//
//		Controls the J W Media Player
//
////////////////////////////////////////////////////////////////////

// Sends instruction to player
function sendEvent(swf,typ,prm)
	{
		thisMovie(swf).sendEvent(typ,prm);
	}

// This is a javascript handler for the player and is always needed.
function thisMovie(movieName) {
	if(navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
	} else {
		return document[movieName];
	}
}


// Gets update from player
// state 0=stop, 1=buffer, 2=play
function getUpdate(typ,pr1,pr2,swf)
{
	// If update is of type state
	if (typ=='state')
	{
		// If state sent is buffer or play
		if ((pr1=='1') || (pr1=='2'))
		{
			// For each item in the MediaPlayers array
			for (q=0; q<MediaPlayers.length; q++)
			{		
				// If the mediaplayer is loaded in the page
				if (document.getElementById(MediaPlayers[q]) != null)
				{
					// If the item is not the mediaplayer sending the state
					if (MediaPlayers[q] != swf)
					{
						sendEvent(MediaPlayers[q],'stop');
					}
				}
			}
		}
	}
}


function Play(x){
s = "sendEvent('playitem', " + x + ")";
setTimeout(s, 500);  
}


function stopAll()
{
	// For each item in the MediaPlayers array
	for (q=0; q<MediaPlayers.length; q++)
	{				
		// If the mediaplayer is loaded in the page
		if (document.getElementById(MediaPlayers[q]) != null)
		{
				sendEvent(MediaPlayers[q],'stop');
		}
	}		
}