
/*******************************************************************************************
*
* functions.js - JavaScript functions
*
* Date Created: 07/07/05
* Last Update:  07/26/07
*
* History
*
*  07/19/05 (MH): - File creation
*	               - Initial content
*
*	06/19/07 (MH): - Formatted for template
*
*  06/22/07 (MH): - Added ExternalLinks template
*
*	07/26/07 (MH): - Template signoff
*
*******************************************************************************************/

/**************************************************************
*
* 
* Generic Functions
*
*
***************************************************************/

/**
*
* LoadImages - Preload images to be used on the site for 
*					quicker performance
*
*/
function LoadImages()
{
	menuButtonInvertedAbout= new Image()
	menuButtonInvertedAbout.src = "../images/menuButtonInvertedAbout.jpg"
}

/**
*
* ValidEmail - Checks for a valid email address
*
* Arguments
*
*  - address: The email address
*
* Returns
*
*  - True if valid
*
*/
function ValidEmail(address)
{
	var amp = address.indexOf("@");
	var period = address.indexOf(".");
	var result = true;

	if(amp == -1 || period == -1)
		result = false;

	return result;
}

/**
*
* ValidDate - Checks for a a valid date
* 
* Author: Matt Hartzell
*
* Last Updated: 7/10/05
* 
* Arguments
*
*  - day: The day
*  - month: The month
*  - year: The year
*
* Returns
*
*  - True if valid
*
*/
function ValidDate(day, month, year)
{
	var result = true;
	
	if(day == 31 && (month == 2 || month == 4 || month == 6 || month == 9 || month == 11))
	{
		result = false;
	}
	
	if((day == 28 || day == 29) && (month != 2))
	{
		result = false;
	}

	return result;
}

/**
*
* ExternalLinks - Makes links in a page external
*
* Copied from: http://www.sitepoint.com/article/standards-compliant-world/3
*
* Use: Set the rel attribute of an anchor to "external"
*
*/
function ExternalLinks() 
{
	if (!document.getElementsByTagName)
		return;

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) 
	{
		var anchor = anchors[i];
		
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
  			anchor.target = "_blank";
	}
} 

/**
*
* OnLoadFunction - Things to do when loading the page
*
*/
function OnLoadFunction()
{
	LoadImages();
	ExternalLinks();
}

/**************************************************************
*
* 
* OnLoad Directives
*
*
***************************************************************/

// Preload images
window.onload = OnLoadFunction;