<!-- Hide code from non-js browsers
//alert("loading this basicjs.js")
//Basic JS Functions for page validation
//cleanAndSet(field) :- This checks a numeric field and sets it to zero if empty
//getFullYear(date) :- gets the 4 digit year for a valid date
//getActualMonth(date) :- gets the month digit for a valid date and increments it by one ie January is 1
//getCalendarMonth(date) :- returns the month name for a valid date
//dateString(date) :- uses the 3 above to return a date string
//timeString(date) :- returns an am or pm time string
//getRadioValue(radioObject) :- returns the values of the selected radio button
//getSelectValue(selectObject) :- returns the value of the selected pulldown
//getCheckValue(checkbox) :- returns the value of the selected checkbox
//twoPlaces(total) :- returns a number with two decimal places
//checkDateObj(fieldObj,millenium) :- checks validity of a field for a date and uses checkDate(fieldObj,millenium)
//  Now only allows 4 digit dates
//  SUPERCEDED by above note >> if the millenium parameter is set to TRUE then if a two digit date was used and when 1900 is added it is less than 1998 it adds 100
//  SUPERCEDED by above note >> ie 00 --> 1900 is less than 1998 so add 100 ie 2000
//checkDate(fieldValue,millenium) :- checks a non empty value for date validity (for millenium parameter see above)
//calcddmmyy(fieldValue) :- takes a value and attempts to convert it and return values of dd,mm & yy
//CheckNum(str,startPos) :- returns the position within a string of the first non-number (used by calcddmmyy(fieldValue))
//removeSpaces(fieldValue):- removes spaces at the beginning of a field
//isEmail(emailFieldObj,noAlert):- validates an email field and if noAlert is TRUE then returns an error message
//isEmpty(s) :- Check whether string s is empty
//isWhitespace(s) :- Returns true if string s is empty or whitespace characters only.
//stripCharsNotInBag(s,bag) :- Removes all characters which do NOT appear in string bag from string s.
//stripCharsNotInBagTidy(s,bag) :- Removes all characters which do NOT appear in string bag from string s & removes leading & trailing spaces.
//stripCharsInBag (s, bag) :- Removes all characters which appear in string bag from string s.
//replaceString(oldS,newS,fullS) :- Replaces oldS with newS in the string fullS
//cleanUpText (fieldValue) :- Removes unacceptable characters and replaces tabs with 4 spaces, commas with single spaces, and returns with '|'
//fixDate(date) :- fixes a bug in Netscape 2.0 
//setCookie(name, value, expires, path, domain, secure):- sets the desired cookie
//getCookie(name):- gets the desired cookie
//deleteCookie(name, path, domain) :- gets the desired cookie
//Date.prototype.getFullYear = getFullYear
//Date.prototype.getActualMonth = getActualMonth
//Date.prototype.getActualDay = getActualDay
//Date.prototype.getCalendarMonth = getCalendarMonth


//These are the 'bags' of characters
var digits = "0123456789";
var lowercaseLetters = "abcdefghijklmnopqrstuvwxyz"
var uppercaseLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
var lettersOnly=lowercaseLetters+uppercaseLetters
var whitespace = " \t\n\r";
var decimalPointDelimiter = "."
var phoneNumberDelimiters = "()- ";
// characters which are allowed in UK phone numbers
var validUKPhoneChars = digits + phoneNumberDelimiters;
var validWorldPhoneChars = digits + phoneNumberDelimiters + "+";
// non-digit characters which are allowed in credit card numbers
var creditCardDelimiters = " "
var nameChars= lowercaseLetters + uppercaseLetters +" -"
var PCChars= lowercaseLetters + uppercaseLetters + digits
var addressChars = nameChars+digits
var dateChars = digits + ".\\/- "
var textChars = nameChars + "-:,"+whitespace
var fileChars = lowercaseLetters + uppercaseLetters+digits+"-"
var emailChars = lowercaseLetters + uppercaseLetters+digits+"-@_."
//var br=""

// CONSTANT STRING DECLARATIONS
// m is an abbreviation for "missing"
var mPrefix = "You did not enter a value into the "
var mSuffix = " field. We need this informnation to process your enquiry. Please enter it now."

// i is an abbreviation for "invalid"
var iEmail = "This field must be a valid email address (like foo@bar.com). Please reenter it now."
var iCreditCardPrefix = "This is not a valid "
var iCreditCardSuffix = " credit card number."

// p is an abbreviation for "prompt"
var pEntryPrompt = "Please enter a "
var pEmail = "valid email address (like foo@bar.com)."
var pCreditCard = "valid credit card number."

// Routine to define the newline string 'rr'
//var rr="\n"; 
//if (navigator.appVersion.IndexOf('Win')>-1){ 
//	rr="\r\n"; 
//} 

//End of constant definitions

// Detect if browser is Netscape 3 + or IE 4 +.
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
    if ((bName == "Netscape" && bVer >= 3) || 
        (bName == "Microsoft Internet Explorer" && bVer >= 4)) br = "n3"; 
    else br = "n2";
	 
// Function to "activate" images.
function imgAct(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "on.src");
    }
}

// Function to "deactivate" images.
function imgInact(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "off.src");
    }
}

// Function to "click" images.
function imgCl(imgName) {
    if (br == "n3") {
    document[imgName].src = eval(imgName + "cl.src");
    }
}




function makeArray() {
  var args = makeArray.arguments;
  for (var i = 0; i < args.length; i++) {
    this[i] = args[i];
  }
  this.length = args.length;
}

function setCookie(name, value, expires, path, domain, secure) {
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}
}


function getCookie(name) {
// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}


function deleteCookie(name, path, domain) {
// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
if (getCookie(name)) {
document.cookie = name + "=" + 
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

function fixDate(date) {
// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}


function makeRemote(width,source) {
	remote = window.open("","remote","width="+width+",height=400,scrollbars=1");
	if (remote.opener == null) remote.opener = window; 
	remote.opener.name = "opener";
	//alert(source)
	remote.location.href = source;
	remote.focus();
}



//Function to display infoBox (a customised alert with options to ignore message
//or go back to the field where the error originated and reneter data
//gives unpredictable returns

function infoBox()
{
infoBox = window.open("","infoBox","height=240,width=300,scrollbars=no,resizable=yes,menubar=no")
		if (infoBox.opener == null) infoBox.opener = window; 
        infoBox.opener.name = "opener";
		infoBox.focus()
		infoBox.document.writeln("<HEAD><TITLE>Information</TITLE></HEAD><BODY>")
		infoBox.document.writeln("testing")
		infoBox.document.writeln("<FORM>")
		infoBox.document.writeln("<INPUT TYPE=button NAME=ignore VALUE=\"Ignore & carry on\" onclick=\"infoBox.close();opener.focus()\">")
		infoBox.document.writeln("</FORM></BODY>")
		infoBox.document.close()
}
		
function cleanAndSet(field) {
//This checks a numeric field and sets it to zero if empty
//& returns an integer
if (isWhitespace(eval(field+".value"))) {eval(field+".value ='0'")}
//alert (eval(field+".value"))
eval(field+".value = stripCharsNotInBag("+field+".value,digits)")
//alert (eval(field+".value"))
if (isWhitespace(eval(field+".value"))) {eval(field+".value ='0'")}
return (eval("parseInt("+field+".value)"))
}

		
		
function getFullYear(date)
{ 
	var n = date.getFullYear()
	alert ("getFullYear is "+n)
	return n 
} 

function getActualMonth(date)
{ 
	var n = date.getMonth()
	n += 1 
	return n 
} 

function getActualDay(date)
{ 
	var n = date.getDate()
	n += 1 
	return n 
} 
        
function getCalendarMonth(date) 
{ 
	 var n = date.getMonth()
	 var moy = new Array(12)
	 moy[0] = "January" 
	 moy[1] = "February" 
	 moy[2] = "March" 
	 moy[3] = "April" 
	 moy[4] = "May" 
	 moy[5] = "June" 
	 moy[6] = "July" 
	 moy[7] = "August" 
	 moy[8] = "September" 
	 moy[9] = "October" 
	 moy[10] = "November" 
	 moy[11] = "December" 
	 return moy[n] 
} 

function olddateString(date)
{

	//return (date.getDate()+" "+getCalendarMonth(date)+" "+ getFullYear(date))
	return (date.getDate()+" "+getCalendarMonth(date)+" "+ date.getFullYear())
}



function dateString(date) {
  var months = new makeArray("January", "February","March", "April", "May", "June", "July", "August","September", "October", "November", "December");
  return months[date.getMonth()] + " " + date.getDate() +", " + ((date.getFullYear() < 100) ? "19" : "") + date.getFullYear();
}


function timeString(date)
{
	temp=date.getHours()
	if (temp>12){
	return (temp-12+"pm")
	}
	else
	{
	if (temp == 0) return "midnight"
	if (temp == 12) return "midday"
	else return (temp+"am")
	}
}

function getRadioValue(radioObject)
{
	var value = ""
	for (var i=0; i<radioObject.length; i++)
	{
		if (radioObject[i].checked)
		{
			value = radioObject[i].value
			break
		}
	}
	return value
}

function getSelectValue(selectObject)
{
	
	return selectObject.options[selectObject.selectedIndex].value
}


function getCheckValue(checkbox) {

	if (eval(checkbox+".checked")) {
		return eval(checkbox+".value")
	}
	else {return "0"}
}


function twoPlaces(total)
//Ensures that string versions of numbers show two decimal places
//ie for displaying costs in pounds
{
  var total_str;

  total = Math.round(total * 100) / 100;
  total_str = total + "";
  i = total_str.indexOf(".");
  l = total_str.length;
  if (i == -1)
    total_str += ".00";
  else if (i == l - 2)
    total_str += "0";
  else
    total_str = total_str.substring(0, i + 3);

  return total_str;
}

function checkDateObj(fieldObj,millenium)
{
if (isWhitespace(fieldObj.value)||isNaN(parseInt(fieldObj.value)))
	{
		fieldObj.focus();
		return false;
	}
fieldObj.value=stripCharsNotInBag(fieldObj.value, dateChars)
if (checkDate(fieldObj.value,millenium)) {
	return (calcDate);
	}
else {return false}
}


function checkDate(fieldValue,millenium)
{
	// Checks that the day number does not exceed the number of days in the month
	// also checking leap year dates (crudely!) and number of months
	// it also adds 100 if it is millenium is 'true' and the last 2 digits are less than 98
	if (fieldValue==""||isNaN(parseInt(fieldValue)))
	{
		return false
	}
	// This first call below translates a string eg 24/10/58 into dd,mm,yy
	if (calcddmmyy(fieldValue))
	{
		if (mm<0||mm>11)
			{
			alert("Please use a month number between 1 and 12")
			return false;
			}
		else if(((mm+1)==4||(mm+1)==6||(mm+1)==9||(mm+1)==11)&&dd>30)
			{
			alert("There are only 30 days in the month!")
			return false;
			}
			else if(((mm+1)==1||(mm+1)==3||(mm+1)==5||(mm+1)==7||(mm+1)==8||(mm+1)==10||(mm+1)==12)&&dd>31)
			{
			alert("There are only 31 days in the month!")
			return false;
			}
	
			else if((mm+1)==02)
		 	{
			if((Math.floor(yy/4)==yy/4))
				{
				if(dd>29)
					{
	            alert("Too many days in February\nEven for a leap year!")
	            return false
	         	}
	         }
				else
					{ 
	           	if (dd>28)
						{
							alert("Too many days in February")
							return false
	       			}
					}
			}
		
		if(yy<1898||yy>2005)
			{
			alert("The year number must be four digits (eg 2001)")
			return false
			}
			if(yy<100){yy=yy+2000}
			//alert ("Temp check alert - yy='"+yy+"'")
		//alert("yy="+yy)
		if(millenium&&yy<99)
		{
			yy = yy+2000
		}
		//alert ("Temp check 2 alert - yy='"+yy+"'")
		
		calcDate= new Date (yy,mm,dd);
		return (calcDate);
		}
	else {return false}
} 

function calcddmmyy(fieldValue)
// note that the these will be in line with normal conventions
// ie January = 0
{
	fieldValue=removeSpaces(fieldValue)
	//alert("fieldValue is >"+fieldValue+"<")
	startPos=0
	while(fieldValue.substr(startPos,1)=="0")
	{
		fieldValue=fieldValue.substring(1)
	}
	//alert("fieldValue is >"+fieldValue+"<")
	
	pos= CheckNum(fieldValue,startPos)
	
	//alert ("dd startPos"+startPos+" pos "+pos+"String is >"+(fieldValue.substring(startPos,pos))+"<")
	dd = parseInt(fieldValue.substring(startPos,pos))
	//alert ("startPos"+startPos)
	startPos=pos+1
	//alert ("startPos"+startPos)
	//alert("fieldValue.substr(startPos,1)=>"+(fieldValue.substr(startPos,1))+"<")
	
	//alert ("startPos"+startPos)
	
	pos = CheckNum(fieldValue,startPos)
	while(fieldValue.substr(startPos,1)=="0")
	{
	 startPos=startPos+1
	 //alert("zero")
	}
	
	//alert("fieldValue is >"+fieldValue+"<")
	//alert ("mm startPos"+startPos+" pos "+pos+"String is >"+(fieldValue.substring(startPos,pos))+"<")
	mm = parseInt((fieldValue.substring(startPos,pos)))-1
	startPos=pos+1
	//altered the line below from
	//yy = parseInt(fieldValue.substring(startPos))
	//to try to get post 2000 dates working on TCW computer
	yy = parseInt(fieldValue.substr(startPos))
	//alert (fieldValue+" dd ="+dd+", mm ="+mm +", yy ="+yy)
	if (isNaN(dd)||isNaN(mm)||isNaN(yy))
	{	return false
	}
	if (Math.floor(dd)!=dd||Math.floor(mm)!=mm||Math.floor(yy)!=yy)
	{	return false
	}
	return true
		
}


function CheckNum(str,startPos) {
// Returns the position in a string of the first non number 
// Used for parsing date strings
	 var ch=""
     for (var i=startPos; i < str.length; i++)
     {
     	ch = str.substring(i,i+1);
       	//alert (ch)
     	if (ch < "0" || ch > "9")
     	{
       		var nonNumericPos=i
			//alert("break")
			break
        } 
     }
     return nonNumericPos;
}
	 
function removeSpaces(fieldValue)
{
// removes spaces at the beginning of a field
	while (fieldValue.substring(0,1)==" ")
	{
		//fieldValue=fieldValue.substring(1,fieldValue.length+1)
		fieldValue=fieldValue.substring(1)
	}
	return fieldValue
}

function isEmail(emailFieldObj,noAlert)
{
	s =emailFieldObj.value
	if (isWhitespace(s))
	{
		if(!(noAlert))
		{
			alert("The E-MAIL field is blank.\n\nPlease enter your e-mail address.")
			emailFieldObj.focus();
		}
		return false; 
	}
	
	if (s.indexOf ('@',0) == -1 ||s.indexOf ('.',0) == -1)
	{
		if(!noAlert)
		{
			alert("\nThe E-MAIL field requires a \"@\" and a \".\"be used.\n\nPlease re-enter your e-mail address.")
			emailFieldObj.select();
			emailFieldObj.focus();
		}
		return false;
	}
	else
	{
		return true;
	}
}

function isEmailValue(email)
{
	s =email
	if (isWhitespace(s))
	{
		return false; 
	}
	if (s.indexOf ('@',0) == -1 ||s.indexOf ('.',0) == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}




// Check whether string s is empty.

function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}



// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s)

{   var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }
	//alert("Whitespace")
    // All characters are whitespace.
    return true;
}


// Removes all characters which do NOT appear in string bag 
// from string s.

function stripCharsNotInBag(s,bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) != -1) returnString += c;
    }

    return returnString;
}


// Removes all characters which do NOT appear in string bag as well as spaces
// at the beginning of string s.
function stripCharsNotInBagTidy(s,bag)
{
	returnString=stripCharsNotInBag(s,bag)
	returnString=removeSpaces(returnString)
	return returnString;
}



// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}


function replaceString(oldS,newS,fullS) {
// Replaces oldS with newS in the string fullS
   for (var i=0; i<fullS.length; i++) {
      if (fullS.substring(i,i+oldS.length) == oldS) {
         fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
      }
   }
   return fullS
}

function cleanUpText(fieldValue) {
//Removes unacceptable characters and replaces commas with single spaces, and returns with ';'
	fieldValue=stripCharsNotInBag(fieldValue,textChars)
	fieldValue=replaceString("\,","  ",fieldValue)
	fieldValue=replaceString("\r","; ",fieldValue)
	fieldValue=replaceString("\n","; ",fieldValue)
	return fieldValue
}

//Functions to put up error messages

var mPrefix = "You did not enter a value into the "
var mSuffix = " field. We need that information to process you enquiry. Please enter it now."

// Notify user that required field theField is empty.
// String s describes expected contents of theField.value.
// Put focus in theField and return false.

function warnEmpty (theField, s)
{   theField.focus()
    alert(mPrefix + s + mSuffix)
    return false
}


// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}



// end hiding -->