<!-- hide me 


//Central Javascript Include File


/*******************
Date Function 
Returns today's date
*******************/

function getDate()
{
	// Days
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
	// Months
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December")
	var now = new Date()
	return(dayNames[now.getDay()] + " " + now.getDate() + " " + monthNames[now.getMonth()] + " " + now.getYear())
}


/*****************************************
This is the pop up window function.
With arguements for the URL, width, height
and whether or not to display scrollbars
*****************************************/

var s='no';
var popUpWindow = null;
var undefinedVariable;
var undefType = typeof undefinedVariable;

function pop(url,w,h,s){
   if (popUpWindow!=null) {
     var windowHasBeenClosed = (typeof popUpWindow.location == undefType ) ;
     if (!windowHasBeenClosed ){
     	 popUpWindow.close();
   	 }
   }
   settings="resizable=yes,toolbar=no,location=no,scrollbars=" + s + ", width=" + w + ",height=" + h + ",status=no";
   popUpWindow = open(url,"g", settings);

   if ( navigator.appVersion.indexOf("MSIE")==-1 ) {
     popUpWindow.resizeTo(w, h);
   }

}

	 



/***************************
login form function checks
something has been submitted
***************************/

function loginForm() 
{
	if (document.login.username.value == ''){ 
		alert("You must enter a valid username and password, or register with us") 
	}
	else { 
		document.login.submit() 
	}
}

/**************************
clears default login values
**************************/

function clearTxt()
{
	document.login.username.value=""
	document.login.password.value=""
}

/******************
Validation Routines
******************/

var emailregex = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*@([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*\.[a-z]{2,4}$/i


/***********************
Email Address validation
***********************/

function validateEmail(field) 
{
	var email = field.value
	if (emailregex.test(email)){
		return true
	}
	else{
		alert("This is not a valid E-mail Address: "+email)
		field.focus()
		return false
	}
}

/*********************
Check for Empty Values
*********************/

function isEmpty(field)
{
	var val = field.value
	
	if ((val==null) || (val=="")){
		return true
	}
	else{
		return false
	}
} 

/***********************
Get Required Field Names
***********************/

function getRequired(str) 
{
	var strLength, fields
	strLength = str.length
	
	if (strLength==0){
		fields = ""
	}
	else{
		fields = str.split(",")
	}
	return fields
}


/******************************
Validate fields and send Form
if OK or display alert message
******************************/

//Arguements: form, field containing list of required fields, field for email validation
function validateForm(which, required, email) {

	var vals = getRequired(required.value)
	var n    = vals.length
	var e    = which.length
	var msg  = ""
	
	for(i=0;i<e;++i) {
		var ele = which.elements[i]
		for(x=0;x<n;++x) {
			var nme = vals[x]
			if ((ele.name == nme) && (isEmpty(ele))){
				msg += ("Field "+ele.name+" must not be left blank\n")
			}
		}
	}
	
	//Display Errors
	if (msg != ""){
		alert(msg)
		return false
	}
	
	//Check Email
	if(email!=null){
		if(!validateEmail(email)){
			return false
		}
	}
	
	return true
}

/*************
Deletion Alert
*************/ 

function deleteAlert(str) {
	if (confirm(str)) {
		return true
	}
	else return false	
}

/******************
Goal Tally Function
******************/ 

function goalAlert(goals, total) {
	
	var tmp
	tmp = total.value
	
	total.value = parseInt(total.value) + parseInt(goals.value)
	
	if (total.value == "NaN"){
		alert("This is not a valid number of goals")
		goals.value = 0
		total.value = tmp
	}
	else{
		if (goals.value>3){
			alert("Are you sure they scored "+goals.value+" goals?!")
		}
	}
}
// end hiding -->