arr=[];
indice=0;
function loadBlock(place,addr){
	if(xmlhttp){
		document.getElementById(place).style['display']= 'block';
//		document.getElementById(place).innerHTML = '<span id="carregando" align=center><img src="imagens/carregando.gif" border="0" /></span>';
		document.getElementById(place).innerHTML = '<span id="carregando" onClick="javascript: this.style[\'display\']=\'none\';" style="position: absolute; display: block; padding-left:40px; padding-right:10px; width: auto; line-height: 40px; border: 1px solid #000; font-weight: bold; background:#FFF url(\'img/loading.gif\') no-repeat 5px center;">Carregando...</span>';
		blockUPDATE(place,addr);
	}
}

function blockUPDATE(place,addr){
	if(xmlhttp){
//tenta criar um objeto XMLHttpRequest
	  //  if(document.getElementById(place)) document.getElementById(place).innerHTML="<span class='carregando'>"+"Carregando...</span>";
    	//Adiciona  fila
	    arr[arr.length]=[place,addr];
	    if((indice+1)== arr.length) RunExecute();
	}
}

function RunExecute(){
	if(!xmlhttp){
//CRIA UM OBJETO XHR
	try{
		    xmlhttp = new XMLHttpRequest();
		}catch(xmlhttp){
	    	try{
    		    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		    }catch(xmlhttp){
	    	    try{
    		        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	        	}catch(xmlhttp){
            		xmlhttp = false;
	    	    }
    		}
		}
	}

	if(xmlhttp){
	xmlhttp.open("GET",arr[indice][1],true); 
	//	xmlhttp.setRequestHeader("Content-type", "charset=utf-8")
		xmlhttp.setRequestHeader('content-type', 'text/html');
		xmlhttp.setRequestHeader('Content-Type','charset=iso-8859-1');
		xmlhttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	    xmlhttp.onreadystatechange=function() {
			//alert(xmlhttp.status+" - "+xmlhttp.readyState);
	        if (xmlhttp.readyState==4){
    	        //EXIBE o HTML recebido
        	    consulta=unescape(xmlhttp.responseText); //.replace(/\+/g," "));
				//alert(consulta);
				if(document.getElementById(arr[indice][0])){
					 document.getElementById(arr[indice][0]).innerHTML=consulta;
				 }
	            //Roda o prximo
    	        indice++;
        	    if(indice<arr.length) setTimeout("RunExecute()",20);
	        }
    	}
	    //Executa
	    xmlhttp.send(null);
	}
}

	//PARA EXIBIR E OCULTAR BLOCOS
	function ShowHide(obj,s){
		if(obj && s) obj.style.display = s;
		else if(!s) obj.style.display = (obj.style.display=='none') ? 'block' : 'none';
		
		if(obj && obj.style.display == 'block') obj.scrollIntoView();
	}
	function ShowHide2(obj,s){
		if(obj && s) obj.style.display = s;
		else if(!s) obj.style.display = (obj.style.display=='none') ? 'block' : 'none';
	}
	//funco antiga para show e hidden
	function v(obj,s){
		document.getElementById(obj).style.visibility= s;
	}
	


	//4 PARAMETROS QUE FAZEM A INTERCALAO DE CONTEDO
	function MinimizeMaximize(obj1,obj2,i1,i2){
		ShowHide(obj1);
		obj2.innerHTML = (obj1.style.display=='none') ? i1 : i2;
	}
	//mostra blocos e e aplica transparencia a botao
	function ChangeBlock(esconde,mostra,botao1,botao2){
		ShowHide2(esconde,"none");
		ShowHide2(mostra,"block");
		makeFade(botao2,'DescOp1');
		makeFade(botao1,'DescOp');
	}



//---------------AJAX COM POST -- //

Ap=[]; inp=0; frm=[];
function postValores(formulario,act,id,url,texto){
//	alert(formulario.name+" - "+act+" - "+id+" - "+url+" - "+texto);
var	valores = "act="+act;
	for (i=0; i < formulario.elements.length; i++){
		if ((formulario.elements[i].value && formulario.elements[i].type != 'button' && formulario.elements[i].type != 'submit' )){
			if(formulario.elements[i].type == 'checkbox' && formulario.elements[i].checked == true){
				valores += "&"+formulario.elements[i].name+"="+formulario.elements[i].value;
			}else if(formulario.elements[i].type == 'select-multiple'){	//PARA SELECTS MULTIPLOS
				var mult = formulario.elements[i];
				for(a=0;a<mult.length;a++){
					if(mult.options[a].selected){
						valores += "&"+formulario.elements[i].name+"="+mult.options[a].value;
					}
				}
			}else if(formulario.elements[i].type == 'radio' && formulario.elements[i].checked == true){ //PARA RADIOBUTTON
					valores += "&"+formulario.elements[i].name+"="+formulario.elements[i].value;
			}else if((formulario.elements[i].type == 'text' || formulario.elements[i].type == 'select-one' || formulario.elements[i].type == 'textarea' || formulario.elements[i].type == 'hidden') && (formulario.elements[i].type != 'checkbox' && formulario.elements[i].type != 'select-multiple')){
					nVal = "";
					nVal = escape(formulario.elements[i].value);
				valores += "&"+formulario.elements[i].name+"="+nVal;
				}
		}
	}
	if(document.getElementById(id)){
		document.getElementById(id).style['display']= 'block';
		document.getElementById(id).innerHTML = (texto) ? '<span id="carregando" align=center> '+texto+'</span>' : '<span id="carregando" align=center><img src="img/loading.gif" border="0" /> Aguarde, carregando dados...</span>';
	}
	frm[Ap.length]=valores.toString();
    Ap[Ap.length]=[id,url];
//	alert(Ap.length+" - "+inp);
    if((inp+1)==Ap.length) RunPost();
}

function RunPost(){
	if(xmlhttp){
		//Abre a conexo
		xmlhttp.open("POST", Ap[inp][1], true);
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded;'); 
		//Funo para tratamento do retorno
	    xmlhttp.onreadystatechange=function() {
			//alert(xmlhttp.status+" - "+xmlhttp.readyState);
	        if (xmlhttp.readyState==4){
    	        //Mostra o HTML recebido
	            retorno=unescape(xmlhttp.responseText); //.replace(/\+/g," "));
				//document.getElementById(Ap[inp][0]).scrollIntoView();
				//alert(retorno);
				if(document.getElementById(Ap[inp][0])){
					 document.getElementById(Ap[inp][0]).innerHTML=retorno;
					// if(document.getElementById('globalSource')) reDimensiona();
				 }
	            //Roda o prximo
            	inp++;
        	    if(inp<Ap.length) setTimeout("RunPost()",20);
    	    }
	    }
    	//Executa	
	    xmlhttp.send(frm[inp]);
	}
}

//slideshow imagens

//PARA EFETUAR FADE EM OUTROS NAVEGADORES
function Fade(){
		var opacs = ["0",".1",".2",".3",".4",".5",".6",".7",".8",".9","1"];
		for (var i=0;i<11;i++){
			  setTimeout('document.getElementById(\'SlideShow\').style.opacity = "'+opacs[i]+'";', ((i==0) ? i : (i*80)));
		}
}

/*function SlideShow(){
	var obj = document.images.SlideShow;
	if(ns6 || (navigator.userAgent.indexOf("Opera") != -1)){
		j = j + 1;
		if (j > (p - 1)) j = 0;
		t2 = setTimeout('Fade()', (velocidade-100));
		t = setTimeout('SlideShow()', velocidade);	
	}
	if(ie && (navigator.userAgent.indexOf("Opera") == -1)) {
			obj.style.filter="blendTrans(duration=2)";
			obj.style.filter="blendTrans(duration=tempoFade)";
			obj.filters.blendTrans.Apply();
		}
	obj.src = ArrF[j].src;
//	obj.width = 100;
//	obj.height = 75;
	document.getElementById("textoP").innerHTML = fotoTexto[j]+((fotoVideo[j]!="") ? '<br /><a href="'+fotoVideo[j]+'" style="padding-left:13px; background:url(\'img/bt_seta.gif\') no-repeat left center;" class="azul"> ver o vdeo</a>':"");
	document.getElementById("linkfoto").href = fotoLinks[j];
	document.getElementById("link_Azul").style.display = "block";
	document.getElementById("link_Azul").href = fotoLinks[j];
	if(ArrF.length > 1) document.getElementById('controle').style.display = "block";
		if(ie && (navigator.userAgent.indexOf("Opera") == -1)) {
			obj.filters.blendTrans.Play();
			j = j + 1;
			if (j > (p - 1)) j = 0;
			t = setTimeout('SlideShow()', velocidade);
			t2 = setTimeout('');	
		}
}*/



function Control(a){
	clearTimeout(t);
	if(t2) clearTimeout(t2);
	if(a=="menos"){
		j = (j==0) ? (p-2) : ((j==1) ? (p-1) : (parseInt(j)-2));
	}
	SlideShow();
}

function abreVideo(a){
return void(window.open(a,'','width=500,height=450,scrolling=no,status=no,menubar=no,toolbar=no'));
}

//LIMPA CAMPO FORMULARIO OU DEIXA O MESMO VALOR
function padrao(i,input,valor){
    var obj = document.forms[i].elements[input]; 
	var str = obj.value 
    if(str != valor && str.length != 0){
		valor = obj.value;
	}  
	obj.value=valor;
} 

function limpapadrao(i,input,valor){
    var obj = document.forms[i].elements[input]; 
	var str = obj.value 
	if(str != valor){
		valor = obj.value;
	}else{
		valor = "";
	}
	obj.value=valor;
}

function makeFade(Oid,c){
		Oid.className=c;
}

function fechaAviso(){
	ShowHide(document.getElementById("_aviso"),"none");
}


//open window
function openPop(_url, _window, _params) {
	var newwindow = window.open(_url, _window, _params);
	if(!newwindow){
			 alert("Seu Navegador bloqueou a janela de visualizao\n Por favor desbloqueie-o bloqueador de popup para visualizar o contedo.")
		}
		newwindow.document.close();
}



//PEGA VARIAVEL APS SUSTENIDO #
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&');
 
    for(var i = 0; i < hashes.length; i++)
    {	
        hash = hashes[i].split('=');
		hash[1] = unescape(hash[1]);
		vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
 
    return vars;
}


var newWindow;
function makeNewWindow(ttl) {
	if (!newWindow || newWindow.closed) {
	newWindow = window.open(ttl,"","width=750,height=600,scroll=yes");
	setTimeout("writeToWindow()", 50);
	} else if (newWindow.focus) {
	newWindow.focus( );
	}
}
function writeToWindow() {
	if(!newWindow){
	 alert("Seu Navegador bloqueou a janela de impresso\n Por favor desbloqueie-o bloqueador de popup para imprimir o contedo.")
	}else{
		var ccal = "<html><head>";
			ccal += "<style>";
			ccal += "body{ font-family:\"Trebuchet MS\", Arial, Helvetica, sans-serif; } #l-leitura h1,#l-leitura h2, #l-leitura h3{ border:none;} #calendario {	font-family:\"Trebuchet MS\"; text-transform:capitalize;}  #calendario ul li {	list-style:none; font-size:13px; margin-bottom:1px;	border-bottom:1px solid #eaeaea; padding:5px; background:#f0f0f0; margin:0px;} #calendario ul li strong { color:#F60; } #calendario ul li{ padding:0px; border-top:1px solid #FFF; } #calendario ul li a{display:block; width:100%; padding:5px;  height:auto; cursor:default; text-decoration:none; font-weight:normal; color:#727272; } #calendario ul li a:hover{ cursor:default; }";
			//ccal += ".agendaItem {	border-bottom:1px dashed #e4e4e4;	padding:20px 0 20px 0;	margin:0; } .agendaItemin {	border-left:15px solid #2690C0;}.data {	float:left;	width:135px;	display:block;	padding:0 0 0 20px; }.data .dia, .data .mes, .data .ano {	font-family:Georgia, \"Times New Roman\", Times, serif;	padding:0 0 5px 0;	margin:0;	border:0;	display:block;} .data .dia{	font-size:30px;	color:#333;} .data .mes {	font-size:20px;	color:#2690C0;} .data .ano {	font-size:25px;	color:#999;}.leituraAgenda {width:520px;	padding:20px;	background:#f6f6f6;	float:left;	font-size:15px;	line-height:1.3;}.leituraAgenda h4 {	color:#2690BF;	font-size:15px;	font-weight:bold;	padding:0 0 5px 0; }";
			ccal += "</style>";
			ccal += "</head><link href=\"" + URL + "css/internas.css\" rel=\"stylesheet\" type=\"text/css\"  media=\"screen\" /><body><div id='l-leitura'>";
			try{
				
				ccal += (document.getElementById("contenttitulo")) ? document.getElementById("contenttitulo").innerHTML.toString() : "";
				
				if(document.getElementById("contentcal")) ccal += document.getElementById("contentcal").innerHTML.toString();
				else if  (document.getElementById("l-leitura")) ccal += document.getElementById("l-leitura").innerHTML.toString();
			}catch(e){ alert("Error"); }

			ccal += "</div></body></html>";
	newWindow.document.write(ccal);
		try{
			if(newWindow.document.getElementById("formleitura")){
				newWindow.document.getElementById("formleitura").style["display"] = "none";
				}
		}catch(e){ }
	newWindow.print();
	}
	newWindow.document.close( ); 
}

/*var pos = 0;
var place = 1;
var Ar_ = Array();
function changeV(v,place){
		document.getElementById('prods').innerHTML = Message.substring(0, place);
}

   function scrollIn(Ar_) {
//	for(a=0;a<Ar.length;$a++){
		for($a=0;$a<Ar_.length;$a++){
			Message = Ar_[pos];
			if (place >= Message.length) {
				place=1;
				window.setTimeout("scrollOut()",300); 
			 } else {
				place++;
				window.setTimeout("scrollIn()",50); 
			 }
		}
//	}
   }

   function scrollOut() {
		document.getElementById('prods').innerHTML = "";
		pos++;		
	}


//MONTA MENU
function menu(desc,lk){
	qtd = desc.length;
	qtd = (qtd>=15) ? qtd-1 : qtd;
	w = parseInt(9.2 * qtd);
	document.write('<span style="display:block; height:13px; width:' + w +'px; overflow-x:hidden;">');
	fls(lk, desc, URL+"img/titulo_menu.swf", "flash", "160", "11","_self","0x8E9593");
	document.write('</span>');
}*/


//POPIN
function open_(url_,h,w) {
	popcont.innerHTML = '' +
		'<div id="popupInner">' +
			'<div id="popupTitleBar">' +
				'<div id="popupControls">' +
					'<a onclick="javascript: hidePopWin(false);" id="popCloseBox"> <font>Fechar</font></a>' +
				'</div>' +
			'</div>' +
				'<iframe src="' + URL + 'load.html" style="width:100%;height:100%;" scrolling="auto" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
		'</div>';
	theBody.appendChild(popmask);
	theBody.appendChild(popcont);
	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popupContainer");
	gPopFrame = document.getElementById("popupFrame");	
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
	showPopWin(url_, w, h,null,true);
	// window.open(url_);
}

function RemoveAcentos(obj) {
    var texto = obj.value.split('');
    var len = obj.value.length;
    var Alterado = false;
    var acento = 'ÀÁÂÃ"Å áâãäå\'\""ÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûü\'ñÿý^´`~';
    var semacento = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'c', 'c', 'd', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'n', 'n', 's', 's', 'y', 'y', 'y', 'z', '', '', '', '', ''];  
    for (var x = 0; x < len; x++) {
        if (acento.indexOf(texto[x]) > -1)
        {
            texto[x] = semacento[acento.indexOf(texto[x])];
            Alterado = Alterado || true;
        }
    }  
    obj.value = texto.join('');   
  //RemoveCaracteresEspeciais(obj, Alterado);
}

function RemoveAcentosString(str) {
    var texto = str.split('');
    var len = str.length;
    var Alterado = false;
    var acento = 'ÀÁÂÃ"Å áâãäå\'\""ÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûü\'ñÿý^´`~';
    var semacento = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'o', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'e', 'c', 'c', 'd', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'i', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'u', 'n', 'n', 's', 's', 'y', 'y', 'y', 'z', '', '', '', '', ''];  
    for (var x = 0; x < len; x++) {
        if (acento.indexOf(texto[x]) > -1)
        {
            texto[x] = semacento[acento.indexOf(texto[x])];
            Alterado = Alterado || true;
        }
    }  
    str = texto.join('');   
	return str;
  //RemoveCaracteresEspeciais(obj, Alterado);
}

function RemoveCaracteresEspeciais(obj, Alterado) {

    var caracNormal = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ@._-';
    var ret =  obj.value.split('');
    var i = 0;   
    for (i = 0; i < obj.value.length; i++) {
         if (caracNormal.indexOf(ret[i],0) == -1) {
              ret[i] = '';
              Alterado = Alterado || true;
         }
    }
    obj.value = ret.join('');   
    ToLowerCase(obj, Alterado);
}

function ToLowerCase(obj, Alterado) {
    var texto = obj.value.split('');
    var len = obj.value.length;
    var ALTA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';    
    var BAIXA = ['a','b','c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
    for (var x = 0; x < len; x++) {
        if (ALTA.indexOf(texto[x]) > -1)
        {
            texto[x] = BAIXA[ALTA.indexOf(texto[x])];
            Alterado = Alterado || true;
        }
    }
    obj.value = texto.join('');
    
}

function utf8_decode_1(str_data) {
    // Converts a UTF-8 encoded string to ISO-8859-1  
    // version: 1008.1718
    // discuss at: http://phpjs.org/functions/utf8_decode    // +   original by: Webtoolkit.info (http://www.webtoolkit.info/)
    // +      input by: Aman Gupta
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: Norman "zEh" Fuchs
    // +   bugfixed by: hitwork    // +   bugfixed by: Onno Marsman
    // +      input by: Brett Zamir (http://brett-zamir.me)
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // *     example 1: utf8_decode('Kevin van Zonneveld');
    // *     returns 1: 'Kevin van Zonneveld'    var tmp_arr = [], i = 0, ac = 0, c1 = 0, c2 = 0, c3 = 0;   
    str_data += '';
	var tmp_arr = str_data.split('');
    
    while ( i < str_data.length ) {        c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if ((c1 > 191) && (c1 < 224)) {            c2 = str_data.charCodeAt(i+1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i+1);            c3 = str_data.charCodeAt(i+2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    } 
    return tmp_arr.join('');
}
function utf8_decode_2(str_data) {
    return unescape(encodeURIComponent(str_data));
}



