function rodaAjax(page){
	var ajaxTeste	= new ajax('GET', page, true, '', 'showConteudo');
	ajaxTeste.ajaxResponse();
	travaTela();
}

function showConteudo(tx_html) {
	// resolve problemas c/ acentuação [' e "]
	tx_html				= decodeURI(tx_html);
	// Pega elementos da div COLUNACTR
	var colunactr		= document.getElementById('colunactr');
	// escreve o retorno do AJAX na div
	colunactr.innerHTML	= tx_html;
	// remove o loadinf da tela
	loading(false);
	
	// Evita criar a div novamente
	if (!document.getElementById('colunactr')) {
		document.body.appendChild(colunactr);
	}

	window.setTimeout('destravaTela()', 100);
}

function rodaTudoSobre(page){
	var ajaxTeste	= new ajax('GET', page, true, '', 'showTudoSobre');
	ajaxTeste.ajaxResponse();
	travaTela();
}

function showTudoSobre(tx_html) {
	// resolve problemas c/ acentuação [' e "]
	tx_html				= decodeURI(tx_html);
	// Pega elementos da div COLUNACTR
	var conteudoTS		= document.getElementById('conteudoTS');
	// escreve o retorno do AJAX na div
	conteudoTS.innerHTML	= tx_html;
	// remove o loadinf da tela
	loading(false);
	
	// Evita criar a div novamente
	if (!document.getElementById('conteudoTS')) {
		document.body.appendChild(conteudoTS);
	}
	window.setTimeout('destravaTela()', 100);
}

/*# Utilizado para criar o efeito de loading */
function loading(opt) {
	if (opt == true) {
		// A tag que receberá a img de loading
		var colunactr = document.getElementById('colunactr');
		// Dizemos que os elementos dentro dela será alinhado ao centro
//		colunactr.style.textAlign = 'center';
		// Criamos uma imagem, img.
		var img = document.createElement('img');
		// Informamos o caminho da img
		img.setAttribute('src','imagens/loading.gif');
		// Setamos um atributo ID na img criada
		img.setAttribute('id','loading');
		// Dizemos que o margin-top será a metada do tamanho da div
		img.style.position = 'absolute'; //(bgBodyHeight[3]/2) + 'px';
		img.style.top = '400px'; //(bgBodyHeight[3]/2) + 'px';
		img.style.left = '180px'; //(bgBodyHeight[3]/2) + 'px';
		// Evita que seja criada duas ou mais img de loading
		if (!document.getElementById('loading')) {
			// Insere a img na tag informada na variável bgBody
			colunactr.insertBefore(img, colunactr.firstChild);
		}
	} else if (opt == false) {
		// Referenciamos a img de login através de seu ID
		var imgLoading = document.getElementById('loading');
		// Removemos a img de loading
		if (imgLoading) {
			imgLoading.parentNode.removeChild(imgLoading);
		}
	}
}

/* Retorna o tamanho da página */
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
	
	return arrayPageSize;

}

/*# redireciona usuário
	@vc_redirect:String		=	página q o usuário será enviada
	@it_segundo	:Integer	=	número de segundos antes de redirecionar
								[opcional, padrão -> 3segundos]			*/
function redirect(vc_redirect, it_segundo) {
	it_segundo	= (it_segundo) ? parseInt(it_segundo * 1000) : 3000;
	setTimeout('self.location.href=\'' + vc_redirect + '\'', it_segundo)
}


function wordWrap(){
/******
* wordWrap - Efetua quebra em palavras que não cabem na largura
*            de seu elemento pai (até que chegue o CSS3)
* Use a vontade mas coloque meu nome nos créditos. Tenha ética.
* Dúvidas, me mande um email.
* Versão: 1.0 - 26/04/2006
* Autor: Micox - Náiron José C. Guimarães - micoxjcg@yahoo.com.br
* Uso: chame a função no onload do body.
*      coloque a classe "word-wrap" nos parágrafos que quiser a quebra
*******/
    var larg_total,larg_carac,quant_quebra,pos_quebra;
    var elementos,quem, caracs, texto, display_orig;
    
    elementos = document.getElementsByTagName("td")
    
    for(var i=0; i<elementos.length;i++){
        if(elementos[i].className=="td_01"){
            quem = elementos[i];
            
            quem.innerHTML = String(quem.innerHTML).replace(/ /g,"Ø")
            texto = String(quem.innerHTML)
            
            quem.innerHTML = " "
            
            display_orig = quem.style.display;
            quem.style.display="block";
            larg_oficial = quem.offsetWidth;
            //alert("oficial: " + larg_oficial)
            //alert("display " + quem.style.display)
            if(!document.all) quem.style.display="table";
            //alert("display " + quem.style.display)
            quem.innerHTML = texto;
            larg_total = quem.offsetWidth;
            //alert("total: " + larg_total)
            
            pos_quebra = 0;
            caracs = texto.length;
            texto = texto.replace(/Ø/g," ")
            larg_carac = larg_total / caracs
            if(larg_total>larg_oficial){
                quant_quebra = parseInt(larg_oficial/larg_carac)
                quant_quebra = quant_quebra - (parseInt(quant_quebra/6)) //quanto menor o num, maior a garantia;
                quem.innerHTML = ""
                while(pos_quebra<=caracs){
                    quem.innerHTML = quem.innerHTML + texto.substring(pos_quebra,pos_quebra + quant_quebra) + " "
                    pos_quebra = pos_quebra + quant_quebra;
                }
            }else{
                quem.innerHTML = texto;
            }//end if do larg_total>larg_oficial
            quem.style.display = display_orig;
        }//end if do word wrap
    }//end for loop dos elementos
}


/*# trava a tela com div branca c/ opacidade */
function travaTela() {
	// Seleciona a tag body. item(0) por que só existe uma tag body
	var tagBody						= document.getElementsByTagName('body').item(0);
	// Pega os tamanhos atuais da página, como largura, altura, ...
	var sizesPage					= getPageSize();
	// Vamos criar uma tag div
	var bgBody						= document.createElement('div');
	// Setar o atributo ID a div criada
	bgBody.setAttribute('id','bgBody');
	with (bgBody.style) {
		top				= '122px';
		left			= (sizesPage[0]-395)/2 + 'px';
		// Essa div terá o tamanho exato da página
		height			= sizesPage[1] + 'px';
		// Essa div terá a largura exata da página
		width			= '395px';
	}
	
	// Evita criar a div novamente
	if (!document.getElementById('bgBody')) {
		tagBody.insertBefore(bgBody, tagBody.firstChild);
	}	
}

/*# Destrava a tela */
function destravaTela() {
	if (document.getElementById('bgBody')) {
		var bgBody		= document.getElementById('bgBody');
		with (bgBody.parentNode) {
			removeChild(bgBody);
		}
	}
}


/*# mostra/esconde Curiosidades */
function showHideResposta(vc_obj,li_obj) {
	// verifica se o elemento existe
	if (document.getElementById(vc_obj)) {
		var obj_detalhe		= document.getElementById(vc_obj);
		var obj_lista		= document.getElementById(li_obj);
		
		if (obj_detalhe.style.display != 'none'){
	// define variáveis para diminuir a altura do iFrame
			var altura_pagina	= parent.document.getElementById('colunactr').offsetHeight;
			var altura_detalhe	= document.getElementById(vc_obj).offsetHeight;

	// apaga div de detalhe
			obj_detalhe.style.display	= 'none'
			obj_lista.style.backgroundPosition	= 'top left';

	// diminui altura do iFrame
			parent.document.getElementById('colunactr').style.height = altura_pagina - altura_detalhe +'px';
			parent.document.getElementById('the_iframe').style.height = altura_pagina - altura_detalhe +'px';
			
		}else{
	// mostra div de detalhe
			obj_detalhe.style.display	= 'inline'
			obj_lista.style.backgroundPosition	= 'top right';

	// define variáveis para diminuir a altura do iFrame
			var altura_pagina	= parent.document.getElementById('colunactr').offsetHeight;
			var altura_detalhe	= document.getElementById(vc_obj).offsetHeight;

	// aumenta altura do iFrame
			parent.document.getElementById('colunactr').style.height = altura_pagina + altura_detalhe +'px';
			parent.document.getElementById('the_iframe').style.height = altura_pagina + altura_detalhe +'px';
		}
	}
}

/*# redimensionamento */
function resizer(){
	parent.document.getElementById('frameconteudo').style.height=document.getElementById('frame').offsetHeight+30+'px';
	parent.document.getElementById('frameconteudo').style.visibility = "visible";
}

//  Exibir Layers 
	
	function sL(layerName){
		document.getElementById(layerName).style.visibility = "visible";
	}

//  Apagar Layers 
	function hL(layerName){
		document.getElementById(layerName).style.visibility = "hidden";
	}

function resizerRet(){
	parent.document.getElementById('frameconteudo').style.height=document.getElementById('frame').offsetHeight+0+'px';
	parent.document.getElementById('frameconteudo').style.visibility = "visible";
	sL('linha');
	sL('ampliar');
}

/*# Abre popup centralizada na tela. Passar largura e altura */
function wopen(page,wdt,hgt)
{
	var _x				= wdt / 2;
	var _y				= hgt / 2;
	var pos_tela_width		= (screen.width / 2) - _x;
	var pos_tela_height		= (screen.height / 2) - _y;

	win = window.open(page,"pre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,noresize,copyhistory=no,width="+wdt+",height="+hgt+",top="+pos_tela_height+",left="+pos_tela_width);
	win.focus();


}

/*# Abre popup para estrada. Passar largura e altura */
function wopenEstrada(page,wdt,hgt)
{
	window.open(page,"pre","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,noresize,copyhistory=no,width="+wdt+",height="+hgt+",top=0,left=0");
}

/*# Reseta forumlário ao recarregar a página */
function resetForms() {
   for (var i = 0; i < document.forms.length; i++) {
     document.forms[i].reset();
   }
}

/*# CONTA CARACTER */
function contaCaracter(obj_campo,vc_contador,it_limite) {
	it_caracter		= eval('document.frm.' + vc_contador);
	
	if (obj_campo.value.length > it_limite) {
		obj_campo.value		= obj_campo.value.substring(0,it_limite);
	} else {
		it_caracter.value	= it_limite - obj_campo.value.length;
	}
}