
//*****************************************************
// Copyright:  © 2002 M H Payet
//
// File:       libMain.js
// Language:	JavaScript
// Developer:  MHP
// Date:       Apr 2002
//
// Description:
//    Daughters of Divine Zeal Website
//    Main library of functions.
//    To be included in all web pages.
//*****************************************************

var graphicsDir = "graphics/";

//=====================================================
// Browser detection.
//=====================================================

var browserType = navigator.userAgent.toLowerCase();
var browserVer = parseFloat(navigator.appVersion);
var browserID = "";
var browserVer4plus = false;

var macOS = false;
if (browserType.indexOf('mac')!=-1) macOS = true;

// Check for non-MSIE and non-NN browsers first for JavaScript functions to
// ignore emulation of these two browsers.  Code will operate according to
// real browser ID otherwise outcome is unpredictable without
// thorough testing on these other browsers.

if (browserType.indexOf('opera') != -1) browserID = "OPERA"
else if (browserType.indexOf('webtv') != -1) browserID = "WEBTV"
else if (browserType.indexOf('msie') != -1) browserID = "MSIE"
else if (browserType.indexOf('mozilla') != -1) browserID = "NN"

// Get actual version number of MSIE browser (NN extracts this) to determine
// if > V4.0.

if ((browserID == "MSIE") && (browserVer == 4.0)) {
   var ver4 = browserType.substring(browserType.indexOf('msie'), browserType.length);

   browserVer = ver4.substring(ver4.indexOf(' '), ver4.indexOf(';'));

   // In case value returned is not a number, return 4.0 browser version again.

   if (isNaN(browserVer)) browserVer = 4.0;
}

// Check that current browser will support JavaScript code version 1.2+.
// If not, then any JavaScript 1.1- code may be executed.

if (((browserID == "MSIE") || (browserID == "NN")) && (browserVer >= 4)) {
   browserVer4plus = true;
}

//=====================================================
// Set padding for 'motto' element in Netscape.
// Restrict formatting of 'pullquote' element to
// MSIE Ver < 6 as browser version 6.0+ has problems with
// text in the highlighted quote overlapping each other.
// Have implemented workaround at present.
//=====================================================
                                              
document.writeln('<style type="text/css">');
document.writeln('<!--');
if (browserID == "NN") {
   document.writeln('   .motto               {padding-top: 5px}');
   document.writeln('   td.sideBarC, td.sideBarL, .smallerTxt, #smallerTxt, .pageLocn, td.gallery {font-size: 90%}');
   document.writeln('   div.sideBarS         {font-size: 100%}');
   document.writeln('   .pullQuote           {color: #333399}');
   document.writeln('   p.faderTxt3          {font-size: 100%}');

   if (browserVer >= 5.0) {
      document.writeln('   .heading2, table.homeTbl td {padding-left: 5px}');
      document.writeln('   .imgRightPad2     {float: right; padding-left: 5px; font-size: 100%}');
      document.writeln('   .imgLeftPad2      {float: left; padding-right: 5px; font-size: 100%}');
      document.writeln('   .pageTop, #copyRight, #pageBottom2, #pageBottom2a, #pageBottom2b, #topPage, h4 a span.smallerTxt, .altEntrance {font-size: 90%}');
      document.writeln('   table.homeTbl     {padding-left: 0px}');
      document.writeln('   #pageBottom2 span {float: right}');
      document.writeln('   div.navFiller1Txt ul {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
      document.writeln('   table.sideBarC td ul, table.sideBarL td ul {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
      document.writeln('   ul.special, ol.special {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
   }
   else {
      document.writeln('.motto               {font-size: 79%}');
      document.writeln('.letter1             {margin-left: 10px; margin-right: 10px; background-color: #FFFFFF; border: 1px solid #CCCCCC; width: 90%}');
   }
}
else if (browserID == "MSIE") {
   if (browserVer < 6.0) {
      document.writeln('   .pullQuote           {');
      document.writeln('                           background-color: #F5F5FF;');
      document.writeln('                           border: 1px solid #FFFFF0;');
      document.writeln('                        }');
   }
   document.writeln('   ul.special, ol.special {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
   document.writeln('   a.linkBar            {text-decoration: none; width: 138px; display: block;}');
   document.writeln('   a.linkBar:hover      {color: #F5F5DC}');
   document.writeln('   div.navFiller1Txt ul {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
   document.writeln('   table.sideBarC td ul, table.sideBarL td ul {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
}
else if (browserID == "OPERA") {
   document.writeln('   a.linkBar:hover      {color: #996600; text-decoration: none}');
   document.writeln('   .pullQuote           {color: #333399}');
   document.writeln('   td.sideBarC, td.sideBarL, .smallerTxt, #smallerTxt, div.sideBarS, .pageLocn, td.gallery {font-size: 90%}');
   document.writeln('   ul.special, ol.special {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
}
document.writeln('-->');
document.writeln('</style>');

//=====================================================
// Date functions
//=====================================================

var currentDate = new Date();
var currentDayOfWeek = currentDate.getDay()
var currentDay = currentDate.getDate();            // dd
var currentMonth = (currentDate.getMonth() + 1);   // mm (0-based so add 1)
var currentYear = currentDate.getFullYear();       // yyyy

//=====================================================
// Show date modified - used in page footers.
//=====================================================

function showDateModified() {
   if (lastDateModified() != "") document.writeln("<span>Last modified: " + lastDateModified() + ", EST Australia.</span>");
   else  document.writeln("<span>Last modified: " + document.lastModified +  ".</span>");
}

//=====================================================
// Last date modified.
//=====================================================

function lastDateModified() {
   var someDate = new Date(document.lastModified);
   return someDate.toLocaleString();
}

//=====================================================
// Status messages.
//=====================================================

function statusMsg(msg) {
   window.status = msg;
   return true;
}

function defaultStatusMsg() {
   window.status = window.defaultStatus;
   return true;
}

//=====================================================
// Change bkg image (on/off) for navigation bar (works in MSIE only).
//=====================================================

function chgImg(item, toggle) {
   if (browserID == "MSIE") {
      if (toggle == 'on')  document.all[item].className = "btnOn";
      if (toggle == 'off')  document.all[item].className = "btnOff";
   }
}

//=====================================================
// Open new browser window
//=====================================================

function openWin(fileName, windowWidth, windowHeight, windowResize) {
   var windowAttributes;

   if (windowWidth==null) windowWidth=500;
   if (windowHeight==null) windowHeight=300;
   if (windowResize==null) windowResize="no";

   windowAttributes="'width=" + windowWidth;
   windowAttributes+=",height=" + windowHeight;
   windowAttributes+=",resizable=" + windowResize;
   windowAttributes+=",scrollbars=yes'";

   // Window name will be the filename without its extension.

   var charPos=fileName.indexOf(".");
   var windowName="";

   if (charPos != -1) windowName=fileName.substring(0, charPos);

   newWindow=window.open(fileName, windowName, eval(windowAttributes));

   // To overcome Netscape bug (in certain versions) re: preventing
   // display of document with window.open method, repeat open
   // statement.

   if (browserID == "NN") {
      newWindow=window.open(fileName, windowName, eval(windowAttributes));
   }
}

//=====================================================
// Get current date name.
//=====================================================

var currentDateName = "";
var currentDate = new Date();
var currentDayOfWeek = currentDate.getDay()
var currentDay = currentDate.getDate();      // dd
var currentMonth = currentDate.getMonth();   // mm
var currentYear = currentDate.getFullYear(); // yyyy

function getCurrentDateName() {
   if (browserVer4plus) {
      currentDateName = (getCurrentDayName(currentDayOfWeek) + ' ' + currentDay + ' ' + getCurrentMonthName(currentMonth) + ' ' + currentYear);
   }
   return currentDateName;
}

//=====================================================
// Get current day name.
//=====================================================

function getCurrentDayName(currentDayOfWeekNumber) {
   dayName = new Array(7);

   dayName[0] = "Sunday";
   dayName[1] = "Monday";
   dayName[2] = "Tuesday";
   dayName[3] = "Wednesday";
   dayName[4] = "Thursday";
   dayName[5] = "Friday";
   dayName[6] = "Saturday";

   return dayName[currentDayOfWeekNumber];
}           
            
//=====================================================
// Get current month name.
//=====================================================

function getCurrentMonthName(currentMonthNumber) {
   monthName = new Array(12);

   monthName[0] = "January";
   monthName[1] = "February";
   monthName[2] = "March";
   monthName[3] = "April";
   monthName[4] = "May";
   monthName[5] = "June";
   monthName[6] = "July";
   monthName[7] = "August";
   monthName[8] = "September";
   monthName[9] = "October";
   monthName[10] = "November";
   monthName[11] = "December";

   return monthName[currentMonthNumber];
}

//=====================================================
// Latest Date Heading.
//=====================================================

function latestDateHeading() {
   if (getCurrentDateName() != "") {
      document.writeln('<br>');
      document.writeln('<h4 class="right">As at ' + getCurrentDateName() + '</h4>');
   }
}

function latestDateHeading2() {
   if (getCurrentDateName() != "") document.writeln(' as at ' + getCurrentDateName());
}

//=====================================================
// Show language translation
//=====================================================

var langTran = true;

function showLangTran() {
//   if ((browserID == "NN") && (browserVer < 5.0)) langTran = false;

   <!-- AltaVista Babel Fish Translator -->
   if (langTran) document.writeln('<br><br><a class="smallerTxt" id="noPrint" href="langTran.html" onMouseOver="return statusMsg(\'View our website in another language...\')" onMouseOut="return defaultStatusMsg()"><img src="graphics/artwork/trans0001.gif" width=104 height=135 alt="Artwork: Flags of countries for language translation - China, Germany, Japan, South Korea, France, Italy, Portugal, Spain." border=0><br>Translate Website</a><br><br>')

   else document.writeln('&nbsp;')
}

function showJubileeInfo() {
   document.writeln ('<br><a class="smallerTxt" href="fdzAU-golden-jubilee.html" onMouseOver="return statusMsg(\'Celebrating 50 years of service...\')" onMouseOut="return defaultStatusMsg()"><img src="graphics/artwork/logo001-white-bkg.gif" width=138 height=130 alt="Logo: Golden Jubilee of FDZ in Australia." border=0><br>Golden Jubilee:<br> 1959 - 2009</a><br>');
   document.writeln ('<div style="padding: 2px;"><p class="left" id="smallerTxt" style="margin-top: 3px; margin-bottom: 3px;">See and read about the activities and celebrations during this wonderful year!:</p><ul class="special" id="smallerTxt" style="text-align: left; margin-top: 3px;"><li><a href="fdzAU-golden-jubilee-gallery.html">Photo Gallery</a></li><li><a href="fdzAU-golden-jubilee-slideshows.html">Slideshows</a></li><li><a href="fdzAU-golden-jubilee.html#homilies">Homilies</a></li><li><a href="fdzAU-golden-jubilee.html#reflections">Messages &amp; Reflections</a></li></ul></div>');
}
function showNelsonsCardsInfo() {
   document.writeln ('<br><div style="padding: 2px;"><a class="smallerTxt" href="downloads/nelson-cards2009.pdf" onMouseOver="return statusMsg(\'Purchase these handmade recycled art cards and raise money for poor children...\')" onMouseOut="return defaultStatusMsg()"><img src="graphics/newsevents/nelson-card01.jpg" width=133 height=211 alt="Photo: Recycled Art Cards." border=0><br>Recycled Art Cards</a><br><span class="smallerTxt">Buy these handmade recycled art cards designed by Nelson Estrella and help the poor kids in Laoag, Philippines.</span></div>');
}

//=====================================================
//
//=====================================================
