
//*****************************************************
// Copyright:  © 2004 M H Payet
//
// File:       libQuote.js
// Language:	JavaScript
// Developer:  MHP
// Date:       Mar 2004
//
// Description:
//    Jesuit Theological College - weekly quote (& picture) functions.
//    Must appear after libMain.js file.
//    To be included on Home web page only.
//*****************************************************

// Variables currentDate and currentYear are declared in libMain.js.

var weeklyQuote = new Array(13);    // Quote array for 13-week lots of the year.
var stringDate = "January 01, " + currentYear;
var firstDayOfYear = new Date(stringDate);
var firstDayOfYearNum = firstDayOfYear.valueOf();
var currentDateNum = currentDate.valueOf();
var daysElapsed = (currentDateNum - firstDayOfYearNum);
var dayOfYear = (daysElapsed/1000/60/60/24 + 1);   // Add 1 as zero-based.
var weekOfYear = Math.floor(dayOfYear/7);
if ((weekOfYear < 0) || (weekOfYear > 51)) weekOfYear = 0;

// Include quote array JavaScript file according to current week of the year.
// 52 weeks of the year have been divided into 4 lots of 13 weeks each.

if (browserVer4plus) {
   if ((weekOfYear >= 0) && (weekOfYear <= 12))       document.writeln('<script type="text/javascript" src="libQuo01.js"></script>');
   else if ((weekOfYear >= 13) && (weekOfYear <= 25)) document.writeln('<script type="text/javascript" src="libQuo02.js"></script>');
   else if ((weekOfYear >= 26) && (weekOfYear <= 38)) document.writeln('<script type="text/javascript" src="libQuo03.js"></script>');
   else if ((weekOfYear >= 39) && (weekOfYear <= 51)) document.writeln('<script type="text/javascript" src="libQuo04.js"></script>');
}

var stIgFeastDay = false;
if ((currentDay == 31) && ((currentMonth + 1) == 7)) stIgFeastDay = true;

//=====================================================
// Create a custom object (quoteObj) with
// picture number, author, and text (up to 8 lines) properties.
//=====================================================

function quoteObj(pictureNum, author, textLine1, textLine2, textLine3, textLine4, textLine5, textLine6, textLine7, textLine8) {
   this.pictureNum = pictureNum;    // Ensure image exists in graphics/artwork/directory. Image filename starts with 'ihsMidx' where x is a digit 0 - 99. 
   this.author = author;
   this.textLine1 = textLine1;
   this.textLine2 = textLine2;
   this.textLine3 = textLine3;
   this.textLine4 = textLine4;
   this.textLine5 = textLine5;
   this.textLine6 = textLine6;
   this.textLine7 = textLine7;
   this.textLine8 = textLine8;
}

//=====================================================
// Get Quote Array Text (to be put into fader function).
//=====================================================

function getQuoteArrayText() {
   var arrayText = '';
   if (!browserVer4plus) return arrayText;

   var quoteAuthor, quoteLine1, quoteLine2, quoteLine3, quoteLine4, quoteLine5, quoteLine6, quoteLine7, quoteLine8;

   if (stIgFeastDay) {
      quoteAuthor = "St Ignatius died on<br> 31&nbsp;July&nbsp;1556.<br><br> Today is his Feast Day.";
      quoteLine1 = "St Ignatius was born on<br> 24&nbsp;December&nbsp;1491<br> in Spain.";
      quoteLine2 = "Discovering Christ's call, he left a worldly life to devote himself to the outstanding service of God and others.";
      quoteLine3 = "He wrote the <em>Spiritual Exercises</em> and gathered companions inspired to give all for the greater glory of God.";
      quoteLine4 = "He founded the <em>Society of Jesus</em>, an Order of contemplatives in action.";
      quoteLine5 = "Jesuits work globally in ministries of spirituality, pastoral care, education, communications and social action.";
   }
   else {
      quoteAuthor = weeklyQuote[weekOfYear].author;
      quoteLine1 = weeklyQuote[weekOfYear].textLine1;
      quoteLine2 = weeklyQuote[weekOfYear].textLine2;
      quoteLine3 = weeklyQuote[weekOfYear].textLine3;
      quoteLine4 = weeklyQuote[weekOfYear].textLine4;
      quoteLine5 = weeklyQuote[weekOfYear].textLine5;
      quoteLine6 = weeklyQuote[weekOfYear].textLine6;
      quoteLine7 = weeklyQuote[weekOfYear].textLine7;
      quoteLine8 = weeklyQuote[weekOfYear].textLine8;
   }

   if ((quoteLine1 != null) && (quoteLine1 != '')) arrayText = "\"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine1 + "</span></div>\"";
   if ((quoteLine2 != null) && (quoteLine2 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine2 + "</span></div>\"";
   if ((quoteLine3 != null) && (quoteLine3 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine3 + "</span></div>\"";
   if ((quoteLine4 != null) && (quoteLine4 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine4 + "</span></div>\"";
   if ((quoteLine5 != null) && (quoteLine5 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine5 + "</span></div>\"";
   if ((quoteLine6 != null) && (quoteLine6 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine6 + "</span></div>\"";
   if ((quoteLine7 != null) && (quoteLine7 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine7 + "</span></div>\"";
   if ((quoteLine8 != null) && (quoteLine8 != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteLine8 + "</span></div>\"";
   if ((quoteAuthor != null) && (quoteAuthor != '') && (stIgFeastDay)) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'>" + quoteAuthor + "</span></div>\"";
   else if ((quoteAuthor != null) && (quoteAuthor != '')) arrayText += ", \"<div><span class='faderTxt' style='color: {COLOR}'><em>" + quoteAuthor + "</em></span></div>\"";
   return arrayText;
}

//=====================================================
// Show picture (ihsMidx - where x is a digit from 0 - 99) according to week of the year.
//=====================================================

function showPicture() {
   var quotePictureNum = 0;
   var quotePictureType = ".jpg";
   var quotePicture, quotePictureDesc;

   if (stIgFeastDay) quotePictureNum = 99;
   else {
      if (browserVer4plus) quotePictureNum = weeklyQuote[weekOfYear].pictureNum
      else                 quotePictureNum = 0;
   }

   quotePicture = "graphics/artwork/ihsMid" + quotePictureNum + quotePictureType;
   if (quotePictureNum == 3)        quotePictureDesc = "Based on the Seal of St Ignatius.";
   else if ((quotePictureNum == 7) || (quotePictureNum == 8))  quotePictureDesc = "The former Joint Theological Library - now Dalton McCaughey Library.";
   else if (quotePictureNum == 9)   quotePictureDesc = "St Ignatius of Loyola - Founder of the Society of Jesus. Collage of images © ARSI - Archives of the Society of Jesus, Rome.  All rights reserved.";
   else if (quotePictureNum == 10)  quotePictureDesc = "AMDG: Ad Majorem Dei Gloriam - For the Greater Glory of God - Motto of the Jesuits.";
   else if (quotePictureNum == 11)  quotePictureDesc = "St Ignatius of Loyola - Founder of the Society of Jesus. © ARSI - Archives of the Society of Jesus, Rome.  All rights reserved.";
   else if (quotePictureNum == 99)  quotePictureDesc = "St Ignatius of Loyola - Founder of the Society of Jesus. Collage of images © ARSI - Archives of the Society of Jesus, Rome.  All rights reserved.";
   else                             quotePictureDesc = "Jesuit Theological College.";

   document.writeln('               <table cellSpacing=0 cellPadding=0 width=268 height=268 border=0>');
   document.writeln('                  <tr><td colspan=3 width=268 height=60><img src="graphics/artwork/ihsTop.jpg" width=268 height=60 alt="Based on the emblem of the Jesuits."></td></tr>');
   document.writeln('                  <tr>');
   document.writeln('                     <td width=60 height=148><img src="graphics/artwork/ihsLeft.jpg" width=60 height=148 alt="Based on the emblem of the Jesuits."></td>');
   document.writeln('                     <td width=148 height=148><img name="emblemImage" class="ihsMid" src="' + quotePicture + '" width=148 height=148 alt="' + quotePictureDesc + '"></td>');
   document.writeln('                     <td width=60 height=148><img src="graphics/artwork/ihsRight.jpg" width=60 height=148 alt="Based on the emblem of the Jesuits."></td>');
   document.writeln('                  </tr>');
   document.writeln('                  <tr><td colspan=3 width=268 height=60><img src="graphics/artwork/ihsBot.jpg" width=268 height=60 alt="Based on the emblem of the Jesuits."></td></tr>');
   document.writeln('               </table>');
}

//=====================================================
//
//=====================================================
