// TOP BAR NAVIGATE BUTTONS
function swapButton(button,num) {
 if (button == 'float_home' && num > 2 && num < 5) {
   num = num - 2;
   float_home.src = '../images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_prayer') {
   bar_prayer.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_memorial') {
   bar_memorial.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_powers') {
   bar_powers.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_candle') {
   bar_candle.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_chapel') {
   bar_chapel.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'bar_about') {
   bar_about.src = 'images/buttons/' + button + '_' + num + '.gif'
 }

 if (button == 'prayer_today') {
   prayer_today.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }
 if (button == 'chaplain_chair') {
   chaplain_chair.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }
 if (button == 'power_month') {
   power_month.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }
 if (button == 'bible_day') {
   bible_day.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }
 if (button == 'torah_day') {
   torah_day.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }
 if (button == 'saint_day') {
   saint_day.src = 'images/buttons/bar_left/' + button + '_' + num + '.gif'
 }

 if (button == 'men_meditate') {
   men_meditate.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_chapel') {
   men_chapel.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_prayer') {
   men_prayer.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_ccedl') {
   men_ccedl.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_bible') {
   men_bible.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_powers') {
   men_powers.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_candle') {
   men_candle.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_memorial') {
   men_memorial.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_links') {
   men_links.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_chaplain') {
   men_chaplain.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_silent') {
   men_silent.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_windows') {
   men_windows.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_headlines') {
   men_headlines.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'men_religious') {
   men_religious.src = 'images/buttons/' + button + '_' + num + '.gif'
 }
 if (button == 'email_friend') {
   email_friend.src = 'images/' + button + '_' + num + '.gif'
 }
 return(false);
}

// BEGIN DAYS UNTIL HOLIDAYS LINKS
function Holidays(num) {
  // Set defaults
  if (num == 1) {
    Event = 'Christmas';
    EventDate = "December 25";
    ToolTip = 'Christmas Day - Tuesday, December 25 commemorates the Birth of Jesus Christ.';
    URL = 'http://www.lifeofchrist.com/life/lifescan/';
  }
  else if (num == 2) {
    Event = 'Hanukah';
    EventDate = 'December 4';
    ToolTip = 'Chanukah, Dec. 4 - 12, 2007 (Kislev 25 - 3 Tevet), commemorates the rededication of the Temple in Jerusalem.';
    URL = 'http://www.chabad.org/holidays/default.asp?AID=6216';
  }

  //////////////////////////////////////////////////////
  day_description = Event;
  today = new Date();
  year = today.getFullYear();
  date = new Date(EventDate + ', ' + year);
  diff = date.getTime() - today.getTime();
  days = Math.floor(diff / (1000 * 60 * 60 * 24));

  TableOpen = '<table border="1" bordercolordark="#000080" bordercolorlight="#0000FF" cellpadding="2" cellspacing="0"><tr><td width="100%" align="center" nowrap><font face="verdana,Ariel" size="1"><b><a class="08" href="' + URL + '" target="_blank" title="' + ToolTip + '"><center>';
  TableClose = '</a></b></font></td></tr></table></center>';

  daynum = days + 1;
           
  document.write(TableOpen);

  if (daynum > 1) 
    document.write('There are ' + daynum + ' days until<br>' + day_description + '!');
  else if (daynum == 1)
    document.write('Tomorrow<br>' + day_description + ' begin!');
  else if (daynum == 0)
    document.write('Today begins<br>' + day_description + '!');
  else if (daynum == -1) {
    daynum = 1;
    document.write(day_description + '<br>began ' + ' 1 day ago this year!');
  }
  else if (daynum < -1) {
    daynum = daynum * -1;
    document.write(day_description + '<br>began ' + daynum + ' days ago this year!');
  }
  document.write(TableClose);
}

// DROPDOWN INSPIRATIONAL MESSAGES -->
function formHandler1(form1)
 {
 var URL =  document.form1.site.options[document.form1.site.selectedIndex].value;
 window.location.href = URL;
 }

// DROPDOWN NEWS MENU -->
function formHandler2(form2)
 {
 var URL =  document.form2.site.options[document.form2.site.selectedIndex].value;
 window.location.href = URL;
 }

// Today's Date Array of month day and year names
dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
monthNames = new Array("January","February","March","April","May","June","July", "August","September","October","November","December");
now = new Date();
Year = now.getFullYear();
MM = now.getMonth();
DD = now.getDate();
DY = now.getDay();
Dte = now.getDate();
Day = dayNames[DY];
Month = monthNames[MM];
Today = '<b>Today is ' + Day + ', ' + Month + ' ' + Dte + ', ' + Year + '</b>';

// Chaplain's Chair Link
Ye = Year - 2000;
if (Ye < 10) Ye = '0' + Ye;
Mo = MM + 1
if (Mo < 10) Mo = '0' + Mo;
Dt = DD;
if (Dt < 10) Dt = '0' + Dt;
ChaplainLink = '<a href="http://chaplainschair.tsmj.org/' + Ye + Mo + '.htm"><img id="chaplain_chair" border="0" src="images/buttons/bar_left/chaplain_chair_1.gif" onmouseover="swapButton(\'chaplain_chair\',2);" onmouseout="swapButton(\'chaplain_chair\',1);" vspace="2" alt="Message from the Chaplain\'s Chair..." width="146" height="46"></a>';

// Power for the Month
PowerLink = '<a href="powers/power' + Mo + '.htm"><img id="power_month" alt="The Spiritual Faculty and Disciple for study this month" src="images/buttons/bar_left/power_month_1.gif" onmouseover="swapButton(\'power_month\',2);" onmouseout="swapButton(\'power_month\',1);" border="0" vspace="2" width="146" height="46"></a>';

// Prayer for Today
PrayerPath = 'http://dailyprayer.tsmj.org/index.htm?';
PrayerLink = '<a onclick="open(\'' + PrayerPath + Ye + Mo + Dt + '.htm?' + '\',\'dailyprayer\',\'left=100,top=40,toolbar=0,location=0,resizable=0,width=580,scrollbars=1,height=600\')" href="javascript:void(0)"><img id="prayer_today" name="prayer_today" alt="Click here to read the TSM Inspirational Prayer for Today" src="images/buttons/bar_left/prayer_today_1.gif" onmouseover="swapButton(\'prayer_today\',2);" onmouseout="swapButton(\'prayer_today\',1);" align="middle" border="0" hspace="4" vspace="2" width="146" height="46"></a>';

// Saint for Today
SaintPath = 'saint_frame.htm';
SaintLink = '<a onclick="open(\'' + SaintPath + '\',\'saints\',\'left=100,top=40,toolbar=1,location=1,resizable=1,width=900,scrollbars=1,height=500\')" href="javascript:void(0)"><img id="saint_day" name="saint_day" alt="Learn about the life of the Christian Saint(s) celebrated on this day" src="images/buttons/bar_left/saint_day_1.gif" onmouseover="swapButton(\'saint_day\',2);" onmouseout="swapButton(\'saint_day\',1);" align="middle" border="0" hspace="4" vspace="2" width="146" height="46"></a>';

// Daily Bible Portion
BiblePath = 'http://www.tsmacademy.org/dailybible/';
BibleLink = '<a onclick="open(\'' + BiblePath + '\',\'bible\',\'left=100,top=40,toolbar=0,location=1,resizable=1,width=900,scrollbars=1,height=500\')" href="javascript:void(0)"><img id="bible_day" name="bible_day" alt="Bible Portion for Today: Study the Bible through the year in Daily Portions with Matthew Henry\'s Commentary" src="images/buttons/bar_left/bible_day_1.gif" onmouseover="swapButton(\'bible_day\',2);" onmouseout="swapButton(\'bible_day\',1);" align="middle" border="0" hspace="4" vspace="2" width="146" height="46"></a>';

// Torah Portion for Today
Mt = MM + 1;
TorahPath = 'http://www.chabad.org/Parshah/Rashi/default.asp?tDate=' +  Mt + '/' + DD + '/' + Year + '&src=ds';
TorahLink = '<a onclick="open(\'' + TorahPath + '\',\'torah\',\'left=100,top=40,toolbar=1,location=1,resizable=1,width=900,scrollbars=1,height=500\')" href="javascript:void(0)"><img id="torah_day" name="torah_day" alt="Torah Portion for Today: Study the Torah through the year in Daily Portions with commentary by Rashi (Rabbi Shlomo Yitzchaki, 1040-1105 CE)." src="images/buttons/bar_left/torah_day_1.gif" onmouseover="swapButton(\'torah_day\',2);" onmouseout="swapButton(\'torah_day\',1);" align="middle" border="0" hspace="4" vspace="2" width="146" height="46"></a>';

// EMAIL A FRIEND
initialsubj="Here is an interesting site I found"
initialmsg="Hi!\n I thought you would like to take a look at this Web page: "+window.location
var good;

function checkEmailAddress(field) {
 goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);

 if (goodEmail) {
  good = true;
  }
 else {
  alert('Please enter a valid email address.');
  field.focus();
  field.select();
  good = false;
  }
 }

u = window.location;
function mailThisUrl() {
 good = false
 checkEmailAddress(document.eMailer.email);
 if (good) {
  window.location = "mailto:"+document.eMailer.email.value+"?subject="+initialsubj+"&body="+initialmsg
  }
 }

Donate = '<table border="0" align="center" width="370" cellspacing="0" cellpadding="0"><tr><td width="100\%" align="center"><form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="contact@tsmj.org"><input type="hidden" name="item_name" value="Donation to The Shea Ministries"><input type="hidden" name="item_number" value="TSM-01"><input type="hidden" name="no_note" value="1"><input type="hidden" name="currency_code" value="USD"><input type="hidden" name="tax" value="0"><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!"></form></td></tr></table>';

EmailFriend = '<table border="0" width="266" align="center" cellspacing="0" cellpadding="0"><tr><td width="100%" align="center"><form name="eMailer"><table border="2" width="40%" bordercolorlight="#0000FF" cellspacing="0" cellpadding="0" bordercolordark="#000080" bgcolor="#85AADC"><tr><td width="100%"><div align="center"><center><table border="0" width="100%"><tr><td width="100%" align="center" nowrap><a name="tell"><b>Tell a friend:</b><input type="text" name="email" size="25" value=" Enter a friend\'s email" onFocus="this.value=\'\'" onMouseOver="window.status=\'Enter email address here and tell a friend about this site...\'; return true" onMouseOut="window.status=\'\';return true" style="font-weight: bold; font-size: 10px"></a></td></tr><tr><td width="100%" align="center"><input type="button" value="Send this URL" onMouseOver="window.status=\'Click to send an email (with this page address) to a friend! Enter email address above...\'; return true" onMouseOut="window.status=\'\';return true" onClick="mailThisUrl();" style="font-size: 10px; font-weight: bold"></td></tr></table></center></div></td></tr></table></form></td></tr></table>';

// Inspirational Quote
// Select a random Number for the selection of a quote page
NumOfFiles = 35;
QuoteNum = Math.floor(Math.random() * NumOfFiles) + 1;
if (QuoteNum < 10) QuoteNum = '00' + QuoteNum;
if (QuoteNum > 9 && QuoteNum < 100) QuoteNum = '0' + QuoteNum;

// Inspirational Moment Frame
frameA = '<iframe src="quotes/quote_';
frameB = QuoteNum;
frameC = '.html" name="quote" scrolling="no" width="480" height="80" align="center"></iframe>';
Inspiration = frameA + frameB + frameC;


