/* LIMPA FORMULARIO */
function limpaForm(formulario) {
	f = document[formulario]
	tmF = f.length
	
	for (iF=0;iF<tmF;iF++) {
		if (f[iF].type != "submit") f[iF].value = ""

	}
}

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 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 exibe(obj) {
	idTag = document.getElementById(obj);
	if (idTag.style.display == 'block') {
		idTag.style.display= 'none';
	} else {
		idTag.style.display= 'block';
	}
	return false;
}








