// JavaScript Document
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

function RetiraPX(str){
	n = String(str).length - 2;
	//window.alert(n);
	return String(str).substring(0,n);
	//Left(str,n);
}

function CentralizarDiv(div){
	var w = window.innerWidth || self.innerWidth || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || document.body.clientHeight;
	var w_div = RetiraPX(document.getElementById(div).style.width);
	var h_div = RetiraPX(document.getElementById(div).style.height);
	//window.alert(h_div);
	//window.alert(w_div);
	
	var topf
	var leftf
	
	topf = (h - h_div)/2;
	leftf = (w - w_div)/2;
	
	if (topf < 0){
		topf = 0;
	}
	
	if (leftf < 0){
		leftf = 0;
	}
	//window.alert(topf);
	//window.alert(leftf);
	document.getElementById(div).style.top = topf;
	document.getElementById(div).style.left = leftf;
	//window.alert('passou1');
	document.getElementById(div).style.visibility = 'visible';
	//window.alert('passou2');
};

function imprimirmapa(){
	var oPrint, oJan;
	oPrint = window.document.getElementById("Layer18").innerHTML;
	oJan = window.open("impressao.html");
	oJan.document.write(oPrint);
	oJan.window.print();
	oJan.window.close();
};

function CallPrint(strid){
	var prtContent = document.getElementById(strid);
	var WinPrint = window.open('','','letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
	WinPrint.close();
}

function AbrirFoto(caminho,id){
	window.open(caminho,id,'top=100,left=100,resizable=yes,location=no,menubar=no,satatusbar=no,titlebar=no,toolbar=no,diretories=no,scrollbars=yes')
}

//Variáveis globais
var _loadTimer	= setInterval(__loadAnima,18);
var _loadPos	= 0;
var _loadDir	= 2;
var _loadLen	= 0;

//Anima a barra de progresso
function __loadAnima(){
	var elem = document.getElementById("barra_progresso");
	if(elem != null){
		if (_loadPos==0) _loadLen += _loadDir;
		if (_loadLen>32 || _loadPos>79) _loadPos += _loadDir;
		if (_loadPos>79) _loadLen -= _loadDir;
		if (_loadPos>79 && _loadLen==0) _loadPos=0;
		elem.style.left		= _loadPos;
		elem.style.width	= _loadLen;
	}
}

//Esconde o carregador
function __loadEsconde(){
	this.clearInterval(_loadTimer);
	var objLoader				= document.getElementById("carregador_pai");
	objLoader.style.display		="none";
	objLoader.style.visibility	="hidden";
}

function AbrePagina2(caminho,id,largura,altura){ //Abre pagina centralizada no video

	var w = window.innerWidth || self.innerWidth || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || document.body.clientHeight
	posicaoY = w/2 - largura/2;
	posicaoX = h/2 - altura/2;
window.open(caminho,id,'top=' + posicaoX +',left=' + posicaoY +',width=' + largura + ',height=' + altura + ',resizable=yes,location=no,menubar=no,satatusbar=no,status=no,titlebar=no,toolbar=no,diretories=no,scrollbars=yes')

}

function AbrePagina(caminho,id,largura,altura,posicaoX,posicaoY){

window.open(caminho,id,'top=' + posicaoX +',left=' + posicaoY +',width=' + largura + ',height=' + altura + ',resizable=yes,location=no,menubar=no,satatusbar=no,status=no,titlebar=no,toolbar=no,diretories=no,scrollbars=yes')

}
//-->

