<!-- hide me
//Central Javascript Include File

// Preloading Images

image1 = new Image();
image1.src = "images/menubg01.gif";

image2 = new Image();
image2.src = "images/menubg11.gif";

image3 = new Image();
image3.src = "images/menubg31.gif";

image4 = new Image();
image4.src = "images/menubg4.gif";

image5 = new Image();
image5.src = "images/menubg5.gif";

image6 = new Image();
image6.src = "images/menubg6.gif";


/********
FUNCTIONS
*********/

/*************************
Set Focus on search fields
*************************/

function setfocus() { 
document.search.rg.focus(); 
} 


/*******************
Date Function 
Returns today's date
*******************/

function getDate()
{
	// Days
	var dayNames = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat")
	// Months
	var monthNames = new Array("Jan","Feb","Mar","Apr","May","June","July","Aug","Sept","Oct","Nov","Dec")
	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,h,w,t,l){
   if (popUpWindow!=null) {
     var windowHasBeenClosed = (typeof popUpWindow.location == undefType ) ;
     if (!windowHasBeenClosed ){
     	 popUpWindow.close();
   	 }
   }
   settings="resizable=yes,toolbar=no,location=no,scrollbars=auto, width=" + w +
",height=" + h + ",top=" + t + ",left=" + l + ",status=no";
   popUpWindow = open(url,"g", settings);

   if ( navigator.appVersion.indexOf("MSIE")==-1 ) {
     popUpWindow.resizeTo(w, h);
   }

}

/******************************
Basic PopUp function for 
displaying Registration Numbers
******************************/

function popup(file,h,w) {
  window.open(file,"popup","height=" + h + ",width=" + w + ",left=200,top=200,menubar=no,location=no,scrollbars=auto,status=no,resize=yes");
}

/******************
Validation Routines
******************/

var emailregex = /^([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]+))*@([a-z0-9]+)([.,_,-]([0-9,a-z,A-Z]+))*\.[a-z]{2,4}$/i


/***********************
Email Address validation
***********************/

function validateEmail(field,frm) 
{
	var email = field.value
	if (emailregex.test(email)){
                if ((frm!=null) && (frm!="")){
                        document.frm.submit()
                }
		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, password) {

	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
		}
	}
        
        //Check Passwords
        if (password.value != which.password2.value){
                alert("Password must be identical in both boxes")
                return false
        }
	
	return true
}

// end hiding -->
