/**********************************************************************************
MUDA O TAMANHO DA FONTE EM UM DETERMINADO DIV
**********************************************************************************/

function MudaTamanhoFonte(tipo,id) {
	// pega o tamanho atual da fonte
	var tamanho_atual = document.getElementById(id).style.fontSize;
	var tamanho_minimo = 11;
	var tamanho_maximo = 20;
	
	// converte para inteiro
	tamanho_atual = tamanho_atual.replace("px","") * 1;	
	
	// verifica o tamanho mínimo a ser respeitado
	if (tamanho_atual == "") {
		tamanho_atual = tamanho_minimo;
	}
	
	// incrementa o tamanho atual
	if (tipo=="mais") {
		tamanho_atual += 1;
	} else {
		tamanho_atual -= 1;
	}
	
	// verifica se o tamanho esta dentro do limite
	if (tamanho_atual < tamanho_minimo) {
		tamanho_atual = tamanho_minimo;
	} else if (tamanho_atual > tamanho_maximo) {
		tamanho_atual = tamanho_maximo;
	}
		
	if (document.getElementById(id)) {
		var elemento = document.getElementById(id);
		var child = elemento.getElementsByTagName("*");
		
		elemento.style.fontSize = tamanho_atual + 'px';
		if (child.length > 0) {
			for (i = 0; i < child.length; i++) {
				child[i].style.fontSize = tamanho_atual + 'px';
			}
		}
	}

}

function trocaValor(target, targetTxt,valor)
{
	input = document.getElementById(target);
	txt =  document.getElementById(targetTxt);
	if (input) {
		input.innerHTML = "R$ "+valor;
	}
	
	if (txt) {
		txt.value = "R$ "+valor;
	}
}

function trocaOpcoesDebito(target,table)
{
	tr = document.getElementById(target);
	if (tr.style.display == "none") {
		tr.style.display = 'inline';
	}
	if (table == "1") {
		document.getElementById("banco").style.display = "inline";
		document.getElementById("luz").style.display = "none";
	}
	else if (table == "2") {
		document.getElementById("banco").style.display = "none";
		document.getElementById("luz").style.display = "inline";
	}
}

function txtBoxFormat(obj, sMask, evtKeyPress) { 
	var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla; 
	if(document.all) { // Internet Explorer 
		nTecla = evtKeyPress.keyCode;
	} else if(document.layers) { // Nestcape 
		nTecla = evtKeyPress.which; 
	} 
	sValue = obj.value; 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( "-", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( ".", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "/", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( "(", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( ")", "" ); 
	sValue = sValue.toString().replace( " ", "" ); 
	sValue = sValue.toString().replace( " ", "" ); 
	fldLen = sValue.length; 
	mskLen = sMask.length; 
	i = 0; 
	nCount = 0; 
	sCod = ""; 
	mskLen = fldLen; 
	while (i <= mskLen) { 
	bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/")) 
	bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " ")) 
		if (bolMask) {
		  sCod += sMask.charAt(i); 
		  mskLen++;
		} else {
		  sCod += sValue.charAt(nCount); 
		  nCount++; 
		} 
		i++; 
	} 

	obj.value = sCod;
	
	if (nTecla != 8) { // backspace 
		if (sMask.charAt(i-1) == "9") { // apenas números... 
		  return ((nTecla > 47) && (nTecla < 58)); // números de 0 a 9 
		} else { // qualquer caracter... 
		  return true; 
		}
	} else { 
		return true; 
	} 
}


function ToggleFloatingLayer(DivID, iState)
{	 
	 if(document.layers)
    {
       document.layers[DivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)
    {
        var obj = document.getElementById(DivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)
    {
        document.all[DivID].style.visibility = iState ? "visible" : "hidden";
    }
	 
}

function MM_openBrWindow(theURL,winName,features)
{  
	window.open(theURL,winName,features);  
}

function iecompattest(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function CentralizaJanela() {

	var ie5=document.all&&document.getElementById
	var ns6=document.getElementById&&!document.all
	
	windowWidth = ns6? window.innerWidth : iecompattest().clientWidth;
	windowHeight = ns6? window.innerHeight : iecompattest().clientHeight;
	screenWidth = screen.width;
	screenHeight = screen.height;
	
	winY = Math.ceil((screenHeight - windowHeight) / 2);
	winX = Math.ceil((screenWidth - windowWidth) / 2);
	
	window.moveTo(winX,winY);
	
}

function CarregaConteudoGeral(arquivo,destino) {
	
	if (arquivo != "") {
		executaAjax(__URL__ + arquivo,destino,'conteudo');		
	}	
}

function escreveConteudo(texto,destino) {
	
		var retorno = texto.split(__DIVISOR__);
	
		document.getElementById(destino).innerHTML = retorno[0];
		
		if (retorno.length > 1) {
			executaCodigo(retorno[1]);
		}
}

function CarregaEnquete() {	

	executaAjax(__URL__ + '_loadfiles/site/enquete/carrega_enquete.php','enqueteHome','conteudo');
	
}

function CarregaNoticia(){
	
	executaAjax(__URL__ + '_loadfiles/site/coluna/carrega_coluna.php','noticiaHomeGaleria','conteudo');
	
}

function CarregaConfronto(contador,destino) {
	
	document.getElementById(destino).innerHTML = '<p style="padding-top:50px;"><b>Aguarde!!!</b><br>Carregando confronto</p>';	
	CarregaConteudoGeral('_loadfiles/site/jogos/confrontos.load.php?rIniConfrontos=' + contador,destino);
	
}

function CarregaConteudoGeral(arquivo,destino) {
	
	executaAjax(__URL__ + arquivo,destino,'conteudo');
	
}

function VerificaStatusTransmissao(cod_transmissao)
{
	executaAjax(__URL__ + '_loadfiles/site/jogos_vivo/transmissao_status.php?cod_transmissao=' + cod_transmissao,'','executa');	
}

function CarregaNoticias()
{
	executaAjax(__URL__ + '_loadfiles/site/noticias/carrega_home.load.php','CarregaNoticias','conteudo');
}
