// JavaScript Document

	function gE(ID) {
		return document.getElementById(ID);
	}
	
	function gEs(tag) {
		return document.getElementsByTagName(tag);
	}
	//exibe2('hidden','floater')
	function exibe2(sw,obj) {
		document.getElementById(obj).style.visibility = sw
	}
	function exibe(sw,obj) {
		document.getElementById(obj).style.display = sw
	}

function troca(ID,ID2,posi) {
	exibe('none','subMenu');
	exibe('none','subMenuBG');
	exibe('none','bio');
	exibe('none','fotosGalerias');
	exibe('none','contato');
	
	exibe('block',ID);
	
	/*document.getElementById('bt1').style.backgroundPosition  = '0 0';
	document.getElementById('bt2').style.backgroundPosition  = '-60px 0';
	document.getElementById('bt3').style.backgroundPosition  = '-120px 0';
	
	document.getElementById(ID2).style.backgroundPosition  = posi;*/
	
}
function swp(img,id) {
	document.getElementById('i'+id).src = img
}
function exibeSubM() {
	exibe('none','subMenu')
}
	
function correctPNG() // correctly handle PNG transparency in Win IE 5.5 or higher.
   {
   for(var i=0; i<document.images.length; i++)
      {
	  var img = document.images[i]
	  var imgName = img.src.toUpperCase()
	  if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
	     {
		 var imgID = (img.id) ? "id='" + img.id + "' " : ""
		 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
		 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
		 var imgStyle = "display:inline-block;" + img.style.cssText 
		 if (img.align == "left") imgStyle = "float:left;" + imgStyle
		 if (img.align == "right") imgStyle = "float:right;" + imgStyle
		 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle		
		 var strNewHTML = "<span " + imgID + imgClass + imgTitle
		 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
	     + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
		 + "(src=\'" + img.src + "\', sizingMethod='no-scale');\"></span>" 
		 img.outerHTML = strNewHTML
		 i = i-1
	     }
      }
   }
   
window.onload = load;

function load() {
	exibeSubM();
	correctPNG();
}


// ajax
	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 atualizaSite(pagina) {

	var meuXML = contectaXML();
	meuXML.open('GET', pagina, true);
	meuXML.onreadystatechange = function() {
		var conteudoSite = gE('fotosGalerias');
		if (meuXML.readyState == 1) {
			//loading(true);
			conteudoSite.innerHTML = ""
		}
		if (meuXML.readyState == 4) {
			if (meuXML.status == 200) {
				//loading(false);
				//removerDivs();
				conteudoSite.innerHTML = meuXML.responseText;
				extraiScript(conteudoSite.innerHTML)
			} else {
				conteudoSite.innerHTML = meuXML.responseText;
			}
		}
	}
	meuXML.send(null);

}	



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);
        }
    }
}









