<!--

function trim ( inputStringTrim ) {
fixedTrim = "";
lastCh = " ";
for (x=0; x < inputStringTrim.length; x++) {
ch = inputStringTrim.charAt(x);
if ((ch != " ") || (lastCh != " ")) { fixedTrim += ch; }
lastCh = ch;
}
if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); }
return fixedTrim;
}

function validateFields() {
if (typeof document.Table2FORM.Filedata != "undefined") {
document.Table2FORM.OriginalPath.value = document.Table2FORM.Filedata.value;
}
var arr= new Array(200);
var error_msg = "";
//################* Careful with the regular expression pattern matching.
var url = /(w+):\/\/([\w.]+)\/(\S*)/;
var phone_match =/^[\(\d\)]{1,}[\s\.]?[\d\s\-\.]{1,}$/;
var alpha_match =/([a-zA-Z]{1,})/; //checks that there is at least one alphanumeric character
var email_match = /([\w-]+[\.{1}\w-]*@{1}([\w-]*\.)*\w+)/;
var number_match=/[0-9]{1,}/; //checks for at least one numeric character
var non_number_match=/[^0-9]{1,}/; //checks for any non-numeric characters

if (typeof document.Table2FORM.Name != "undefined") {
var Name=document.Table2FORM.Name.value;
if (Name=="") arr[100] = "Name\n"; //this line makes the field compulsory
if ((Name.match(alpha_match)==null) && Name !="") arr[100] = "Please check your Name is entered correctly\n\n";
}
if (typeof document.Table2FORM.Company != "undefined") {
var Company=document.Table2FORM.Company.value;
if (Company=="") arr[101] = "Company\n";
}
if (typeof document.Table2FORM.Address1 != "undefined") {
var Address1=document.Table2FORM.Address1.value;
if (Address1=="") arr[1] = "Address1\n";
}
if (typeof document.Table2FORM.City != "undefined") {
var City=document.Table2FORM.City.value;
if (City=="") arr[4] = "City\n";
}
if (typeof document.Table2FORM.Postcode != "undefined") {
var Postcode=document.Table2FORM.Postcode.value;
if (Postcode=="") arr[5] = "Postcode\n";
}
if (typeof document.Table2FORM.Country != "undefined") {
var Country=document.Table2FORM.Country.value;
//if (Country=="") arr[1] = "Country\n";
}
if (typeof document.Table2FORM.Jobtitle != "undefined") {
var Jobtitle=document.Table2FORM.Jobtitle.value;
if (Jobtitle=="") arr[1] = "Job Title\n";
}
if (typeof document.Table2FORM.Telephone != "undefined") {
var Telephone=document.Table2FORM.Telephone.value;
if (Telephone=="") arr[102] = "Telephone\n";
//if ((Telephone.match(phone_match)==null) && Telephone !="") arr[102] = "Please check your home telephone number is entered correctly\n\n";
}
if (typeof document.Table2FORM.Email != "undefined") {
var Email=document.Table2FORM.Email.value;
if (Email=="") arr[90] = "Email\n";
if ((Email.match(email_match)==null) && Email !=""){ arr[90] = "Please check your email address is entered correctly\n\n";};
}
if (typeof document.Table2FORM.NumberEmployees != "undefined") {
var NumberEmployees=document.Table2FORM.NumberEmployees.value;
if (NumberEmployees=="") arr[103] = "Number of Employees\n";
if ((NumberEmployees.match(number_match)==null) && NumberEmployees !="") arr[103] = "Please check the number of employees is entered correctly\n\n";
}

var IamA =document.Table2FORM.IamA.value;
if (IamA=="") arr[104] = "I am a\n";
if ((IamA.match(alpha_match)==null) && IamA !="") arr[104] = "Please check one of the 'I am' radioboxes is selected\n\n";

//for (x in arr) if( x != null) error_msg += arr[x];

for (i = 0; i < 201; i++) {
 if (arr[i] != null) error_msg += arr[i];
}

if (error_msg == null || error_msg =="")
 {
// alert ("Everything looks OK!");
 return true;
 }
 else {
 alert ("Please check and/or complete the following fields:\n\n" + error_msg + "\n");
 return false;
 }
}
-->