// JavaScript Document
// global variables

var prevField = null;

var field = null;

function fieldCheck(fieldname,value){


/* this function checks if a mandatory entry field has been skipped or if a valid email address has been entered for email fields. */

/* IE has a neat property of event which says what the current element is. We do this test as

 the blur event is raised when we select the erroneous field in order to highlight it. We don't want to come here twice */

  if (navigator.appName == "Microsoft Internet Explorer") 

    {

    if (prevField == event.srcElement.name) return;

    }

  else

    return true; 	//for the time being we will not run this in Navigator

    prevField = null;		// reinitialize erroneous field holder

		

/* IE and Navigator have different properties of event to hold the element where the event

 occurred */



  navigator.appName == "Microsoft Internet Explorer"? 

    field = event.srcElement : field = event.target;

  if (!value)

    {	// if value is null or undefined

    alert("Field '" + fieldname + "' is empty. Please replace the Xs with a value");  

    field.value = "XXXXXXXXXX";	//fill the field with Xs to flag it as requiring data

    }

  else 

    if (fieldname == "email" && value.indexOf("@") == -1) // if no @ in an email field

      

	alert("Field '" + fieldname + "' is not a valid email address. Please enter a valid email address");

    else 

      return true; // the data entered is valid, so exit



//the following code is executed if the value is invalid

	  

/* this method is supposed to stop the inferred blurring that occurs when focus is given,

 but it doesn't seem to work. */

/*  document.activeElement.blur(); */

 if (navigator.appName == "Microsoft Internet Explorer")

   prevField = document.activeElement.name;

 field.focus();

 field.select();

 return true;  	  

}	// function fieldCheck

//-->
