function MediaPlayer(lar,alt)
{
	this.lar = lar ? lar : "";
	this.alt = alt ? alt : "";
}
MediaPlayer.prototype.ini = function(media, player, controle)
{
	if (controle)
	{
		this.uiMode = "none";
		$("#" + controle).html
		(
			"<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">"+
			"  <tr>"+
			"	<td>"+
			"	<table width=\"100%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#000033\" id=\"p_buffer\">"+
			"	  <tr>"+
			"		<td><table width=\"55%\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" bgcolor=\"#999999\" id=\"p_porcentagem\">"+
			"		  <tr>"+
			"			<td>&nbsp;</td>"+
			"		  </tr>"+
			"		</table></td>"+
			"	  </tr>"+
			"	</table>"+				
			"	</td>"+
			" </tr>"+
			"  <tr>"+
			"	<td>play() | stop() </td>"+
			"  </tr>"+
			"</table>"
		);
	}
	else
	{
		this.uiMode = "full";
	}
	
	
	try
	{
		$("#" + player).html
		(
			
			"<OBJECT ID=\"Player\" CLASSID=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\">"+
			"<PARAM name=\"player\" value=\"True\">"+
			"</OBJECT>"					
		)
		this.defaults = 
		{ 
			uiMode:this.uiMode,		
			Url: media,
			autoStart:false
			 
		};
		mediap = this.mediap = $.extend( document.getElementById("player") , this.defaults);
		//id_interval_porc = setInterval(this.porcentagem,1000);		
	}
	catch(e)
	{
		try
		{
			$("#" + player).html
			(
			"<embed fileName=\""+ media +"\" name=\"player\" ID=\"player\" width=\"480\" height=\"430\" type=\"video/x-ms-asf-plugin\""+
			" showaudiocontrols=1 showgotobar=0 showtracker=1 controltype=0 animationatstart=0"+ " autosize=1 bufferingtime=5 showcontrols=1 showdisplay=1 showstatusbar=1 > </embed>"
			)
			this.defaults = 
			{
				fileName: media
			};
			//mediap = this.mediap = $.extend( document.getElementById("player") , this.defaults);
		}
		catch(ex)
		{
			alert(ex);
			$("#" + player).html("Você não possuí o plugin necessário para assistir. Faça o download do plugin Windows Media Player <a href='http://port25.technet.com/pages/windows-media-player-firefox-plugin-download.aspx'>clicando aqui</a>");
		}
		
	}
	
	$("#Player").width(this.lar);
	$("#Player").height(this.alt); 
		
		
	
}

MediaPlayer.prototype.porcentagem = function()
{
	this.porcent = (Math.round(mediap.controls.currentPosition) / Math.round(mediap.currentMedia.duration)) * 100;
	this.download = mediap.network.downloadProgress;
	$("#p_porcentagem").attr("width",this.porcent + "%");
	$("#p_buffer").attr("width",this.download + "%");	
	
}

MediaPlayer.prototype.converteHoraSeg = function (pramHora)
{
	var hora = pramHora.split(":");
	var resultado = 0;
	
	resultado = Math.floor((hora[0] * 60) * 60);
	resultado += Math.floor(hora[1] * 60);
	resultado += Math.floor(hora[2]);
	
	return Math.floor(resultado);
}

MediaPlayer.prototype.converteSegHora = function (Segs)
{
	var Hrs, Min;
	Hrs = Math.floor(Segs / 3600);
	Segs = Math.floor(Segs % 3600);
	Min = Math.floor(Segs / 60);
	Segs = Math.floor(Segs % 60);
	
	if(Hrs <= 9)
	{
		Hrs = "0" + Hrs;
	}
	if(Segs <= 9)
	{
		Segs = "0" + Segs;
	}
	if(Min <= 9)
	{
		Min = "0" + Min;
	}
	
	return (Hrs + ":" + Min + ":" + Segs);
}
