// header.js
//

var mod_date = new Date (document.lastModified);   

var onImages=new Array();

var i;

var gnDocuments = 1;
var gsDefaultName = '';

var agt = navigator.userAgent.toLowerCase();
var aname = navigator.appName;
var aver = parseInt(navigator.appVersion.substring(0,1));
var mie = false;

NS6 = (document.getElementById && !document.all)
IE = (document.all)
NS = (navigator.appName == "Netscape" && navigator.appVersion.charAt(0) == "4")

checkBrowser();

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

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

gsCurrentDoc = document.location.href.toLowerCase ();
gbCurrentHome = "F";
if ((gsCurrentDoc == "http://www.muscovytrading.com/") || (gsCurrentDoc == "http://www.muscovytrading.com/index.html"))
{
    gbCurrentHome = "T";
}

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

gnCurrentPos = gsCurrentDoc.indexOf ("com") + 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, '');

gasDocumentName[gnDocuments] = gsDefaultName + 'index';
gasDocumentTitle[gnDocuments] = 'Home';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'catalog';
gasDocumentTitle[gnDocuments] = 'Merchandise';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'wwwnews';
gasDocumentTitle[gnDocuments] = 'News';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'history';
gasDocumentTitle[gnDocuments] = 'History';
gnDocuments++;

gasDocumentName[gnDocuments] = gsDefaultName + 'clients';
gasDocumentTitle[gnDocuments] = 'Customers';
gnDocuments++;

document.write ('<LINK Rel=stylesheet HREF="/include/style.css" TYPE="text/css">');
//Generate transition CSS (transition=0 to 23)
document.write('<STYLE TYPE="text/css">.imgTrans{ filter:revealTrans(duration=0.4,transition=12) }</STYLE>');

//document.write ('Name: ', gsCurrentName);
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));

document.write (' <STYLE TYPE="text/css">');
document.write (' \#dek {POSITION:absolute\;VISIBILITY:hidden\;Z-INDEX:200\;}');
document.write (' </STYLE>');
document.write ('<DIV ID="dek"></DIV>');

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 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 ();

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
{

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

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

	// DATA CELL 1,1
    document.write ('<TD BackGround="/images/muscovy0.jpg" Width="45%" Align="Left" VAlign="Middle" BgColor="white">');
    //document.write ('<FONT Size=+1 Face="Verdana, Arial, Helvetica" COLOR="#2222CC">');
    document.write ('<FONT Size=+2 COLOR="#9999CC">');
	document.write ('<B>Muscovy Trading Company</B>');
    document.write ('</FONT>');
    document.write ('</TD>');

	// DATA CELL 1,2
    document.write ('<TD BackGround="/images/muscovy0.jpg" Width="45%" Align=Right vAlign="middle" BgColor="white">');
    document.write ('<FONT COLOR="#9999CC" SIZE="-3">');

    document.write ('<B>Updated: ');   

    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 ('</B></FONT>');
    document.write ('</TD>');

	// DATA CELL 1,3
    document.write ('<TD BackGround=/images/muscovy0.jpg Width="10%" Align=Right BgColor="white">');
    doc_name = document.location.pathname.toLowerCase ();

    document.write ('<A HREF="/index.html" Target="_top"><IMG ALIGN="bottom" ALIGN="center" Border=0 Src="/images/mtc_logo_137_na.gif" Width=50 ALT="Home Page" TITLE="Home Page"></A>');

    document.write ('</TD>');
    document.write ('</TR>');
    document.write ('</TABLE>');
    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>');

	// CHECK EACH DOCUMENT NAME IN LIST -- ONLY INCLUDE ANNOUNCEMENT ON 
	// MAIN PAGES
	for (i = 1; i < gnDocuments; i++)
	{
	    // CHECK IF CURRENT PAGE CONTAINS DOCUMENT #[i]	
	    //if (gsCurrentName.indexOf (gasDocumentName[i]) > -1)
	    //{
	//	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) 
	{
	    // IF THE CURRENT PAGE IS CALLED index AND IT IS NOT THE HOME PAGE'
	    // KEEP HOME PAGE AS A LINK
	    if ((gsCurrentName.indexOf ("index") > -1) && (gbCurrentHome == "F"))
	    {
		document.write ('<TD Class="MenuLink" Align="center" vAlign="middle">');
		// IF CURRENT DOCUMENT IS NOT THIS DOCUMENT # IN LIST, PRINT AS LINK
		document.write ('<A Class=MenuLink HREF="/', gasDocumentName[i], '.html" Target=_top>', gasDocumentTitle[i], '</A>');
	    }
	    else
	    {
		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 Class=MenuLink HREF="/', gasDocumentName[i], '.html" Target=_top>', 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 ('October 28, 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] = 'Orange County Police K-9<BR>Association Benefit Show';
	gnAnnounceLines++

	// LINE #1
	gasAnnounceStyle[gnAnnounceLines] = 'B14';
	gasAnnounceLine[gnAnnounceLines] = 'Sun, Oct 28';
	gnAnnounceLines++

	// LINE #2
	gasAnnounceStyle[gnAnnounceLines] = 'BI14';
	gasAnnounceLine[gnAnnounceLines] = '3:00 p.m. to 7:00 p.m.';
	gnAnnounceLines++

	// LINE #3
	gasAnnounceStyle[gnAnnounceLines] = 'B14';
	gasAnnounceLine[gnAnnounceLines] = 'Eddie West Field, Santa Ana<BR><HR>';
	gnAnnounceLines++

	// LINE #4
	gasAnnounceStyle[gnAnnounceLines] = 'BI10';
	gasAnnounceLine[gnAnnounceLines] = 'Vendors and Pet Adoption, 3-5 p.m., Police Canine Show, 5-7 p.m.';
	gnAnnounceLines++

	// LINE #5
	gasAnnounceStyle[gnAnnounceLines] = 'BI10';
	gasAnnounceLine[gnAnnounceLines] = 'ODPA Booth needs volunteers, 3-5 p.m.';
	gnAnnounceLines++;

	// LINE #6
	//gasAnnounceStyle[gnAnnounceLines] = 'BI10';
	//gasAnnounceLine[gnAnnounceLines] = 'text.';
	//gnAnnounceLines++;
	gasAnnounceStyle[gnAnnounceLines] = 'B10';
	gasAnnounceLine[gnAnnounceLines] = '<A HRef="http://www.muscovytrading.com/show.html">K-9 Show</A>';
	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);

	//document.write ('Current >', gnCurrent, '<  Expires >', gnExpires, '<');
	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>');
}

function checkBrowser()
{    
    if(aname.indexOf("Internet Explorer")!=-1)
    {
	if(aver >= 4)
	{
	    gbJavaEnabled=navigator.javaEnabled();
	}
	mie = true;
    }
    if(aname.indexOf("Netscape") != -1)
    {
	if(aver >= 4)
	{
	    gbJavaEnabled = navigator.javaEnabled();
	}
    }
}
