
// JavaScript Document
function ById(id){return document.getElementById(id);}

/*Carrega o conteúdo da pagina solicitada*/

//Cria elemento para precarregamento.
var ldConteudo = document.createElement('div');
var vrConteudo = "";
var imgsLoad = "";

function backIndex()
{
	//Limpa o conteúdo carregado nas áreas
	ById("cmdInterna").style.display='none';
	ById("cmdLoaderDiv").style.display='none';
	ById("cmdIndex").style.display='block';
}

function fcaTituloPgs()
{
	var swf = ById('swfName').value;
	var swfWidth = ById('swfWidth').value;
	var tFilho = ById('tituloFilho').value;

	AC_FL_RunContentTitulo('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','width',swfWidth,'height','20','src','titulos_swf/'+swf,'quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','titulos_swf/'+swf ); //end AC code
	var cmdSorceSWF = document.getElementById("cmdTituloPaginas").innerHTML
	document.getElementById("cmdTituloPaginas").innerHTML = "<table border=0 cellpadding=0 cellspacing=0 ><tr><td>"+cmdSorceSWF+"</td><td><span class=fonte_titulo >"+tFilho+"</span></td></table>"
}

function ShowSonPages(id)
{
//Carrega o novo conteúdo nas áreas.
var xmlhttp = doXMLRequester();
	xmlhttp.open("GET","sisadmin/sisadmin.menu.filho.asp?id="+id, true);
	xmlhttp.onreadystatechange=function()
	{
		if (xmlhttp.readyState==4)
		{
			ById("cmdSonPages").innerHTML=xmlhttp.responseText;
		}
	}
	xmlhttp.send(null);
}

function ShowPaginaContent(id,idSon,idNews,Gl,idGl)
{
	//Limpa o conteúdo carregado nas áreas
	ById("cmdIndex").style.display='none';
	ById("cmdInterna").style.display='block';
	ById("cmdLoaderDiv").style.display='block';
	
	ShowSonPages(id);
	
	if(Gl==1)
	{
		ById("cmdLoaderDiv").style.display='none';
		//Carrega a galeria em flash na camada de conteúdo
		AC_FL_RunContentBriba('codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0','flashvars','varXmlToLoad=galeria'+idGl+'.xml&varSlideTime='+CLISLIDETIME+'&','width','782','height','431','src','SolGaleriaXML','quality','high','pluginspage','http://www.macromedia.com/go/getflashplayer','wmode','transparent','movie','SolGaleriaXML' ); //end AC code
	}
	else
	{
		ById("cmdConteudo").innerHTML='<table height="431" border="0" cellpadding="0" cellspacing="0"><tr><td width="496" align="center" bgcolor="#FFFFFF" style="padding:20px 40px 20px 40px;" class="principal">carregando...</td><td width="206" align="center" valign="top" style="background:#93BABC url(images/bg_fundo_get_interna.gif) repeat-x;padding:8px 0px 0px 0px;" ><img src="images/logo_interna.gif" width="188" height="120" /></td></tr></table>';
		
		if(isNaN(idNews)){idNews=0;}
		var pageLoad = "get.interna.asp";
		if(id==8){pageLoad="get.news.asp";}
		if(id==9){pageLoad="get.reservas.asp";}
		if(id==11){pageLoad="get.contato.asp";}
		if(id==10){pageLoad="get.cadastro.asp";}
	
		vrConteudo = "";
		imgsLoad = "";

		//Carrega o novo conteúdo nas áreas.
		var xmlhttp = doXMLRequester();
			xmlhttp.open("GET",pageLoad+"?id="+id+"&idSon="+idSon+"&idNews="+idNews, true);
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4)
				{
					vrConteudo = xmlhttp.responseText;
					ldConteudo.innerHTML=vrConteudo;
					imgsLoad = ldConteudo.getElementsByTagName("img");
					
					if(imgsLoad.length==0)
					{
						 showContent();	
					}
					else
					{
						preLoadImages();
					}
				}
			}
			xmlhttp.send(null);
	}

}

function preLoadImages()
{
	var ix=0;
	for(i=0;i<imgsLoad.length;i++)
	{
		if(imgsLoad[i].complete)
		{
			ix++;
		}
	}
	
	if(ix==imgsLoad.length)
	{
		showContent();
	}else{
		setTimeout("preLoadImages();",500);
	}
}

function showContent()
{
	ById("cmdLoaderDiv").style.display='none';
	ById("cmdConteudo").innerHTML=ldConteudo.innerHTML;
	fcaTituloPgs();
}


/*Descarrega o conteúdo*/
function HidePaginaContent(id)
{
	ById("cmdConteudo").innerHTML='';
}

function showDivConteudo(cmd)
{
	ById(cmd).style.display='block';
}


function showHideON()
{
	var sit = ById("cmdOutrasNotícias").style.display;
	if(sit=="none")
	{
		ById("cmdNoticia").style.display="none";
		ById("cmdOutrasNotícias").style.display="block";
	}
	else
	{
		ById("cmdOutrasNotícias").style.display="none";
		ById("cmdNoticia").style.display="block";
	}
}

