var thisMonth = new Array ("January", "February", "March", "April", "May", "June",
                           "July", "August", "September", "October", "November", "December");
var thisDay = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", 
                         "Friday", "Saturday");
var JAN = 0;
var FEB = 1;
var MAR = 2;
var APR = 3;
var MAY = 4;
var JUN = 5;
var JUL = 6;
var AUG = 7;
var SEP = 8;
var OCT = 9;
var NOV = 10;
var DEC = 11;					   

function showYear() {
   rightNow = new Date();
   thisYear = rightNow.getYear();
   if (thisYear < 1900) {
      thisYear += 1900;
   }
   document.write(thisYear);
}

function writeDate() {
   rightNow = new Date();
   thisYear = rightNow.getYear();
   if (thisYear < 1900) {
      thisYear += 1900;
   }
   document.write(thisDay[rightNow.getDay()] + ", " + thisMonth[rightNow.getMonth()] + " " + rightNow.getDate() + ", " + thisYear);
}

function specialAnnouncent() {
   var rightNow = new Date();
   //rightNow.setMonth(0);
   //rightNow.setDate(1);
   //alert(rightNow.getTime());  
   //var eventTime = new Date(1041465059890);  // date for January 1, 2003
   var eventTime = new Date(1072933200000);  // date for January 1, 2004
   var eventTime2 = new Date(2005, 04, 06, 19, 30, 00); 
   var eventTime3 = new Date(2005, 04, 13, 19, 30, 00); 
   var eventTime4 = new Date(2005, 04, 27, 19, 30, 00);
   var eventTime5 = new Date(2005, 06, 04, 12, 00, 00);
 
   // var eventTime3 = new Date(1072933200000); 
   // set the month and date to set a deadline date
   
   //eventTime.setMonth(11);
   eventTime.setMonth(11)
   eventTime.setDate(10);
   eventTime.setHours(19);
   eventTime.setMinutes(0);
   thisYear = eventTime.getYear();
   
  
   //thisYear = eventTime.getYear();
   
   //alert (thisDay[eventTime.getDay()] + ", " + thisMonth[eventTime.getMonth()] + " " + eventTime.getDate() + ", " + thisYear);
   var specAnnounce = document.getElementById("specAnnounce");
   if (rightNow < eventTime2) { 
     document.write("<b>DeMolay to present Flower Talk (Mother's Talk) at Ridgewood Chapter #39 OES<br /><hr />");
   }
   if (rightNow < eventTime3) { 
     document.write("<b>Fellowcraft Degree May 13th, 7:30 pm<br /><br /><hr />");
   }
   if (rightNow < eventTime4) {
    document.write("<b>Official Visit of the DDGM for presentation of Golden Tokens, May 27th</font><br /><hr />");
	}
    if (rightNow < eventTime5) {
	   document.write("<b>We will again be marching in the <font color=\"maroon\">Ridgewood Independence Day Parade.</font> Information to follow!</b><br />");
	}
   else {
      document.write("Please look here for special announcements and events for our lodge.");
  }
   //var nextYear = new Date(2004, 0, 1);
   //document.write("nextYear is " + nextYear.getTime());
}

function getMeetingDate() {
   //alert("hello");
   //xxxxxxxxx
   var theFinalDate = new Date();
   var thisDate = theFinalDate.getDate();
   var dateFound = "false";
   while (dateFound == "false") {
     thisDate = theFinalDate.getDate();
     //alert(theFinalDate.getMonth() + " " + theFinalDate.getDate());
     if (theFinalDate.getMonth() == JUL || theFinalDate.getMonth() == AUG) {
	   dateFound = "false";
	 }
	 else if (theFinalDate.getDay() != 5) {
	   dateFound = "false";
	 }
	 else if (dateInRange(theFinalDate) == "false") {
	   dateFound = "false";
	 }
     else {
	   dateFound = "true";
	 }
	 //alert(thisDay + " " + dateFound);
	 if (dateFound == "false"){
	   //alert(thisDate);
	    thisDate++;
		//alert(thisDate);
	    theFinalDate.setDate(thisDate);
	 }
	 
	} 
   //alert("out of while");
   var theCorrectYear = theFinalDate.getYear();
   if (theCorrectYear < 1900) {
      theCorrectYear += 1900;
   }
   document.write(thisDay[theFinalDate.getDay()] + ", " + thisMonth[theFinalDate.getMonth()] + " " + theFinalDate.getDate() + ", " + theCorrectYear);  
}

function dateInRange(theDate) {
  returnVal = "false";
  if (theDate.getMonth() == NOV || theDate.getMonth() == DEC) {
     if (theDate.getDate() >= 8 && theDate.getDate() <= 14) {
	   returnVal = "true";
	 }
  }
  else if (theDate.getDate() >= 8 && theDate.getDate() <= 14) {
    returnVal = "true";
  }
  else if (theDate.getDate() >= 22 && theDate.getDate() <= 28) {
    returnVal = "true";
  }
  return returnVal;
}

function dayGreeting() {
  var rightNow = new Date();
  if (rightNow.getHours() < 12) {
     document.write("Good morning, and ");
  } else if (rightNow.getHours() < 18) {
     document.write("Good afternoon, and ");
  } else {
    document.write("Good evening, and ");
  }
}

// <a href="mailto:gmfirkser86@aol.com">webmaster</a>

function writeEmail(handle, isp, theText) {
   var tempAddress = new String();
   tempAddress = handle + "@" + isp;   
   var eAddress = new String("<a href=\"mailto:");
   eAddress += (tempAddress + "\">");
   if (theText == null || theText.toLowerCase() == "email") {
      eAddress += (tempAddress + "</a>");
   } else {
      eAddress += (theText + "</a>");
   }
   document.write(eAddress);
}

function historyLinks() {
   var thisURL = document.URL;
   alert(thisURL.indexOf("history"));
   //var thisPage = thisURL.subString(thisURL.indexOf("history"));
   //alert(thisPage);
   if (thisURL.indexOf("historyintro.html") == -1) {
      document.write("<td><a href=\"historyintro.html\">Introduction/Contents</a></td>")
   }
   
}

function getDaysToClass() {
     //alert("hello");
     var classDate = new Date(2005, 02, 19, 00, 00, 00); 
	 var rightNow = new Date();
	 rightNow.setMinutes(0);
	 rightNow.setHours(0);
	 if (rightNow < classDate) {
	   var rightNowMS = rightNow.getTime();
	   var classDateMS = classDate.getTime();
	   var timeDiff = classDateMS - rightNowMS;
	   var dayDiff =  Math.round((((timeDiff/1000)/60)/60)/24);
	   //alert (dayDiff + " days to go");
	   document.write("<br />" + dayDiff + " days until the Grand Lodge One Day Class");
	  }
 }

function printMod(){
  var lastMod = document.lastModified;
   var nav = navigator.appName;
   var isExplorer = false;
  var theLastMod = new Date(lastMod);

  if (nav.indexOf("Explorer") > -1) {
     isExplorer = true;
  }

  if (isExplorer) {
    var theIndex = lastMod.substr(0,2);
    var theIndex2 = lastMod.substr(3,2);
    var theIndex3 = lastMod.substr(6,4);
    document.write("This page last modified: " + thisDay[theLastMod.getDay()]  + ", " + thisMonth[theIndex - 1] + " " + theIndex2 + ", " + theIndex3);
  }
  else {
      document.write("This page last modified: " + lastMod);
  }
}


