// JavaScript Document

function contectaXML() {
	var meuXML;
	try {
		meuXML = new XMLHttpRequest();
	} catch(ee) {
		try  {
			meuXML = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try  {
				meuXML = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				meuXML = false;
			}
		}
	}
	return meuXML;
}


function extraiScript(texto){
//Maravilhosa função feita pelo SkyWalker.TO do imasters/forum
//http://forum.imasters.com.br/index.php?showtopic=165277
    // inicializa o inicio ><
    var ini = 0;
    // loop enquanto achar um script
    while (ini!=-1){
        // procura uma tag de script
        ini = texto.indexOf('<script', ini);
        // se encontrar
        if (ini >=0){
            // define o inicio para depois do fechamento dessa tag
            ini = texto.indexOf('>', ini) + 1;
            // procura o final do script
            var fim = texto.indexOf('</script>', ini);
            // extrai apenas o script
            codigo = texto.substring(ini,fim);
            // executa o script
            //eval(codigo);
            /**********************
            * Alterado por Micox - micoxjcg@yahoo.com.br
            * Alterei pois com o eval não executava funções.
            ***********************/
            novo = document.createElement("script")
            novo.text = codigo;
            document.body.appendChild(novo);
        }
    }
}

/* FUNÇÃO ATUALIZA FRAME ------------------*/
function atualizaSite(pagina,recipiente) {

	var meuXML = contectaXML();
	meuXML.open('GET', pagina, true);
	meuXML.onreadystatechange = function() {
		var conteudoSite = gE(recipiente);
		if (meuXML.readyState == 1) {
			//loading(true);
			conteudoSite.innerHTML = ""
		}
		if (meuXML.readyState == 4) {
			if (meuXML.status == 200) {
				extraiScript(meuXML.responseText);
				conteudoSite.innerHTML = meuXML.responseText;
			} else {
				conteudoSite.innerHTML = meuXML.responseText;
			}
		}
	}
	meuXML.send(null);
}

function gE(ID) {
	return document.getElementById(ID);
}

function oculta(obj) {
	gE(obj).style.display= 'none';
}
function exibe(obj) {
	gE(obj).style.display= 'block';
}


function openWindow(url,name,w,h) {
	xPos = (screen.width - w) / 2;
	yPos = (screen.height - h) / 2;
	config = 'left=' + xPos + ',screenX=' + xPos + ',top=' + yPos + ',screenY=' + yPos + ',width=' + w + ',height=' + h; 
	newWindow = window.open(url, name, config);
}


function altura() {
	altura = document.documentElement.clientHeight
	if (altura > 560) {
		gE("flash").style.position = "absolute";
		gE("flash").style.top = "50%";
		gE("flash").style.left = "50%";
		gE("flash").style.margin = "-260px 0 0 -389px";
		gE("flash").style.display = "block"
	} else {
		gE("flash").style.display = "block"
		gE("flash").style.margin = "0 auto";
	}
}

function carrega(nomeFuncao) {
    if (window.attachEvent) {
       var r = window.attachEvent("onload", nomeFuncao);
       return r;
    } else if (window.addEventListener) {
       window.addEventListener("load", nomeFuncao, false);
       return true;
    }  else {
       return false;
    }
}

carrega(altura);







	