var janela = null
function verificarNavegador() {
	if (window.navigator.appName == "Microsoft Internet Explorer") {
		return true;
	} else {
		return false;
	}
}
function fecharJanela() {
	if (janela != null) {
		janela.close()
	}
}
function parar() {
	if (document.MediaPlayer) {
		if (verificarNavegador()) {
			document.MediaPlayer.stop();		
		} else {
			document.MediaPlayer.controls.stop();		
		}
	}
}
function teste() {
	$("MediaPlayer").onclick = function() {
		alert(document.MediaPlayer.playState);
	}
}
function abrir(endereco, nome, largura, altura, rol) {
	parar();
	var x, y, propriedades;	
	x = (screen.width - largura) / 2;
	y = (screen.height - altura) / 2;	
	if (largura != 0 && altura != 0) {
		propriedades = "height =" + altura + ",width =" + largura + ",top =" + y + ",left =" + x + ",scrollbars =" + rol + ",resizable";
		window.open(endereco, nome, propriedades);
		if (janela == null) {
			janela = window.open(endereco, nome, propriedades);
			janela.focus();
		} else {
			janela.close();
			janela = window.open(endereco, nome, propriedades);
			janela.window.focus();
		}
	} else {
		window.open(endereco);
	}
}
function inserirSwf(arquivo, nome, l, a) {
	if (verificarNavegador()) {
		document.write("<object id=\""+nome+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+l+"\" height=\""+a+"\">");		
	} else {
		document.write("<object id=\""+nome+"\" type=\"application/x-shockwave-flash\" data=\""+arquivo+"\" width=\""+l+"\" height=\""+a+"\">");		
	}
	document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\">");
	document.write("<param name=\"movie\" value=\""+arquivo+"\">");
	document.write("<param name=\"quality\" value=\"high\">");
	document.write("<param name=\"wmode\" value=\"transparent\">");	
	document.write("</object>");
}
function rolar() {
	if ($('track') && $('sb')) {
		new Control.Slider('sb', 'track', 
			{
				range:$R(1,100), 
				axis:'vertical', 
				sliderValue:1,
				onChange:function(v) {
					yFinal = $('track').offsetHeight - $('sb').offsetHeight;
					posTop =- ($('audios').offsetHeight - yFinal) * ($('sb').offsetTop - 0) / yFinal;
					$('audios').style.top = posTop + "px";
				},
				onSlide:function(v) {
					yFinal = $('track').offsetHeight - $('sb').offsetHeight;
					posTop =- ($('audios').offsetHeight - yFinal) * ($('sb').offsetTop - 0) / yFinal;
					$('audios').style.top = posTop + "px";
				}
			});
	}
}
function ocultarRolagem() {
	if ($('audios') && $('track')) {
		linha = $('audios').getElementsByTagName('tr');
		if (linha.length > 8) {
			$('track').style.display = 'block';
		} else {
			$('track').style.display = 'none';
		}
	}
}
function pngTransparente() {
	if (verificarNavegador()) {
		for(var i=0; i< document.images.length; i++) {
			var img = document.images[i]
			var imgName = img.src.toUpperCase()
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : ""
				var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				var imgStyle = "display:inline-block;" + img.style.cssText
				if (img.align == "left") imgStyle = "float:left;" + imgStyle
				if (img.align == "right") imgStyle = "float:right;" + imgStyle
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
				+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
				img.outerHTML = strNewHTML
				i = i-1
			}      	
		}
	}
}
function aovivo() { /* RÁDIO REVISTA */
	var c;
	c = "<img src=\"imagens/radio_revista_15h.gif\" alt=\"Ao Vivo\" title=\"Ao Vivo\" />";
	c += "<div id=\"contemPlayer\">";
	c += "<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" src=\"mms://media02.wtv.com.br/usjt_aovivo\" name=\"MediaPlayer\" width=\"362\" height=\"45\" autostart=\"1\"></embed>";
	c += "</div>";	
	if ($("aovivo")) {
		$("aovivo").innerHTML = c;
	}	
}
function aovivoOff() {
	var c;
	c = "<img src=\"imagens/aovivo2.jpg\" alt=\"Ao Vivo\" title=\"Ao Vivo\" />";	
	if ($("aovivoOff")) {
		$("aovivoOff").innerHTML = c;
	}
}
function mostrarAovivo() {
	if ($("aovivo") && $("aovivo").style.display == "none") {		
		$("aovivo").style.display = "block";
	} else if ($("aovivoOff")) {
		$("aovivoOff").style.display = "block";		
	}
}
function criarPlayerSemana(el, l, a, url) {	
 	var c = "";
	/*document.write("<embed type=\"application/x-mplayer2\" pluginspage=\"http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/\" src=\""+url+"\" name=\"MediaPlayer\" id=\"MediaPlayer\" width=\""+l+"\" height=\""+a+"\" showstatusbar=\"false\" autostart=\"true\"></embed>");*/
	if (verificarNavegador()) {
		c = "<object classid=\"CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" name=\"MediaPlayer\"  width=\""+l+"\" height=\""+a+"\" id=\"MediaPlayer\">";
	} else {
		c = "<object type=\"audio/x-ms-wma\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701\" name=\"MediaPlayer\"  width=\""+l+"\" height=\""+a+"\" id=\"MediaPlayer\" >";
    }
    c += "<param name=\"filename\" value=\""+url+"\">";
    c += "<param name=\"autoplay\" value=\"true\">";
    c += "<param name=\"controller\" value=\"true\">"; 
	c += "</object>";
    $(el) ? $(el).innerHTML = c : "";
}
var flashFuncao = function(nome) {	
	var isIE = navigator.appName.indexOf ("Microsoft") != -1;
    if(isIE) var movieID = window["sinopse_flash"];
    else var movieID = document["sinopse_flash"];
    movieID.SetVariable("_root.functionName", nome);
    movieID.SetVariable("_root.flag", true);
};
window.onload = function() {
	rolar();
	ocultarRolagem();
	pngTransparente();
	aovivo();
	aovivoOff();
}
