﻿
function calcHeight()
{
  frm = document.getElementById('news');
  if (frm.contentDocument) //firefox, opera
  {
  	//find the height of the internal page
  	var the_height=frm.contentDocument.body.parentNode.offsetHeight;
  	//change the height of the iframe
  	frm.style.height=the_height;
  }
  else //IE
  {
  	//find the height of the internal page
  	var the_height=frm.contentWindow.document.body.scrollHeight;
  	//change the height of the iframe
  	frm.style.height=the_height;
  }
}

function resizeIframe(){
/*
this.obj=obj
//this.obj.width=null
//this.obj.width=window.frames["eps"].document.body.scrollWidth
this.obj.style.height="" // for Firefox and Opera
setTimeout("this.obj.style.height=this.obj.contentWindow.document.body.scrollHeight+(notIE?heightOffset:0)",10) // setTimeout required for Opera
*/

el=document.getElementById(eps)
el.style.height="100px" // for Firefox and Opera
setTimeout("el.style.height=el.contentWindow.document.body.scrollHeight+'px'",10) // setTimeout required for Opera
}

function hideDiv(id) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(id).style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.id.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.id.style.visibility = 'hidden'; 
} 
} 
}

function showDiv(id) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(id).style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.id.visibility = 'visible'; 
} 
else { // IE 4 
document.all.id.style.visibility = 'visible'; 
} 
} 
}

function aparecer(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
       else
          e.style.display = 'block';
    }

function ajaxInit() {
var xmlhttp;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest != 'undefined' ) {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false ;
}
}
return xmlhttp;
}

function url_encode(str) {
var hex_chars = "0123456789ABCDEF";
var noEncode = /^([a-zA-Z0-9\_\-\.])$/;
var n, strCode, hex1, hex2, strEncode = "";

for(n = 0; n < str.length; n++) {
if (noEncode.test(str.charAt(n))) {
strEncode += str.charAt(n);
} else {
strCode = str.charCodeAt(n);
hex1 = hex_chars.charAt(Math.floor(strCode / 16));
hex2 = hex_chars.charAt(strCode % 16);
strEncode += "%" + (hex1 + hex2);
}
}
return strEncode;
}

// url_decode version 1.0
function url_decode(str) {
var n, strCode, strDecode = "";

for (n = 0; n < str.length; n++) {
if (str.charAt(n) == "%") {
strCode = str.charAt(n + 1) + str.charAt(n + 2);
strDecode += String.fromCharCode(parseInt(strCode, 16));
n += 2;
} else {
strDecode += str.charAt(n);
}
}

return strDecode;
}
function getSecoes(pagina,layer) {
document.getElementById(layer).innerHTML = "Carregando";
ajax = ajaxInit();
//aqui estão as propriedade que puxão sua página//
ajax.open("GET",pagina+".php", true);
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
var resultado = ajax.responseText;
resultado=resultado.replace(/\+/g," ");
resultado = unescape(resultado);
document.getElementById(layer).innerHTML = url_decode(resultado);
}
}
ajax.send(null);
}function getpag(pagina,layer) {
document.getElementById(layer).innerHTML = "Carregando";
ajax = ajaxInit();
//aqui estão as propriedade que puxão sua página//
ajax.open("GET",pagina, true);
ajax.onreadystatechange = function() {
if(ajax.readyState == 4 && ajax.status == 200) {
var resultado = ajax.responseText;
resultado=resultado.replace(/\+/g," ");
resultado = unescape(resultado);
document.getElementById(layer).innerHTML = url_decode(resultado);
}
}
ajax.send(null);
}
function extras(id) {
       var e = document.getElementById(id);
       if(e.style.display == 'block')
          e.style.display = 'none';
		  
       else
          e.style.display = 'block';
    }
function um(id) { 
document.getElementById(id).src = "botao/menubotao_03.png";
} 
function dois(id) { 
document.getElementById(id).src="botao/menubotao_06.png";
} 


notIE=document.getElementById&&!document.all
heightOffset=20
function resizeIframe(id){
/*
this.obj=obj
//this.obj.width=null
//this.obj.width=window.frames["new"].document.body.scrollWidth
this.obj.style.height="" // for Firefox and Opera
setTimeout("this.obj.style.height=this.obj.contentWindow.document.body.scrollHeight+(notIE?heightOffset:0)",10) // setTimeout required for Opera
*/

el=document.getElementById(id)
el.style.height="100px" // for Firefox and Opera
setTimeout("el.style.height=el.contentWindow.document.body.scrollHeight+'px'",10) // setTimeout required for Opera
}

function navegacaoIndex() {
	var variaveis = document.location.href.split("#");

	if(variaveis[1]) {
		var novavar = variaveis[1].split("/");
		var url = "",param = "", pag = 1;

		if(novavar[0] == "multimidia") {
			url = "multimedia/episodios.php";
			param = "news";
		} else {
			url = "index.php";
			param = "";
		}	
		 getpag(url,param);
	} else {
		getpag('index.php','');
	}
}
