// JavaScript Document
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];}
}

function RunCal(Data,Local,Tipo)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100" height="50">\n');
    document.write('<param name="movie" value="Flash/Cal.swf?DATA='+Data+'&LOCAL='+Local+'&T='+Tipo+'">\n');
    document.write('<param name="quality" value="high"><param name="menu" value="false">\n');
    document.write('<embed src="Flash/Cal.swf?DATA='+Data+'&LOCAL='+Local+'&T='+Tipo+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="50"></embed></object>\n');	
}

function RunCalExt(Data,Local,Tipo)
{
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100" height="50">\n');
    document.write('<param name="movie" value="Flash/Cal.swf">\n');
	document.write('<param name=FlashVars value="DATA='+Data+'&LOCAL='+Local+'&T='+Tipo+'">\n');
    document.write('<param name="quality" value="high"><param name="menu" value="false">\n');
    document.write('<embed src="Flash/Cal.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100" height="50"></embed></object>\n');	
}

function ShowHidePanels(ID)
{
  obj=document.all.item(ID);
  if(obj!=null){
    if(obj.style.display=="none"){
	  obj.style.display="";
    }else{
	  obj.style.display="none";
	}
  }
}

function AddMenuItem(Tema,SubTemas,Idx,ID,BgColor,BorderColor,ImgIdx){
  if(Idx==1){
    document.write('<table width="100%" border="0" cellpadding="0" cellspacing="0" background="/Img/BMenu.gif">');
	document.write('<tr><td height="40" align="right"><table width="155" border="0" cellspacing="0" cellpadding="0"><tr>');
	if(SubTemas.length>0){
      document.write('<td width="20"><a href="javascript:ShowHidePanels(\'T'+Idx+'\');" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;"><img src="/Img/Cz'+ImgIdx+'.gif" width="18" height="19" border="0"></a></td>');
      document.write('<td><a href="javascript:ShowHidePanels(\'T'+Idx+'\');" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;" class="Menu">'+Tema);
	}else{
      document.write('<td width="20">&nbsp;</td>');
      document.write('<td><a href="Temas.asp?ID='+ID+'" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;" class="Menu">'+Tema);
	}
    document.write('</a></td></tr></table></td></tr></table>');
  }else{	
    document.write('<table width="100%" height="40" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">');
    document.write('<tr><td align="center" valign="middle"> <table width="165" height="40" border="0" cellpadding="0" cellspacing="0"><tr>');
    document.write('<td align="center" bgcolor="#FFFFFF"><table width="163" border="0" cellpadding="0" cellspacing="0"><tr>');
    document.write('<td height="38" align="right" valign="middle" bgcolor="'+BgColor+'"><table width="155" border="0" cellspacing="0" cellpadding="0">');
	if(SubTemas.length>0){
      document.write('<tr><td width="20"><a href="javascript:ShowHidePanels(\'T'+Idx+'\');" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;"><img src="/Img/Cz'+ImgIdx+'.gif" width="18" height="19" border="0"></a></td>');
      document.write('<td><a href="javascript:ShowHidePanels(\'T'+Idx+'\');" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;" class="Menu">'+Tema);
	}else{
      document.write('<tr><td width="20">&nbsp;</td>');
      document.write('<td><a href="Temas.asp?ID='+ID+'" onMouseOver="window.status=\'Abrir Tema\';return true" onMouseOut="window.status=\'\';return true;" class="Menu">'+Tema);
	}
    document.write('</a></td></tr></table></td></tr></table></td></tr></table>');
  }
  document.write('<DIV id=T'+Idx+'Holder style="DISPLAY: none; HEIGHT: 0px"></DIV><DIV id=D'+Idx+' style="LEFT: 0px; TOP: 0px" width="100%" valign="top">');
  document.write('<div id=T'+Idx+' STYLE="display:none"><table width="100%" border="0" cellspacing="0" cellpadding="0">');
  for (var i=0; i<SubTemas.length/2; i++){
    document.write('<tr><td align="center"><table width="163" border="0" cellpadding="0" cellspacing="0" bgcolor="'+BorderColor+'">');
	document.write('<tr><td height="25" align="center" valign="top"> <table width="163" border="0" cellpadding="0" cellspacing="0" bgcolor="'+BorderColor+'">');
	document.write('<tr><td height="24" align="right" valign="middle" bgcolor="'+BgColor+'"><table width="120" border="0" cellspacing="0" cellpadding="0">');
	document.write('<tr><td height="24"><a href="SubTemas.asp?ID='+SubTemas[i*2+1]+'&X='+Idx+'" class="SMenu">'+SubTemas[i*2]+'</a></td></tr></table></td></tr></table></td></tr></table></td></tr>');
  }
  document.write('</table></div></div>');
  if(Idx!=1)
    document.write('</td></tr></table>');
}

function PopUp(Url, Parameters, Name)
{
  window.open(Url,Name,Parameters);
}

function ImprimeArtigo(ID)
{
  PopUp('/PArtigos.asp?ID='+ID,'scrollbars=yes,toolbar=yes,status=no,resizable=yes,menubar=yes,width=640,height=480','Printer');
}

function Imprime() {
  if (window.print) {
    setTimeout('window.print();',200);
  }
  else {
    alert("Para imprimir este artigo carregue em 'Ctrl+P' no seu teclado.")
  }
}

function Back()
{
  parent.history.back();
}

function TestaEMail(EMail) {
  if((EMail.indexOf(' ')==-1) && (0<EMail.indexOf('@')) && (EMail.indexOf('@')+1 < EMail.length))
    return true;
  return false;
}

function ValidaCom(){
  Email=document.PROJ.EMAIL.value;
  Nome=document.PROJ.NOME.value;
  Com=document.PROJ.COMENT.value;
  options = 'dialogWidth:600px;dialogHeight:300px;status=0;scroll=no;titlebar=false;center:yes;help:no;unadorned=no';
  if(Nome.length<=0){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz um nome válido!</strong>',window,options);
    return false;
  }
  if(!TestaEMail(Email)){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz um E-Mail válido!</strong>',window,options);
    return false;
  }
  if(Com.length<=0){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz o teu comentário!</strong>',window,options);
    return false;
  }
  return true;
}

function ValidaOra(){
  Email=document.PROJ.EMAIL.value;
  Nome=document.PROJ.NOME.value;
  Com=document.PROJ.PEDIDO.value;
  options = 'dialogWidth:600px;dialogHeight:300px;status=0;scroll=no;titlebar=false;center:yes;help:no;unadorned=no';
  if(Nome.length<=0){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz um nome válido!</strong>',window,options);
    return false;
  }
  if(!TestaEMail(Email)){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz um E-Mail válido!</strong>',window,options);
    return false;
  }
  if(Com.length<=0){
    showModalDialog('Msg.asp?T=0&M=<strong>Por favor introduz o teu pedido de oração!</strong>',window,options);
    return false;
  }
  return true;
}

function ShowPage(Idx)
{
  document.FVirtual.Page.value=Idx;
  document.FVirtual.submit();
}

function VouOrar(Idx)
{
  document.FVirtual.Pedido.value=Idx;
  document.FVirtual.submit();
}



function DecEM(S){
  var i,C1,C2;
  H = new String('AZBYCWDXEVFUGTHS');
  F = new String('');
  for(i=0;i<S.length;i+=2){
    C1=S.charAt(i);
	C2=S.charAt(i+1);
    F+=String.fromCharCode(H.indexOf(C1)*16+H.indexOf(C2));
  }
  document.write('<a href=\"mailto:'+F+'\">'+F+'</a>');
}

