//////////////////////////////////////////////////////////////
// This script is © 2001-2002 by Aaron Brigatti. All Rights Reserved!
// You are free to modify this script as you wish just as long
// as this copyright notice remains intact. Unauthorised distribution
// is strictly forbidden without my prior consent. Email me at
// Aaron@brigatti.co.uk if you have any questions/comments.
//////////////////////////////////////////////////////////////

//###############################################################
//#
//# Filename: scipts.js
//# Purpose:  This contains all of the validation and other
//#           miscellaneous JavaScripts used on the website.
//#
//###############################################################

/***************************************
*
*  STATUS BAR MESSAGE
*
****************************************/
window.defaultStatus='IMA International - http://www.imainternational.com';



/***************************************
*
*  CURRENT YEAR (FOR COPYRIGHT!)
*
****************************************/
var today=new Date();
var copyright;
copyright=today.getFullYear();


/***************************************
*
*  LAUNCH POP-UP WINDOW (LOST PASSWORD)
*
****************************************/
function ShowPopupWindow(fileName)
{
    myFloater = window.open('','myWindow','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=325,height=450')
    myFloater.location.href = fileName;
}


/***************************************
*
*  LAUNCH POP-UP INFORMATION WINDOWS
*
****************************************/
function launchWindow(type)
{
    var url="";

    if (type=="adminforgottenpassword") url="infopages/adminforgottenpassword.html";
    if (type=="information1") url="infopages/information1.html";
    if (type=="information2") url="infopages/information2.html";
    if (type=="information3") url="infopages/information3.html";
    if (type=="information4") url="infopages/information4.html";
    if (type=="information5") url="infopages/information5.html";
    if (type=="information6") url="infopages/information6.html";
    if (type=="information7") url="infopages/information7.html";
    if (type=="information8") url="infopages/information8.html";
    if (type=="information9") url="infopages/information9.html";
    if (type=="information10") url="infopages/information10.html";
    if (type=="information11") url="infopages/information11.html";
    if (type=="information12") url="infopages/information12.html";

    window.open(url, "information",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=300,height=375');
}


/***************************************
*
*  WELCOME GREETING
*
****************************************/
function welcomeGreeting(greeting)
{
    day = new Date()
    hr = day.getHours()
    var greeting;

    // morning greeting
    if((hr==0)||(hr==1)||(hr==2)||(hr==3)||(hr==4)||(hr==5)||(hr==6)||(hr==7)||(hr==8)||(hr==9)||(hr==10)||(hr==11))
    {
        greeting = "Good morning";
        return greeting;
    }
    // afternoon greeting
    if((hr==12)||(hr==13)||(hr==14)||(hr==15)||(hr==16)||(hr==17))
    {
        greeting = "Good afternoon";
        return greeting;
    }
    // evening greeting
    if((hr==18)||(hr==19)||(hr==20)||(hr==21)||(hr==22)||(hr==23))
    {
        greeting = "Good evening";
        return greeting;
    }
}


/***************************************
*
*  VALIDATES TELEPHONE/FAX NUMBERS
*
****************************************/
function isValidNumber(number)
{
    var num = " +.-()0123456789";

    for (var intLoop = 0; intLoop < number.value.length; intLoop++)
    {
        if (num.indexOf(number.value.charAt(intLoop)) == -1)
        {
            alert("You have entered an invalid telephone/fax number. \nOnly the numerical digits 0-9 and the following characters are valid: \n   - dashes/hyphens (\"-\"),\n   - spaces (\" \"),\n   - the plus sign (\"+\"),\n   - left and right parenthesis (\"()\") and\n   - point/full-stop (\".\")\n\n Suggested format: +country code(area code) number e.g. +44(01234) 567890");
            number.focus();
            return false;
        }
    }
    return true;
}


/***************************************
*
*  REMOVES AND REPLACES CARRIAGE
*  RETURNS /r TO <BR> FROM TEXT AREA/BOX
*
****************************************/
function removeCarriageReturns(text)
{
    var output = "";

    for (var i = 0; i < text.length; i++)
    {
        if ((text.charCodeAt(i) == 13) && (text.charCodeAt (i + 1) == 10))
        {
            i++;
            output += "<br>";
        }
        else
        {
            output += text.charAt(i);
        }
    }
    return output;
}


/***************************************
*
*  REMOVES AND REPLACES <BR> BACK TO
*  CARRIAGE RETURNS /r FROM TEXT AREA/BOX
*
****************************************/
function removeCarriageReturns2(text)
{
    var output = "";

    for (var i = 0; i < text.length; i++)
    {
        if ((text.charCodeAt(i)== "<") && (text.charCodeAt (i + 1) == "b") && (text.charCodeAt (i + 2) == "r") && (text.charCodeAt (i + 3) == ">"))
        {
            i++;
            output += "\r\n";
        }
        else
        {
            output += text.charAt(i);
        }
    }
    return output;
}


/***************************************
*
*  PERSONAL STATEMENT 200 WORD LIMIT
*
****************************************/
function wordCounter(field, countfield, maxlimit)
{
    wordcounter=0;

    for (x=0;x<field.value.length;x++)
    {
        if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")
        {
            // Counts the spaces while ignoring double spaces, usually one in between each word.
            wordcounter++
        }
        if (wordcounter > maxlimit)
        {
            field.value = field.value.substring(0, x);
            alert("You have reached the maximum number of words.");
            form5.statement.focus();
            return false;
        }
        else
        {
            countfield.value = maxlimit - wordcounter;
        }
    }
    return true;
}


/***************************************
*
*  PERSONAL STATEMENT 255 CHAR. LIMIT
*
****************************************/
//function textCounter(field, countfield, maxlimit)
//{
//  if (field.value.length > maxlimit)
//  {
//    field.value = field.value.substring(0, maxlimit);
//  }
//  else
//  {
//    countfield.value = maxlimit - field.value.length;
//  }
//}


/***************************************
*
*  DISABLES/ENABLES A SELECTION BOX
*  (FOR SEARCH FORMS!)
*
****************************************/
function skip()
{
    this.blue();
}
// Disabled selection box 1
function DisEnSelection1(select)
{
    if (!select.disabled)
    {
        select.disabled = true;
        select.options.selectedIndex = 0;
        select.options.selectedIndex.selected = true;

        if (!document.all && !document.getElementById)
        {
            select.oldOnFocus = select.onFocus ? select.onFocus : null;
            select.onFocus = skip;
        }
    }
}
// Disabled selection box 2
function DisEnSelection2(select)
{
    if (select.disabled)
    {
        select.disabled = false;
        if (!document.all && !document.getElementById)
        {
            select.onFocus = select.oldOnFocus;
        }
    }
}


/***************************************
*
*  CHECK CONSULTANT LOGIN FORM
*
****************************************/
function CheckLoginConsultant()
{
    if (webform.con_username.value == "" || webform.con_username.value == null)
    {
        alert("You have not entered your username (e-mail address).");
        webform.con_username.focus();
        return false;
    }
    if (webform.con_username.value.indexOf ('@',0) == -1 || webform.con_username.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are the inform user@domain.com).");
        webform.con_username.focus();
        return false;
    }
    if (webform.con_password.value.length < 6)
    {
        if (webform.con_password.value == "" || webform.con_password.value == null)
        alert("You have not entered your password.")
        else
        alert("Password must be at least 6 characters.");
        webform.con_password.focus();
        return false;
    }
    if (webform.con_password.value.length > 15)
    {
        alert("Password must be no more than 15 characters");
        webform.con_password.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADMIN LOGIN FORM
*
****************************************/
function CheckLoginAdmin()
{
    if (webform.admin_username.value == "" || webform.admin_username.value == null)
    {
        alert("You have not entered your username.");
        webform.admin_username.focus();
        return false;
    }
    if (webform.admin_password.value.length < 6)
    {
        if (webform.admin_password.value == "" || webform.admin_password.value == null)
        alert("You have not entered your password.")
        else
        alert("Password must be at least 6 characters.");
        webform.admin_password.focus();
        return false;
    }
    if (webform.admin_password.value.length > 15)
    {
        alert("Password must be no more than 15 characters");
        webform.admin_password.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADD ADMIN LOGIN FORM
*
****************************************/
function CheckLoginAddAdmin()
{
    if (addadmin.firstname.value == "" || addadmin.firstname.value == null)
    {
        alert("You have not entered a first name.");
        addadmin.firstname.focus();
        return false;
    }
    if (addadmin.surname.value == "" || addadmin.surname.value == null)
    {
        alert("You have not entered a surname.");
        addadmin.surname.focus();
        return false;
    }
    if (addadmin.username.value == "" || addadmin.username.value == null)
    {
        alert("You have not entered a username.");
        addadmin.username.focus();
        return false;
    }
    if (addadmin.password.value.length < 6)
    {
        if (addadmin.password.value == "" || addadmin.password.value == null)
        alert("You have not entered a password.")
        else
        alert("Password must be at least 6 characters.");
        addadmin.password.focus();
        return false;
    }
    if (addadmin.password.value.length > 15)
    {
        alert("Password must be no more than 15 characters");
        addadmin.password.focus();
        return false;
    }
}


/***************************************
*
*  CHECK UPDATE ADMIN LOGIN FORM
*
****************************************/
function CheckLoginUpdateAdmin()
{
    if (updateadmin.firstname.value == "" || updateadmin.firstname.value == null)
    {
        alert("You have not entered a first name.");
        updateadmin.firstname.focus();
        return false;
    }
    if (updateadmin.surname.value == "" || updateadmin.surname.value == null)
    {
        alert("You have not entered a surname.");
        updateadmin.surname.focus();
        return false;
    }
    if (updateadmin.password.value.length < 6)
    {
        if (updateadmin.password.value == "" || updateadmin.password.value == null)
        alert("You have not entered a password.")
        else
        alert("Password must be at least 6 characters.");
        updateadmin.password.focus();
        return false;
    }
    if (updateadmin.password.value.length > 15)
    {
        alert("Password must be no more than 15 characters");
        updateadmin.password.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADMIN NEW FIELD FORM
*
****************************************/
function CheckAdminNewField()
{
    if (addnewfieldform.thenewfield.value == "" || addnewfieldform.thenewfield.value == null)
    {
        alert("You have not entered a new field");
        addnewfieldform.thenewfield.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADMIN NEW FIELD (SPECIALIST) FORM
*
****************************************/
function CheckAdminNewFieldSpec()
{
    if (addnewfieldform.thenewfield.value == "" || addnewfieldform.thenewfield.value == null)
    {
        alert("You have not entered a new field");
        addnewfieldform.thenewfield.focus();
        return false;
    }
    if (addnewfieldform.newmajorexp.options[addnewfieldform.newmajorexp.selectedIndex].value <= 0)
    {
        alert("You have not selected a Corresponding Main Discipline Subject.");
        addnewfieldform.newmajorexp.focus();
        return false;
    }
}



/***************************************
*
*  CHECK ADMIN NEW FIELD (COUNTRY) FORM
*
****************************************/
function CheckAdminNewFieldRegion()
{
    if (addnewfieldform.thenewfield.value == "" || addnewfieldform.thenewfield.value == null)
    {
        alert("You have not entered a new field");
        addnewfieldform.thenewfield.focus();
        return false;
    }
    if (addnewfieldform.newregion.options[addnewfieldform.newregion.selectedIndex].value <= 0)
    {
        alert("You have not selected a Corresponding Region.");
        addnewfieldform.newregion.focus();
        return false;
    }
}



/***************************************
*
*  CHECK UPDATE ADMIN LOGIN FORM
*
****************************************/
function CheckAdminDatabase()
{
    // set var radio_choice to false
    var radio_choice = false;

    // Loop from zero to the one minus the number of radio button selections
    for (counter = 0; counter < admindatabase.dbfield.length; counter++)
    {
        // If a radio button has been selected it will return true
        // (If not it will return false)
        if (admindatabase.dbfield[counter].checked)
        radio_choice = true;
    }
    if (!radio_choice)
    {
        // If there were no selections made display an alert box
        alert("You have not selected a database field to view.")
        return (false);
    }
    return (true);
}


/***************************************
*
*  CHECK UPDATE ADMIN MAIL FORM
*
****************************************/
function CheckAdminMail()
{
    // set var radio_choice to false
    var radio_choice = false;

    // Loop from zero to the one minus the number of radio button selections
    for (counter = 0; counter < adminmail.mailfield.length; counter++)
    {
        // If a radio button has been selected it will return true
        // (If not it will return false)
        if (adminmail.mailfield[counter].checked)
        radio_choice = true;
    }
    if (!radio_choice)
    {
        // If there were no selections made display an alert box
        alert("You have not selected a message to view.")
        return (false);
    }
    return (true);
}


/***************************************
*
*  CHECK UPDATE ADMIN LOGIN FORM
*
****************************************/
function CheckAdminAuthorise()
{
    // set var radio_choice to false
    var radio_choice = false;

    // Loop from zero to the one minus the number of radio button selections
    for (counter = 0; counter < adminauthorise.authorisation.length; counter++)
    {
        // If a radio button has been selected it will return true
        // (If not it will return false)
        if (adminauthorise.authorisation[counter].checked)
        radio_choice = true;
    }
    if (!radio_choice)
    {
        // If there were no selections made display an alert box
        alert("You have not selected an authorisation decision.")
        return (false);
    }
    return (true);
}


/***************************************
*
*  CHECK UPDATE ADMIN LOGIN FORM
*
****************************************/
function CheckAdminDocReceived()
{
    if ((admindocreceived.cvdocreceived.checked==false) && (admindocreceived.qualdocreceived.checked==false) && (admindocreceived.accept.checked==false))
    {
        // If there were no selections made display an alert box
        alert("You have not selected an verification decision.")
        return false;
    }
}


/***************************************
*
*  CHECK VERIFICATION DOCS. RESPONSES
*
****************************************/
function BypassDocVerification(accept)
{
    if(admindocreceived.accept.checked)
    {
        // Set cv and qual field as disabled and checked
        // only the accept field is enabled (i.e. can be selected)
        admindocreceived.cvdocreceived.disabled=true;
        admindocreceived.qualdocreceived.disabled=true;
        admindocreceived.accept.disabled=false;
        admindocreceived.cvdocreceived.checked=true;
        admindocreceived.qualdocreceived.checked=true;
    }
    else
    {
        // Reset each option to their default (NULL) value
        // all fields are enabled (i.e. can be selected)
        admindocreceived.cvdocreceived.disabled=false;
        admindocreceived.qualdocreceived.disabled=false;
        admindocreceived.accept.disabled=false;
    }
}


/***************************************
*
*  RESETS VERIFICATION DOCS. RESPONSES
*
****************************************/
function resetResponses()
{
    // Reset each option to their default (NULL) value
    // all fields are unchecked
    admindocreceived.cvdocreceived.checked = false;
    admindocreceived.qualdocreceived.checked = false;
    admindocreceived.accept.checked = false;
}


/***************************************
*
*  RESETS AUTHORISATION RESPONSES
*
****************************************/
function resetAuthResponses()
{
    // Reset each option to their default (NULL) value
    // all fields are unchecked
    adminauthorise.authorisation.checked = false;
    adminauthorise.authorisation.checked = false;
}


/***************************************
*
*  CHECK DATE VALIDITY
*
****************************************/
function IsValidDate (theDay, theMonth, theYear)
{
    var correctDays = 0;

    // September, April, June and November have 30 days
    if ((theMonth == 4) || (theMonth == 6)|| (theMonth == 9)|| (theMonth ==11))
    correctDays = 30;
    else
    {
        // All the rest have 31 days except February
        if((theMonth == 2))
        {
            // determine whether the year is a yeap year
            if (( theYear % 4 == 0 && theYear % 100 != 0) || theYear % 400 == 0 )
            correctDays = 29;
            else
            correctDays = 28;
        }
        else
        correctDays = 31;
    }
    if (theDay > correctDays)
    return false;
    return true;
}


/***************************************
*
*  CHECK CLIENT SEARCH FORM
*
****************************************/
function CheckFormClient()
{
    // check empty fields
//    if (clientform1.majordis_exp.options[clientform1.majordis_exp.selectedIndex].value <= 0 && clientform1.subspeciality_exp.options[clientform1.subspeciality_exp.selectedIndex].value <= 0)
//    {
//        alert("You have not selected either a main discipline or speciality discipline area to search under.");
//        clientform1.majordis_exp.focus();
//        return false;
//    }
    if (clientform1.majordis_exp.options[clientform1.majordis_exp.selectedIndex].value == '%' && clientform1.subspeciality_exp.options[clientform1.subspeciality_exp.selectedIndex].value  == '%' &&
    clientform1.country_exp.options[clientform1.country_exp.selectedIndex].value == '%' && clientform1.language_exp.options[clientform1.language_exp.selectedIndex].value  == '%' &&
    clientform1.qualification_exp.options[clientform1.qualification_exp.selectedIndex].value == '%')
    {
        alert("You have not selected either a discipline or experience area to search under.");
        clientform1.majordis_exp.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CLIENT FURTHER DETAILS FORM
*
****************************************/
function CheckFormClient2()
{
    // contact details
    if (clientform.client_firstname.value == "" || clientform.client_firstname.value == null)
    {
        alert("You have not entered a first name.");
        clientform.client_firstname.focus();
        return false;
    }
    if (clientform.client_surname.value == "" || clientform.client_surname.value == null)
    {
        alert("You have not entered a surname.");
        clientform.client_surname.focus();
        return false;
    }
    if (clientform.client_addressa.value == "" || clientform.client_addressa.value == null)
    {
        alert("You have not entered your contact address.");
        clientform.client_addressa.focus();
        return false;
    }
    if (clientform.client_country.options[clientform.client_country.selectedIndex].value <= 0)
    {
        alert("You have not selected a country.");
        clientform.client_country.focus();

        return false;
    }
    if (clientform.client_phone.value == "" || clientform.client_phone.value == null)
    {
        alert("You have not entered your telephone number.");
        clientform.client_phone.focus();
        return false;
    }
    if (clientform.client_email.value == "" || clientform.client_email.value == null)
    {
        alert("You MUST entered a username (e-mail address).");
        clientform.client_email.focus();
        return false;
    }
    if (clientform.client_email.value.indexOf ('@',0) == -1 || clientform.client_email.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
        clientform.client_email.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADMIN CONSULTANT SEARCH FORM 1
*
****************************************/
function CheckFormAdminSearch1()
{
    // check empty fields
    if ((adminsearch1.consultant_id.value == "" || adminsearch1.consultant_id.value == null) &&
    (adminsearch1.consultant_surname.value == "" || adminsearch1.consultant_surname.value == null) &&
    (adminsearch1.consultant_country.options[adminsearch1.consultant_country.selectedIndex].value == '%') &&
    (adminsearch1.consultant_address.value == "" ) &&
    (adminsearch1.consultant_notes.value == "" ))
    {
        alert("You MUST enter either the Consultant's ID, Surname, \nCountry of Residence, Address or Notes to proceed. \n(Or type ALL in the Consultant ID box to list all of the records).");
        adminsearch1.consultant_id.focus();
        return false;
    }
}


/***************************************
*
*  CHECK ADMIN CONSULTANT SEARCH FORM 2
*
****************************************/
function CheckFormAdminSearch2()
{
    // check empty fields
//    if (adminsearch2.majordis_exp.options[adminsearch2.majordis_exp.selectedIndex].value <= 0 && adminsearch2.subspeciality_exp.options[adminsearch2.subspeciality_exp.selectedIndex].value <= 0)
//    {
//        alert("You have not selected either a main discipline or speciality discipline area to search under.");
//        adminsearch2.majordis_exp.focus();
//        return false;
//    }

    if (adminsearch2.majordis_exp.options[adminsearch2.majordis_exp.selectedIndex].value == '%' && adminsearch2.subspeciality_exp.options[adminsearch2.subspeciality_exp.selectedIndex].value  == '%' &&
    adminsearch2.country_exp.options[adminsearch2.country_exp.selectedIndex].value == '%' && adminsearch2.language_exp.options[adminsearch2.language_exp.selectedIndex].value  == '%' &&
    adminsearch2.qualification_exp.options[adminsearch2.qualification_exp.selectedIndex].value == '%' && adminsearch2.regions_exp.options[adminsearch2.regions_exp.selectedIndex].value  == '%')
    {
        alert("You have not selected a search criteria to initiate a search.");
        adminsearch2.majordis_exp.focus();
        return false;
    }
}


/***************************************
*
*     CONSULTANT APPLICATION FORM 1
*              YEAR FIELD
*
****************************************/
function display_day_combo()
{
	var i

	// write beginning of day-combo
	// loop through each day
	document.write('<option value=\"\" selected>[Day]</OPTION>')
	for(i=1;i<=31;i++) {
		document.write('<option value=\"' + i + '\">' + i +'</option>')
	}
}


/***************************************
*
*     CONSULTANT APPLICATION FORM 1
*              YEAR FIELD
*
****************************************/
function display_year_combo()
{
	var thisYear, i

	// get current date
	date=new Date()

	// year 2000 problem in old versions of netscape
        // (Netscape returns 101 for the year 2001)
	if(date.getYear()<1000)
	{
		thisYear = date.getYear() + 1900;
	} else {
		thisYear = date.getYear();
	}

	// write beginning of year-combo
	// loop through each year
	document.write('<option value=\"\" selected>[Year]</OPTION>')
	for(i=thisYear-25;i>=1900;i--) {
		document.write('<option value=\"' + i + '\">' + i
                      +'</option>')
	}
}


/***************************************
*
*  CHECK ADMIN CONSULTANT REGISTRATION APPLICATION FORM
*
****************************************/
function AdminCheckAppRegForm()
{
    // application registration
    if (regform.adminemail.value == "" || regform.adminemail.value == null)
    {
        alert("You MUST entered a username (e-mail address).");
        regform.adminemail.focus();
        return false;
    }
    if (regform.adminemail.value.indexOf ('@',0) == -1 || regform.adminemail.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
        regform.adminemail.focus();
        return false;
    }
    if (regform.adminemail.value != regform.adminemailconfirm.value)
    {
        alert("Your e-mail address and 'confirm' e-mail address do not match.");
        regform.adminemailconfirm.focus();
        return false;
    }
    if (regform.adminpassword.value.length < 6)
    {
        if (regform.adminpassword.value == "" || regform.adminpassword.value == null)
        alert("You have not entered your password.");
        else
        alert("Password must be at least 6 characters.")
        regform.adminpassword.focus();
        return false;
    }
    if (regform.adminpassword.value.length > 15)
    {
        alert("Password must be no more than 15 characters.");
        regform.adminpassword.focus();
        return false;
    }
    if (regform.adminpassword.value != regform.adminpasswordconfirm.value)
    {
        alert("Your password and 'confirm' password do not match.");
        regform.adminpasswordconfirm.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CONSULTANT REGISTRATION APPLICATION FORM
*
****************************************/
function CheckAppRegForm()
{
    // application registration
    if (regform.email.value == "" || regform.email.value == null)
    {
        alert("You MUST entered a username (e-mail address).");
        regform.email.focus();
        return false;
    }
    if (regform.email.value.indexOf ('@',0) == -1 || regform.email.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
        regform.email.focus();
        return false;
    }
    if (regform.email.value != regform.emailconfirm.value)
    {
        alert("Your e-mail address and 'confirm' e-mail address do not match.");
        regform.emailconfirm.focus();
        return false;
    }
    if (regform.password.value.length < 6)
    {
        if (regform.password.value == "" || regform.password.value == null)
        alert("You have not entered your password.");
        else
        alert("Password must be at least 6 characters.")
        regform.password.focus();
        return false;
    }
    if (regform.password.value.length > 15)
    {
        alert("Password must be no more than 15 characters.");
        regform.password.focus();
        return false;
    }
    if (regform.password.value != regform.passwordconfirm.value)
    {
        alert("Your password and 'confirm' password do not match.");
        regform.passwordconfirm.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 1
*
****************************************/
function CheckAppForm1()
{
    // personal details
    if (form1.title.selectedIndex == 0)
    {
        alert("You have not selected a title.");
        form1.title.focus();
        return false;
    }
    if (form1.first_name.value == "" || form1.first_name.value == null)
    {
        alert("You have not entered a first name.");
        form1.first_name.focus();
        return false;
    }
    if (form1.surname.value == "" || form1.surname.value == null)
    {
        alert("You have not entered a surname.");
        form1.surname.focus();
        return false;
    }
    if (form1.DOBDay.options[form1.DOBDay.selectedIndex].value <= 0)
    {
        alert("You have not selected a Date of Birth (Day).");
        form1.DOBDay.focus();
        return false;
    }
    if (form1.DOBMonth.options[form1.DOBMonth.selectedIndex].value <= 0)
    {
        alert("You have not selected a Date of Birth (Month).");
        form1.DOBMonth.focus();
        return false;
    }
    if (form1.DOBYear.options[form1.DOBYear.selectedIndex].value <= 0)
    {
        alert("You have not selected a Date of Birth (Year).");
        form1.DOBYear.focus();
        return false;
    }
    if (IsValidDate (form1.DOBDay.value, form1.DOBMonth.value, form1.DOBYear.value) == false)
    {
        alert("You have selected an invalid Date of Birth.");
        form1.DOBDay.focus();
        return false;
    }
    if (form1.nationality1.options[form1.nationality1.selectedIndex].value <= 0)
    {
        alert("You have not selected a nationality.");
        form1.nationality1.focus();
        return false;
    }
    if (form1.nationality1.value == form1.nationality2.value)
    {
        alert("Your selection of nationality and dual-nationality are the same.");
        form1.nationality2.focus();
        return false;
    }

    // contact details
    if (form1.perm_address.value == "" || form1.perm_address.value == null)
    {
        alert("You have not entered your home address.");
        form1.perm_address.focus();
        return false;
    }
    if (form1.perm_country.options[form1.perm_country.selectedIndex].value <= 0)
    {
        alert("You have not selected a country.");
        form1.perm_country.focus();

        return false;
    }
    if (form1.perm_phone.value == "" || form1.perm_phone.value == null)
    {
        alert("You have not entered your telephone number.");
        form1.perm_phone.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 2
*
****************************************/
function CheckAppForm2()
{
    // academic qualification details
    if (form2.qualification.options[form2.qualification.selectedIndex].value <= 0)
    {
        alert("You have not selected a qualification.");
        form2.qualification.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 3
*
****************************************/
function CheckAppForm3()
{
    // reference details
    if (form3.referee_name1.value == "" || form3.referee_name1.value == null)
    {
        alert("You have not entered your referees full name (including title).");
        form3.referee_name1.focus();
        return false;
    }
    if (form3.referee_address1.value == "" || form3.referee_address1.value == null)
    {
        alert("You have not entered your referees contact address.");
        form3.referee_address1.focus();
        return false;
    }
    if (form3.referee_country1.options[form3.referee_country1.selectedIndex].value <= 0)
    {
        alert("You have not selected your referees country.");
        form3.referee_country1.focus();
        return false;
    }
    if (form3.referee_phone1.value == "" || form3.referee_phone1.value == null)
    {
        alert("You have not entered your referees telephone number.");
        form3.referee_phone1.focus();
        return false;
    }
    if (form3.referee_email1.value != "")
    {
        if (form3.referee_email1.value.indexOf ('@',0) == -1 || form3.referee_email1.value.indexOf ('.',0) == -1)
        {
            alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
            form3.referee_email1.focus();
            return false;
        }
    }
    if (form3.referee_email2.value != "")
    {
        if (form3.referee_email2.value.indexOf ('@',0) == -1 || form3.referee_email2.value.indexOf ('.',0) == -1)
        {
            alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
            form3.referee_email2.focus();
            return false;
        }
    }
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 4
*
****************************************/
function CheckAppForm4()
{
    // not practically possible to check Select Arrays
    // using JavaScript - well I couldn't find a way
    // so used PHP error checking instead
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 5
*
****************************************/
function CheckAppForm5()
{
    // not practically possible to check Select Arrays
    // using JavaScript - well I couldn't find a way
    // so used PHP error checking instead
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 6
*
****************************************/
function CheckAppForm6()
{
    // language details
    if (form6.duration.options[form6.duration.selectedIndex].value <= 0)
    {
        alert("You have not selected your preferred contract duration.");
        form6.duration.focus();
        return false;
    }
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 6b
*
****************************************/
function CheckAppForm6b()
{
    // not practically possible to check Select Arrays
    // using JavaScript - well I couldn't find a way
    // so used PHP error checking instead
}


/***************************************
*
*  CHECK CONSULTANT APPLICATION FORM 7
*
****************************************/
function CheckAppForm7()
{
    // date last worked details
    if (IsValidDate (form7.DateLastWorkedDay.value, form7.DateLastWorkedMonth.value, form7.DateLastWorkedYear.value) == false)
    {
        alert("You have selected an invalid Date.");
        form7.DateLastWorkedDay.focus();
        return false;
    }
}


/***************************************
*
*  CHECK PASSWORD LOOKUP FORM
*
****************************************/
function CheckConsultantPasswordLookup()
{
    if (consultantlostpassword.con_username.value == "" || consultantlostpassword.con_username.value == null)
    {
        alert("You MUST entered a username (e-mail address).");
        consultantlostpassword.con_username.focus();
        return false;
    }
    if (consultantlostpassword.con_username.value.indexOf ('@',0) == -1 || consultantlostpassword.con_username.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
        consultantlostpassword.con_username.focus();
        return false;
    }
}


/***************************************
*
*  UPDATE CONSULTANT E-MAIL ADDRESS
*
****************************************/
function CheckUpdateEmail()
{
    if (consultantupdateemail.newemail.value == "" || consultantupdateemail.newemail.value == null)
    {
        alert("You MUST entered a new username (e-mail address).");
        consultantupdateemail.newemail.focus();

        return false;
    }
    if (consultantupdateemail.newemail.value.indexOf ('@',0) == -1 || consultantupdateemail.newemail.value.indexOf ('.',0) == -1)
    {
        alert("You have entered an invalid email address. \n(E-mail addresses are in the form of user@domain.com).");
        consultantupdateemail.newemail.focus();
        return false;

    }
    if (consultantupdateemail.newemail.value != consultantupdateemail.newemailconfirm.value)
    {
        alert("Your new e-mail address and 'confirm' e-mail address do not match.");
        consultantupdateemail.newemailconfirm.focus();
        return false;
    }
}


/***************************************
*
*  UPDATE CONSULTANT PASSWORD
*
****************************************/
function CheckUpdatePassword()
{
    if (consultantupdatepassword.newpassword.value.length < 6)
    {
        if (consultantupdatepassword.newpassword.value == "" || consultantupdatepassword.newpassword.value == null)
        alert("You MUST entered a new password.");
        else
        alert("Password must be at least 6 characters.");
        consultantupdatepassword.newpassword.focus();
        return false;
    }
    if (consultantupdatepassword.newpassword.value.length > 15)
    {
        alert("Password must be no more than 15 characters");
        consultantupdatepassword.newpassword.focus();
        return false;
    }
    if (consultantupdatepassword.newpassword.value != consultantupdatepassword.newpasswordconfirm.value)
    {
        alert("Your new password and 'confirm' password do not match.");
        consultantupdatepassword.newpasswordconfirm.focus();
        return false;
    }
}


/***************************************
*
*  FOR THE MAJOR DISC AND SUB-SPEC
*  CONSULTANT NEW APP. FORM
*
****************************************/
// major discipline selection box 1
function MM_jumpMenu1(targ,selObj,restore){ //v3.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='consultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}
// major discipline selection box 2
function MM_jumpMenu2(targ,selObj,restore){ //v3.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='consultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}
// major discipline selection box 3
function MM_jumpMenu3(targ,selObj,restore){ //v3.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='consultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}


/***************************************
*
*  FOR THE MAJOR DISC AND SUB-SPEC
*  CONSULTANT AMENDMENT APP. FORM
*
****************************************/
// major discipline selection box 1
function MM_jumpMenuAmend1(targ,selObj,restore){ //v3.0
    //3 lines below do not work in Firefox - dave 25/10/06
    //m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    //m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    //m3=form5.menu3.options[form5.menu3.selectedIndex].value;

    m1 = document.form5.menu1.value;
    m2 = document.form5.menu2.value;
    m3 = document.form5.menu3.value;

    eval(targ+".location='consultant_expert.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}
// major discipline selection box 2
function MM_jumpMenuAmend2(targ,selObj,restore){ //v3.0

    m1 = document.form5.menu1.value;
    m2 = document.form5.menu2.value;
    m3 = document.form5.menu3.value;

    eval(targ+".location='consultant_expert.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}
// major discipline selection box 3
function MM_jumpMenuAmend3(targ,selObj,restore){ //v3.0

    m1 = document.form5.menu1.value;
    m2 = document.form5.menu2.value;
    m3 = document.form5.menu3.value;

    eval(targ+".location='consultant_expert.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
}


/***************************************
*
*  FOR THE MAJOR DISC AND SUB-SPEC
*  ADMIN CONSULTANT NEW APP. FORM
*
****************************************/
// major discipline selection box 1
function MM_jumpMenuAdmin1(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantform5.php?menu1="+selObj.options[selObj.selectedIndex].value+"'");
}
// major discipline selection box 2
function MM_jumpMenuAdmin2(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantform5.php?menu2="+selObj.options[selObj.selectedIndex].value+"'");
}
// major discipline selection box 3
function MM_jumpMenuAdmin3(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantform5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantform5.php?menu3="+selObj.options[selObj.selectedIndex].value+"'");
}


/***************************************
*
*  FOR THE MAJOR DISC AND SUB-SPEC
*  ADMIN CONSULTANT AMENDMENT APP. FORM
*
****************************************/
// major discipline selection box 1
function MM_jumpMenuAdminAmend(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantamend5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantamend5.php?menu1="+selObj.options[selObj.selectedIndex].value+"'");
}
// major discipline selection box 2
function MM_jumpMenuAdminAmend2(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantamend5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantamend5.php?menu2="+selObj.options[selObj.selectedIndex].value+"'");
}
// major discipline selection box 3
function MM_jumpMenuAdminAmend3(targ,selObj,restore){ //v2.0
    m1=form5.menu1.options[form5.menu1.selectedIndex].value;
    m2=form5.menu2.options[form5.menu2.selectedIndex].value;
    m3=form5.menu3.options[form5.menu3.selectedIndex].value;
    eval(targ+".location='adminconsultantamend5.php?menu1="+m1+"&menu2="+m2+"&menu3="+m3+"'");
    //  eval(targ+".location='adminconsultantamend5.php?menu3="+selObj.options[selObj.selectedIndex].value+"'");
}


/***************************************
*
*  FOR THE CLIENT SEARCH FORM
*
****************************************/
// client search major discipline selection box
function MM_jumpClientMenu(targ,selObj,restore){ //v3.0
    m1=clientform1.majordis_exp.options[clientform1.majordis_exp.selectedIndex].value;
    m2=clientform1.country_exp.options[clientform1.country_exp.selectedIndex].value;
    m3=clientform1.language_exp.options[clientform1.language_exp.selectedIndex].value;
    m4=clientform1.qualification_exp.options[clientform1.qualification_exp.selectedIndex].value;
    eval(targ+".location='client.php?majordis_exp="+m1+"&country_exp="+m2+"&language_exp="+m3+"&qualification_exp="+m4+"'");
}


/***************************************
*
*  FOR THE CLIENT SEARCH FORM
*  (ON -NO RECORD- FOUND PAGE)
*
****************************************/
// client search major discipline selection box
function MM_jumpClientNoFoundMenu(targ,selObj,restore){ //v3.0
    m1=clientform1.majordis_exp.options[clientform1.majordis_exp.selectedIndex].value;
    m2=clientform1.country_exp.options[clientform1.country_exp.selectedIndex].value;
    m3=clientform1.language_exp.options[clientform1.language_exp.selectedIndex].value;
    m4=clientform1.qualification_exp.options[clientform1.qualification_exp.selectedIndex].value;
    eval(targ+".location='clientsearch.php?majordis_exp="+m1+"&country_exp="+m2+"&language_exp="+m3+"&qualification_exp="+m4+"'");
}