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

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 fillLayer(objName,newText) { 
  if ((obj=MM_findObj(objName))!=null) with (obj)
    if (document.layers) {document.write(unescape(newText)); document.close();}
    else innerHTML = unescape(newText);
}

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>audácia</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 color="#DECF98" 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=400,width=550,resize=no,scrollbars=no,status=yes");
	notifyW.document.write('<html><head><title>audácia</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
	notifyW.document.write('<link href="http://www.audacia.org/styles.css" rel="stylesheet" type="text/css">');
	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('</head><body BGCOLOR="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	notifyW.document.write('<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0"><tr><td width="47" height="47" align="right" valign="top" background="/imgs/tile_esq.gif"><img src="/imgs/tile_canto_te.gif" width="47" height="47"></td><td align="left" valign="top">&nbsp;</td><td width="47" height="47" align="left" valign="top" background="/imgs/tile_dir.gif"><img src="/imgs/tile_canto_td.gif" width="47" height="47"></td></tr><tr><td width="47" height="100%" background="/imgs/tile_esq.gif"> </td><td align="center" valign="top"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0"><tr><td height="50%"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0"><tr><td height="100%" colspan="2" valign="top" class="noticias_bg"><form action="/cgi-bin/search/search.pl" method="get" name="pesquisa"><table width="100%" height="20" bgcolor="#008b85" class="menutopo"><tr><td width="100%" align="right"><img src="/imgs/spacer.gif" width="20" height="26" align="absmiddle"></td></tr></table></form><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ECEDED"><tr><td align="left" valign="top" background="/imgs/canto_destaques_2.gif" bgcolor="#ffedfe" class="snap_d"><table width="100%"  border="0" cellspacing="0" cellpadding="0"><tr><td height="32" align="left" valign="middle"><img src="/imgs/spacer.gif" width="10" height="1"></td><td height="32" align="right" valign="top"><img src="/imgs/canto_destaques__2.gif" width="132" height="32"></td></tr></table><div class="margens"><form action="/cgi-bin/notify.pl" method="post" name="formulario" id="formulario" onSubmit="MM_validateForm(\'nomein\',\'\',\'R\',\'nomeout\',\'\',\'R\',\'email\',\'\',\'RisEmail\');return document.MM_returnValue"><table border="0" align="center" cellpadding="5" cellspacing="1" class="txt_normal"><tr bgcolor="#ffedfe"><td align="right" valign="middle" nowrap>O teu nome :</td><td align="left" valign="middle"><input name="seu_nome" type="text" class="pesquisa" id="seu_nome" size="40"></td></tr><tr bgcolor="#ffedfe"><td align="right" valign="middle" nowrap>O nome do(a) teu/tua amigo(a)<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="#ffedfe"><td align="right" valign="middle" nowrap bgcolor="#ffedfe">E-mail do(a) teu/tua amigo(a): </td><td align="left" valign="middle"><input name="email" type="text" class="pesquisa" id="email" size="40"></td></tr><tr bgcolor="#ffedfe"><td align="right" valign="top" nowrap bgcolor="#ffedfe">Mensagem:</td><td align="left" valign="middle" bgcolor="#ffedfe"><textarea name="mensagem" cols="30" rows="4" class="pesquisa" id="mensagem"></textarea></td></tr><tr align="center" valign="middle"><td>&nbsp;</td><td align="left"><input name="Submit" type="submit" class="pesquisa" value="Enviar"><input type="hidden" value="'+newsid+'" id="newsid" name="newsid"><input type="hidden" value="'+titulo+'" id="titulo" name="titulo"></td></tr></table><br><input name="urlredirect" type="hidden" id="urlredirect" value="/notify_ok.html"></form></div></td></tr></table></td></tr></table></td></tr><tr class="home"><td height="25" align="center" background="/imgs/bg_rodape_2.gif"><img src="/imgs/spacer.gif" width="15" height="25" align="absmiddle"><a href="javascript:window.top.close();" class="home2">fechar esta janela</a></td></tr></table></td><td width="47" height="100%" background="/imgs/tile_dir.gif"> </td></tr><tr><td width="47" height="47" background="/imgs/tile_esq.gif"><img src="/imgs/tile_canto_be.gif" width="47" height="47"></td><td background="/imgs/tile_base.gif"> </td><td width="47" height="47" background="/imgs/tile_dir.gif"><img src="/imgs/tile_canto_bd.gif" width="47" height="47"></td></tr></table>');
	notifyW.document.write('</body></html>');
}

var requestW;
function requestPW() {
	if (requestW){
		requestW.close();
	}
	requestW=window.open("", "requestW", "height=400,width=550,resize=no,scrollbars=no,status=yes");
	requestW.document.write('<html><head><title>audácia</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
	requestW.document.write('<link href="http://www.audacia.org/styles.css" rel="stylesheet" type="text/css">');
	requestW.document.write('<scr'+'ipt language="JavaScript" type="text/JavaScript">');
	requestW.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");
	requestW.document.write('</scr'+'ipt>');
	requestW.document.write('</head><body BGCOLOR="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	requestW.document.write('<table width="100%"  border="0" align="center" cellpadding="0" cellspacing="0"><tr><td width="47" height="47" align="right" valign="top" background="/imgs/tile_esq.gif"><img src="/imgs/tile_canto_te.gif" width="47" height="47"></td><td align="left" valign="top">&nbsp;</td><td width="47" height="47" align="left" valign="top" background="/imgs/tile_dir.gif"><img src="/imgs/tile_canto_td.gif" width="47" height="47"></td></tr><tr><td width="47" height="100%" background="/imgs/tile_esq.gif"> </td><td align="center" valign="top"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0"><tr><td height="50%"><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0"><tr><td height="100%" colspan="2" valign="top" class="noticias_bg"><form action="/cgi-bin/search/search.pl" method="get" name="pesquisa"><table width="100%" height="20" background="/imgs/tile_barra.gif" class="menutopo"><tr><td width="100%" align="right"><img src="/imgs/spacer.gif" width="20" height="26" align="absmiddle"></td></tr></table></form><table width="100%" height="100%"  border="0" cellpadding="0" cellspacing="0" bgcolor="#ECEDED"><tr><td align="left" valign="top" background="/imgs/canto_destaques2.gif" bgcolor="#ffedfe" class="snap_d"><table width="100%"  border="0" cellspacing="0" cellpadding="0"><tr><td height="32" align="left" valign="middle" background="/imgs/bg_destaques.gif"><img src="/imgs/spacer.gif" width="10" height="1"></td><td height="32" align="right" valign="top"><img src="/imgs/canto_destaques.gif" width="132" height="32"></td></tr></table><div class="margens"><form action="/cgi-bin/forms.pl" method="post" name="formulario" id="formulario" onSubmit="MM_validateForm(\'nomein\',\'\',\'R\',\'nomeout\',\'\',\'R\',\'email\',\'\',\'RisEmail\');return document.MM_returnValue"><table border="0" align="center" cellpadding="5" cellspacing="1" class="txt_normal"><tr bgcolor="#CFF581"><td align="right" valign="middle" nowrap>O teu nome :</td><td align="left" valign="middle"><input name="nomein" type="text" class="pesquisa" id="nomein" size="40"></td></tr><tr bgcolor="#CFF581"><td align="right" valign="middle" nowrap>O nome do(a) teu/tua amigo(a)<b></b>:</td><td align="left" valign="top"><input name="nomeout" type="text" class="pesquisa" id="nomeout" size="40"></td></tr><tr bgcolor="#CFF581"><td align="right" valign="middle" nowrap>E-mail do(a) teu/tua amigo(a): </td><td align="left" valign="middle"><input name="email" type="text" class="pesquisa" id="email" size="40"></td></tr><tr bgcolor="#CFF581"><td align="right" valign="top" nowrap>Mensagem:</td><td align="left" valign="middle"><textarea name="mensagem" cols="30" rows="4" class="pesquisa" id="mensagem"></textarea></td></tr><tr align="center" valign="middle"><td>&nbsp;</td><td align="left"><input name="Submit" type="submit" class="pesquisa" value="Enviar"></td></tr></table><br></form></div></td></tr></table></td></tr></table></td></tr><tr class="home"><td height="25" align="center" background="/imgs/bg_rodape.gif"><img src="/imgs/spacer.gif" width="15" height="25" align="absmiddle"><a href="javascript:window.top.close();" class="home">fechar esta janela</a></td></tr></table></td><td width="47" height="100%" background="/imgs/tile_dir.gif"> </td></tr><tr><td width="47" height="47" background="/imgs/tile_esq.gif"><img src="/imgs/tile_canto_be.gif" width="47" height="47"></td><td background="/imgs/tile_base.gif"> </td><td width="47" height="47" background="/imgs/tile_dir.gif"><img src="/imgs/tile_canto_bd.gif" width="47" height="47"></td></tr></table>');
	requestW.document.write('</body></html>');
}

var requestW;
function requestPW() {
	if (requestW){
		requestW.close();
	}
	requestW=window.open("/palavrachave.html", "requestW", "height=500,width=550,resize=no,scrollbars=yes,status=yes");
}

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 MM_validateForm() { //TDI
  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]);
	limit = (args[i+1]) ? args[i+1] : 0;
//	alert('1 limit:'+limit+' agora:'+val.value.length);
    if (val) { nm=findName(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' && limit != 0) { 
		  if (val.length > limit) errors += '. '+nm+': Tem muito texto, o limite são '+limit+' caracteres.\n';
		  if (val.length < 25) errors += '. '+nm+': Tem pouco texto, o mínimo são 25 caracteres.\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'; 
	  }
	}
  }
  errors = respostasErrors+errors;
  if (errors) alert('Ocorreram os seguintes erros:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function valRadio(btn) {
    var cnt = -1;
    for (var i=btn.length-1; i > -1; i--) {
        if (btn[i].checked) {cnt = i; i = -1;}
    }
    if (cnt > -1) return btn[cnt].value;
    else return null;
}

var respostas = new Array();
var respostasErrors = "";

function valRespostas(){
	args=valRespostas.arguments;
	respostasErrors = "";
	for (i=1; i<args.length; i++){
		var btn = valRadio(document.concurso[args[i]]);
		if (btn == null) respostasErrors += '. resposta a '+findName(args[i])+': É necessário.\n'; 
	}
}

function findName(ref){
	if (respostas[ref]) {
		return respostas[ref];
	} else {
		return ref;
	}
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1208693-33']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

