// Script: scripts.js
// Desc  : Template Scripts for website pages!

var NetscapeChk = (navigator.appName == "Netscape");

// Func: WriteHeader
// Desc: Handles after start BODY tag, Sidebar and Header HTML.
function WriteHeader(rootdir,doctitle,nohome,imgdir) {

  // Parameters:
  if (rootdir == null)  rootdir = "../"
  if (doctitle == null) doctitle = document.title;
  if (nohome == null) nohome = false;
  if (imgdir == null) imgdir = rootdir+"images/";

  // Logo Header and Title:
  document.writeln('<FONT FACE="Times New Roman" STYLE="font-size:10.5px" SIZE=-2><BR></FONT>');
  document.writeln('<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD>');
  document.writeln('<TABLE WIDTH=102 ALIGN=LEFT CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD WIDTH=100%>');
  document.writeln('<FONT FACE="Verdana,Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2>');
  document.writeln('<CENTER><A HREF="',rootdir,'index.html"><IMG ALT="HFP Logo" SRC="',imgdir,'hfplogo.gif" BORDER=0 WIDTH=80 HEIGHT=80></A></CENTER>');
  document.writeln('</TD></TABLE>');
  document.writeln('<TABLE WIDTH=460 BORDER=0 CELLPADDING=0 CELLSPACING=0><TR VALIGN=TOP>');
  document.writeln('<TD COLSPAN=3 ALIGN=RIGHT><IMG ALT="Holy Family Parish &middot East Kamias &middot West Kamias &middot Pinyahan &middot Quezon City Philippines" SRC="',imgdir,'hfpname1.gif" WIDTH=460 HEIGHT=60></TD>');
  document.writeln('<TR VALIGN=TOP><TD WIDTH=6><IMG SRC="',imgdir,'x.gif" WIDTH=6 HEIGHT=1></TD>');
  document.writeln('<TD><FONT FACE="Verdana,Arial,Helvetica" STYLE="font-size:13px" SIZE=-1><B>',doctitle,'</B>');
  document.writeln('<IMG SRC="',imgdir,'x.gif" WIDTH=290 HEIGHT=1></FONT></TD>');
  document.writeln('<TD ALIGN=RIGHT><FONT FACE="Verdana,Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2><IMG SRC="',imgdir,'hfpname2.gif" WIDTH=140 HEIGHT=20></FONT></TD>');
  document.writeln('</TABLE>');
  document.writeln('</TD></TABLE>');

  // Right Bar:
  RightBar(rootdir,imgdir);

  // Side Bar Menu:
  document.writeln('<TABLE WIDTH=93 ALIGN=LEFT><TD WIDTH=100%>');
  document.writeln('<FONT FACE="Verdana,Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2>');
  document.writeln('<CENTER>');
  document.writeln('<BR><BR>');
  document.writeln('<A HREF="',rootdir,'page.html?section=21"><IMG SRC="',imgdir,'iconread.gif" ALT="Gospel Reflections" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('Gospel Reflections<BR>');
  document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'church/index.html"><IMG SRC="',imgdir,'iconch.gif" ALT="The Church and its Services" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('The Church and<BR>its Services<BR>');
  document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'page.html?page=!comm"><IMG SRC="',imgdir,'iconcomm.gif" ALT="The Community, its Ministries and Organzation" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('The Community,<BR>its Ministries<BR>and<BR>Organization<BR>');
  document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'stories.html"><IMG SRC="',imgdir,'iconnews.gif" ALT="News and other Stories" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('News and other<BR>Stories<BR>');
  document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'page.html?page=!rsc&section=RSC"><IMG SRC="',imgdir,'iconrsc.gif" ALT="Information Resources" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('Information<BR>Resources<BR>');
  document.writeln('<BR>');
  //document.writeln('<A HREF="',rootdir,'comm/involve.html"><IMG SRC="',imgdir,'iconinv.gif" ALT="Be Involved!" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  //document.writeln('Be Involved!<BR>');
  //document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'page.html?page=!continfo"><IMG SRC="',imgdir,'iconinfo.gif" ALT="Contact Info" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('Contact Info<BR>');
  document.writeln('<BR>');
  var d_Date = new Date();
  document.writeln('<A HREF="http://books.dreambook.com/hfpweb/main.html?'+d_Date.getTime()+'"><IMG SRC="',imgdir,'iconfb.gif" ALT="Comments, Questions and Suggestions" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('Feedback<BR>');
  document.writeln('<BR>');
  document.writeln('<A HREF="',rootdir,'page.html?page=!help&section=HELP"><IMG SRC="',imgdir,'iconhelp.gif" ALT="Are you lost? Click here!" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
  document.writeln('Help<BR>');
  document.writeln('<BR>');
  if (!nohome) {
    document.writeln('<A HREF="',rootdir,'index.html"><IMG SRC="',imgdir,'iconhome.gif" ALT="Home" WIDTH=40 HEIGHT=30 BORDER=0></A><BR>');
    document.writeln('Home<BR>');
    document.writeln('<BR>');
  };
  document.writeln('<IMG SRC="',imgdir,'x.gif" ALT="" WIDTH=93 HEIGHT=1 BORDER=0>');
  document.writeln('<IMG SRC="',imgdir,'x.gif" ALT="" WIDTH=1 HEIGHT=640 BORDER=0>');
  document.writeln('</CENTER>');
  document.writeln('</FONT></TD></TABLE>');

  // Content Table:
  document.writeln('<TABLE WIDTH=450 CELLSPACING=0 CELLPADDING=0 BORDER=0><TR>');
  if (NetscapeChk) document.writeln('<TD><IMG SRC="',imgdir,'x.gif" WIDTH=8 BORDER=0></TD>');
    else document.writeln('<TD><IMG SRC="',imgdir,'x.gif" WIDTH=10 BORDER=0></TD>');
  document.writeln('<TD><FONT FACE="Arial,Helvetica" STYLE="font-size:13px" SIZE=-1>');
};

// Func: SpliceContent
// Desc: Splices the table content so that the browser will first completed tables.
function SpliceContent(rootdir,imgdir) {

  // Parameters:
  if (rootdir == null) rootdir = "../"
  if (imgdir == null) imgdir = rootdir+"images/";

  // End Table:
  document.writeln('</FONT></TD></TABLE>');

  // Begin New Table:
  document.writeln('<TABLE WIDTH=450 CELLSPACING=0 CELLPADDING=0 BORDER=0><TR>');
  if (NetscapeChk) document.writeln('<TD><IMG SRC="',imgdir,'x.gif" WIDTH=6 BORDER=0></TD>');
    else document.writeln('<TD><IMG SRC="',imgdir,'x.gif" WIDTH=10 BORDER=0></TD>');
  document.writeln('<TD><FONT FACE="Arial,Helvetica" STYLE="font-size:13px" SIZE=-1>');

};

// Func: WriteFooter
// Desc: Handles Copyright and before end BODY tag.
function WriteFooter(rootdir,imgdir) {

  // Parameters:
  if (rootdir == null) rootdir = "../"
  if (imgdir == null) imgdir = rootdir+"images/";

  // Copyright Info:
  document.writeln('<IMG SRC="',imgdir,'copysect.gif" ALT="&copy; Holy Family Parish Kamias Quezon City Philippines" WIDTH=450 HEIGHT=20><BR>');
  document.writeln('<TABLE ALIGN=RIGHT><TD VALIGN=MIDDLE>');
  document.writeln('<FONT FACE="Verdana,Arial,Helvetica" COLOR="#FF0000" STYLE="font-size:10.5px" SIZE=-2>Powered by:<BR>');
  document.writeln('<A HREF="http://www.freeservers.com/"><IMG SRC="',imgdir,'freeservers.gif" HEIGHT=30 ALT="www.freeservers.com"></A>');
  document.writeln('<A HREF="http://www.brinkster.com/"><IMG SRC="',imgdir,'brinkster.gif" HEIGHT=30 ALT="www.brinkster.com"></A>');
  document.writeln('</FONT></TD></TABLE>');

  // Content End:
  document.writeln('</FONT></TD></TABLE>');

};

var BoxColor = "#FFFFCC";

// Func: BoxStart
// Desc: Defines the top left side of a box
function BoxStart(rootdir,width,imgdir) {

  if (rootdir == null) rootdir = "../";
  if (width == null) width = "100%"; width = ""+width;
  if (imgdir == null) imgdir = rootdir+"images/";
  var spacer = "&nbsp;"
  if (width.indexOf("%") < 0) {
    var wid = parseInt(width,10)-32;
    spacer  = '<IMG SRC="'+imgdir+'x.gif" WIDTH='+wid+' HEIGHT=1>'
  };

  document.writeln('<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=0>');
  document.writeln('<TR BGCOLOR="',BoxColor,'"><TD BGCOLOR="#FFFFFF"><IMG SRC="',imgdir,'boxtl.gif" WIDTH=16 HEIGHT=16 BORDER=0></TD>');
  document.writeln('<TD><FONT STYLE="font-size:10px" SIZE=-3>'+spacer+'</FONT></TD><TD BGCOLOR="#FFFFFF"><IMG SRC="',imgdir,'boxtr.gif" WIDTH=16 HEIGHT=16 BORDER=0></TD>');
  document.writeln('<TR BGCOLOR="',BoxColor,'"><TD><FONT STYLE="font-size:10px" SIZE=-3>&nbsp;</FONT></TD><TD>');
};

// Func: BoxEnd
// Desc: Defines the right bottom side of a box
function BoxEnd(rootdir,imgdir) {

  if (rootdir == null) rootdir = "../";
  if (imgdir == null) imgdir = rootdir+"images/";

  document.writeln('</TD><TD><FONT STYLE="font-size:10px" SIZE=-3>&nbsp;</FONT></TD>');
  document.writeln('<TR BGCOLOR="',BoxColor,'"><TD BGCOLOR="#FFFFFF"><IMG SRC="',imgdir,'boxbl.gif" WIDTH=16 HEIGHT=16 BORDER=0></TD>');
  document.writeln('<TD><FONT STYLE="font-size:10px" SIZE=-3>&nbsp;</FONT></TD><TD BGCOLOR="#FFFFFF"><IMG SRC="',imgdir,'boxbr.gif" WIDTH=16 HEIGHT=16 BORDER=0></TD>');
  document.writeln('</TABLE>');
};

// Func: WaitImg
// Desc: Shows the wait image.
function WaitImg(name,rootdir,imgdir,origimg) {

  if (rootdir == null) rootdir = "../";
  if (imgdir == null)  imgdir  = rootdir+"images/";
  if (origimg == null) origimg = "";

  var cVer = navigator.appVersion; cVer = cVer.substring(0,cVer.indexOf(" "));
  var lImg = (eval(cVer) >= 4);
  if (lImg) {
    document.write('<IMG NAME="',name,'" SRC="',imgdir,'wait.gif" WIDTH=450 HEIGHT=20 BORDER=0>');
  } else {
    if (origimg != "") document.write('<IMG SRC="',origimg,'" BORDER=0>');
  };
};

// Func: WaitEnd
// Desc: Replaces the wait image with the original image (if any).
function WaitEnd(name,rootdir,imgdir,origimg) {

  if (rootdir == null) rootdir = "../";
  if (imgdir == null)  imgdir  = rootdir+"images/";
  if (origimg == null) origimg = "";

  var cVer = navigator.appVersion; cVer = cVer.substring(0,cVer.indexOf(" "));
  var lImg = (eval(cVer) >= 4);
  if (lImg) {
    if (origimg == "") eval('document.'+name+'.src="'+imgdir+'x.gif"');
      else eval('document.'+name+'.src="'+origimg+'"');
  };
};

var RightBarWidth = 140;

// Func: rbBoxStart
// Desc: Defines the top left side of a box
function rbBoxStart(rootdir,imgdir,heading) {

  var width = RightBarWidth;
  if (rootdir == null) rootdir = "../";
  if (width == null) width = "100%"; width = ""+width;
  if (imgdir == null) imgdir = rootdir+"images/";
  if (heading == null) heading = "";

  document.writeln('<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 BORDER=1>');
  document.writeln('<TR BGCOLOR="#66CC98"><TD><FONT STYLE="font-size:10.5px" SIZE=-2 FACE="Verdana,Arial,Helvetica" COLOR="#FFFFFF"><B>');
  document.writeln('<IMG SRC="'+imgdir+'x.gif" WIDTH='+width+' HEIGHT=2><BR>');
  document.writeln('&nbsp; '+heading+'<BR>');
  document.writeln('<IMG SRC="'+imgdir+'x.gif" WIDTH='+width+' HEIGHT=2><BR>');
  document.writeln('</B></FONT></TD></TR>');
  document.writeln('<TR BGCOLOR="#FFFFFF"><TD><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=8><TD>');
  document.writeln('<FONT FACE="Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2>');

};

// Func: rbBoxEnd
// Desc: Defines the right bottom side of a box
function rbBoxEnd(rootdir,imgdir) {

  if (rootdir == null) rootdir = "../";
  if (imgdir == null) imgdir = rootdir+"images/";

  document.writeln('</FONT></TD></TABLE></TD></TR></TABLE>');
};

// Func: _rb...
// Desc: Search Routines defined in a window.
function _rbWindow(url,wid) {
  if (wid == null) wid = 580;
  var x = window.open(url,"_rbWindow","menubar=no,toolbar=no,status=no,width="+wid+",scrollbars=yes,resizable=yes");
  x.focus();
};

function _rbBibleSearch() {
  var qstr = "";
  if (!(document.rbSearchForm.passage.value == "")) {
    qstr = "http://bible.gospelcom.net/bible?passage="+escape(document.rbSearchForm.passage.value);
  } else {
    if (!(document.rbSearchForm.topic.value == ""))
      qstr = "http://wbsa.logos.com/default.asp?searchFor="+escape(document.rbSearchForm.topic.value);
  };
  if (qstr == "") { alert("Please specify a Topic or Passage.") } else {
    _rbWindow(qstr);
  };
};

function _rbCatSearch() {
  var qstr = document.rbSearchForm.catechism.value;
  if (qstr == "") { alert("Please specify a Keyword.") } else {
    _rbWindow("http://www.ziplink.net/cgi-bin/cgiwrap/kerygma/a.pl?b=C&t=and&k="+escape(qstr),660);
  };
};

function _rbNetSearch() {
  var qstr = document.rbSearchForm.SearchKey.value;
  if (qstr == "") { alert("Please specify what are you searching for.") } else {
    if (document.rbSearchForm.Where[1].checked)
      qstr = "http://www.altavista.com/cgi-bin/query?pg=q&what=web&fmt=.&q=" + escape(qstr);
    else
      qstr = "http://search.atomz.com/search/?sp-a=000329df-sp00000000&sp-q=" + escape(qstr);
    window.location.href = qstr;
  };
};

var l_flash = false;

// Func: Set_Flash
// Desc: Sets the l_flash variable
function Set_Flash(l_set) {
  l_flash = l_set;
};

// Func: RightBar
// Desc: Draws the Right Bar.
function RightBar(rootdir,imgdir) {


  // Start of RightBar:
  document.writeln('<DIV ID="RightBar" STYLE="position:absolute;top:0px;left:590px">');
  document.writeln('<TABLE WIDTH='+RightBarWidth+' BORDER=0 CELLPADDING=0 CELLSPACING=0><TR VALIGN=TOP><TD><FONT FACE="Arial,Helvetica" STYLE="font-size:13px" SIZE=-1>');
  document.writeln('<BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><CENTER><A HREF="'+rootdir+'"><IMG SRC="'+imgdir+'hf.gif" BORDER=2></A></CENTER><BR>');

  // Ad Space: Begin: ------------------

  // Flash?:
  var x_flash = 0;
  if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
    if (navigator.plugins && navigator.plugins["Shockwave Flash"]) Set_Flash(true);
  } else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 && (navigator.userAgent.indexOf("Windows 95")>=0 || navigator.userAgent.indexOf("Windows 98")>=0 || navigator.userAgent.indexOf("Windows NT")>=0)) {
    document.write('<SC'+'RIPT LANGUAGE="VBScript">\n'); document.write('on '+'error '+'resume '+'next\n');
    document.write('x_flash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3")))\n');
    document.write('if ( x_flash <= 0 ) then x_flash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4")))\n');
    document.write('if ( x_flash <= 0 ) then x_flash = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5")))\n');
    document.write('if ( x_flash ) then Set_Flash(TRUE)\n');
    document.write('</SC'+'RIPT> \n');
  };

  if ( l_flash ) {
    document.writeln('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=2><TR><TD>');
    document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
    document.writeln(' CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"');
    document.writeln(' WIDTH="140" HEIGHT="300" NAME="vision" ID="vision">');
    document.writeln(' <PARAM NAME="movie" VALUE="'+imgdir+'vision.swf">');
    document.writeln(' <PARAM NAME="quality" VALUE="high">');
    document.writeln(' <PARAM NAME="loop" VALUE="true">');
    document.writeln(' <PARAM NAME="play" VALUE="true">');
    document.writeln(' <EMBED src="'+imgdir+'vision.swf" quality=high bgcolor=#FFFFFF WIDTH=140 HEIGHT=300 TYPE="application/x-shockwave-flash"></EMBED>');
    document.writeln('</OBJECT>');
    document.writeln('</TD></TR></TABLE>');

  // Non-Flash:
  } else {
    // document.writeln('<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=2><TR><TD>');
    // document.writeln('<CENTER><A HREF="'+rootdir+'comm/"><IMG SRC="'+imgdir+'vismiss.gif" BORDER=0></A></CENTER><BR>');
    // document.writeln('</TD></TR></TABLE>');
  };

  // Ad Space: End: --------------------

  // TextBox Width:
  var TxtWid = 1; // Rev.: Mozilla 1.2.1: if (NetscapeChk) TxtWid = (10/16);

  // This Week's Readings:
  // rbBoxStart(rootdir,imgdir,"This Week's Readings:");
  // rbBoxEnd(rootdir,imgdir);
  // document.writeln('<FONT STYLE="font-size:10px" SIZE=-3>&nbsp;<BR></FONT>');

  // Initialize Forms:
  document.writeln('<FORM NAME="rbSearchForm">');

  // Search The Bible:
  rbBoxStart(rootdir,imgdir,"Search The Bible:");
  document.writeln('<FONT FACE="Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2><NOBR>');
  document.writeln('<FONT STYLE="font-size:10.5px" SIZE=-2>Topic (e.g. Love):</FONT><BR>');
  document.writeln('<FONT STYLE="font-size:16px" SIZE=+0><INPUT TYPE=TEXT NAME="topic" SIZE="',Math.round(16*TxtWid),'" onChange="document.rbSearchForm.passage.value = \'\'"></FONT><BR>');
  document.writeln('<FONT STYLE="font-size:10.5px" SIZE=-2>Passage (e.g. John 3:16):</FONT><BR>');
  document.writeln('<FONT STYLE="font-size:16px" SIZE=+0><INPUT TYPE=TEXT NAME="passage" SIZE="',Math.round(16*TxtWid),'" onChange="document.rbSearchForm.topic.value = \'\'"></FONT><BR>');
  document.writeln('<IMG SRC="'+imgdir+'x.gif" WIDTH=7 HEIGTH=7><BR>');
  document.writeln('<A HREF="javascript:_rbBibleSearch()"><IMG SRC="'+imgdir+'searchbtn.gif" BORDER=0 ALIGN=RIGHT></A>&nbsp;');
  document.writeln('</NOBR></FONT>');
  rbBoxEnd(rootdir,imgdir);
  document.writeln('<FONT STYLE="font-size:10px" SIZE=-3>&nbsp;<BR></FONT>');

  // Catholic Catechism:
  rbBoxStart(rootdir,imgdir,"Catholic Catechism:");
  document.writeln('<FONT FACE="Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2><NOBR>');
  document.writeln('<FONT STYLE="font-size:10.5px" SIZE=-2>Keyword (e.g. Baptism):</FONT><BR>');
  document.writeln('<FONT STYLE="font-size:16px" SIZE=+0><INPUT TYPE=TEXT NAME="catechism" SIZE="',Math.round(16*TxtWid),'"></FONT><BR>');
  document.writeln('<IMG SRC="'+imgdir+'x.gif" WIDTH=7 HEIGTH=7><BR>');
  document.writeln('<A HREF="javascript:_rbCatSearch()"><IMG SRC="'+imgdir+'searchbtn.gif" BORDER=0 ALIGN=RIGHT></A>&nbsp;');
  document.writeln('</NOBR></FONT>');
  rbBoxEnd(rootdir,imgdir);
  document.writeln('<FONT STYLE="font-size:10px" SIZE=-3>&nbsp;<BR></FONT>');

  // Search The Net:
  rbBoxStart(rootdir,imgdir,"Search The Net:");
  document.writeln('<FONT FACE="Arial,Helvetica" STYLE="font-size:10.5px" SIZE=-2><NOBR>');
  document.writeln('<FONT STYLE="font-size:10.5px" SIZE=-2>Search For:</FONT><BR>');
  document.writeln('<FONT STYLE="font-size:16px" SIZE=+0><INPUT TYPE=TEXT NAME="SearchKey" SIZE="',Math.round(16*TxtWid),'"></FONT><BR>');
  document.writeln('<INPUT TYPE="RADIO" NAME="Where" VALUE="HFP" CHECKED>HFP Website<BR>');
  document.writeln('<INPUT TYPE="RADIO" NAME="Where" VALUE="NET">The Internet<BR>');
  document.writeln('<IMG SRC="'+imgdir+'x.gif" WIDTH=7 HEIGTH=7><BR>');
  document.writeln('<A HREF="javascript:_rbNetSearch()"><IMG SRC="'+imgdir+'searchbtn.gif" BORDER=0 ALIGN=RIGHT></A>&nbsp;');
  document.writeln('</NOBR></FONT>');
  rbBoxEnd(rootdir,imgdir);
  document.writeln('<FONT STYLE="font-size:10px" SIZE=-3>&nbsp;<BR></FONT>');

  // End of Forms:
  document.writeln('</FORM>');

  // End of RightBar:
  document.writeln('</FONT></TD></TABLE>');
  document.writeln('</DIV>');

};


