
/*******************************************************************************************
*
* 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();
}

/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var baseopacity=30

function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",50)
}

function slowlow(which2){
cleartimer()
instantset(baseopacity)
}

function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}

function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}

function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}

// HV Menu v5.411- by Ger Versluis (http://www.burmees.nl/)
// Submitted to Dynamic Drive (http://www.dynamicdrive.com)
// Visit http://www.dynamicdrive.com for this script and more

// function Go(){return}

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

// Preload images
window.onload = OnLoadFunction;
