// header.js
//

var i;

var gnDocuments = 1;
var gsDefaultName = '';

//document.write ('Host: ', location.host);

gsCurrentPath = document.location;
//document.write ('<BR>Path: ', gsCurrentPath, '<BR>');

gsCurrentDoc = document.location.href.toLowerCase ();
//document.write ('Orig: ', gsCurrentDoc, '<BR>');

gnLenDoc = gsCurrentDoc.length;
//document.write ('Len: ', gnLenDoc, '<BR>');

gnCurrentPos = gsCurrentDoc.indexOf ("org") + 3;
//document.write ('Pos: ', gnCurrentPos, '<BR>');

gnPosDoc = gnLenDoc - gnCurrentPos;
//document.write ('Doc: ', gnPosDoc, '<BR>');

gsCurrentName = gsCurrentDoc.substr (gnCurrentPos, gnPosDoc);
//document.write ('Name: ', gsCurrentName);

//document.write ('Path: ', gsDefaultPath, '<BR>');
//document.write ('BASE Href=', gsCurrentPath);

gasDocumentName = new createDocList (10, '');
gasDocumentTitle = new createDocList (10, '');

if (location.host.indexOf ("webcom") > -1)
{

	document.write ('<BASE Href="http://www.st-mike.org">');
	//gsDefaultName = "www.st-mike.org/"
}
gasDocumentName[gnDocuments] = gsDefaultName + 'welcome';
gasDocumentTitle[gnDocuments] = 'Home';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'educate';
gasDocumentTitle[gnDocuments] = 'Education';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'english';
gasDocumentTitle[gnDocuments] = 'Reenactment';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'rpfs';
gasDocumentTitle[gnDocuments] = 'Southern';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'rpfn';
gasDocumentTitle[gnDocuments] = 'Northern';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'sm_user';
gasDocumentTitle[gnDocuments] = 'Users';
gnDocuments++;

document.write ('<LINK Rel=stylesheet HREF="/include/style.css" TYPE="text/css">');

if (gsCurrentName == '/')
{
    gsCurrentName = '/welcome';
}
gnCurrentLength = gsCurrentName.length;
gsCurrentPage = gsCurrentName.substring(1, gnCurrentLength);
gsCurrentTitle = document.title + '(' + gsCurrentPage + ')';

var agt=navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);

this.ie = (agt.indexOf("msie") != -1);
this.ie3 = (this.ie && (this.major < 4));

this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1))

this.nav4 = (this.nav && (this.major == 4));

if (this.ie3)
{
	document.write ('<TABLE border="0" width="100%" cellpadding=3 cellspacing=0>');
	document.write ('<TR>');
	document.write ('<TD width="700" ALIGN="right" VALIGN="middle">');
    document.write ('<FONT face="Verdana, Arial, Helvetica" COLOR="#000000" SIZE="-3">');

	document.write ('Internet Explorer (old): ', agt, ', ', this.major, ', ', this.minor);
	document.write ('</FONT>');
	document.write ('</TD>');
	document.write ('</TR>');
	document.write ('</TABLE>');
	document.write ('<HR SIZE="1" ALIGN="RIGHT" WIDTH="50%">');
}
else
{
    var DOWArray = new initArray ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");   
    var MOYArray = new initArray ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");   

    var mod_date = new Date (document.lastModified);   

    var hours = mod_date.getHours ();
    var minutes = mod_date.getMinutes ();
    var seconds = mod_date.getSeconds ();

    var timeValue = "" + ((hours > 12) ? hours - 12 : hours);

    var currname = document.location.pathname.toLowerCase ();

    timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
//    timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
    timeValue += (hours >= 12) ? " p.m." : " a.m.";

    document.write ('<TABLE Border="0" Width="100%" CellPadding=3 CellSpacing=0>');
	// ROW 1
    document.write ('<TR>');

	// DATA CELL 1,1
    document.write ('<TD Width="350" Align="Left" VAlign="Middle" BgColor="Black">');
    document.write ('<FONT Face="Verdana, Arial, Helvetica" COLOR="White">');
	document.write ('<B>St. Michael\'s Living History</B>');
    document.write ('</FONT>');
    document.write ('</TD>');

	// DATA CELL 1,2
    document.write ('<TD Width="350" Align="Right" VALIGN="middle" BGCOLOR="black">');
    document.write ('<FONT face="Verdana, Arial, Helvetica" COLOR="white" SIZE="-3">');
    document.write ('Page updated on: ');   
    document.write (DOWArray[(mod_date.getDay()+1)], ', ');   
    document.write (MOYArray[(mod_date.getMonth()+1)], ' ');   
    document.write (mod_date.getDate (), ', '); 
    if (navigator.appName == ("Netscape"))
    {
		document.write (mod_date.getYear () + 1900);
    }
    else
    {
		document.write (mod_date.getYear ());
    }
 
    document.write (', ', timeValue);
    document.write ('</FONT>');
    document.write ('</TD>');

	// DATA CELL 1,3
    document.write ('<TD BGCOLOR="black">');
    doc_name = document.location.pathname.toLowerCase ();

	if (location.host.indexOf ("st-mike.org") > -1)
	{
		document.write ('<A HREF="http://www.st-mike.org/welcome.html"><IMG ALIGN="bottom" ALIGN="center" BORDER="1" SRC="http://www.st-mike.org/images/tenticon.gif" ALT="Home Page" TITLE="Home Page"></A>');
	}
	else
	{
		document.write ('<A HREF="welcome.html"><IMG ALIGN="bottom" ALIGN="center" BORDER="1" SRC="images/tenticon.gif" ALT="Home Page" TITLE="Home Page"></A>');
	}

    document.write ('</TD>');
    document.write ('</TR>');
    document.write ('</TABLE>');

	document.write ('<CENTER>');

	// CREATE OUTER TABLE WITH A BORDER AND 1 DATA CELL CONTAINING THE INNER TABLE
	document.write ('<TABLE Border="1" Width="100%" CellPadding="0" CellSpacing="0"><TR><TD>');

	// CREATE INNER TABLE
	document.write ('<CENTER><TABLE Border="0" Width="100%" CellPadding="3" CellSpacing="0"><TR>');

	menuBar();

	// CLOSE INNER TABLE
	document.write ('</TD></TABLE>');
	// CLOSE OUTER TABLE
	document.write ('</TD></TR></TABLE>');
	document.write ('</CENTER>');

	hostAnnounce ();
}

// MENU BAR
function menuBar()
{
	var i;

	// CHECK EACH DOCUMENT NAME IN LIST
	for (i = 1; i < gnDocuments; i++)
	{

		// CHECK IF CURRENT PAGE CONTAINS DOCUMENT #[i]	
		if (gsCurrentName.indexOf (gasDocumentName[i]) > -1)
		{
			document.write ('<TD Class="MenuCurr" Align="center" vAlign="middle">');
			// IF CURRENT DOCUMENT IS THIS DOCUMENT # IN LIST, USE BOLD TITLE
			document.write ('<B>', gasDocumentTitle[i], '</B>');
		}
		else
		{
			document.write ('<TD Class="MenuLink" Align="center" vAlign="middle">');
			// IF CURRENT DOCUMENT IS NOT THIS DOCUMENT # IN LIST, PRINT AS LINK
			document.write ('<A HREF="/', gasDocumentName[i], '.html">', gasDocumentTitle[i], '</A>');
			//document.write ('<A HREF="http://www.st-mike.org/', gasDocumentName[i], '">', gasDocumentTitle[i], '</A>');
		}
		document.write ('</TD>');
	}
}

// INITIALIZE ARRAY
function initArray() 
{  
    this.length = initArray.arguments.length;
    for (var i = 0; i < this.length; i++)      
    {
		this[i+1] = initArray.arguments[i];
    }
}   

// REQUIRED JAVASCRIPT FUNCTION TO CREATE ARRAYS/LISTS
function createDocList(n, init)
{
	this.size = n;
	for (i = 1; i <= n; i++)
	{
		this[i] = init;
	}
	return this;
}

function hostAnnounce()
{
    var i = 0;
    var gsExpireDate;
    var gsTodaysDate;
    var gsExpireTest;
    var gsTodaysTest;
    var gnCurYear;
    var gnExpYear;
    var gnExpires;
    var gnCurrent;

    var MONArray = new initArray ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");   

	// STEP:1
	// ENTER ANNOUNCEMENT EXPIRATION DATE IN "Month Date, Year" FORMAT
	// e.g. 'December 31, 1999'
	var gsExpireDate = new Date ('April 8, 2001');

	// ANNOUNCEMENT LINE COUNTER
	var gnAnnounceLines = 0;

	gasAnnounceLine = new createDocList (10, '');
	gasAnnounceStyle = new createDocList (10, '');

	// STEP:1
	// ENTER TEXT AND FONT STYLE FOR AS MANY LINES AS DESIRED
	// FONTS:  B=Bold, I=Italic, 10-18=Point Size
	// LINE #0
	gasAnnounceStyle[gnAnnounceLines] = 'B18';
	gasAnnounceLine[gnAnnounceLines] = 'Work Shops Rained Out!';
	gnAnnounceLines++

	// LINE #1
	gasAnnounceStyle[gnAnnounceLines] = 'B12';
	gasAnnounceLine[gnAnnounceLines] = 'Saturday, April 7, 2001';
	gnAnnounceLines++

	// LINE #2
	gasAnnounceStyle[gnAnnounceLines] = 'B10';
	gasAnnounceLine[gnAnnounceLines] = 'Rehearsals cancelled.  Everything Re-Scheduled for Sunday, 4/8';
	gnAnnounceLines++

	// LINE #3
	gasAnnounceStyle[gnAnnounceLines] = 'BI12';
	gasAnnounceLine[gnAnnounceLines] = '<HR>';
	gnAnnounceLines++

	// LINE #4
	gasAnnounceStyle[gnAnnounceLines] = 'I10';
	gasAnnounceLine[gnAnnounceLines] = 'Check here for updates -- St. Michael\'s Staff';
	gnAnnounceLines++

	gsTodaysDate = new Date ();

	if (navigator.appName == ("Netscape"))
	{
		gnCurYear = gsTodaysDate.getYear () + 1900;
		gnExpYear = gsExpireDate.getYear () + 1900;
	}
	else
	{
		gnCurYear = gsTodaysDate.getYear ();
		gnExpYear = gsExpireDate.getYear ();
	}

	gsTodaysTest = MONArray[(gsTodaysDate.getMonth()+1)] + ' ' + gsTodaysDate.getDate () + ', ' + gnCurYear;

	gsExpireTest = MONArray[(gsExpireDate.getMonth()+1)] + ' ' + gsExpireDate.getDate () + ', ' + gnExpYear;

	gnExpires = Date.parse (gsExpireTest);
	gnCurrent = Date.parse (gsTodaysTest);

	if (location.host.indexOf ("webcom") > -1)
	{
		document.write ('<BR>');
		document.write ('<CENTER><TABLE Border="5" CellSpacing=0 Width="50%" BgColor="White"><TR><TD Align="Center">');
		// INNER TABLE
		document.write ('<TR><TD Align="Center"><FONT Size="+2"><B>FINAL NOTICE!</B></FONT><BR>');
		document.write ('<B><I>We Are Moving off of Webcom.</I></B><BR>');
		document.write ('to <B>&lt; <A HREF="http://www.st-mike.org"> http://www.st-mike.org </A> &gt;.</B></TD></TR>');
		document.write ('<TR><TD Align="Center">If you arrived here via<BR>');
		document.write ('<B>', location.hostname, '</B><BR>');
		document.write ('please bookmark our new URL.</TD></TR></TABLE><BR>');
		document.write ('</TD></TR></TABLE></CENTER>');
		document.write ('<BR>');
	}
	else
	{
		if (gnExpires < gnCurrent)
		{
			return
		}

		document.write ('<BR>');
		// OUTER TABLE
		document.write ('<CENTER><TABLE Border=5 CellSpacing=0 Width="50%" BgColor="White"><TR><TD Align="Center">');
		// INNER TABLE
		document.write ('<TABLE Border="0" BgColor="White">');

		for (i = 0; i < gnAnnounceLines; i++)
		{

			document.write ('<TR><TD Align="Center" Class="', gasAnnounceStyle[i], '">');
			document.write (gasAnnounceLine[i]);
			document.write ('</TD></TR>');
		}

		document.write ('</TABLE>');
		document.write ('</TD></TR></TABLE></CENTER>');

		document.write ('<CENTER><FONT Color=Blue Size=-2>');
		document.write ('Announcement Expires after ', gsExpireTest);
		document.write ('</CENTER></FONT><BR>');
	}
}

