function createPlayer(
						player_id,
						width,
						height,
						AutoStart,
						uiMode,
						url
					)
{
	html = "";
	if(navigator.appName.indexOf("Explorer") != -1)
	{
		html +='<object id="'+player_id+'" name="'+player_id+'"\n';
//		html +='	classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"\n'; //wmp6
		html +='	classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"\n'; //wmp  7
		html +='	codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" ';
		html +='	type="application/x-oleobject"\n';
		html +='	width="'+width+'"\n';
		html +='	height="'+height+'"\n';
		html +='	>';
		html +='    <param name="enabled" value="True">';
		html +='    <param name="AutoStart" value="'+AutoStart+'">';
		html +='    <param name="ShowControls" value="0">';
		html +='    <param name="PlayCount" value="1">';
		html +='    <param name="Volume" value="50">';
		html +='    <param name="balance" value="0">';
		html +='    <param name="Rate" value="1.0">';
		html +='	<param name="Mute" value="False">';
		html +='    <param name="fullScreen" value="False">';
		html +='    <param name="uiMode" value="'+uiMode+'">';
		html +='	<PARAM NAME="URL" VALUE="'+url+'">';
		html +='</object>';
	}
	else
	{
		AutoStart = (AutoStart=="True"?1:0);
		height += 60;
		html +='<embed	';
		html +='	id="'+player_id+'" name="'+player_id+'"\n';
		html +='	type="application/x-mplayer2"\n';
		html +='	pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"\n';
		html +='	width="'+width+'"\n';
		html +='	height="'+height+'"\n';
		html +='	src="'+url+'"\n';
		html +='	FileName="'+url+'"\n';
		html +='	autostart="'+AutoStart+'"\n';
		html +='	showcontrols="1"\n';
		html +='	showstatusbar="1"\n';
		html +='	showdisplay="0"\n';
		html +='	SendPlayStateChangeEvents="1"\n';
		html +='/>';
	}
	document.write(html);
}

function activateControls(controlsContainer, player_id, playerLoaded, playerStatus, playerDurationTxt, MoreInfoA)
{
	if(navigator.appName.indexOf("Explorer") == -1)
	{
		document.getElementById(controlsContainer).style.display = "none";
	}
	else
	{
		var Player =  document.getElementById(player_id);
		value = Math.round(Player.settings.volume / VOLUME_LEVELS_VALUE);	
		setVolume(player_id, value);
		setPosition(player_id, playerLoaded, playerStatus, playerDurationTxt, MoreInfoA);
	}	
}
var WMState = new Array();
WMState[0]  = "Undefined";
WMState[1]  = "Stopped";
WMState[2]  = "Paused";
WMState[3]  = "Playing";
WMState[4]  = "Scan Forward";
WMState[5]  = "Scan Reverse";
WMState[6]   = "Buffering";
WMState[7]  = "Waiting";
WMState[8]  = "Media Ended";
WMState[9]  = "Transitioning";
WMState[10] = "Ready";
WMState[11] = "Reconnecting";

var VOLUME_LEVELS = 8;
var VOLUME_LEVELS_VALUE = Math.round(100 / VOLUME_LEVELS);

function Status (player_id)
{
	var Player =  document.getElementById(player_id);
	x = Player.playState;
	alert("Windows Media  Player is " + WMState[x] + "\r\r" + "Player Version:"  + Player.versionInfo);
}

function Play (player_id, button)
{
	var Player =  document.getElementById(player_id);

	x = Player.playState;
	if (x == 2)
	{
		Player.controls.play();
		document.getElementById(button).className = '';
	}
	else
	{
		if (x == 3)
		{
			Player.controls.pause();
			document.getElementById(button).className = 'active';
		}
		else
		{
			Player.URL = Player.URL;
			Player.AutoStart = true;
			document.getElementById(button).className = '';
		}
	}
}

function Pause (player_id)
{
	var Player =  document.getElementById(player_id);
	Player.controls.pause();
}

function Stop (player_id)
{
	var Player =  document.getElementById(player_id);
	Player.controls.stop();
}

function setPosition(player_id, playerLoaded, playerStatus, playerDurationTxt, MoreInfoA)
{
	var Player =  document.getElementById(player_id);
		y = Player.controls.currentPosition;
		
		duration = Player.currentMedia.duration;
		if(duration > 0)
		{
			percent = duration / 100;
			percents = Math.round(Player.controls.currentPosition / percent);
		}
		else
		{
			percent = 0;
			percents = 0;
		}
		
window.status= ""; 
window.status += " percents:"; 
window.status += percents; 
window.status += " percent:"; 
window.status += percent; 
window.status += " duration:"; 
window.status += duration; 
window.status += " playState:"; 
window.status += WMState[Player.playState]; 

		var playerLoadedElement = document.getElementById(playerLoaded);
		if(playerLoadedElement)
		{
			playerLoadedElement.style.width = percents+"%";
		}
		
		var playerStatusElement = document.getElementById(playerStatus);
		if(playerStatusElement)
		{
			playerStatusElement.innerHTML = Player.currentMedia.name;
		}
		
		var playerDurationTxtElement = document.getElementById(playerDurationTxt);
		if(playerDurationTxtElement)
		{
			playerDurationTxtElement.innerHTML = Player.controls.currentPositionString;
		}
		
/*** /		
		var MoreInfoAElement = document.getElementById(MoreInfoA);
		if(MoreInfoAElement)
		{			
			MoreInfoAElement.href = cm.getItemInfoByType("MoreInfoRef","", 0);
		}
/**/		
	setTimeout("eval('setPosition(\""+player_id+"\", \""+playerLoaded+"\" , \""+playerStatus+"\" , \""+playerDurationTxt+"\" , \""+MoreInfoA+"\" )' )", 500);
	
}

function previous(player_id)
{
	var Player =  document.getElementById(player_id);
	Player.controls.previous();
}

function setFullScreen(player_id)
{
	var Player =  document.getElementById(player_id);
	Player.fullScreen = true;
}

function MoreInfo(player_id)
{
	var Player =  document.getElementById(player_id);

	url = cm.getItemInfoByType("MoreInfoRef","", 0);
	if(url == "")
		return true;
	return false;	
}

function Rew(player_id)
{
	var Player =  document.getElementById(player_id);
	y = Player.controls.currentPosition;
	Player.controls.currentPosition = y - 10;
}

function Ffwd(player_id)
{
	var Player =  document.getElementById(player_id);
	y = Player.controls.currentPosition;
	Player.controls.currentPosition = y + 10;
}

function MuteMe (player_id, button)
{
	var Player =  document.getElementById(player_id);
	x = Player.settings.mute;
	if (x == 0)
	{
	   Player.settings.mute =  "1";
	   document.getElementById(button).className = '';
	}
	else
	{
	   Player.settings.mute =  "0";
	   document.getElementById(button).className = 'active';
	}
}

function UnMuteMe (player_id)
{
	var Player =  document.getElementById(player_id);
	Player.settings.mute =  "0";
}

function setVolume(player_id, value)
{
	var Player =  document.getElementById(player_id);
	Player.settings.volume = value * VOLUME_LEVELS_VALUE;	
	for(var i=1; i<=value; i++)
	{
		document.getElementById("vlm0"+i).className = 'active';
	}
	for(var i=value+1; i<=VOLUME_LEVELS; i++)
	{
		document.getElementById("vlm0"+i).className = '';
	}
}

function VolumeUp (player_id)
{
	var Player =  document.getElementById(player_id);
	X = Player.settings.volume;
	Player.settings.volume = X + 10;
}
function VolumeDown (player_id)
{
	var Player =  document.getElementById(player_id);
	X = Player.settings.volume;
	Player.settings.volume = X - 10;
}

