function MouseOn(IDName) 
// This function was extracted and modified based on similar functions found at
// "http://forums.devshed.com/archive/t-165929" posted by "doze"
{
	if (document.getElementById(IDName).filters) 
	{
		document.getElementById(IDName).filters[0].Apply();
		document.getElementById(IDName).style.visibility = "visible";
		document.getElementById(IDName).filters.revealTrans.transition = 12;
		document.getElementById(IDName).filters.revealTrans.Play();
	} 
	else 
    { document.getElementById(IDName).style.visibility = "visible"; }
}

function MouseOut(IDName) 
// This function was extracted and modified based on similar functions found at
// "http://forums.devshed.com/archive/t-165929" posted by "doze"
{
	if (document.getElementById(IDName).filters) 
	{
    document.getElementById(IDName).filters[0].Apply();
		document.getElementById(IDName).style.visibility = "hidden";
		document.getElementById(IDName).filters[0].transition = 12;
		document.getElementById(IDName).filters[0].Play();
	} 
	else 
  	{ document.getElementById(IDName).style.visibility = "hidden"; }
}

function AdjustYear(aDate)
{
	// getYear returns a two digit year which must be adjusted around the Year 2000
	// Check out http://www.quirksmode.org/js/lastmod.html for the original code
	// All changes made were to make the code more readable

	aYear = aDate.getYear();

	var FixedYear = aYear % 100;
	
	if (FixedYear < 38)    { FixedYear = FixedYear + 2000 }
	else			             { FixedYear = FixedYear + 1900 }
	
	return FixedYear;
}

function ElapsedModified()
{
	// Calculates the difference (in days) from the last modification of the web page
	// Check out http://www.quirksmode.org/js/lastmod.html for the original code
	// All changes made were to make the code more readable

	var ModifiedLocal = new Date (document.lastModified);

	ModifiedGMT = new Date(ModifiedLocal.toGMTString());
	ModifiedYear = AdjustYear(ModifiedGMT)
	ModifiedMonth = ModifiedGMT.getMonth();
	ModifiedDay = ModifiedGMT.getDate();

	ModifiedElapsed = (Date.UTC(ModifiedYear,ModifiedMonth,ModifiedDay,0,0,0))/86400000;

	TodayLocal = new Date();

	TodayGMT = new Date(TodayLocal.toGMTString());
	TodayYear = AdjustYear(TodayGMT);
	TodayMonth = TodayGMT.getMonth();
	TodayDay = TodayGMT.getDate();
	
	TodayElapsed = (Date.UTC(TodayYear,TodayMonth,TodayDay,0,0,0))/86400000;

	DaysBetween = TodayElapsed - ModifiedElapsed;

	if (DaysBetween < 0) return '';
	Unit = 'days';

	if (DaysBetween > 730)
	{
		DaysBetween = Math.floor(DaysBetween/365);
		Unit = 'years';
	}
	else if (DaysBetween > 60)
	{
		DaysBetween = Math.floor(DaysBetween/30);
		Unit = 'months';
	}
	else if (DaysBetween > 14)
	{
		DaysBetween = Math.floor(DaysBetween/7);
		Unit = 'weeks';
	}

	var Output = '';

	if (DaysBetween == 0) Output = Output + 'today';
	else if (DaysBetween == 1) Output = Output + 'yesterday';
	else Output = Output + DaysBetween + ' ' + Unit + ' ago';

	return Output;
}

function Buffer(Number)
{
  if (Number < 10)
    { Number = "0" + Number; }

  return Number;
}

function DateInBar()
{
  var TimeDate = new Date();

  var TimeHour = TimeDate.getHours();
  var TimeMinute = TimeDate.getMinutes();
  var TimeSecond = TimeDate.getSeconds();
  var AMPM = "";

  if (TimeHour > 11)
  {
    AMPM = "p.m.";
    TimeHour = TimeHour - 12;     // Corrects for military time
  }
  else
    { AMPM = "a.m."; }
  
  var TimeDisplay = Buffer(TimeHour) + ':' + Buffer(TimeMinute) + ':' + Buffer(TimeSecond) + AMPM;

  defaultStatus = "You arrived at this page at " + TimeDisplay;
}

//Preload images
ImageOn = new Image(128,25)
ImageOn.src = "http://www.ghrae.com/images/BlurMetalLa3.gif"

ImageOff = new Image(128,25)
ImageOff.src = "http://www.ghrae.com/images/BlurMetalLh3.gif"

function ChangeMenuImage(TheCell,OnOff,WinStatus)
// Found on "http://forums.devshed.com/t104187/s.html" posted by "Nasrim"
// Modified by Scott Miller

// OnOff = status of the menu background.  Value of "1" is On and a value of "0" is Off
{
  if (OnOff == 1)
  	{ document.getElementById(TheCell).style.backgroundImage = "url(" + ImageOn.src + ")"; }
	else
	  { document.getElementById(TheCell).style.backgroundImage = "url(" + ImageOff.src + ")"; }

	window.status = WinStatus;
}

function OpenWin(address,name,params)
{
	window.open(address,name,params+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no');
}

function popupWindow(url) 
{
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}

function PicScript(ImgName,AltName,TitleName)
{
  document.write('<a href="javascript:popupWindow(\'http://www.ghrae.com/picture.php?id=1\')"><img src="' + ImgName + '" border="0" alt="' + AltName + '" title="'+ TitleName + '" hspace="5" vspace="5"></a>');
}
