var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

function newPage(nextFile) {
	var thisFile = findThisFileName ();
	if (nextFile == thisFile) return;
	if (nextFile.indexOf("/") != -1) {
		self.location.href=nextFile;
	} else {
		self.location.href="/htmls/"+nextFile+"?inpg";
	}
}

if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub menu_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call menu_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('Sub topo_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call topo_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
} 

var fotoWindow;
function popImg(filename,extraInfo) {
	var extraHeight = extraInfo ?40 : 0;
	if (fotoWindow){
		fotoWindow.close();
	}
	fotoWindow=window.open("", "fotoWindow", "height=150,width=150,resize=yes,scrollbars=yes,status=yes");
	fotoWindow.document.write("<HTML>");
	fotoWindow.document.write("<HEAD>");
	fotoWindow.document.write("<SCRIPT LANGUAGE=\"JavaScript\">function resizeMe(picRef) {MM_showHideLayers('tempLayer','','hide');if (window.screen){ var Wlimit = screen.width-70; var Hlimit = screen.height-80; } var picW = picRef.width+50; var picH = picRef.height+70+"+extraHeight+"; var targetW = (Wlimit) ? (picW > Wlimit) ? Wlimit : picW : picW; var targetH = (Hlimit) ? (picH > Hlimit) ? Hlimit : picH : picH; window.resizeTo(targetW,targetH); var window_left = (window.screen.width/2) - ((targetW/2) + 5); 	var window_top = (window.screen.height/2) - ((targetH/2) + 22); 	window.moveTo(window_left,window_top);} </SCR"+"IPT>");
	fotoWindow.document.write('<script language="JavaScript" type="text/JavaScript">function MM_reloadPage(init) {  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);function MM_findObj(n, d) { var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_showHideLayers() { var i,p,v,obj,args=MM_showHideLayers.arguments;for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];if (obj.style) { obj=obj.style; v=(v==\'show\')?\'visible\':(v==\'hide\')?\'hidden\':v; }obj.visibility=v; }}</scr'+'ipt>');
	fotoWindow.document.write("<TITLE>Imagem</TITLE>");
	fotoWindow.document.write("<HEAD>");
	fotoWindow.document.write("<BO"+"DY onmouseover=\"window.status='';return true;\" leftmargin='10' topmargin='10' marginwidth='10' marginheight='10' bgcolor='#cccccc'>");
	fotoWindow.document.write('<div id="tempLayer" style="position:absolute; left:0; top:0; width:150; height:150; z-index:10; background-color: #cccccc; layer-background-color: #cccccc; border: 1px none #333333; visibility: visible; overflow: visible;"><table width="130" height="130"  border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><font face="Verdana" size="2">Por favor aguarde.</font></td></tr></table></div>');
	fotoWindow.document.write("<A href=javascript:self.close()>");
	fotoWindow.document.write("<IMG name=foto id=foto src="+filename+" onLoad=resizeMe(this) border=0 alt=\"clique para fechar esta imagem\"></a>");
	if (extraInfo) {fotoWindow.document.write('<p align="center"><font face="Verdana" size="2">'+extraInfo+'</font></p>');}
	fotoWindow.document.write("</body></HTML>");
}

var infoWindow;
function popinfo(file,w,h) {
	if (infoWindow){
		infoWindow.close();
	}
	infoWindow=window.open(file, "infoWindow", "height="+h+",width="+w+",resize=no,scrollbars=yes,status=yes");
}

function findThisFileName () {
	var thisFile = self.location.href.substr(self.location.href.lastIndexOf("/")+1);
	if (thisFile.indexOf("?") >= 0){
		thisFile = thisFile.substr(0,thisFile.indexOf("?"));
	}
	return thisFile;
}

function fillLayer(objName,newText) { 
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

//-----------------------------------------

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_setTextOfLayer(objName,x,newText) { //v4.01
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

//-----------------------------------------------

function swapMenuImage(layerId,isOver) {
//	newImage = (isOver) ? "url(<FilePath: CustomField_tilemenu_over>)" : "url(<FilePath: CustomField_tilemenu_out>)";
//	newColor = (isOver) ? "#<Field: CustomField_cor_menu_over>" : "#<Field: CustomField_cor_menu>";
<!--#include virtual="/data/js_coresmenus.txt" -->
	document.getElementById(layerId).style.backgroundImage = newImage;
	document.getElementById(layerId).style.backgroundColor = newColor;
}

var expandedMenus = new Array();
function swapMenuText (layerId) {
	if (tree[layerId].length == 3) {
		window.location.href = (tree[layerId][2]) ? tree[layerId][2] : '/cgi-bin/getinfos.pl?'+tree[layerId][1];
		return false;
	} else if (expandedMenus[layerId]) {
		MM_setTextOfLayer(layerId,'',"<img src=/imgs/spacer.gif width=1 height=25 align=absmiddle><span class=menus><b>"+tree[layerId][0]+"</b></span>"+spacerCode);
		expandedMenus[layerId] = false;
	} else {
		MM_setTextOfLayer(layerId,'',"<img src=/imgs/spacer.gif width=1 height=25 align=absmiddle><span class=menus><b>"+tree[layerId][0]+"</b></span>"+printSubmenus(layerId)+spacerCode);
		expandedMenus[layerId] = true;
	}
}

function printSubmenus(menuId) {
	var output = '<span class=menus>';
	for(var i=3; i<tree[menuId].length; i+=3){
		output += '<br><img src=/imgs/menu_linha.gif vspace=2 hspace=0><br>&nbsp;&nbsp;&nbsp;»<a href="';
		output += (tree[menuId][i+2]) ? tree[menuId][i+2] : '/cgi-bin/getinfos.pl?'+tree[menuId][i+1];
		output += '" class=menus>'+tree[menuId][i]+'</a>';
	}
	output += '</span>';
	return output;
}

var spacerCode='<br>';

function buildMainMenus () {
	var output = '';
	for(var i=0 in tree){
		output += "<div id="+i+" class=menu_normal onMouseOver=swapMenuImage('"+i+"',1) onMouseOut=swapMenuImage('"+i+"',0); onClick=swapMenuText('"+i+"')><img src=/imgs/spacer.gif width=1 height=25 align=absmiddle><span class=menus><b>"+tree[i][0]+spacerCode+"</b></span></div>\n";
	}
	document.write(output);
}

var tree = new Array();
<!--#include virtual="/script/menus.js" -->
<!--#include virtual="/script/submenus.js" -->
<!--#include virtual="/data/menu_galerias.txt" -->
<!--#include virtual="/data/menu_musica.txt" -->
<!--#include virtual="/data/menu_loja.txt" -->
<!--#include virtual="/data/menu_extras.txt" -->
<!--#include virtual="/data/menu_contactos.txt" -->