<!-- Begin

var space = " \t\n\r";
var alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
var digit = "0123456789";
var other = space + "\+\-\/" + "()";
var comma = ",";
var empty = false;
var today = new Date();
var year = today.getYear() + 1;
var wdhelp

if (navigator.appName == 'Netscape') year = year + 1900;
if ((navigator.appName == 'Microsoft Internet Explorer') && (year < 100)) year = year + 1900;

function makeArray(num)
	{
	for (var cnt = 1; cnt <= num; cnt++)
		{
		this[cnt] = 0
		}
	return this
	}

var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

function daysInFeb(year)
	{
	return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28);
	}

function warnEmpty(fld,lbl)
	{
	fld.focus();
	alert('Validation Error\r\r' + lbl + ' is a required field.\rPlease provide this information.');
	return false;
	}

function warnInvalid(fld,msg)
	{
	fld.focus();
	if ((fld.type == 'password') || (fld.type == 'text') || (fld.type == 'textarea')) fld.select();
	alert(msg);
	return false;
	}

function isEmpty(str)
	{
	return ((str == null) || (str.length == 0));
	}

function isSpace(str)
	{
	var cnt;
	if (isEmpty(str)) return true;
	for (cnt = 0; cnt < str.length; cnt++)
		{
		var chr = str.charAt(cnt);
		if (space.indexOf(chr) == -1) return false;
		}
	return true;
	}

function isInteger(str,emptyOK)
	{
	if (isInteger.arguments.length == 1) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(str)) return true;
	var cnt;
	for (cnt = 0; cnt < str.length; cnt++)
		{
		var chr = str.charAt(cnt);
		if (!(digit.indexOf(chr) != -1)) return false;
		}
	return true;
	}

function make2digits(n)
{
if (n >=10)
	return '' + n;

return '0' + n;
	
}

function isCharInString(chr,str)
	{
	var cnt;
	for (cnt = 0; cnt < str.length; cnt++)
		{
		if (str.charAt(cnt) == chr) return true;
		}
	return false;
	}

function stripCharsInBag(str,bag)
	{
	var cnt;
	var rtn = "";
	for (cnt = 0; cnt < str.length; cnt++)
		{
		var chr = str.charAt(cnt);
		if (bag.indexOf(chr) == -1) rtn += chr;
		}
	return rtn;
	}

function stripCharsNotInBag(str,bag)
	{
	var cnt;
	var rtn = "";
	for (cnt = 0; cnt < str.length; cnt++)
		{
		var chr = str.charAt(cnt);
		if (bag.indexOf(chr) != -1) rtn += chr;
		}
	return rtn;
	}

function stripPreSpace(str)
	{
	if (isEmpty(str)) return "";
	var cnt = 0;
	while ((cnt < str.length) && isCharInString(str.charAt(cnt),space))
		{
		cnt++;
		}
	return str.substring(cnt,str.length);
	}

function stripPostSpace(str)
	{
	if (isEmpty(str)) return "";
	var cnt = str.length;
	while ((cnt > 0) && isCharInString(str.charAt(cnt-1),space))
		{
		cnt--;
		}
	return str.substring(0,cnt);
	}

function isIntegerInRange(str,min,max)
	{
	if (!isInteger(str)) return false;
	var num = parseFloat(str);
	return ((num >= min) && (num <= max));
	}

function isFloatInRange(str,min,max)
	{
	var num=parseFloat(str);
	if ((num==0) && (str!="0"))
		{
		return false;
		}
	return ((num>=min) && (num <=max));
	}

function isYear(str)
	{
	if (isEmpty(str))
		{
		if (isYear.arguments.length == 1) return empty;
		else return (isYear.arguments[1] == true);
		}
	return ((str.length == 4) && (isIntegerInRange(str,1900,year)));
	}

function isMonth(str)
	{
	if (isEmpty(str))
		{
		if (isMonth.arguments.length == 1) return empty;
		else return (isMonth.arguments[1] == true);
		}
	return ((str.length == 2) && isIntegerInRange(str,1,12));
	}

function isDay(str)
	{
	if (isEmpty(str))
		{
		if (isDay.arguments.length == 1) return empty;
		else return (isDay.arguments[1] == true);
		}
	return ((str.length == 2) && isIntegerInRange(str,1,31));
	}

function isDate(year,month,day)
	{
	if (!(isYear(year) && isMonth(month) && isDay(day))) return false;
	var intYear = parseInt(year);
	var intMonth = parseInt(month);
	var intDay = parseInt(day);
	if (intDay > daysInMonth[intMonth]) return false;
	if ((intMonth == 2) && (intDay > daysInFeb(intYear))) return false;
	return true;
	}

function checkNumeric(fld,lbl,emptyOK)
	{
	if (checkNumeric.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	var cnt;
	for (cnt = 0; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,digit))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only numbers (no spaces).\rPlease edit your entry.');
		}
	return true;
	}

function checkAlphaNumeric(fld,lbl,emptyOK)
	{
	if (checkAlphaNumeric.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	var cnt;
	for (cnt = 0; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,alpha) || isCharInString(chr,digit))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only the following characters:\rletters and numbers (no spaces).\rPlease edit your entry.');
		}
	return true;
	}

function checkAlphaNumericSpace(fld,lbl,emptyOK)
	{
	if (checkAlphaNumericSpace.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	var cnt;
	for (cnt = 0; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,alpha) || isCharInString(chr,digit) || isCharInString(chr,space))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only the following characters:\rletters, numbers and spaces.\rPlease edit your entry');
		}
	return true;
	}

function checkAlphaNumericOther(fld,lbl,emptyOK)
	{
	if (checkAlphaNumericOther.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	var cnt;
	for (cnt = 0; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,alpha) || isCharInString(chr,digit) || isCharInString(chr,other))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only the following characters:\rletters, numbers, spaces, plus, minus, round brackets and forward slash.\rPlease edit your entry');
		}
	return true;
	}

function checkAlphaNumericComma(fld,lbl,emptyOK)
	{
	if (checkAlphaNumericComma.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	var cnt;
	for (cnt = 0; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,alpha) || isCharInString(chr,digit) || isCharInString(chr,other) || isCharInString(chr,comma))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only the following characters:\rletters, numbers, spaces, commas, plus, minus, round brackets and forward slash.\rPlease edit your entry');
		}
	return true;
	}

function checkPhone(fld,lbl,emptyOK)
	{
	if (checkPhone.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	if (fld.value.charAt(0) != "+") return warnInvalid(fld,'Validation Error\r\r' + lbl + ' must start with plus (+27 21 6592500).\rPlease edit your entry.');
	var cnt;
	for (cnt = 1; cnt < fld.value.length; cnt++)
		{
		var chr = fld.value.charAt(cnt);
		if (!(isCharInString(chr,digit) || isCharInString(chr,space))) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' can contain only numbers and spaces,\rstarting with plus (+27 21 6592500).\rPlease edit your entry.');
		}
	return true;
	}

function checkEmail(fld,lbl,emptyOK)
	{
	if (checkEmail.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	if (isSpace(fld.value)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' is not in the correct format.\rPlease edit your entry.');
	fld.value = stripCharsInBag(fld.value,space);
	var cnt = 1;
	while ((cnt < fld.value.length) && (fld.value.charAt(cnt) != "@"))
		{
		cnt++;
		}
	if ((cnt >= fld.value.length) || (fld.value.charAt(cnt) != "@")) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' is not in the correct format.\rPlease edit your entry.');
	else cnt += 2;
	while ((cnt < fld.value.length) && (fld.value.charAt(cnt) != "."))
		{
		cnt++;
		}
	if ((cnt >= fld.value.length - 1) || (fld.value.charAt(cnt) != ".")) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' is not in the correct format.\rPlease edit your entry.');
	else return true;
	}

function countSelect(fld)
	{
	var cnt;
	var sel = 0;
	for (cnt = 1; cnt < fld.options.length; cnt++)
		{
		if (fld.options[cnt].selected == true) sel++;
		}
	return sel;
	}

function checkSelect(fld,lbl)
	{
	if (countSelect(fld) == 0) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' is not selected.\rPlease select one from the list.');
	else return true;
	}

function checkSelectMax(fld,lbl,max)
	{
	if (countSelect(fld) > max) return warnInvalid(fld,'Validation Error\r\rYou have selected more than ' + max + ' items in ' + lbl + '.\rPlease select up to ' + max + ' items only.');
	else return true;
	}

function checkMultiSelect(fld,lbl)
	{
	if (countSelect(fld) == 0) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' is not selected.\rPlease select one or more from the list.');
	else return true;
	}

function checkTickIfSelect(fld1,lbl1,fld2,lbl2)
	{
	if ((countSelect(fld1) == 0) && (fld2.checked == true)) return warnInvalid(fld1,'Validation Error\r\r' + lbl1 + ' is not selected, but the related checkbox ' + lbl2 + ' is ticked.\rPlease either make a selection from the list or untick the checkbox.');
	else return true;
	}

function checkLength(fld,lbl,max,emptyOK)
	{
	if (checkLength.arguments.length == 3) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	fld.value = stripPreSpace(fld.value);
	fld.value = stripPostSpace(fld.value);
	if (isSpace(fld.value)) fld.value = "";
	if (isSpace(fld.value)) return warnEmpty(fld,lbl);
	if (fld.value.length > max) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' cannot contain more than ' + max + ' characters.\rPlease edit your entry.');
	else return true;
	}

function checkInRange(fld,lbl,min,max,emptyOK)
	{
	if (checkInRange.arguments.length == 4) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	fld.value = stripPreSpace(fld.value);
	fld.value = stripPostSpace(fld.value);
	if (isSpace(fld.value)) fld.value = "";
	if (isSpace(fld.value)) return warnEmpty(fld,lbl);
	if (fld.value < min) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' cannot be less than ' + min + ' characters.\rPlease edit your entry.');
	if (fld.value > max) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' cannot be more than ' + max + ' characters.\rPlease edit your entry.');
	else return true;
	}

function CheckIntegerInRange(fld,lbl,min,max,emptyOK)
	{
	if ((isEmpty(fld.value)) && (emptyOK == true)) return true;
	if (isEmpty(fld.value)) return warnEmpty(fld,lbl);
	if (!isIntegerInRange(fld.value,min,max)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' must be in the range ' + min + ' to ' + max + '.\rPlease edit your entry.');
	return true
	}

function CheckFloatInRange(fld,lbl,min,max,emptyOK)
	{
	if ((isEmpty(fld.value)) && (emptyOK == true)) return true;
	if (isEmpty(fld.value)) return warnEmpty(fld,lbl);
	if (!isFloatInRange(fld.value,min,max)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' must be in the range ' + min + ' to ' + max + '.\rPlease edit your entry.');
	return true
	}

function checkSame(fld1,lbl1,fld2,lbl2)
	{
	if (fld1.value != fld2.value) return warnInvalid(fld1,'Validation Error\r\r' + lbl1 + ' and ' + lbl2 + ' are not the same.\rPlease edit your entry.');
	else return true;
	}

function checkYear(fld,lbl,emptyOK)
	{
	if (checkYear.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	if (!isYear(fld.value,false)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' has to be 4 digits (from 1900 to ' + year + ').\rPlease edit your entry.');
	else return true;
	}

function checkMonth(fld,lbl,emptyOK)
	{
	if (checkMonth.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	if (!isMonth(fld.value,false)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' has to be 2 digits (from 01 to 12).\rPlease edit your entry.');
	else return true;
	}

function checkDay(fld,lbl,emptyOK)
	{
	if (checkDay.arguments.length == 2) emptyOK = empty;
	if ((emptyOK == true) && isEmpty(fld.value)) return true;
	if (!isDay(fld.value,false)) return warnInvalid(fld,'Validation Error\r\r' + lbl + ' has to be 2 digits (from 01 to 31).\rPlease edit your entry.');
	else return true;
	}

function checkDate (fld,Year,Month,Day,lbl)
	{
	if (!isYear(Year)) return warnInvalid(fld,'Validation Error\r\rThe YEAR in ' + lbl + ' has to be 4 digits (from 1900 to ' + year + ').\rPlease edit your entry.');	
	if (!isMonth(Month)) return warnInvalid(fld,'Validation Error\r\rThe MONTH in ' + lbl + ' has to be 2 digits (from 01 to 12).\rPlease edit your entry.');
	if (!isDay(Day)) return warnInvalid(fld,'Validation Error\r\rThe DAY in ' + lbl + ' has to be 2 digits (from 01 to 31).\rPlease edit your entry.');
	if (!isDate(Year,Month,Day)) return warnInvalid(fld,'Validation Error\r\rThe DAY in ' + lbl + ' has to be 2 digits (from 01 to 31).\rPlease edit your entry.');
	return true;
	}

function isDateOK(fld,lbl,emptyOK)
	{
	var strYear, strMonth, strDay, strDate
	
	strDate = fld.value
	
	if ((emptyOK == true) && (strDate == "")) return true;
		
	strYear = strDate.substr(6,4);
	strMonth = strDate.substr(3,2);
	strDay = strDate.substr(0,2);
	
	return checkDate(fld,strYear,strMonth,strDay,lbl);	
	}

function checkselected(fld,lbl)
	{	
// note that you have to use the selectedIndex property for Netscape compatibility	
	var selind
	
	selind = fld.selectedIndex;
	if (selind == 0) return !warnInvalid(fld,'Validation Error\r\rPlease choose a value for ' + lbl + '.');
	return false;
	}

function DateOK(datedd,datemm,dateyyyy,strerror)
{
var dd
var mm
var yyyy

 if (checkselected(datedd,strerror + ' - Day')) return false;
 if (checkselected(datemm,strerror + ' - Month')) return false;
 if (checkselected(dateyyyy,strerror + ' - Year')) return false;
 
dd = datedd[datedd.selectedIndex].value
mm = datemm.selectedIndex
yyyy = dateyyyy[dateyyyy.selectedIndex].value
mm = make2digits(mm)

if (!isDate(yyyy,mm,dd))
 {	
 	warnInvalid(datedd,'Validation Error\r\rPlease choose a valid ' + strerror);
 	return false;
 }	
return true;
}

// Returns a full date from the dd, mm and yyyy form fields
function dttotxt(ddfield,mmfield,yyyyfield)
{
if (ddfield.selectedIndex==0) return '';
return ddfield[ddfield.selectedIndex].value + '/' + mmfield.selectedIndex + '/' + yyyyfield[yyyyfield.selectedIndex].value;
}


function browsername()
{
	if (document.all)
		{ return 'ie' }
	else
		{ return 'nn' }
}		


 function showhelp(bookmark)
 {
 var url
 var nme
 var sizing

 url = 'Help.asp' + '#' + bookmark 
 nme = 'Help'
 sizing = 'status=no,menubar=no,scrollbars=yes,width=615,height=450,resizable=yes' 
 
 if ((wdhelp == null) || (wdhelp.closed))
 	wdhelp =  window.open(url,nme,sizing)
 	else 
 	{
 	wdhelp.location.href = url
 	wdhelp.focus()
 	}
}

// closes the help window if it is open
function wdunload()
{
	window.status=""
	if (wdhelp != null) 
	{
		wdhelp.close()
	}
}


// END -->