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

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

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_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_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+"'");
  }
}

var fotoWindow;
function popImg(filename,extraInfo) {
	var fundo = "#cccccc";
	var texto = "#666666";
	var extraHeight = extraInfo ? 60 : 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;\" bgcolor='"+fundo+"' leftmargin='10' topmargin='10' marginwidth='10' marginheight='10'>");
	fotoWindow.document.write('<div id="tempLayer" style="position:absolute; left:0; top:0; width:150; height:150; z-index:10; background-color: '+fundo+'; layer-background-color: '+fundo+'; border: 1px none #000000; visibility: visible; overflow: visible;"><table width="130" height="130"  border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><b><font color="'+texto+'" size="1" face="Verdana, Arial, Helvetica, sans-serif">Por favor aguarde.</b></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><font size="1" face="Verdana, Arial, Helvetica, sans-serif">'+extraInfo+'</font></p>');}
	fotoWindow.document.write("</HTML>");
}

var notifyW;
function notify(newsid,titulo) {
	if (notifyW){
		notifyW.close();
	}
	notifyW=window.open("", "notifyW", "height=250,width=380,resize=no,scrollbars=no,status=yes");
	notifyW.document.write('<html><head><title>Avisar amigo</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
	notifyW.document.write('<scr'+'ipt language="JavaScript" type="text/JavaScript">');
	notifyW.document.write("function MM_validateForm() { \nvar i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;\nfor (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);\nif (val) { nm=val.name; if ((val=val.value)!=\"\") {\nif (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');\nif (p<1 || p==(val.length-1)) errors+='. '+nm+': Tem que conter um endereço de e-mail válido.\\n';\n} else if (test!='R') { num = parseFloat(val);\nif (isNaN(val)) errors+='. '+nm+': O número não é valido.\\n';\nif (test.indexOf('inRange') != -1) { p=test.indexOf(':');\nmin=test.substring(8,p); max=test.substring(p+1);\nif (num<min || max<num) errors+='. '+nm+' Tem que ser um número entre '+min+' e '+max+'.\\n';\n} } } else if (test.charAt(0) == 'R') errors += '. '+nm+': É necessário.\\n'; }\n} \nif (errors) alert('Os seguintes campos têm erros:\\n'+errors);\ndocument.MM_returnValue = (errors == '');\n}\n\nfunction MM_findObj(n, d) { \nvar p,i,x;  if(!d) d=document; if((p=n.indexOf(\"?\"))>0&&parent.frames.length) {\nd=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}\nif(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];\nfor(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);\nif(!x && d.getElementById) x=d.getElementById(n); return x;\n}\n");
	notifyW.document.write('</scr'+'ipt>');
	notifyW.document.write('<link href="/styles.css" rel="stylesheet" type="text/css"></head>');
	notifyW.document.write('<body BGCOLOR="#ffffff" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	notifyW.document.write('<table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0"><tr><td align="center" valign="middle"><div class="margens"><p><b>Quer avisar algu&eacute;m para visitar este site?</b><br>Indique o seu Nome e o Nome e E-mail do destinat&aacute;rio no formul&aacute;rio abaixo e clique em &quot;enviar&quot;.</p><form action="/cgi-bin/notify.pl" method="post" name="formulario" id="formulario" onSubmit="MM_validateForm(\'seu_nome\',\'\',\'R\',\'seu_email\',\'\',\'RisEmail\',\'nome_destinatario\',\'\',\'R\',\'email\',\'\',\'RisEmail\');return document.MM_returnValue"><table border="0" align="center" cellpadding="5" cellspacing="0" class="txt_normal"><tr bgcolor="#eeeeee"><td align="right" valign="middle" nowrap>O seu nome:</td><td align="left" valign="middle"><input name="seu_nome" type="text" class="pesquisa" id="seu_nome" size="40"></td></tr><tr bgcolor="#eeeeee"><td align="right" valign="middle" nowrap>O seu E-mail:</td><td align="left" valign="middle"><input name="seu_email" type="text" class="pesquisa" id="seu_email" size="40"></td></tr><tr bgcolor="#eeeeee"><td align="right" valign="middle" nowrap>O nome do destinat&aacute;rio<b></b>:</td><td align="left" valign="top"><input name="nome_destinatario" type="text" class="pesquisa" id="nome_destinatario" size="40"></td></tr><tr bgcolor="#eeeeee"><td align="right" valign="middle" nowrap>E-mail do destinat&aacute;rio:</td><td align="left" valign="middle"><input name="email" type="text" class="pesquisa" id="email" size="40"></td></tr><tr align="center" valign="middle"><td><input type="hidden" value="'+newsid+'" id="newsid" name="newsid"><input type="hidden" value="'+titulo+'" id="titulo" name="titulo"></td><td align="left"><input name="Submit" type="submit" value="Enviar"></td></tr></table></form></div><div align="center"><a href="javascript:window.top.close();">fechar esta janela</a><br><br></div></td></tr></table>');
	notifyW.document.write('</body></html>');
}

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

function swapMenuImage(layerId,isOver) {
//	newImage = "";//(isOver) ? "url(/imgs/menu_on.gif)" : "url(/imgs/menu_off.gif)";
	newColor = (isOver) ? "#eeeeee" : "#ffffff";
	newColorText = (isOver) ? "#ff0000" : "#555555";
//	document.getElementById(layerId).style.backgroundImage = newImage;
	document.getElementById(layerId).style.backgroundColor = newColor;
	document.getElementById(layerId).style.color = newColorText;
}

var expandedMenus = new Array();
function swapMenuText (layerId) {
	//alert(layerId);
/*	var linkPage = layerId;
	if (layerId.indexOf('|,|') > 0) {
		linkPage = layerId.split(|,|);
		linkPage = linkPage[1];
	}
*/
	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('menuv_'+layerId,'',"&nbsp;&gt; "+tree[layerId][0]);
		expandedMenus[layerId] = false;
	} else {
		MM_setTextOfLayer('menuv_'+layerId,'',"<img src=/imgs/spacer.gif width=1 height=25 align=absmiddle><span class=menu_text><b>"+tree[layerId][0]+"</b></span>"+printSubmenus(layerId));
		expandedMenus[layerId] = true;
	}
}

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

var spacerCode='';//<br><img src=/imgs/menu_sep.gif>';

function buildMainMenus () {
	var output = '';
	for(var i=0 in tree){
		output += "<div id=menuv_"+i+" class=menus onMouseOver=swapMenuImage('menuv_"+i+"',1) onMouseOut=swapMenuImage('menuv_"+i+"',0); onClick=swapMenuText("+i+")>&nbsp;&gt; "+tree[i][0]+"</div><hr class=menus_hr>\n";
	}
	document.write(output);
}

var forumWindow;
function forum() {
	if (forumWindow){
		forumWindow.close();
	}
	forumWindow=window.open("/cgi-bin/forum/index.pl", "forumWindow", "height=580,width=750,resize=yes,scrollbars=yes,status=yes");
}

var tree = new Array();

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='• '+nm+': Tem que conter um endereço de e-mail válido.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='• '+nm+': O número não é valido.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='• '+nm+' Tem que ser um número entre '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '• '+nm+': É necessário.\n'; }
  } 
  if (document.assinatura.tipo.value == "cobranca" && !document.assinatura.assinante.value) {
	errors += '• Número de Assinante: É necessário.\n';
  }
  if (errors) alert('Os seguintes campos têm erros:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function updateValue() {
	document.assinatura.mensagem.value = "\n\nDestino da assinatura: "+document.assinatura.tipo.value;
	if (document.assinatura.assinante.value) document.assinatura.mensagem.value += "\nNúmero de assinante: "+document.assinatura.assinante.value;
	document.assinatura.mensagem.value += "\nForma de Pagamento: "+document.assinatura.pagamento.value;
	document.assinatura.mensagem.value += "\nNome: "+document.assinatura.nome_completo.value;
	document.assinatura.mensagem.value += "\nMorada: "+document.assinatura.morada.value;
	document.assinatura.mensagem.value += "\nCódigo Postal: "+document.assinatura.codigo_postal.value+" "+document.assinatura.localidade.value;
	document.assinatura.mensagem.value += "\nPaís: "+document.assinatura.pais.value;
	document.assinatura.mensagem.value += "\nTelefone: "+document.assinatura.telefone.value;
	document.assinatura.mensagem.value += "\nE-mail: "+document.assinatura.email.value;
	document.assinatura.mensagem.value += "\nData de Nascimento: "+document.assinatura.data_nascimento.value;
	document.assinatura.mensagem.value += "\nProfissão: "+document.assinatura.profissao.value;
	
	var precos = new Array();
	precos['pt'] = 20;
	precos['eu'] = 36;
	precos['resto'] = 48;
									
	var fullTotal = precos[document.assinatura.tipo.value];
	document.assinatura.mensagem.value += "\n\nValor apresentado: "+fullTotal+" Eur.";
	
	/*if (errors == '')*/ MM_setTextOfLayer("LayerInfo",0,"<p class='txt_normal'>Preço da sua Assinatura: <b>"+fullTotal+"€</b></p>");
}

//===========================================================
// ypChaser class definition
//===========================================================
function ypChaser(sLayerId, iTopOffset, iSlideTime, iCeiling, iFloor) {
this.chaserDiv = null
this.layerId = sLayerId
this.topOffset = iTopOffset
this.slideTime = iSlideTime
this.ceiling = iCeiling
this.floor = iFloor
ypChaser.registry[ypChaser.registry.length] = this
}
ypChaser.isIE = window.clientInformation ? true : false
ypChaser.isIEDTD = ((document.doctype && document.doctype.name.indexOf(".dtd")>-1) || document.compatMode == "CSS1Compat") ? true : false;
ypChaser.isN4 = document.layers ? true : false
ypChaser.isN6 = navigator.appName == "Netscape" && parseInt(navigator.appVersion) >= 5
ypChaser.isO5 = navigator.userAgent.indexOf("Opera") != -1 && parseInt(navigator.appVersion) >= 4
ypChaser.registry = new Array( )
ypChaser.callRate = 10
window.setInterval("ypChaser.timer( )", ypChaser.callRate)
ypChaser.timer = function() {
for (var i = 0; chObj = this.registry[i]; i++) {
if (!chObj.chaserDiv) chObj.attemptLoad()
if (chObj.chaserDiv) chObj.main()
}
}
ypChaser.prototype.attemptLoad = function() {
var chDiv = null
if (ypChaser.isN6 || ypChaser.isO5) chDiv = document.getElementById(this.layerId)
else if (ypChaser.isIE) chDiv = document.all[this.layerId]
else if (ypChaser.isN4) chDiv = document.layers[this.layerId]
if (chDiv && chDiv != null) {
this.chaserDiv = chDiv
}
}
ypChaser.prototype.main = function( )
{
this.currentY = this.getCurrentY()
var scrollTop = ypChaser.getWindowScroll() 
var newTargetY = scrollTop + this.topOffset
var floor = ypChaser.getDocumentHeight() - this.floor
newTargetY = Math.max( newTargetY, this.ceiling)
if (!ypChaser.isO5) newTargetY = Math.min(newTargetY, floor)
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY
this.slideInit( )
}
this.slide( )
}
}
ypChaser.prototype.slideInit = function( )
{
this.A = (this.targetY - this.currentY) / this.slideTime / this.slideTime
this.startT = (new Date()).getTime()
this.startP = this.getCurrentY()
this.D = this.targetY - this.startP
}

ypChaser.prototype.slide = function( )
{
var elapsed = (new Date()).getTime() - this.startT
if (elapsed < this.slideTime) {
this.moveTo(this.D - (Math.round(Math.pow(this.slideTime - elapsed, 2) * this.A)) + this.startP)
}
}
ypChaser.prototype.moveTo = function(ny) {
if (ypChaser.isN4) this.chaserDiv.top = ny
else this.chaserDiv.style.top = ny + "px"
}
ypChaser.prototype.getCurrentY = function() {
var n = ypChaser.isN4 ? this.chaserDiv.top : parseInt(this.chaserDiv.style.top)
return isNaN(n) ? 0 : n
}
ypChaser.getWindowScroll = function() {
if (ypChaser.isIEDTD) 
{
//window.status=document.documentElement.scrollTop;
return document.documentElement.scrollTop;
}
else if (ypChaser.isIE) return document.body.scrollTop;
else return window.pageYOffset
}
ypChaser.getDocumentHeight = function() {
if (ypChaser.isO5) return 0 // opera can't retreive this property.
else if (ypChaser.isIEDTD) return Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight)
else if (ypChaser.isIE) return Math.max(document.body.scrollHeight, document.body.offsetHeight)
else return window.document.height
}
///////