function centraliza(largura,altura){
	window.moveTo((window.screen.width-largura)/2,(window.screen.height-altura)/2);
}
function abreJanela(arquivo,nome,barra,largura,altura) {
	window.open(arquivo,nome,"resizable=no,toolbar=no,status=no,menubar=no,scrollbars="+barra+",width="+largura+",height="+altura);
}
function redimenciona(){
	var i=0;
	function resize() {
		if (navigator.appName == 'Netscape') i=40;
		if (document.images[0]) window.resizeTo(document.images[0].width +50, document.images[0].height+80-i);
		if (window.moveTo((window.screen.width-document.images[0].width)/2,(window.screen.height-document.images[0].height)/2));
	}
}
function montaSWF(arquivo,largura,altura){
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="swf/'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed wmode="transparent" menu="false" src="swf/'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}
function montaSWFClickTag(arquivo, largura, altura, clicktag) {
    var now = new Date();
    var dia = now.getDay();
    var mes = now.getMonth();
    var ano = now.getFullYear();
    var hora = now.getHours();
    var mintuto = now.getMinutes();
    var segundo = now.getSeconds();
    var data = ano + "" + mes + "" + dia + "" + hora;

    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
    document.write('<param name="movie" value="swf/' + arquivo + '.swf?ieSux=' + data + '" />');
    document.write('<param name="quality" value="high" />');
    document.write('<param name="menu" value="false" />');
  //  document.write('<param name="wmode" value="transparent" />');
    document.write('<param name="flashVars" value="clicktag=' + clicktag + '" />');
    document.write('<embed flashVars="clicktag=' + clicktag + '" menu="false" src="swf/' + arquivo + '.swf?ieSux=' + data + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
    document.write('</object>');
}
function montaSWF2(arquivo,largura,altura){
	var now = new Date();	
	var dia = now.getDay();
	var mes = now.getMonth();
	var ano = now.getFullYear();
	var hora = now.getHours();
	var mintuto = now.getMinutes();
	var segundo = now.getSeconds();
	var data = ano+""+mes+""+dia+""+hora;

	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + largura + '" height="' + altura + '">');
	document.write('<param name="movie" value="'+ arquivo +'.swf?ieSux='+ data +'" />');
	document.write('<param name="quality" value="high" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<embed wmode="transparent" menu="false" src="'+ arquivo +'.swf?ieSux='+ data +'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + largura + '" height="' + altura + '"></embed>');
	document.write('</object>');
}
function showPainel(i) {
    document.getElementById("relevancia").style.display = 'none';
    document.getElementById("textoMateria").style.display = 'none';
    document.getElementById("pnlTv").style.display = 'none';
    document.getElementById("pnlInfografico").style.display = 'none';
    document.getElementById("pnlEnquete").style.display = 'none';
    document.getElementById("pnlImagens").style.display = 'none';
    document.getElementById("pnlRelacionadas").style.display = 'none';
    document.getElementById("pnlPodcast").style.display = 'none';
    
    document.getElementById("materia").className = 'desativado1';
    document.getElementById("tv").className = 'desativado2';
    document.getElementById("info").className = 'desativado3';
    document.getElementById("enquete").className = 'desativado4';
    document.getElementById("imagem").className = 'desativado5';
    document.getElementById("relacionada").className = 'desativado6';
    document.getElementById("podcast").className = 'desativado6';
    
    switch(i) {
        case 1:
            document.getElementById("relevancia").style.display = '';
            document.getElementById("textoMateria").style.display = '';
            document.getElementById("materia").className = 'ativo';
            break;
        case 2:
            document.getElementById("pnlTv").style.display = '';
            document.getElementById("tv").className = 'ativo';
            break;
        case 3:
            document.getElementById("pnlInfografico").style.display = '';
            document.getElementById("info").className = 'ativo';
            break;
        case 4:
            document.getElementById("pnlEnquete").style.display = '';
            document.getElementById("enquete").className = 'ativo';
            break;
        case 5:
            document.getElementById("pnlImagens").style.display = '';
            document.getElementById("imagem").className = 'ativo';
            break;
        case 6:
            document.getElementById("pnlRelacionadas").style.display = '';
            document.getElementById("relacionada").className = 'ativo';
            break;
        case 7:
            document.getElementById("pnlPodcast").style.display = '';
            document.getElementById("podcast").className = 'ativo';
    }
}
Resize = function(n,w,h) {
    var img = n;
	var	iw = img.width;
	var	ih = img.height;
	
	if(iw > w || ih > h) {
		var nim = iw/w;
		
		if(ih / nim > h) {
			nim = ih/h;
		}
		
		w = Math.round(iw / nim);
		h = Math.round(ih / nim);
		
		img.setAttribute('width', w);
		img.setAttribute('height', h);
	}
	else {
		img.setAttribute('width', iw);
		img.setAttribute('height', ih);
	}
}
function showPicture(a,i,d) {
    document.getElementById('tblAutor').innerHTML = "<b>" + a + "</b>";
    document.getElementById('tblImagem').src = "Arquivos/Imagens/" + i;
    document.getElementById('tblDescricao').innerHTML = d;
}
function showInfografico(i) {
    document.getElementById('tblInfografico').src = "Arquivos/Infograficos/" + i;
}
function lerForum(i) {
    doRequest("server.aspx?Query=forum&IDForum=" + i,resultado);
}
function resultado(dados) {
    d = document.getElementById("corpoForum");
	if (window.ActiveXObject) {
		ret = xmldoc.loadXML(dados);
		if (ret!=true) {
			return(0);	
		}
		xmldoc.resolveExternals = false;
		xmldoc.async = true;
		var root = xmldoc.documentElement;
		d.innerHTML = "";
		for (var i=0; i <= root.childNodes.length-1; i++) {
			if (root.childNodes.item(i).nodeName == 'row') {
				d.innerHTML += root.childNodes.item(i).nodeTypedValue;
			}
		}
	}
	else {
		var xmlParser = new DOMParser();
		xmldoc = xmlParser.parseFromString(dados,"text/xml");
		xmldoc.resolveExternals = false;
		xmldoc.async = true;
		var root = xmldoc.documentElement;
		d.innerHTML = "";
		for (var i=0; i <= root.childNodes.length-1; i++) {
			if (root.childNodes.item(i).nodeName == 'row') {
				d.innerHTML += root.childNodes.item(i).childNodes.item(0).nodeValue;
			}
		}
	}
}
function setActiveStyleSheet(title) {
	for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) {
				a.disabled = false;
			}
		}
	}
}
function starIN(p,img) {
    p.style.cursor = 'pointer';
    var i = 0;
    for(i = 1; i <= img; i++) {
        document.getElementById("img" + i).src = "img/estrela.gif";
    }
    for(j = 5; j > img; j--) {
        document.getElementById("img" + j).src = "img/estrela2.gif";
        i++;
    }
}
function starOUT(img) {
    var i = 0;
    for(i = 1; i <= img; i++) {
        document.getElementById("img" + i).src = "img/estrela.gif";
    }
    for(j = 5; j > img; j--) {
        document.getElementById("img" + j).src = "img/estrela2.gif";
        i++;
    }
}
function starVOTO(n,i,key) {
    if (key) {
        doRequest("server.aspx?Query=votarrelevancia&IDMateria=" + i + "&Nota="+ n,function(){});
        alert('Seu voto foi registrado com sucesso.');
        doRelevancia();
    }
    else {
        alert('Voce ja votou nessa materia.');
    }
}
function Move()
{
	switch (arguments[1])
	{
	case 1:
		arguments[0].style.clip = "rect(0px,340px,485px,0px)";
		break;
	case 2:
		arguments[0].style.clip = "rect(0px,340px,485px,168px)";
		break;
	}
}
function Move2()
{
	switch (arguments[1])
	{
	case 1:
		arguments[0].style.clip = "rect(0px,970px,487px,0px)";
		break;
	case 2:
		arguments[0].style.clip = "rect(0px,970px,487px,803px)";
		break;
	}
}
	
function abreBanner()
{

}

function fechaBanner()
{

}

var ie =(((navigator.userAgent.indexOf("MSIE")>-1)||(navigator.userAgent.indexOf("Mozilla/5.0")>-1))&&navigator.userAgent.indexOf("Opera")==-1?true:false);
var ns =(navigator.userAgent.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Opera")==-1?true:false);
function ajustar_data(input, evento) {
    var tecla = (evento.keyCode ? evento.keyCode: evento.which ? evento.which : evento.charCode);
    if (tecla == 8 || tecla == 46 || tecla == 39 || tecla == 37 || tecla == 36 || tecla == 35 || tecla == 9) {
        return true;
    }
    if (tecla < 48 || tecla > 57) {
        evento.returnValue = false;
        return false;
    }
    else {
        if (input.value.length == 2 || input.value.length == 5) {
            input.value += "/";
        }
    }
    return true;
}