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

function menu_DoFSCommand(command, args) {
	var myFlashObj = InternetExplorer ? menu : document.menu;
	if (command == "getDepth") {
		getDepth(myFlashObj);
	} else if (command == "newPage") {
		newPage(args);
	}
}

function topo_DoFSCommand(command, args) {
	var myFlashObj = InternetExplorer ? topo : document.topo;
	if (command == "getDepth") {
		getDepth(myFlashObj);
	} else if (command == "newPage") {
		newPage(args);
	}
}

function topo_DoFSCommand(command, args) {
	var myFlashObj = InternetExplorer ? destaques : document.destaques;
	if (command == "getDepth") {
		getDepth(myFlashObj);
	} else if (command == "newPage") {
		newPage(args);
	}
}

function getDepth(obj){
	/*var param = self.location.href.substr(self.location.href.indexOf("?")+1,4);
	if (param == "inpg"){
		obj.SetVariable("innerpage", 1);
	}*/
	var param = self.location.href.indexOf("?");
	if (param){
		obj.SetVariable("innerpage", 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');
} 

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;
}

var fotoWindow;
function popImg(filename,extraInfo) {
	var extraHeight = extraInfo ? 140 : 90;
	if (fotoWindow){
		fotoWindow.close();
	}
	fotoWindow=window.open("", "fotoWindow", "height=150,width=150,resize=yes,scrollbars=auto,status=yes");
	fotoWindow.document.write("<HTML>");
	fotoWindow.document.write("<HEAD>");
	fotoWindow.document.write("<SCRIPT LANGUAGE=\"JavaScript\">function resizeMe(picRef) {MM_showHideLayers('tempLayer','','hide'); MM_showHideLayers('imgLayer','','show'); var Wlimit = 0; var Hlimit = 0; var picW = picRef.width+50; var picH = picRef.height+"+extraHeight+"; var targetW = (Wlimit) ? (picW > Wlimit) ? Wlimit : picW : picW; var targetH = (Hlimit) ? (picH > Hlimit) ? Hlimit : picH : picH; if ((document.all)&&(navigator.appVersion.indexOf('IE 7.') > 0)){ if (picW >= picH) {targetH += 10;} else {targetH += 20;}}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\">function resizeMe(picRef) {MM_showHideLayers('tempLayer','','hide'); MM_showHideLayers('imgLayer','','show'); var Wlimit = 0; var Hlimit = 0; var picW = picRef.width+50; var picH = picRef.height+"+extraHeight+"; var targetW = (Wlimit) ? (picW > Wlimit) ? Wlimit : picW : picW; var targetH = (Hlimit) ? (picH > Hlimit) ? Hlimit : picH : picH; if ((document.all)&&(navigator.appVersion.indexOf('IE 7.') > 0)){targetH += 120; targetW += 80;}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:300; height:300; 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("<DIV align='center' id='imgLayer' style='visibility: hidden;'><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><font face="Verdana" size="2">'+extraInfo+'</font></p>');}
	fotoWindow.document.write("</DIV></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 buildTree() {
	var outPut = '<ul>';
	for (i=0; i<tree.length; ++i){
		/*outPut += '<li><span  class="txt_titulo">'+tree[i][0]+'</span></li>';
		for (x=1; x<tree[i].length; ++x){
			outPut += '<ul>';
			if (tree[i][x][0]){
				outPut += '<li><span class="txt_titulosub">'+tree[i][x][1]+'</span></li>';
				for (z=0; z<tree[i][x][2].length; ++z){
					outPut += '<ul><li><a href="javascript:newPage(\''+tree[i][x][2][z+1]+'\');">'+tree[i][x][2][z++]+'</a></li></ul>';
				}
			} else {
				outPut += '<li><a href="javascript:newPage(\''+tree[i][x][2][1]+'\');">'+tree[i][x][1]+'</a></li>';
			}
			outPut += '</ul>';
		}*/
		outPut += '<li><a href="'+tree[i][2]+'">'+tree[i][1]+'</a></li>';
	}
	outPut += '</ul>';
	document.write(outPut);
}


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 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_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_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_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];}
}
