/**************************************************
	mlf_lib.js
	Midlife Flight JavaScript Library
	Functions called by multiple pages

	Place <SCRIPT LANGUAGE="JavaScript" SRC="ref/mlf_lib.js"></SCRIPT> in the page <HEAD>
**************************************************/

/**************************************************
  txtModDate: shows the last modified date in a text string
	Paste <SCRIPT LANGUAGE="JavaScript">txtModDate()</SCRIPT> into page to show date
**************************************************/
function txtModDate(){
modDate = new Date(document.lastModified);
day = modDate.getDate();
month = modDate.getMonth();
year = modDate.getYear();
	if (year < 2000)
	year = year + 1900;
weekday = modDate.getDay();

  //Arrays to assign text to days and months
    dayArray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    monthArray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September",  "October", "November", "December") ;

txtWeekday = dayArray[weekday];
txtMonth = monthArray[month];

modDateString = "This page was last modified " + txtWeekday + ", " + txtMonth + " "
modDateString += + day + ", " + year + ".  "

document.write(modDateString)
}


/**************************************************
  Zulu Time:  Returns and updates times in local and Zulu format in a text box
  It's made up of a number of functions that perform a set of tasks interdependently.
**************************************************/
function stopclock (){
timerID = null;
timerRunning = false;
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}

function showtime () {
IE3 = (navigator.appName.indexOf('Microsoft') >= 0
        && parseInt(navigator.appVersion) < 4);
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
utcOffset=now.getTimezoneOffset()/60;
     //Correction for error in IE3 interpretation
if (IE3) utcOffset = -utcOffset;
utcHours=hours + utcOffset
timeValue = "" + ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += (hours >= 12) ? " PM" : " AM"
utcValue = ((utcHours >= 24) ? "0" + (utcHours -24) : ((utcHours <10) ? "0" + utcHours : utcHours))
utcValue += ((minutes < 10) ? "0" : "") + minutes + " Zulu"
document.timedisplay.displayface.value="" + utcValue + " -- " + timeValue + " Local"
timerID = setTimeout("showtime()",10000);
timerRunning = true;
}

function startclock() {
stopclock();
showtime();
}



/**************************************************
  Preload images script
  By JavaScript Kit (http://javascriptkit.com)
  Over 400+ free scripts here!

	Mark's additon: buttonPreload calls preloadimages
	in the onload event
**************************************************/

var myimages=new Array()
function preloadimages(){
for (i=0;i<preloadimages.arguments.length;i++){
myimages[i]=new Image()
myimages[i].src=preloadimages.arguments[i]
}
}

//Enter path of images to be preloaded inside parenthesis. Extend list as desired.
// 8/30/2002. Used relative paths so that the source in the script and the
// source in the page are the same.

function buttonPreload(){
preloadimages("images/mnuindex_mo.gif","images/mnulearn_mo.gif","images/mnulinks_mo.gif","images/mnuplaces_mo.gif","images/mnustories_mo.gif","images/mnuwhymlf_mo.gif","images/mnuguest_mo.gif")
}


/**************************************************
	PopMsg:	Opens url in a pop-up window
					Used for mail form and some information screens
**************************************************/
function PopMsg (url) {
var msg=window.open(url,"","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=450,height=400");
msg.focus();
}


/**************************************************
	pickListItem: Opens the url chosen out of an option list
								Used in Places and Stories pages
	(Currently called goPlaces -- change in the primary pages)
**************************************************/
function pickMe(selectObj){
var i=selectObj.selectedIndex;
var URL = selectObj.options[i].value;
window.location.href = URL;
}

/**************************************************
	formCheck: mail form validation.
**************************************************/
function formCheck() {
	if (document.msgForm.realname.value=="") {
		alert("May I please have your name?");
		document.msgForm.realname.focus();
		return false
	}

	if (document.msgForm.email.value=="") {
		alert("May I please have your email address?");
		document.msgForm.email.focus();
		return false
	}

	if (document.msgForm.email.value.indexOf('@',
	0) == -1 || document.msgForm.email.value.indexOf('.') == -1) {
		alert("Sorry, but that doesn't look right. Please check your email address");
		document.msgForm.email.focus();
		return false
	}
}

/**************************************************
  emai_nospam: breakes up the email address into code snippets.
  The email address shows up on the page and as a mailto property,
  but doesn't appear in the source (which supposedly is what the
  spambots are reading. The addresses have also all been changed
  to xxx.web@ addresses as an additional precaution.

  Paste <SCRIPT LANGUAGE="JavaScript">email_nospam("xxx with the
  quotes")</SCRIPT> into page.
**************************************************/
function email_nospam(ename){
var etag="@";
var elink="full@name.com";
var ename2=".web";
var ehost="midlife";
var ehost2="flight"
var etld=".com";
document.write("<a href="+"mail"+"to:"+ename+ename2+etag+ehost+ehost2+etld+
">"+ename+ename2+etag+ehost+ehost2+etld+"</a>")
}


/**************************************************
  emai_subj_nospam: Same as emal_nosapm, but add a default
  subject.

  Paste <SCRIPT LANGUAGE="JavaScript">email_subj_nospam("xxx","yyy")
  </SCRIPT> into page (with the quotes)
**************************************************/
function email_subj_nospam(ename,esubj){
var etag="@";
var etag2="?subject=";
var elink="full@name.com";
var ename2=".web";
var ehost="midlife";
var ehost2="flight"
var etld=".com";
document.write("<a href="+"mail"+"to:"+ename+ename2+etag+ehost+ehost2+etld+etag2+esubj+
">"+ename+ename2+etag+ehost+ehost2+etld+"</a>")
}