$pl = function(id) { return document.getElementById(id) }
var bVersion=navigator.userAgent;

function plShowHide() {
	var texto = $pl('linkplayList').getElementsByTagName("a")[0].innerHTML;
  var modo = ($pl('playList').style.display=="block") ? "none" : "block";
	var innerCont = (modo=="block") ? '<a href="#" onclick="plShowHide();return false" id="linkPlOpen">'+texto+'</a>' : '<a href="#" onclick="plShowHide();return false" id="linkPlClose">'+texto+'</a>';
	$pl('playList').style.display = modo;
	$pl('fecharplayList').style.display = modo;
	$pl('linkplayList').innerHTML = innerCont;
	if(bVersion.indexOf('MSIE 6')!=-1 || bVersion.indexOf('MSIE 5')!=-1) {
		$pl('barrauol1').style.position = 'absolute';
	}
	else {
		newHeight();
	}
}

function playerBand() {
	var playCode = $pl('player-progs').src.match(/au=.+\d/).toString().replace(/au=/,"");
	var newSrc = (playCode.lastIndexOf("_56")!=-1) ? playCode.replace(/_56/,"_128") : playCode.replace(/_128/,"_56");
	$pl('linkBand').innerHTML = (newSrc.lastIndexOf("_56")!=-1) ? '<img src="http://m.i.uol.com.br/radiouol/bt_128k.gif" alt="128K" />' : '<img src="http://m.i.uol.com.br/radiouol/bt_56k.gif" alt="56K" />';
	$pl('player-progs').src = "http://video.noticias.uol.com.br/exclusivo/radiouolprog-inline.htmx?asxurl=1&au="+newSrc;
}

var heightCache=0;
var posCache=0;

function newHeight(browser) {
	var materiaHeight  = $pl('materia').offsetHeight+80;
	var leftHeight     = $pl('col-esquerda').offsetHeight;
	var posUOLBar      = $pl('barrauol1').offsetTop;
	
	if (materiaHeight>leftHeight)
	{
		var newHeight = materiaHeight-leftHeight;
		$pl('col-esquerda').style.height = leftHeight+newHeight+'px';
		$pl('col-centro').style.height   = leftHeight+newHeight+'px';
		$pl('barrauol1').style.position = 'absolute';
		$pl('copyright').style.position = 'absolute';
		$pl('barrauol1').style.top = posUOLBar+newHeight+'px';
		$pl('copyright').style.top = posUOLBar+newHeight+25+'px';
		heightCache = leftHeight;
		posCache = posUOLBar;
	}
	else if(heightCache!=0)
	{
		$pl('col-esquerda').style.height = heightCache+'px';
		$pl('col-centro').style.height   = heightCache+'px';
		$pl('barrauol1').style.top       = posCache+'px';
		$pl('copyright').style.top       = posCache+25+'px';
	}
}
