<!--

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() {
	
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,})/;
var email_match = /([\w-]+[\.{1}\w-]*@{1}([\w-]*\.)*\w+)/;
//var email_match = /(([a-zA-Z_0-9]{1,})@{1}([a-zA-Z_0-9]{1,})\.{1}([a-zA-Z_0-9]{1,}))/;
var comma_match = /(([0-9]{1,}),{1}([0-9]{1,}))/;
var number_match=/[0-9]{1,}/;
var emailmatch = /@{1}/;
var good1 = 0;

var number_field=document.Table2FORM.APL_1_salary.value;
var pac_number_field=document.Table2FORM.APL_1_package.value;
var telephone_value=document.Table2FORM.APL_1_phone.value;
var telephoneM_value=document.Table2FORM.APL_1_mobile.value;
var email_value=document.Table2FORM.APL_1_email.value;
var firstname_value=document.Table2FORM.APL_1_firstname.value;
var lastname_value=document.Table2FORM.APL_1_lastname.value;
var known_as_value=document.Table2FORM.APL_1_known_as.value;
var marital_value=document.Table2FORM.APL_1_maritalstat.value;
var dobday_value=document.Table2FORM.APL_1_dob_day.value;
var dobmonth_value=document.Table2FORM.APL_1_dob_month.value;
var dobyear_value=document.Table2FORM.APL_1_dob_year.value;

//################*  ##################################
//################* Validation for compulsory fields ##################################

if (document.Table2FORM.APL_1_firstname.value=="") arr[101] = "First Name\n";
if (document.Table2FORM.APL_1_lastname.value=="") arr[102] = "Surname\n";
if (document.Table2FORM.APL_1_initials.value=="") arr[103] = "Initials\n";
if (document.Table2FORM.APL_1_known_as.value=="") arr[104] = "Known as\n";
if (document.Table2FORM.APL_1_title.value=="") arr[105] = "Title\n";
if (document.Table2FORM.APL_1_address.value=="") arr[106] = "Address\n";
if (document.Table2FORM.CMP_1_name.value=="") arr[107] = "Current Employer\n";
if (document.Table2FORM.EMP_1_From_year.value=="") arr[108] = "Date from: Year\n";
if (document.Table2FORM.EMP_1_title.value=="") arr[109] = "Job Title\n";
if (document.Table2FORM.APL_1_salary.value=="") arr[110] = "Basic Salary\n";

//if (document.Table2FORM.APL_1_dob_day.value=="") arr[108] = "Day of birth\n";
//if (document.Table2FORM.APL_1_dob_month.value=="") arr[109] = "Month of birth\n";
//if (document.Table2FORM.APL_1_dob_cent.value=="") arr[110] = "Century of birth\n";

if (document.Table2FORM.APL_1_dob_year.value=="") arr[111] = "Year of birth\n";
if (document.Table2FORM.APL_1_sex.value=="") arr[112] = "Sex\n";
if (document.Table2FORM.APL_1_maritalstat.value==" ") arr[113] = "Marital Status\n";
if (document.Table2FORM.APL_1_currentloc.value=="") arr[114] = "Current location\n";
if (document.Table2FORM.APL_1_relocate.value=="") arr[115] = "Are you willing to relocate\n";
if (document.Table2FORM.APL_1_user_text_1.value=="") arr[116] = "Notice period\n";
if (document.Table2FORM.APL_1_user_text_2.value==" ") arr[117] = "Driving licence\n";
if (document.Table2FORM.APL_1_salary=="") arr[118] = "Salary\n";


if ((firstname_value.match(alpha_match)==null) && firstname_value !="") arr[119] = "Please check that your first name is entered correctly\n\n";
if ((lastname_value.match(alpha_match)==null) && lastname_value !="") arr[120] = "Please check that your surname is entered correctly\n\n";
if ((known_as_value.match(alpha_match)==null) && known_as_value !="") arr[121] = "Please check that the value in 'known as' is entered correctly\n\n";
if ((telephone_value.match(phone_match)==null) && telephone_value !="") arr[122] = "Please check that your home telephone number is entered correctly\n\n";
if ((telephoneM_value.match(phone_match)==null) && telephoneM_value !="") arr[123] = "Please check that your mobile phone number is entered correctly\n\n";
if (email_value.match(email_match)==null && email_value !=""){ arr[130] = "Please check that your email address is entered correctly\n\n";};
if (dobday_value.match(number_match)==null && dobday_value !="") arr[131] = "Please check thatyour day of birth is entered correctly\n\n";
if (dobmonth_value.match(number_match)==null && dobmonth_value !="") arr[132] = "Please check that your month of birth is entered correctly\n\n";
if (dobyear_value.match(number_match)==null && dobyear_value !="") arr[133] = "Please check that your year of birth is entered correctly\n\n";
if (number_field.match(number_match)==null && number_field !="") arr[134] = "Please check that your salary is entered correctly\n\n";
if (pac_number_field.match(number_match)==null && pac_number_field !="") arr[135] = "Please check that your package is entered correctly\n\n";

//alert("sssss");
//################* Validation for the phone field ##################################
//if ((telephone_value.match(phone_match)==null) && telephone_value !="") arr[77] = "Please check your home telephone number is entered correctly\n\n";
//if ((telephoneM_value.match(phone_match)==null) && telephoneM_value !="") arr[78] = "Please check your mobile phone number is entered correctly\n\n";
//################*  ##################################
//alert ("!!!"+email_value+"!!!\n"+email_value.match(email_match));
//if (email_value.match(email_match)==null && email_value !=""){ arr[5] = "Please check your email address is entered correctly\n\n";};
//if (dob_value.match(number_match)==null && dob_value !="") arr[112] = "Please check your year of birth is entered correctly\n\n";
//if (document.Table2FORM.id.value== "") {
//	if (empstartdate_value.match(number_match)==null && empstartdate_value !="") arr[111] = "Please check the date of start of your current employment is entered correctly\n\n";
//}

//#The following will ensure that titles are entered with company names in employment history.
//if ((document.Table2FORM.FormsEditField92.value=="")&&(document.Table2FORM.FormsEditField91.value!="")) arr[115] = "A job Title is required for previous company 1\n";
//if ((document.Table2FORM.FormsEditField97.value=="")&&(document.Table2FORM.FormsEditField96.value!="")) arr[116] = "A job Title is required for previous company 2\n";
//if ((document.Table2FORM.FormsEditField21.value=="")&&(document.Table2FORM.FormsEditField20.value!="")) arr[117] = "A job Title is required for previous company 3\n";

//if ((document.Table2FORM.FormsEditField95.value=="")&&(document.Table2FORM.FormsEditField91.value!="")) arr[118] = "A start date is required for previous company 1\n";
//if ((document.Table2FORM.FormsEditField99.value=="")&&(document.Table2FORM.FormsEditField96.value!="")) arr[119] = "A start date is required for previous company 2\n";
//if (trim(document.Table2FORM.FormsEditField101.value=="")&&(document.Table2FORM.FormsEditField20.value!="")) arr[120] = "A start date is required for previous company 3\n";

//if (number_field.match(comma_match)!=null && number_field !=""){ arr[75] = "\nopps.No commas in Salary Fie!\n";};

//################* Number validation for salary field ##################################
if (number_field.match(comma_match)!=null && number_field !="") good1 ++;
if (number_field.match(alpha_match)!=null && number_field.match(alpha_match)!="" && number_field.match(number_match)==null && number_field !=null && number_field !="") good1 = 1;
if (number_field.match(alpha_match)==null && number_field.match(number_match)==null && number_field =="") good1 ++;
if (number_field.match(alpha_match)!=null)good1 ++;
if (number_field.match(alpha_match)==null && number_field.match(number_match)==null && number_field =="'") good1 ++;
if (number_field =="") good1 =0;
if (good1 !=0) {arr[14] = "\nSalary should contain only numbers.e.g. no commas or currency. \n\n";};

//################*  ##################################
//################* Number validation for package field ##################################
if (pac_number_field.match(comma_match)!=null && number_field !="") good1 ++;
if (pac_number_field.match(alpha_match)!=null && pac_number_field.match(alpha_match)!="" && pac_number_field.match(number_match)==null && pac_number_field !=null && pac_number_field !="") good1 = 1;
if (pac_number_field.match(alpha_match)==null && pac_number_field.match(number_match)==null && pac_number_field =="") good1 ++;
if (pac_number_field.match(alpha_match)!=null)good1 ++;
if (pac_number_field =="") good1 =0;
if (good1 !=0) {arr[15] = "Package should contain only numbers.e.g. no commas or currency. \n\n";};

//##############* Number local_salary##################################
//if (loc_number_field.match(comma_match)!=null && number_field !="") good1 ++;
//if (loc_number_field.match(alpha_match)!=null && loc_number_field.match(alpha_match)!="" && loc_number_field.match(number_match)==null && loc_number_field !=null && loc_number_field !="") good1 = 1;
//if (loc_number_field.match(alpha_match)==null && loc_number_field.match(number_match)==null && loc_number_field =="") good1 ++;
//if (loc_number_field.match(alpha_match)!=null)good1 ++;
//if (loc_number_field =="") good1 =0;
//if (good1 !=0) {arr[16] = "Local Salary should contain only numbers.e.g. no commas or currency. \n\n";};

//##############* Number validation for local_package field ##################################
//if (lpac_number_field.match(comma_match)!=null && number_field !="") good1 ++;
//if (lpac_number_field.match(alpha_match)!=null && lpac_number_field.match(alpha_match)!="" && lpac_number_field.match(number_match)==null && lpac_number_field !=null && lpac_number_field !="") good1 = 1;
//if (lpac_number_field.match(alpha_match)==null && lpac_number_field.match(number_match)==null && lpac_number_field =="") good1 ++;
//if (lpac_number_field.match(alpha_match)!=null)good1 ++;
//if (lpac_number_field =="") good1 =0;
//if (good1 !=0) {arr[17] = "Local Package should contain only numbers.e.g. no commas or currency. \n\n";};

for (x in arr) if( x != null) error_msg += arr[x];

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;
 }
}

-->