
//*****************************************************
// Copyright:  © 2002 M H Payet
//
// File:       libMain.js
// Language:	JavaScript
// Developer:  MHP
// Date:       Jan 2002
//
// Description:
//    Daughters of Divine Zeal Website
//    Main library of functions.
//    To be included in all web pages.
//*****************************************************

//=====================================================
// Browser detection.
//=====================================================

var browserType = navigator.userAgent.toLowerCase();
var browserVer = parseFloat(navigator.appVersion);
var browserID = "";
var browserVer4plus = false;

// 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.0)) {
   browserVer4plus = true;
}

//=====================================================
// Browser-specific CSS element definitions.
//=====================================================
                                              
document.writeln('<style type="text/css">');
document.writeln('<!--');
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}');
}
else if (browserID == "NN") {
   if (browserVer < 5.0) {
      document.writeln('   table.colBkg {padding-left: 5px; padding-right: 5px}');
      document.writeln('   img.bordered         {border: none}');
   }
   else {
      document.writeln('   ul.special, ol.special {padding-left: 0px; padding-right: 1px; margin-left: 20px}');
   }
   document.writeln('   .smallerTxt, #smallerTxt, .itemDate, td.gallery, .thumbnails p {font-size: 90%}');
   document.writeln('   .pullQuote           {color: #333399}');
}
else if (browserID == "OPERA") {
   document.writeln('   a.linkBar:hover      {color: #008080; text-decoration: none}');
   document.writeln('   .smallerTxt, #smallerTxt, .itemDate, td.gallery, .thumbnails p {font-size: 90%}');
   document.writeln('   .pullQuote           {color: #333399}');
   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;
}

//=====================================================
// Bullet for link bar functions.
//=====================================================

var numOfBullets = 7;
var bulletWidth = 10;
var bulletHeight = 10;
var bulletOn = new Array();
var bulletOff = new Array();

for (i=0; i < numOfBullets; i++) {
   bulletOn[i] = new Image(bulletWidth, bulletHeight);
   bulletOff[i] = new Image(bulletWidth, bulletHeight);
   bulletOn[i].src = "graphics/bulletOn.gif";
   bulletOff[i].src = "graphics/bullet1.gif";
}

function showBullet(style, img) {
   if (style == 'on') {
      if (browserID == "MSIE")      eval("bullet" + img).src = bulletOn[img].src
      else if (browserID == "NN")   document.eval("bullet" + img).src = bulletOn[img].src;
   }
   else {
      if (browserID == "MSIE")      eval("bullet" + img).src = bulletOff[img].src
      else if (browserID == "NN")   document.eval("bullet" + img).src = bulletOff[img].src;
      }
   }

//=====================================================
// 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));
   }
}

//=====================================================
// 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><div class="centre"><a class="linkBarSmall" 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></div>')
   else document.writeln('&nbsp;')
}

//=====================================================
// Screen & Window Width & Height - global variables.
// Function must be called within <body> section of
// HTML file.
//=====================================================

var screenWidth = 0;
var screenHeight = 0;
var windowWidth = 0;
var windowHeight = 0;

function getDisplayDimensions() {
   if ((browserVer4plus) || ((browserID == "OPERA") && (browserVer >= 6.0))) {
      // Actual screen dimensions.

      screenWidth = screen.width;
      screenHeight = screen.height;

      // Available screen dimensions displayed in browser window.

      windowWidth = ((browserID == "NN") || (browserID == "OPERA")) ? window.innerWidth : document.body.clientWidth;
      windowHeight = ((browserID == "NN")  || (browserID == "OPERA")) ? window.innerHeight : document.body.clientHeight;
   }
}

//=====================================================
//
//=====================================================
