var IE = (document.all) ? true : false
var NS = (document.addEventListener) ? true : false


// FIREWORKS HTML FUNCTIONS
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];}
}
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_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];}}
}
MM_preloadImages('images/menu/potiron_f2.jpg','images/menu/ortodocs_f2.jpg','images/menu/interdocs_f2.jpg','images/menu/z3950_f2.jpg','images/menu/projetos_f2.jpg','images/menu/comunidades_f2.jpg','images/menu/noticias_f2.jpg','images/menu/contato_f2.jpg','images/menu/home_f2.jpg');

var MAINTEXT_WIDTH = (IE) ? document.body.scrollWidth-12 : "95%"
var MAINTEXT_HEIGHT = (IE) ? document.body.scrollHeight-120 :  400

var html_menu_str = '\
<TABLE width=99% cellPadding=0 cellSpacing=0 border=0><TR><TD rowspan=2 valign=top style="padding: 0px;">\
<table border=0 cellpadding=0 cellspacing=0 width=218 id=HTML-MENU>\
  <tr>\
   <td><img src="images/menu/spacer.gif" width=6 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=8 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=1 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=9 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=3 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=8 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=19 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=3 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=2 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=8 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=2 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=1 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=2 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=3 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=18 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=12 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=4 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=1 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=1 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=13 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=12 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=2 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=7 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=6 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=3 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=6 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=4 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=6 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=19 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=6 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=1 height=0></td>\
   <td><img src="images/menu/spacer.gif" width=22 height=0></td>\
  </tr>\
  <tr>\
   <td colspan=32><img name="v2_menu_r1_c1" src="images/menu/v2_menu_r1_c1.jpg" width=218 height=75></td>\
  </tr>\
  <tr>\
   <td rowspan=2 colspan=10><img name=v2_menu_r2_c1 src="images/menu/v2_menu_r2_c1.jpg" width=67 height=46></td>\
   <td colspan=18><a href="v2_potiron.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'potiron\',\'\',\'images/menu/potiron_f2.jpg\',1);"><img name="potiron" src="images/menu/potiron.jpg" width="103" height="40" border="0" alt="Potiron"></a></td>\
   <td rowspan=2 colspan=4><img name=v2_menu_r2_c29 src="images/menu/v2_menu_r2_c29.jpg" width=48 height=46></td>\
  <tr>\
   <td colspan=18><img name="v2_menu_r3_c11" src="images/menu/v2_menu_r3_c11.jpg" width=103 height=6></td>\
  </tr>\
  <tr>\
   <td rowspan=6 colspan=9><img name="v2_menu_r4_c1" src="images/menu/v2_menu_r4_c1.jpg" width=59 height=139 border=0></td>\
   <td colspan=20><a href="v2_ortodocs.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'ortodocs\',\'\',\'images/menu/ortodocs_f2.jpg\',1);"><img name=ortodocs src="images/menu/ortodocs.jpg" width=130 height=40 border=0 alt="OrtoDocs"></a></td>\
   <td rowspan=2 colspan=3><img name="v2_menu_r4_c30" src="images/menu/v2_menu_r4_c30.jpg" width=29 height=46></td>\
  </tr>\
  <tr>\
   <td colspan=20><img name="v2_menu_r5_c10" src="images/menu/v2_menu_r5_c10.jpg" width=130 height=6></td>\
  </tr>\
  <tr>\
   <td rowspan=4 colspan=4><img name="v2_menu_r6_c10" src="images/menu/v2_menu_r6_c10.jpg" width=13 height=93></td>\
   <td colspan=17><a href="v2_interdocs.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'interdocs\',\'\',\'images/menu/interdocs_f2.jpg\',1);"><img name=interdocs src="images/menu/interdocs.jpg" width=123 height=40 border=0 alt="Interdocs"></a></td>\
   <td rowspan=2 colspan=2><img name="v2_menu_r6_c31" src="images/menu/v2_menu_r6_c31.jpg" width=23 height=47></td>\
  </tr>\
  <tr>\
   <td colspan=17><img name="v2_menu_r7_c14" src="images/menu/v2_menu_r7_c14.jpg" width=123 height=7></td>\
  </tr>\
  <tr>\
   <td rowspan=2 colspan=2><img name="v2_menu_r8_c14" src="images/menu/v2_menu_r8_c14.jpg" width=21 height=46></td>\
   <td colspan=16><a href="v2_z3950.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'z3950\',\'\',\'images/menu/z3950_f2.jpg\',1);"><img name="z3950" src="images/menu/z3950.jpg" width=103 height=40 border=0 alt="Z39.50"></a></td>\
   <td rowspan=12><img name="v2_menu_r8_c32" src="images/menu/v2_menu_r8_c32.jpg" width=22 height=286></td>\
	</tr>\
  <tr>\
   <td colspan=16><img name="v2_menu_r9_c16" src="images/menu/v2_menu_r9_c16.jpg" width=103 height=6></td>\
  </tr>\
  <tr>\
   <td rowspan=2 colspan=4><img name="v2_menu_r10_c1" src="images/menu/v2_menu_r10_c1.jpg" width=24 height=46></td>\
   <td colspan=21><a href="v2_projetos.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'projetos\',\'\',\'images/menu/projetos_f2.jpg\',1);"><img name=projetos src="images/menu/projetos.jpg" width=130 height=40 border=0 alt="Projetos"></a></td>\
   <td rowspan=8 colspan=6><img name="v2_menu_r10_c26" src="images/menu/v2_menu_r10_c26.jpg" width=42 height=186></td>\
  </tr>\
  <tr>\
   <td colspan=21><img name="v2_menu_r11_c5" src="images/menu/v2_menu_r11_c5.jpg" width=130 height=6></td>\
  </tr>\
  <tr>\
   <td rowspan=8><img name="v2_menu_r12_c1" src="images/menu/v2_menu_r12_c1.jpg" width=6 height=194></td>\
   <td colspan=24><a href="v2_comunidade.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'comunidades\',\'\',\'images/menu/comunidades_f2.jpg\',1);"><img name="comunidades" src="images/menu/comunidades.jpg" width=148 height=40 border=0 alt="Comunidades"></a></td>\
  </tr>\
  <tr>\
   <td colspan=24><img name="v2_menu_r13_c2" src="images/menu/v2_menu_r13_c2.jpg" width=148 height=7></td>\
  </tr>\
  <tr>\
   <td colspan=20><a href="v2_noticias.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'noticias\',\'\',\'images/menu/noticias_f2.jpg\',1);"><img name="noticias" src="images/menu/noticias.jpg" width=130 height=40 border=0 alt="Notícias"></a></td>\
   <td rowspan=2 colspan=4><img name="v2_menu_r14_c22" src="images/menu/v2_menu_r14_c22.jpg" width=18 height=46></td>\
  </tr>\
  <tr>\
   <td colspan=20><img name="v2_menu_r15_c2" src="images/menu/v2_menu_r15_c2.jpg" width=130 height=6></td>\
  </tr>\
  <tr>\
   <td rowspan=4 colspan=2><img name="v2_menu_r16_c2" src="images/menu/v2_menu_r16_c2.jpg" width=9 height=101></td>\
   <td colspan=19><a href="v2_contato.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'contato\',\'\',\'images/menu/contato_f2.jpg\',1);"><img name="contato" src="images/menu/contato.jpg" width=123 height=40 border=0 alt="Contato"></a></td>\
   <td rowspan=2 colspan=3><img name="v2_menu_r16_c23" src="images/menu/v2_menu_r16_c23.jpg" width=16 height=47></td>\
  </tr>\
  <tr>\
   <td colspan=19><img name="v2_menu_r17_c4" src="images/menu/v2_menu_r17_c4.jpg" width=123 height=7></td>\
  </tr>\
  <tr>\
   <td rowspan=2 colspan=5><img name="v2_menu_r18_c4" src="images/menu/v2_menu_r18_c4.jpg" width=42 height=54></td>\
   <td colspan=18><a href="v2_index.htm" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage(\'home\',\'\',\'images/menu/home_f2.jpg\',1);"><img name="home" src="images/menu/home.jpg" width=103 height=40 border=0 alt="Home"></a></td>\
   <td rowspan=2 colspan=5><img name="v2_menu_r18_c27" src="images/menu/v2_menu_r18_c27.jpg" width=36 height=54></td>\
  </tr>\
<tr>\
	<td colspan=18><img name="v2_menu_r19_c9" src="images/menu/v2_menu_r19_c9.jpg" width=103 height=14></td>\
</tr>\
</table><DIV id=SwitchVersion><A href="javascript:void(0)" onClick="FlashMenuOn=true;setCookie();location.reload();">» versão flash</A></DIV></td>\
<TD style="padding-top: 1px; padding-top:expression(\'1px\');" height=113><IMG SRC="images/menu/top.jpg" BORDER="0"></TD>\
<TR>\
<TD class=MainTextCell vAlign=top width=100% height='+MAINTEXT_HEIGHT+'>\
	<DIV id=MainTextDiv>\
'

// FLASH MENU UPDATE FUNCTIONS
function FlashMenu_Update (text, which, pos) {
	if (!IE) return
	var FirstLetter = text.substring(0,1)
	var RestLetters = text.substring(1, text.length)
	
	var fTitle = document.getElementById("FlashTop")
	
	fTitle.SetVariable("TitleFirstLetter", FirstLetter)
	fTitle.SetVariable("TitleSmallLetters", RestLetters)

	var fMenu = document.getElementById("FLASHMENU")
	fMenu.SetVariable("spiral.ActiveButton", which)
	fMenu.SetVariable("spiral.NewPosY", pos)
	fMenu.TSetProperty("spiral.Vertex1.ball", 7, 0)
	fMenu.TSetProperty("spiral." + which + ".ball", 7, 1)
	fMenu.TSetProperty("spiral." + which, 7, 1)
	fMenu.TGotoFrame('spiral.'+which, 15);
	//fMenu.TPlay("spiral."+which);
	
}
//window.onerror = function () { return true; }
window.onresize = function () {
	var avHeight = document.body.clientHeight
	document.getElementById("MainTextDiv").style.height = avHeight-70-44-20
}



var FLASHMENU_HEIGHT = (screen.height > 760) ? 430 : 370;
var FLASHTITLE_HEIGHT = (screen.height > 760) ? 44 : 40;


var flash_menu_str = "\
<TABLE BORDER=0 CELLPADDING=0 cellSpacing=0 WIDTH=100%>\
<TR>\
	<TD width=520 align=left><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH=520 HEIGHT=70 ID=FlashTop>\
	<PARAM NAME=MOVIE VALUE='v2_top.swf'>\
 	<PARAM NAME=QUALITY VALUE=BEST>\
	<PARAM NAME=BGCOLOR VALUE=WHITE>\
	<EMBED SRC='v2_top.swf' NAME=FLASHTOP ID=FlashTop QUALITY=BEST BGCOLOR=WHITE WIDTH=520 HEIGHT=70 TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>\
	</OBJECT></TD>\
	<TD align=right style='background-image: url(images/bg_top_grid.jpg); background-repeat: no-repeat;'><IMG src='images/potiron_logo.gif' align=right></TD>\
</TR></TABLE>\
<TABLE BORDER=0 CELLPADDING=0 cellSpacing=0>\
<TR>\
	<TD valign=top width=218 rowSpan=2><OBJECT CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  CODEBASE='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH=218 height="+FLASHMENU_HEIGHT+" ID=FLASHMENU>\
	<PARAM NAME=MOVIE VALUE='v2_menu.swf'>\
 	<PARAM NAME=QUALITY VALUE=BEST>\
	<PARAM NAME=BGCOLOR VALUE=WHITE>\
	<PARAM NAME=SCALE VALUE=EXACTFIT>\
	<EMBED SRC='v2_menu.swf' NAME=FLASHMENU SCALE=EXACTFIT QUALITY=BEST BGCOLOR=WHITE WIDTH=218 height="+ FLASHMENU_HEIGHT +" TYPE='application/x-shockwave-flash' PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' ID=FLASHMENU></EMBED>\
</OBJECT><DIV id=SwitchVersion><A href='javascript:void(0)' onClick='FlashMenuOn=false;setCookie();location.reload();'>» versão html</A></DIV>\
	</TD>\
	<TD height=30><OBJECT id=FlashTitle classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' WIDTH=540 height="+FLASHTITLE_HEIGHT+">\
	<PARAM NAME=movie VALUE='v2_title.swf'>\
 	<PARAM NAME=quality VALUE=best>\
	<PARAM NAME=bgcolor VALUE=white>\
	<PARAM NAME=scale VALUE=exactfit>\
	<EMBED src='v2_title.swf' name=FlashTitle quality=best bgcolor=white  WIDTH=580 height="+FLASHTITLE_HEIGHT+" TYPE='application/x-shockwave-flash' scale=exactfit PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'></EMBED>\
</OBJECT>\
</TD>\
</TR>\
	<TD class=MainTextCell colspan=2 vAlign=top height="+MAINTEXT_HEIGHT+">\
	<DIV id=MainTextDiv>"

	
// READ & SET DOCUMENT COOKIE FOR SCHEME DATA
function readCookie() {
	var _data = unescape(document.cookie)
	_data = _data.substring(_data.indexOf("[")+1, _data.indexOf("]"))
	eval(_data)
}

function setCookie() {
	var data = "FlashMenuOn=" + escape(FlashMenuOn + ";")
	var expires = "expires=" + new Date("February 15, 2008").toGMTString() + ";"
	document.cookie = "POTIRON=[" + data + "];" + expires
}

function deleteCookie() {
	var expires = "expires=" + new Date("February 1, 2000").toGMTString() + ";"
	document.cookie = "POTIRON=;" + expires
}

readCookie()


if (self.FlashMenuOn == self.undefined) {
	var isXP = navigator.userAgent.indexOf("Windows NT 5") > 0
	var is32 = screen.colorDepth >= 32
	var is1024 = screen.width >= 1024
	FlashMenuOn = true
	//if (isXP || is32 || is1024) FlashMenuOn = true
	//else FlashMenuOn = false
	setCookie()
}

if (FlashMenuOn && IE && document.body.clientHeight > 500) {

	document.write ("\
		<STYLE>\
			#MainTextDiv { overflow:auto; height: 100%; width: 100%; }\
			.TextHeader {width: 100px;}\
			BODY { overflow: hidden; overflow:expression('auto'); }\
		</STYLE>\
	")
}
//if (FlashMenuOn) document.title = document.title.replace("Potiron", "POTIRON")

if (FlashMenuOn) document.write(flash_menu_str)
else document.write(html_menu_str)

var menuNav = {
	v2_index : ["Home", "Vertex1", 225],
	v2_contato : ["Contato", "Vertex2", 270],
	v2_noticias : ["Notícias", "Vertex3", 315],
	v2_comunidade : ["Comunidades", "Vertex4", 360],
	v2_projetos : ["Projetos", "Vertex5", 405],
	v2_z3950 : ["Z39.50", "Vertex6", 450],
	v2_interdocs : ["Interdocs", "Vertex7", 495],
	v2_ortodocs : ["OrtoDocs", "Vertex8", 540],
	v2_ortodocs_aplicado : ["OrtoDocs Aplicado", "Vertex8", 540],
	v2_multitier_archictecture : ["OrtoDocs MultiTier", "Vertex8", 540],
	v2_portifolio : ["OrtoDocs Clientes", "Vertex8", 540],
	v2_potiron : ["Potiron", "Vertex9", 585]
}

var menuNavLookup = ["v2_index", "v2_contato", "v2_noticias", "v2_comunidade", "v2_projetos", "v2_z3950", "v2_interdocs", "v2_ortodocs", "v2_potiron"]
menuNavLookup = menuNavLookup.reverse()


var page = document.location.href.split("/")
var page = page[page.length-1].split(".")[0]

window.onload = function () {
	if (FlashMenuOn && menuNav[page]) {
		
		
		if (page == "v2_index") setTimeout("FlashMenu_Animate()", 500)
		FlashMenu_Update (menuNav[page][0], menuNav[page][1], menuNav[page][2])
	}
	if (!FlashMenuOn) {
		var img = document.images[menuNav[page][0].replace("í", "i").replace(".", "").toLowerCase()]
		if (img) { 
			img.parentNode.onmouseover()
			img.parentNode.onmouseover = img.parentNode.onmouseout = null;
		}
	}
}

function FlashMenu_Animate () {
	var i = FlashMenu_Animate.i++
	var which = menuNav[menuNavLookup[i]][1]
	var pos = menuNav[menuNavLookup[i]][2]
	
	var fMenu = document.getElementById("FLASHMENU")
	
	fMenu.SetVariable("spiral.NewPosY", pos)
	fMenu.TGotoFrame('spiral.'+which, 2); 
	fMenu.TPlay("spiral."+which);
	if (i > 0) {
		fMenu.TGotoFrame('spiral.'+menuNav[menuNavLookup[i-1]][1], 20);
		fMenu.TPlay("spiral."+menuNav[menuNavLookup[i-1]][1]);
	}
	
	//fMenu.TSetProperty("spiral.Vertex1.ball", 7, 0)
	//fMenu.TSetProperty("spiral." + which + ".ball", 7, 1)
	fMenu.TSetProperty("spiral." + which, 7, 1)
	if (i < menuNavLookup.length-1)
		setTimeout("FlashMenu_Animate()", 800)
	else {
		fMenu.TGotoFrame('spiral.'+menuNav[menuNavLookup[i]][1], 20);
		fMenu.TPlay("spiral."+menuNav[menuNavLookup[i]][1]);
	}
	
}
FlashMenu_Animate.i = 0
