// JavaScript Document

SIS_ULT_NOTICIA_ATUAL = 0;

function muda_ultima_noticia() {
	div = document.getElementById('lista-ultimas-noticias');
	elementos = div.getElementsByTagName('DIV');
	var divId = null;
	
	/* for(n=0;n<elementos.length;n++) {
		if (elementos[n].className == 'div-noticia') {
			SIS_ULT_NOTICIA_ATUAL++;
			if (n == SIS_ULT_NOTICIA_ATUAL) {
				//alert('sim');
				//elementos[n].style.maginTop = '-20px';
				divId = elementos[n].id;
				//alert(divId);
				t0 = new Tween(document.getElementById(divId).style, 'marginTop', Tween.regular, 0, -200, 1, 'px'); 
				t0.start();
			}
		}
	} */
	
	//return false;
	
	SIS_ULT_NOTICIA_ATUAL++;
	
	if (SIS_ULT_NOTICIA_ATUAL == 1) {
		
		t0 = new Tween(document.getElementById('ult-not-1').style, 'marginTop', Tween.regular, 0, -30, 0.3, 'px'); 
		setTimeout("t0.start();", 1000);
		
		t1 = new Tween(document.getElementById('ult-not-2').style, 'marginTop', Tween.regular, 30, 0, 0.3, 'px'); 
		setTimeout("t1.start();", 1000);
		
		t2 = new Tween(document.getElementById('ult-not-3').style, 'marginTop', Tween.regular, 60, 30, 0.3, 'px'); 
		setTimeout("t2.start();", 1000);
	}
	
	if (SIS_ULT_NOTICIA_ATUAL == 2) {
		t0 = new Tween(document.getElementById('ult-not-1').style, 'marginTop', Tween.regular, -30, -60, 0.3, 'px'); 
		setTimeout("t0.start();", 1000);
		
		t1 = new Tween(document.getElementById('ult-not-2').style, 'marginTop', Tween.regular, 0, -30, 0.3, 'px'); 
		setTimeout("t1.start();", 1000);
		
		t2 = new Tween(document.getElementById('ult-not-3').style, 'marginTop', Tween.regular, 30, 0, 0.3, 'px'); 
		setTimeout("t2.start();", 1000);
	}
	
	if (SIS_ULT_NOTICIA_ATUAL == 3) {
		t0 = new Tween(document.getElementById('ult-not-1').style, 'marginTop', Tween.regular, -60, 0, 0.3, 'px'); 
		setTimeout("t0.start();", 1000);
		
		t1 = new Tween(document.getElementById('ult-not-2').style, 'marginTop', Tween.regular, -30, 30, 0.3, 'px'); 
		setTimeout("t1.start();", 1000);
		
		t2 = new Tween(document.getElementById('ult-not-3').style, 'marginTop', Tween.regular, 0, 60, 0.3, 'px'); 
		setTimeout("t2.start();", 1000);
		
		SIS_ULT_NOTICIA_ATUAL = 0;
	}
	
	//elementos[0].style.marginTop = "0px";
	//elementos[1].style.marginTop = "0px";
	//elementos[2].style.marginTop = "0px";
}

SIS_SLIDE_ATUAL = 2;

function muda_materia_slide() {
	
	var div = document.getElementById('lista-slides');
	var elementos = div.getElementsByTagName('DIV');
	var total_elementos = 0;
	
	for (n=0;n<elementos.length;n++) {
		if (elementos[n].id.indexOf('slide-') > -1) {
			total_elementos++;
		}
	}
	//alert(total_elementos);
	if (total_elementos == 1) {
		total_elementos = 0;
	}
	
	//alert(SIS_SLIDE_ATUAL);
	for (n=1;n<(total_elementos+1);n++) {
		if (n != SIS_SLIDE_ATUAL) {
			MM_effectAppearFade('slide-'+n, 500, 100, 0, false);
			setTimeout("document.getElementById('slide-"+n+"').style.display = 'none';", 10);
			document.getElementById('opt-'+n).className = '';
		} else {
			//alert(n);
			MM_effectAppearFade('slide-'+n, 1500, 40, 100, false);
			document.getElementById('slide-'+n).style.display = 'block';
			document.getElementById('opt-'+n).className = 'ativo';
		}
	}
	
	SIS_SLIDE_ATUAL++;
	if (SIS_SLIDE_ATUAL > total_elementos) {
		SIS_SLIDE_ATUAL = 1;
	}
			
	/*SIS_SLIDE_ATUAL++;
	//alert(SIS_SLIDE_ATUAL);
	
	 if (SIS_SLIDE_ATUAL == 1) {
		
		t10 = new Tween(document.getElementById('slide-1').style, 'marginTop', Tween.regular, 0, -350, 1, 'px'); 
		setTimeout("t10.start();", 0);
		
		document.getElementById('opt-1').className = '';
		document.getElementById('opt-2').className = 'ativo';
		document.getElementById('opt-3').className = '';
		
	}
	
	if (SIS_SLIDE_ATUAL == 2) {
		t10 = new Tween(document.getElementById('slide-1').style, 'marginTop', Tween.regular, -350, -700, 1, 'px'); 
		setTimeout("t10.start();", 0);
		
		t11 = new Tween(document.getElementById('slide-2').style, 'marginTop', Tween.regular, 0, -350, 1, 'px'); 
		setTimeout("t11.start();", 0);
		
		document.getElementById('opt-1').className = '';
		document.getElementById('opt-2').className = '';
		document.getElementById('opt-3').className = 'ativo';
	}
	
	if (SIS_SLIDE_ATUAL == 3) {
		t10 = new Tween(document.getElementById('slide-1').style, 'marginTop', Tween.regular, -700, 0, 0.5, 'px'); 
		setTimeout("t10.start();", 0);
		
		t11 = new Tween(document.getElementById('slide-2').style, 'marginTop', Tween.regular, -350, 0, 0.5, 'px'); 
		setTimeout("t11.start();", 0);
		
		document.getElementById('opt-1').className = 'ativo';
		document.getElementById('opt-2').className = '';
		document.getElementById('opt-3').className = '';
		
		SIS_SLIDE_ATUAL = 0;
	} */
}

function avanca_slide_inicio() {
	//t20 = new Tween(document.getElementById('slide-1').style, 'marginTop', Tween.regular, -700, 0, 0.5, 'px'); 
	//setTimeout("t20.start();", 0);
	
	document.getElementById('slide-1').style.marginTop = '-350px';
}

function ir_para_slide(num) {
	//avanca_slide_inicio();
	SIS_SLIDE_ATUAL = num;
	setTimeout("muda_materia_slide();", 100); 
	clearInterval(intervalDestaques);
	intervalDestaques = setInterval('muda_materia_slide();', 5000);
}

function MM_effectAppearFade(targetElement, duration, from, to, toggle)
{
	Spry.Effect.DoFade(targetElement, {duration: duration, from: from, to: to, toggle: toggle});
}


timeout = null;
ultima_id = null;
function exibe_menu(id, acao, marginLeft, proprioElemento) {
	
	
	div = document.getElementById('sub-menus-principais');
	elementos = div.getElementsByTagName('DIV');
	for(n=0;n<elementos.length;n++) {
		if (elementos[n].className == 'div-caixa-menu') {
			elementos[n].style.display = 'none';
		}
	}
	
	if (proprioElemento && id == ultima_id) {
		//clearTimeout(timeout);
		//clearTimeout(timeout2);
		//clearTimeout(timeout3);
		//setTimeout("document.getElementById('sub-menus-principais').style.visibility = 'visible';", 500);
		//setTimeout("document.getElementById('"+id+"').style.display = 'block';", 500);
		//setTimeout("document.getElementById('sub-menus-principais').style.marginLeft = '"+marginLeft+"px';", 500);
	}
	
	ultima_id = id;
	
	if (acao == "mouseover") {
		document.getElementById('sub-menus-principais').style.visibility = 'visible';
		document.getElementById('sub-menus-principais').style.marginLeft = marginLeft+"px";
		document.getElementById(id).style.display = 'block';
	} else if (acao == "mouseout") {
		//timeout = setTimeout("document.getElementById('sub-menus-principais').style.visibility = 'hidden';", 1000);
		//timeout2 = setTimeout("document.getElementById('"+id+"').style.display = 'none';", 1000);
		//timeout3 = setTimeout("document.getElementById('sub-menus-principais').style.marginLeft = '0px';", 1000);
	}
}

function fechar_menu() {
	div = document.getElementById('sub-menus-principais');
	elementos = div.getElementsByTagName('DIV');
	for(n=0;n<elementos.length;n++) {
		if (elementos[n].className == 'div-caixa-menu') {
			elementos[n].style.display = 'none';
		}
	}
	document.getElementById('sub-menus-principais').style.visibility = 'hidden';
}


tamanhoAtual = 16;
function mudar_tamanho_texto(acao) {
	
	//var tamanhoAtual = document.getElementById('conteudo-materia').style.fontSize;
	
	//alert(tamanhoAtual);
	if (acao == "aumentar" && tamanhoAtual < 22) {
		tamanhoAtual += 2;
		document.getElementById('conteudo-materia').style.fontSize = (tamanhoAtual+2)+"px";
	} else if (acao == "diminuir" && tamanhoAtual > 12) {
		tamanhoAtual -= 2;
		document.getElementById('conteudo-materia').style.fontSize = (tamanhoAtual-2)+"px";
	}
	//alert(tamanhoAtual);
}


function materias_categorias(HTML, div_id) {
	
	//alert(document.getElementById('html_'+div_id).id);
	//document.getElementById('html_'+div_id).innerHTML = "teste";
	
	var div = document.getElementById('lista-leia-mais');
	var elementos = div.getElementsByTagName('DIV');
	
	//alert(div.id);
	
	for(n=0;n<elementos.length;n++) {
		if (elementos[n].id == "html_"+div_id) {
			elementos[n].innerHTML = HTML;
		} else if (elementos[n].className == "html") {
			elementos[n].innerHTML = '';
		}
	}
	
	/* if (document.getElementsByClassName('div-mais-sobre-ativo')[0]) {
		document.getElementsByClassName('div-mais-sobre-ativo')[0].className = 'div-mais-sobre';
	}
	for(n=0;n<document.getElementsByClassName('html').length;n++) {
		document.getElementsByClassName('html')[n].innerHTML = "";
	}
	
	var div = $('mais-sobre-'+div_id);
	div.className = 'div-mais-sobre-ativo';
	document.getElementById('html_'+div_id).innerHTML = HTML; */
}




//JANELA DICAS
mouseX = 0;
mouseY = 0;
var totalT = 0;
function mudarJanelaDicas(HTML, fechar, backColor, textColor, x, y, W, H) {
	if (!fechar) {
		if (backColor != undefined) document.getElementById('div-textos-centrado-fixado').style.backgroundColor = backColor;
		if (textColor != undefined) document.getElementById('div-textos-centrado-fixado').style.color = textColor;
		
		if (W != undefined) document.getElementById('div-textos-centrado-fixado').style.width = W+"px";
		if (H != undefined) {
			 document.getElementById('div-textos-centrado-fixado').style.height = H+"px";
			 document.getElementById('div-textos-centrado-fixado').style.display = "table";
			 document.getElementById('div-textos-centrado-fixado').style.overFlow = "scroll";
		}
		
		
		/* if (window.pageYOffset) {
			var acresX = window.pageXOffset;
			var acresY = window.pageYOffset;
		} else {
			var acresX = document.body.scrollLeft;
			var acresY = document.body.scrollTop;
		} */
		
		if (window.pageXOffset != undefined) {
			var topScroll 	= window.pageYOffset;
			var leftScroll 	= window.pageXOffset;
			var res = "window.pageXOffset";
		} else if (document.documentElement.scrollTop != undefined) {
			var topScroll 	= document.documentElement.scrollTop;
			var leftScroll 	= document.documentElement.scrollLeft;
			var res = "document.documentElement.scrollTop";
		} else if (document.body.scrollTop != undefined) {
			var topScroll 	= document.body.scrollTop;
			var leftScroll 	= document.body.scrollLeft;
			var res = "document.body.scrollTop";
		}
		
		
		document.getElementById('div-textos-centrado-fixado').style.position = "absolute";
		if (y == 'mouse') {
			y = ((mouseY+200));
			//document.getElementById('div-textos-centrado-fixado').style.position = "fixed";
		}
		if (x == 'mouse') {
			x = ((mouseX+40));
			//document.getElementById('div-textos-centrado-fixado').style.position = "fixed";
		}
		if (x != undefined) { 
			document.getElementById('div-textos-centrado-fixado').style.left = (leftScroll+x)+"px";
			document.getElementById('div-textos-centrado-fixado').style.top = (topScroll+y)+"px";
		} else {
			document.getElementById('div-textos-centrado-fixado').style.left = '';
			document.getElementById('div-textos-centrado-fixado').style.top = '';
		}
		//if (y != undefined) document.getElementById('div-textos-centrado-fixado').style.top = (acresY+y)+"px";
		
		setTimeout("document.getElementById('div-textos-centrado-fixado').style.visibility = 'visible'", 0);
		document.getElementById('div-textos-centrado-fixado_texto').innerHTML = HTML;
		document.getElementById('div-textos-centrado-fixado').style.marginLeft = -(document.getElementById('div-textos-centrado-fixado').scrollWidth/2)+"px";
		document.getElementById('div-textos-centrado-fixado').style.marginTop = -((document.getElementById('div-textos-centrado-fixado').scrollHeight)/2)+"px";
		
		
		$('div-escurecer').style.visibility = 'visible';
		$('div-escurecer').style.width = (document.body.scrollWidth)+"px";
		$('div-escurecer').style.height = (document.body.scrollHeight)+"px";
		$('div-escurecer').style.left = "0px";
		$('div-escurecer').style.top = "0px";
	} else {
		//setTimeout("document.getElementById('div-textos-centrado-fixado').style.visibility = 'hidden'", 3000);
		//setTimeout("document.getElementById('div-textos-centrado-fixado_texto').innerHTML = ''", 3000);
		document.getElementById('div-textos-centrado-fixado').style.visibility = 'hidden';
		document.getElementById('div-textos-centrado-fixado_texto').innerHTML = '';
		
		$('div-escurecer').style.visibility = 'hidden';
	}
}


function mudarTagDicas(HTML, cor, letras) {
	if (cor != undefined) {
		document.getElementById('div-textos-fixado').style.background = cor;
	} else {
		setTimeout("document.getElementById('div-textos-fixado').style.background = ''", 4000);;
	}
	
	if (letras != undefined) {
		document.getElementById('div-textos-fixado').style.color = letras;
	} else {
		setTimeout("document.getElementById('div-textos-fixado').style.color = ''", 4000);
	}
	
	if (HTML != undefined && HTML != "(esconder)") {
		document.getElementById('div-textos-fixado').style.visibility = 'visible';
		document.getElementById('div-textos-fixado').innerHTML = HTML;
	} else if(HTML == undefined) {
		setTimeout("document.getElementById('div-textos-fixado').style.visibility = 'hidden'; document.getElementById('div-textos-fixado').innerHTML = '';", 4000);
	} else {
		document.getElementById('div-textos-fixado').style.visibility = 'hidden';
		document.getElementById('div-textos-fixado').innerHTML = '';
	}
}



function trocar_opcoes_menu(divid_mestre, num_opcao, objeto_clicado) {
	var elemento = document.getElementById(divid_mestre);
	
	var divs_elementos = elemento.getElementsByTagName('DIV');
	var n_div = 0;
	
	for(n=0;n<divs_elementos.length;n++) {
		if (divs_elementos[n].className.indexOf("conteudo") > -1 || divs_elementos[n].className.indexOf("conteudo-sem-borda") > -1) {
			
			if (n_div == num_opcao) {
				divs_elementos[n].style.display = '';
			} else {
				divs_elementos[n].style.display = 'none';
			}
			n_div++;
			
		} else if (divs_elementos[n].className == "div-opcoes") {
			
			var divs_opcoes = divs_elementos[n].getElementsByTagName('DIV');
			//alert(divs_opcoes.length);
			for(n2=0;n2<divs_opcoes.length;n2++) {
				divs_opcoes[n2].className = '';
			}
			objeto_clicado.className = 'ativo';
		}
	}
}


function alertar_link_externo(dominio, link_href) {
	if (dominio != "lc.bahiaco.com" && dominio != "bahiaco.macrobol.com") {
		var html = '<table border="0" cellspacing="3" cellpadding="3" width="400">   <tr>     <td colspan="2" align="center">ATEN&Ccedil;&Atilde;O! Voc&ecirc; est&aacute; tentando abrir um link externo!</td>   </tr>   <tr>     <td colspan="2">Este link n&atilde;o foi oferecido pelo Blog Bahia&ccedil;o! <br>Se voc&ecirc;&nbsp;confia no site <strong>'+dominio+'</strong>, clique em abrir o link, caso contr&aacute;rio, recuse!</td>   </tr>   <tr>     <td colspan="2" class="marcador">Deseja abrir este link?</td>   </tr>   <tr>     <td align="center"><input name="button" type="submit" class="menor" value="Abrir link" onclick="window.open(\'http://'+dominio+link_href+'\');" /></td>     <td align="center"><input name="button2" type="submit" class="menor" value="N&atilde;o abrir" onclick="mudarJanelaDicas(undefined, true);" /></td>   </tr> </table>';
		mudarJanelaDicas(html, false, undefined, undefined, '600', 'mouse', undefined, undefined);
	} else {
		window.open('http://'+dominio+link_href);
	}
}


function dados_tabela_interativa(html, timeCod) {
	//alert(timeCod);
	//var tabela = document.getElementById('tabela_classificacao');
	var trs = document.getElementsByTagName('TR');
	//var tds = tabela.getElementsByTagName('TD');
	for (n=0;n<trs.length;n++) {
		if (trs[n].id.indexOf('tr_') > -1) {
			trs[n].style.display = 'none';
			trs[n].getElementsByTagName('TD')[0].style.innerHTML = '';
		}
	}
	if (html != undefined) {
		document.getElementById('td_'+timeCod+'_html').innerHTML = html;
		document.getElementById('tr_'+timeCod+'_html').style.display = 'table-row';
	} else {
		document.getElementById('td_'+timeCod+'_html').innerHTML = '<img src="sources/imagens/carregando.gif" width="20" />';
		document.getElementById('tr_'+timeCod+'_html').style.display = 'table-row';
	}
}



/* classificacao */
function pega_fase_torneio(irpara, ano, campeonato) {
	
	
	var array_fase_final = Array("oitavas-de-final", "quartas-de-final", "semi-final", "final", "disputa-3-lugar");
	var array_nome_fase_final = Array("Oitavas de final", "Quartas de final", "Semi-final", "Final", "Disputa 3º lugar");
	
	
	if (irpara == "anterior" && FASE_NIVEL > 1) {
		FASE_NIVEL--;
		var liberar = true;
	} else if (irpara == "proxima" && FASE_NIVEL < MAX_FASE_NIVEL) {
		FASE_NIVEL++;
		var liberar = true;
	}
	
	var val_diferenca = (FASE_NIVEL-INICIA_FASE_FINAL);
	
	if (EXIBIR_FASE_FINAL_ESPECIAL == 0 && val_diferenca >= 0) {
		var liberar = true;
	} else if (EXIBIR_FASE_FINAL_ESPECIAL == 1 && val_diferenca >= 1) {
		var liberar = false;
		//var liberar = true;
	} else {
		var liberar = true;
	}
	
	//alert(FASE_NIVEL);
	if (FASE_NIVEL == MAX_FASE_NIVEL || FASE_NIVEL == 0) {
		//var liberar = false;
	}
	
	if (liberar) {
		if (window.location.href.indexOf("classificacao_frame.php") > -1) {
			carregar_dados_externos('/ajax/sources/frames/classificacao_frame.js?acao=pegar_fase&ano='+ano+'&campeonato='+campeonato+'&fase_nivel='+FASE_NIVEL+'&exibir_classificacao='+EXIBIR_CLASSIFICACAO+'&exibir_jogos='+EXIBIR_JOGOS);
		} else {
			carregar_dados_externos('/ajax/classificacao.js?acao=pegar_fase&ano='+ano+'&campeonato='+campeonato+'&fase_nivel='+FASE_NIVEL+'&exibir_classificacao='+EXIBIR_CLASSIFICACAO+'&exibir_jogos='+EXIBIR_JOGOS);
		}
	}
	
	if (/* val_diferenca >= -1 */ FASE_NIVEL >= INICIA_FASE_FINAL && EXIBIR_FASE_FINAL_ESPECIAL) {
		//alert('foi');
		interval = setInterval("sobe_fases_finais();", 10);
	} else {
		clearInterval(interval);
	}
	
	if (val_diferenca >= 1) {
		
		var elementos = document.getElementsByTagName('DIV');
		for(n=0;n<elementos.length;n++) {
			if (elementos[n].className.indexOf("fase-final") > -1) {
				elementos[n].className = "fase-final";
			}
		}
		
		//document.getElementById('nome-fase').innerHTML = array_nome_fase_final[val_diferenca];
		if (array_nome_fase_final[val_diferenca] == "Oitavas de final" && !document.getElementById('oitavas-de-final')) {
			val_diferenca++;
		}
		if (array_nome_fase_final[val_diferenca] == "Quartas de final" && !document.getElementById('quartas-de-final')) {
			val_diferenca += 2;
		}
		if (array_nome_fase_final[val_diferenca] == "Semi-final" && !document.getElementById('semi-final')) {
			val_diferenca += 3;
		}
		if (array_nome_fase_final[val_diferenca] == "Final" && !document.getElementById('final')) {
			val_diferenca += 4;
		}
		document.getElementById('nome-fase').innerHTML = array_nome_fase_final[val_diferenca];
		
		if (val_diferenca == 0) {
			document.getElementById(array_fase_final[val_diferenca]).className = 'fase-final selecionada';
			//setTimeout("document.getElementById('"+array_fase_final[val_diferenca]+"').className = 'fase-final selecionada';", 1000);
		} else {
			document.getElementById(array_fase_final[val_diferenca]).className = 'fase-final selecionada';
		}
	}
	
	
	for(n3=0;n3<document.getElementsByTagName('DIV').length;n3++) {
		//alert(document.getElementsByTagName('DIV')[n3].className);
		if (document.getElementsByTagName('DIV')[n3].className.indexOf("div-jogo") > -1) {
			//document.getElementsByTagName('DIV')[n3].style.marginTop = subir+"px";
			//alert('foi');
		}
	}
}
function mudar_fase_torneio(nome_fase, HTML) {
	//alert(nome_fase);
	document.getElementById('nome-fase').innerHTML = nome_fase;
	document.getElementById('div-lista-grupos').innerHTML = HTML;
}
function sobe_fases_finais() {
	if (!document.getElementById('oitavas-de-final')) {
		if (document.getElementById('quartas-de-final')) {
			for(n=0;n<16;n++) {
				if (document.getElementById('quartas-de-final').getElementsByTagName('DIV')[n].className == "div-lista-jogos") {
					//alert(document.getElementById('quartas-de-final').getElementsByTagName('DIV')[n].style.marginTop);
					//document.getElementById('quartas-de-final').getElementsByTagName('DIV')[n].style.marginTop = (document.getElementById('quartas-de-final').getElementsByTagName('DIV')[n].style.marginTop.replace("px", "")-10)+"px";
					document.getElementById('quartas-de-final').getElementsByTagName('DIV')[n].style.marginTop = "-180px";
				}
			}
		}
		if (document.getElementById('semi-final')) {
			for(n=0;n<16;n++) {
				if (document.getElementById('semi-final').getElementsByTagName('DIV')[n].className == "div-lista-jogos") {
					document.getElementById('semi-final').getElementsByTagName('DIV')[n].style.marginTop = "-180px";
				}
			}
		}
		//alert('foi');
		if (document.getElementById('final')) {
			
			for(n=0;n<20;n++) {
				if (document.getElementById('final').getElementsByTagName('DIV')[n].className == "div-lista-jogos") {
					document.getElementById('final').getElementsByTagName('DIV')[n].style.marginTop = "-180px";
				}
			}
		}
		//if (document.getElementById('final')) document.getElementById('final').style.marginTop = "-120px";
	}
	if (!document.getElementById('quartas-de-final')) {
		//if (document.getElementById('semi-final')) document.getElementById('semi-final').style.marginTop = "-140px";
		//if (document.getElementById('final')) document.getElementById('final').style.marginTop = "-140px";
	}
}



//RODADA_GRUPOS = Array();
function mudar_rodada_grupo(irpara, nome_grupo, ano, campeonato, HTML) {
	
	//alert(HTML);
	if (RODADA_ATUAL_GRUPOS[nome_grupo] < 0 || RODADA_ATUAL_GRUPOS[nome_grupo] == undefined) {
		RODADA_ATUAL_GRUPOS[nome_grupo] = 1;
	}
	
	
	if (HTML == undefined) {
		
		if (irpara == "anterior") {
			RODADA_ATUAL_GRUPOS[nome_grupo]--;
		}
		if (irpara == "proxima") {
			RODADA_ATUAL_GRUPOS[nome_grupo]++;
		}
		
		//alert(RODADA_ATUAL_GRUPOS[nome_grupo]);
		
		if (RODADA_ATUAL_GRUPOS[nome_grupo] < 1) {
			RODADA_ATUAL_GRUPOS[nome_grupo] = 1;
			return false;
		}
		
		
		if (RODADA_ATUAL_GRUPOS[nome_grupo] > NUM_MAX_RODADAS[nome_grupo]) {
			RODADA_ATUAL_GRUPOS[nome_grupo] = NUM_MAX_RODADAS[nome_grupo];
			return false;
		}
		
		//alert(EXIBIR_JOGOS);
		if (window.location.href.indexOf("classificacao_frame.php") > -1) {
			carregar_dados_externos('/ajax/sources/frames/classificacao_frame.js?acao=pegar_rodada&ano='+ano+'&campeonato='+campeonato+'&fase_nivel='+FASE_NIVEL+'&rodada='+RODADA_ATUAL_GRUPOS[nome_grupo]+'&grupo='+nome_grupo+'&exibir_classificacao='+EXIBIR_CLASSIFICACAO+'&exibir_jogos='+EXIBIR_JOGOS);
		} else {
			carregar_dados_externos('/ajax/classificacao.js?acao=pegar_rodada&ano='+ano+'&campeonato='+campeonato+'&fase_nivel='+FASE_NIVEL+'&rodada='+RODADA_ATUAL_GRUPOS[nome_grupo]+'&grupo='+nome_grupo+'&exibir_classificacao='+EXIBIR_CLASSIFICACAO+'&exibir_jogos='+EXIBIR_JOGOS);
		}
		
	} else {
		/*var elementos = document.getElementsByTagName("DIV");
		for(n=0;n<elementos.length;n++) {
			if (elementos[n].getAttribute("nome_grupo") == nome_grupo) {
				
			}
		} */
		//alert(HTML);
		document.getElementById("nome_rodada_"+nome_grupo).innerHTML = RODADA_ATUAL_GRUPOS[nome_grupo]+"º rodada";
		document.getElementById("tabela_jogos_"+nome_grupo).innerHTML = HTML;
	}
}




function gera_codigo_plugin(dominio) {
	var split_camp = document.getElementById('campeonato').value.split("/", 100);
	var itens_class = "";
	
	//alert(document.form_plugin.itens_class);
	for(n=0;n<document.form_plugin.itens_class.length;n++) {
		if (document.form_plugin.itens_class[n].checked == true && document.form_plugin.itens_class[n].disabled == false) {
			itens_class += document.form_plugin.itens_class[n].value;
		}
	}
	for(n=0;n<document.form_plugin.exibir_classificacao.length;n++) {
		if (document.form_plugin.exibir_classificacao[n].checked == true) {
			var exibir_classificacao = document.form_plugin.exibir_classificacao[n].value;
		}
	}
	for(n=0;n<document.form_plugin.exibir_jogos.length;n++) {
		if (document.form_plugin.exibir_jogos[n].checked == true) {
			var exibir_jogos = document.form_plugin.exibir_jogos[n].value;
		}
	}
	//alert(document.form_plugin.exibir_jogos[1].value);
	//alert(itens_class);
	//alert(document.form_plugin.exibir_classificacao[document.form_plugin.exibir_classificacao.checkedIndex].value);
	
	var exibir = document.getElementById('exibir').value.replace("_1", "");
	exibir = exibir.replace("_2", "");
	//alert(exibir);
	//document.getElementById('id').value
	//alert(split_camp);
	
	var data = new Date();
	var id = exibir+"_"+data.getHours()+""+data.getMinutes()+""+data.getSeconds();
	
	if (document.getElementById('num_times_pegar').disabled == false) {
		var num_times_pegar = document.getElementById('num_times_pegar').value;
	}
	if (document.getElementById('time').disabled == false) {
		var time_cod = document.getElementById('time').value;
	} else {
		var time_cod = "";
	}
	
	
	if (exibir == "Selecione") {
		alert("Selecione o que deseja exibir");
		return false;
	}
	if (exibir != "proximo-jogo" && (split_camp[0] == "" || split_camp[0] == "Selecione")) {
		alert("Selecione um campeonato/torneio");
		return false;
	}
	if (exibir == "mini-classificacao" && num_times_pegar < 1) {
		alert("Digite o número máximo de times para serem exibidos");
		return false;
	}
	
	if (document.getElementById('end_blog').value == "") {
		alert("Digite o endereço do seu blog/site! Ex.: www.bahiaco.com");
		return false;
	}
	
	if (document.getElementById('largura').value == "") {
		alert("Digite o tamanho da largura para o widget pro seu site");
		return false;
	}
	
	
	/* var valor = "<script type=\"text/javascript\">  \n var _bh_pegar = \""+exibir+"\"; //'tabela-jogos' ou 'proximo-jogo' ou 'ultimo-jogo' ou 'mini-classificacao' \n var _bh_campeonato = \""+split_camp[0]+"\"; \n var _bh_num_times_pegar = \""+num_times_pegar+"\"; //limite de times a serem obtidos para a mini-classificação \n var _bh_class_itens = \""+itens_class+"\"; //itens a serem exibidos. Os disponíveis são: pts, j, v, e, d, gp, gc, sg, aprov \n var _bh_ano = \""+split_camp[2]+"\"; \n var _bh_divisao = '"+split_camp[1]+"'; \n var _bh_time_cod = '"+time_cod+"'; \n var _bh_frame_id = \""+id+"\"; \n  \n var _bh_exibir_classificacao = \""+exibir_classificacao+"\"; //'sim' ou 'nao' \n var _bh_exibir_jogos = \""+exibir_jogos+"\"; //'sim' ou 'nao' \n var _bh_largura = \""+document.getElementById('largura').value+"\"; \n  \n</script> \n<script type=\"text/javascript\" src=\"http://"+dominio+"/ajax/sources/frames/embed_classificacao.php\"></script>"; */
	
	var valor = "<script type=\"text/javascript\" src=\"http://"+dominio+"/ajax/sources/frames/embed_classificacao.php?pegar="+exibir+"&time_cod="+time_cod+"&campeonato="+split_camp[0]+"&ano="+split_camp[2]+"&divisao="+split_camp[1]+"&exibir_jogos="+exibir_jogos+"&exibir_classificacao="+exibir_classificacao+"&limite_times="+num_times_pegar+"&class_itens="+itens_class+"&largura="+document.getElementById('largura').value+"&frame_id="+id+"&origem_site="+document.getElementById('end_blog').value+"\"></script>";
	
	document.getElementById("caixa_codigo").value = valor;
	document.getElementById("caixa_codigo").select();
}




function carregarArquivoJS(filename, filetype) {
	var fileref = document.createElement('script')
	fileref.setAttribute("type","text/javascript")
	fileref.setAttribute("src", filename);
	document.getElementsByTagName("head")[0].appendChild(fileref);
	setTimeout("document.getElementsByTagName('head')[0].removeChild(fileref);", 10000);
}


function carregar_dados_externos(url) {
	/*
	var fileref = document.createElement('script')
	fileref.setAttribute("type","text/javascript")
	fileref.setAttribute("src", filename);
	document.getElementsByTagName("head")[0].appendChild(fileref);
	setTimeout("document.getElementsByTagName('head')[0].removeChild(fileref);", 10000);
	*/
	frame.location = url;
}

function ao_carregar_pagina() {
	new SmoothScroll({ duration: 1000 });
	intervalUltNoti = setInterval('muda_ultima_noticia();', 3000);
	//mudarTagDicas('teste');
	//mudarTagDicas(undefined);
	//mudarJanelaDicas('Agora você vai ver o novo blog Bahiaço');
	//$('#conteudo-principal').insertAfter('<div id="space">fdfdfdfdfdfdfdfdfdfdfdfgdfdfdfdfldkfsadjfksajfhdsfhsduihfsdgsdg</div>');
	
	scripts_paginas_separadas();
}


function on_document_ready() {
	
}
