//************************************************************	
// Redirecionamentos
//************************************************************
// redirecionar para outra página
function fctLinkPrc(item)
	{
		top.principal.document.location.href = item; 
	}
	
//redirecionar para outra página
function fctLink(item)
	{
		document.location.href = item;
	}
		
//************************************************************	
// Mudar cor quando passar o ponteiro do mouse
//************************************************************	
function fctCapituloOn(item)
	{
		item.style.color="maroon"; 
		item.style.cursor = "hand";
		item.style.textDecoration = "underline";
	}

function fctCapituloOff(item)
	{
		item.style.color="#08496d";
		item.style.textDecoration = "";
	}
			
//************************************************************	
// Abrir div enquanto fechar outras divs
//************************************************************
function fctAbrir_Div(item)
	{
        var strItem = "div" + item;
		if (eval(strItem).style.display == "none")
       		{
       			for(i=0; i < document.form1.linha.length;i++)	
       				{
       					var strDiv = "div" + i + 1;
						eval(strDiv).style.display = "none";
       				}
       			eval(strItem).style.display = "";
     		}
       	else
       		{
      			for(i=0; i < document.form1.linha.length;i++)	
       				{
       					var strDiv = "div" + i + 1;
						eval(strDiv).style.display = "none";
       				}
      			eval(strItem).style.display = "none";
    		}
	}
	
//************************************************************	
// Cookie - arquivo de jornal em xml 
//************************************************************	
function fctRedirJornal(item)
	{
		document.cookie=item;
		document.location.href="jorleitura.html";
	}
	
function fctVoltarJornal()
	{
		document.cookie='';
		document.location.href="jornal.html";
	}	

//************************************************************	
// Leitura de textos em xml
//************************************************************
// leitura em textos
function fctLeitura(item)
	{
		var browser=window.ActiveXObject
		if (browser)
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

		function loadXML(xmlFile)
			{
				xmlDoc.async="false";
				xmlDoc.load(xmlFile);
				texto=xmlDoc.documentElement;
			}

		if (browser)
			{
				loadXML(item);
				var conteudo = "";
				for(var j=0; j<texto.childNodes.length; j++)
					{
					    conteudo += "<table width='100%' cellspacing='1' cellpadding='1'>";
						conteudo += "<tr><td width='98%' name='"+j +1+"' id='"+j +1+"'><input type='hidden' name='linha' id='linha'><a class= 'TXT_Capitulo' onclick=fctAbrir_Div('" + j +1+ "') onMouseOver=fctCapituloOn(this) onMouseOut=fctCapituloOff(this)><li class='MAR_Texto'>" + texto.childNodes(j).childNodes(0).firstChild.text + "</li></a></td></tr>";
						
						conteudo += "<tr><td vAlign='top'>";																	
						conteudo += "<div name='div"+j+1+"' id='div"+j+1+"' style='display:none'>";
						conteudo += "<table cellspacing='0' cellpadding='0'>";

						var item_count=texto.childNodes(j).childNodes(1).childNodes.length;
						for(i=0; i<item_count; i++)
							{
								var strFonte = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('fonte');
								
								if (texto.childNodes(j).childNodes(1).childNodes(i).firstChild.text == "branco")
									{
										var strTexto = "";
									}
								else
									{
										var strTexto = texto.childNodes(j).childNodes(1).childNodes(i).firstChild.text;
									}								
								
								if (strFonte == "sim")
									{ 
										var strStyle = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('letras'); 
										conteudo += "<tr><td class='TXT_Texto' style='" + strStyle + "'>" + strTexto + "</td></tr>" ;
									}
								else
									{	
										conteudo += "<tr><td class='TXT_Texto'>" + strTexto + "</td></tr>" ;
									}
					       }
    					conteudo += "</td></tr></table></div></table>";  																
					}
			document.all.div1.innerHTML = conteudo;															
		}
}

// leitura em jornal
function fctLeituraJornal(item)
	{
		var browser=window.ActiveXObject
		if (browser)
		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

		function loadXML(xmlFile)
			{
				xmlDoc.async="false";
				xmlDoc.load(xmlFile);
				texto=xmlDoc.documentElement;
			}

		if (browser)
			{
				loadXML(item);
				var conteudo = "";
				
				conteudo += "<table width='100%' cellspacing='1' cellpadding='1'>";
				conteudo += "<tr><td colspan='2' class='TXT_Subtitulo'>Jornal " + texto.childNodes(j).getAttribute('mesano') + "</td></tr>";
						
				for(var j=0; j<texto.childNodes.length; j++)
					{
					   conteudo += "<tr><td width='98%' name='"+j +1+"' id='"+j +1+"'><input type='hidden' name='linha' id='linha'><a class= 'TXT_Capitulo' onclick=fctAbrir_Div('" + j +1+ "') onMouseOver=fctCapituloOn(this) onMouseOut=fctCapituloOff(this)><li class='MAR_Texto'>" + texto.childNodes(j).childNodes(0).firstChild.text + "</li></a></td></tr>";
						
						conteudo += "<tr><td vAlign='top'>";																	
						conteudo += "<div name='div"+j+1+"' id='div"+j+1+"' style='display:none'>";
						conteudo += "<table cellspacing='0' cellpadding='0'>";

						var item_count=texto.childNodes(j).childNodes(1).childNodes.length;
						for(i=0; i<item_count; i++)
							{
								var strFonte = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('fonte');
								var strImagem = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('imagem');
								
								if (texto.childNodes(j).childNodes(1).childNodes(i).firstChild.text == "branco")
									{
										var strTexto = "";
									}
								else
									{
										var strTexto = texto.childNodes(j).childNodes(1).childNodes(i).firstChild.text;
									}								
								
								if (strFonte == "sim")
									{ 
										var strStyle = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('letras'); 
										conteudo += "<tr><td colspan='2' class='TXT_Texto' style='" + strStyle + "'>" + strTexto + "</td></tr>" ;
									}
								else if (strImagem == "sim")
										{ 
											var strFigura = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('figura'); 
											var strAlinhamento = texto.childNodes(j).childNodes(1).childNodes(i).getAttribute('alinhamento'); 
											conteudo += "<tr><td><img src='" + strFigura +"'></td><td class='TXT_Texto' vAlign='top' align='" + strAlinhamento + "'>" + strTexto + "</td></tr>" ;
										}
									else	
										{	
											conteudo += "<tr><td colspan='2' class='TXT_Texto'>" + strTexto + "</td></tr>" ;
										}
									
					       }
    					conteudo += "</td></tr></table></div>";  																
					}
				conteudo += "</table>";
				document.all.div1.innerHTML = conteudo;															
			}
}

//************************************************************	
// Visualizar fotos
//************************************************************																				
function fctAnterior(item)
	{
		var strDados = document.form1.txt_img.value;
		strDados = strDados.split(".");
		var strAnt = strDados[0]-1;
		if (strAnt < 1)
			{
				strAnt = item;
			}
		document.img.src = strAnt + ".jpg";
		document.form1.txt_img.value = strAnt + ".jpg";
	}
																					
function fctPosterior(item)
	{
		var strDados = document.form1.txt_img.value;
		strDados = strDados.split(".");
		var strPost = strDados[0];
		strPost++; 
		if (strPost > item)
			{
				strPost = 1;
			}
		else if(strPost == "1")
				{
					strPost++; 
				}
		document.img.src = strPost + ".jpg";
		document.form1.txt_img.value = strPost + ".jpg";
	}			
		
function fctVisualizarFotos(item)
	{																			
		var conteudo = "";
		for(i=1; i <item+1; i++)
			{
				conteudo += "<table width='100%' cellspacing='1' cellpadding='1'>";
				conteudo += "<tr><td>";
				conteudo += "<tr><td onclick=fctVerImagem('"+i+".jpg') align='center'><IMG SRC='pequenas/"+i+".jpg' style='cursor:hand'>";
				conteudo += "</td></tr>";
				conteudo += "</table>";
			}
		div1.innerHTML = conteudo;	
	}
	
function fctVerImagem(item)
	{
		document.img.src = item;
		document.form1.txt_img.value = item;
	}					