<!--
    var blnPositionGroup1 = false;
    var blnPositionGroup2 = false;

//Validate User Form////////////////////////////////////////////////////////////////////////
    function check(myForm,checkEmail)
    {

        var missingElements = '';
        //alert(myForm.firstName.name);
        //return false;

        //Primary Information fields///////////////////////////////////////////////////
        if(myForm.firstName)
		{
			myForm.firstName.value = Trim(myForm.firstName.value);
	        if(myForm.firstName.value == '')
	        {
	            missingElements += '-> first name \n'
	        }
		}

        if(myForm.lastName)
		{
	        if(myForm.lastName.value == '')
			{
		        if(myForm.lastName.value == '')
		        {
		            missingElements += '-> last name \n'
		        }
			}
		}
			
        if(myForm.email)
        {
			

			if(checkEmail == 'true'){
	            var strEmail = myForm.email.value;
				strEmail = Trim(strEmail);
				myForm.email.value = strEmail;

	            if(strEmail == '')
	            { //ADD EMAIL SYNTAX VALIDATION
		                missingElements += '-> email \n'
	            } else {
	                if(!checkemail(strEmail))
					{
						//alert('BAD EMAIL!  BAD!');
		                missingElements += '-> email is in the incorrect format \n'
	                }
	            }
			}
        }
		
        if(myForm.ssn)
        {
            var strSSN = myForm.ssn.value;
            if(strSSN == '')
            {
                missingElements += '-> social security number \n'
            } else {
                if(!checkssn(strSSN)){
                    missingElements += '-> social security number is in the incorrect format \n'
                }
            }
        }

        //phone1Type select menu check
        if(myForm.phone1Type)
        {
            if (selectCheck(myForm.phone1Type))
            {
                missingElements += '-> primary phone type \n';
            }
        }

        if(myForm.phone1 || myForm.phone)
        {
            var strPhone1 = ((myForm.phone1) ? myForm.phone1.value : myForm.phone.value);
            if(strPhone1 == '')
            { //ADD SYNTAX VALIDATION
                missingElements += '-> primary phone number \n'
            } else {
                if(!checkphone(strPhone1)){
                    //alert('BAD EMAIL!  BAD!');
                    missingElements += '-> primary phone number is in the incorrect format \n'
                }
            }
        }

        if(myForm.phone2)
        {
            var strPhone2 = myForm.phone2.value;
            if(strPhone2.length > 0)
            {
                //phone2Type select menu check
                if (selectCheck(myForm.phone2Type))
                {
                    if(myForm.phone2 && myForm.phone2.value != '')
                    missingElements += '-> secondary phone type \n';
                }

                if(!checkphone(strPhone2)){
                missingElements += '-> secondary phone number is in the incorrect format \n'
                }
            }
            if (!selectCheck(myForm.phone2Type) && myForm.phone2.value.length < 1)
            {
                missingElements += '-> secondary phone number \n'
            }
			
        }

        //address1
        if(myForm.address1)
        {	            
			var strVal = myForm.address1.value;
			strVal = Trim(strVal);
			myForm.address1.value = strVal;
			
            if(myForm.address1.value == '')
            { //ADD SYNTAX VALIDATION
                missingElements += '-> address line 1 \n'
            }
        }
        //city
        if(myForm.city)
        {
			var strVal = myForm.city.value;
			strVal = Trim(strVal);
			myForm.city.value = strVal;
			
            if(myForm.city.value == '')
            { //ADD SYNTAX VALIDATION
                missingElements += '-> city \n'
            }
        }

        //state select menu check
        if(myForm.state)
        {
            if (selectCheck(myForm.state))
            {
                missingElements += '-> state \n';
            }
        }

        //zipcode
        if(myForm.zipcode)
        {
            if(myForm.zipcode.value == '')
            { //ADD SYNTAX VALIDATION
                missingElements += '-> zip code \n'
            }
        }

        //Applicant Details fields///////////////////////////////////////////////////
        //position select menu check
        if(myForm.position)
        {
            if (selectCheck(myForm.position))
            {
                missingElements += '-> position \n';
            }
        }

        //currentlyWorking Check: START

        if(myForm.currentlyWorking)
        {
            rNoCheck=true;

            for (var i=0, j=myForm.currentlyWorking.length; i<j; i++)
            {

                    if (myForm.currentlyWorking[i].checked != 0)
                    {
                            rNoCheck=false;
                    }

            }

            if (rNoCheck)
            {
                missingElements += '-> currently working \n';
            }
        }
        //currentlyWorking Check: END

        //fullPartTime Check: START

        if(myForm.fullPartTime)
        {
            rNoCheck=true;


            for (var i=0, j=myForm.fullPartTime.length; i<j; i++)
            {

                    if (myForm.fullPartTime[i].checked != 0)
                    {
                            rNoCheck=false;
                    }

            }

            if (rNoCheck)
            {
                missingElements += '-> available full or part-time \n';
            }
        }

        //fullPartTime Check: END

        //workDays select menu check
        if(myForm.workDays)
        {
            if (selectCheck(myForm.workDays))
            {
                missingElements += '-> available work days \n';
            }
        }

        //shift select menu check
        if(myForm.shift)
        {
            if (selectCheck(myForm.shift))
            {
                missingElements += '-> available work shifts \n';
            }
        }

        //dateFirstAvailable
        if(myForm.dateFirstAvailable)
        {
			var myYear = new Date(); 
			myYear = myYear.getYear();
			if (myYear < 1000) 
			{ 
				myYear += 1900; 
			} 
			
            if(myForm.dateFirstAvailable.value.length < 1)
            { 
                missingElements += '-> first date available \n'
			} else if(myForm.dateFirstAvailable.value.length >= 1  && myForm.dateFirstAvailable.value.length < 10) { 
				missingElements += '-> first date available: '+ '\'' + myForm.dateFirstAvailable.value + '\' does not conform to the expected format: mm-dd-yyyy  \n'
            } else if(parseInt(myForm.dateFirstAvailable.value.substr(6)) < myYear) { 
				missingElements += '-> first date available: '+ '\'' + myForm.dateFirstAvailable.value + '\' must be in the current year or later.  \n'
            } else {
				
				if(dateCheck(myForm.dateFirstAvailable.value,'%mm-%dd-%yyyy')) 
				{
					/*do nothing*/
					//alert(dateCheck(myForm.dateFirstAvailable.value,'%mm-%dd-%yyyy'));
					//return;
					 missingElements += '-> first date available: ' + dateCheck(myForm.dateFirstAvailable.value,'%mm-%dd-%yyyy') +' \n'
				}
			}
        }

        //closestLocation select menu check
        if(myForm.closestLocation)
        {
            if (selectCheck(myForm.closestLocation))
            {
                missingElements += '-> which locations is closest to where you live \n';
            }
        }

        //transportation select menu check
        if(myForm.transportation)
        {
            if (selectCheck(myForm.transportation))
            {
                missingElements += '-> public/private transportation \n';
            }
        }
		
        //milesTravel select menu check
        if(myForm.milesTravel)
        {
            if (selectCheck(myForm.milesTravel))
            {
                missingElements += '-> commute miles \n';
            }
        }

        //Position Recently Held fields///////////////////////////////////////////////////
        //formerCompany1
        if(myForm.formerCompany1)
        {
			var strVal = myForm.formerCompany1.value;
			strVal = Trim(strVal);
			myForm.formerCompany1.value = strVal;
			
            if(myForm.formerCompany1.value == '')
            {
                missingElements += '-> company name or recent position (1) \n'
            }
        }
		
        //formerPosition1
        if(myForm.formerPosition1)
        {
    		var strVal = myForm.formerPosition1.value;
			strVal = Trim(strVal);
			myForm.formerPosition1.value = strVal;
			
            if(myForm.formerPosition1.value == '')
            {
                missingElements += '-> occupation/title (1) \n'
            }
        }
		
		//supervisor : field from Clinical Reserch Form
        if(myForm.supervisor)
        {
			var strVal = myForm.supervisor.value;
			strVal = Trim(strVal);
			myForm.supervisor.value = strVal;
        }
		
        //supervisorPhone : field from Clinical Reserch Form
        if(myForm.supervisorPhone)
        {
            var strPhone1 = myForm.supervisorPhone.value;
            if(strPhone1.length > 1)//Only check syntax if there is a value in the field, firled is not required.
            { 
				if(!checkphone(strPhone1)){
                    missingElements += '-> supervisor phone number is in the incorrect format \n'
                }
            }
        }


		
        //formerDuties1
        if(myForm.formerDuties1)
        {
		
    		var strVal = myForm.formerDuties1.value;
			strVal = Trim(strVal);
			myForm.formerDuties1.value = strVal;
			
            if(myForm.formerDuties1.value == '')
            {
                missingElements += '-> duties (1) \n'
            }
            if(myForm.formerDuties1.value.length > 250)
            {
                missingElements += '-> duties (1) has more than 250 characters \n'
            }
        }
		
        //employedFromMonth1 select menu check
        if(myForm.employedFromMonth1)
        {
            blnPositionGroup1 = true; //if this object exists then all of the associated objects must exist
            if (selectCheck(myForm.employedFromMonth1))
            {
                missingElements += '-> employed from: month (1) \n';
            }
        }
		
        //employedFromYear1 select menu check
        if(myForm.employedFromYear1)
        {
            if (selectCheck(myForm.employedFromYear1))
            {
                missingElements += '-> employed from: year (1) \n';
            }
        }
		
        //employedToMonth1 select menu check
        if(myForm.employedToMonth1)
        {
            if (selectCheck(myForm.employedToMonth1))
            {
                missingElements += '-> employed to: month (1) \n';
            }
        }
        //employedToYear1 select menu check
        if(myForm.employedToYear1)
        {
            if(selectCheck(myForm.employedToYear1))
            {
                missingElements += '-> employed to: year (1) \n';
            }
        }

        //compare dates (1) for sequence
        if(blnPositionGroup1)
        {   
            if(!compareDates('1','1'))
            {
                missingElements += '-> employed to date (1) entered is before the employed from date (1) entered \n';
            }
        }

        //reasonForLeaving1 select menu check
        if(myForm.reasonForLeaving1)
        {
            if(selectCheck(myForm.reasonForLeaving1))
            {
                missingElements += '-> reason for leaving (1) \n';
            }
        }

        //Position Recently Held 2nd block: This set of fields is only required if a value is entered in anyone field
        if((myForm.formerCompany2 && myForm.formerPosition2
            && myForm.formerDuties2 && myForm.employedFromMonth2
            && myForm.employedFromYear2 && myForm.employedToMonth2
            && myForm.employedToYear2 && myForm.reasonForLeaving2)
            && (myForm.formerCompany2.value.length
            + myForm.formerPosition2.value.length
            + myForm.formerDuties2.value.length
            + eval(myForm.employedFromMonth2.options[myForm.employedFromMonth2.selectedIndex].value.length)
            + eval(myForm.employedFromYear2.options[myForm.employedFromYear2.selectedIndex].value.length)
            + eval(myForm.employedToMonth2.options[myForm.employedToMonth2.selectedIndex].value.length)
            + eval(myForm.employedToYear2.options[myForm.employedToYear2.selectedIndex].value.length)
            + eval(myForm.reasonForLeaving2.options[myForm.reasonForLeaving2.selectedIndex].value.length) > 0))
        {
            //formerCompany2
            if(myForm.formerCompany2.value == '')
            {
			
	    		var strVal = myForm.formerCompany2.value;
				strVal = Trim(strVal);
				myForm.formerCompany2.value = strVal;
			
                missingElements += '-> company name or recent position (2) \n'
            }

            //formerPosition2
    		var strVal = myForm.formerPosition2.value;
			strVal = Trim(strVal);
			myForm.formerPosition2.value = strVal;
			
            if(myForm.formerPosition2.value == '')
            {
                missingElements += '-> occupation/title (2) \n'
            }

            //formerDuties2
    		var strVal = myForm.formerDuties2.value;
			strVal = Trim(strVal);
			myForm.formerDuties2.value = strVal;
			
            if(myForm.formerDuties2.value == '')
            {
                missingElements += '-> duties (2) \n'
            }
            if(myForm.formerDuties2.value.length > 250)
            {
                missingElements += '-> duties (2) has more than 250 characters \n'
            }


            //employedFromMonth2 select menu check
	         if(myForm.employedFromMonth2)
			 {
			    if (selectCheck(myForm.employedFromMonth2))
	            {
	                missingElements += '-> employed from: month (2) \n';
	            }
			}

            //employedFromYear2 select menu check
			if(myForm.employedFromYear2)
			{
	            if (selectCheck(myForm.employedFromYear2))
	            {
	                missingElements += '-> employed from: year (2) \n';
	            }
			}
            //employedToMonth2 select menu check
            if (myForm.employedToMonth2)
			 {
			    if (selectCheck(myForm.employedToMonth2))
	            {
	                missingElements += '-> employed to: month (2) \n';
	            }
			}

            //employedToYear2 select menu check
            if (myForm.employedToYear2)
			{
	            if (selectCheck(myForm.employedToYear2))
	            {
	                missingElements += '-> employed to: year (2) \n';
	            }
			}

        //compare dates (2) for sequence
        if(blnPositionGroup1)
        {
            if(!compareDates('2','1'))
            {
                missingElements += '-> employed to date (2) entered is before the employed from date (2) entered \n';
            }
    
                //reasonForLeaving2 select menu check
                if (selectCheck(myForm.reasonForLeaving2))
                {
                    missingElements += '-> reason for leaving (2) \n';
                }
    
            }
        }
        //Education fields set(1)///////////////////////////////////////////////////
        if(myForm.degree1)
        {
            if (myForm.degree1.options[myForm.degree1.selectedIndex].text != 'No Degree')
            {

                //degree1 select menu check
                if (selectCheck(myForm.degree1))
                {
                    missingElements += '-> degree (1) \n';
                }

                //major1 select menu check
                if(myForm.major1)
                {
                    if (selectCheck(myForm.major1))
                    {
                        missingElements += '-> major (1) \n';
                    }
                }

                //university1
                if(myForm.university1)
                {
			   		var strVal = myForm.university1.value;
					strVal = Trim(strVal);
					myForm.university1.value = strVal;
					
                    if(myForm.university1.value == '')
                    {
                        missingElements += '-> university (1) \n'
                    }
                }

                //graduationMonth1 select menu check
                if(myForm.graduationMonth1)
                {
                    if (selectCheck(myForm.graduationMonth1))
                    {
                        missingElements += '-> graduation month (1) \n';
                    }
                }

                //graduationYear1 select menu check
                if(myForm.graduationYear1)
                {
                    if (selectCheck(myForm.graduationYear1))
                    {
                        missingElements += '-> graduation year (1) \n';
                    }
                }
            }
        }

        //Education fields set(2):  This set of fields is only required if a value is entered in anyone field
        if(myForm.degree2
            && (myForm.degree2.options[myForm.degree2.selectedIndex].value.length
            + myForm.major2.options[myForm.major2.selectedIndex].value.length
            + myForm.university2.value.length
            + myForm.graduationMonth2.options[myForm.graduationMonth2.selectedIndex].value.length
            + myForm.graduationYear2.options[myForm.graduationYear2.selectedIndex].value.length > 0))
        {
            if (myForm.degree2.options[myForm.degree2.selectedIndex].text != 'No Degree')
            {

                //degree2 select menu check
                if (selectCheck(myForm.degree2))
                {
                    missingElements += '-> degree (2) \n';
                }

                //major2 select menu check
                if(myForm.major2)
                {
                    if (selectCheck(myForm.major2))
                    {
                        missingElements += '-> major (2) \n';
                    }
                }

                //university2
                if(myForm.university2)
                {
			   		var strVal = myForm.university2.value;
					strVal = Trim(strVal);
					myForm.university2.value = strVal;
					
                    if(myForm.university2.value == '')
                    {
                        missingElements += '-> university (2) \n'
                    }
                }

                //graduationMonth2 select menu check
                if(myForm.graduationMonth2)
                {
                    if (selectCheck(myForm.graduationMonth2))
                    {
                        missingElements += '-> graduation month (2) \n';
                    }
                }

                //graduationYear2 select menu check
                if(myForm.graduationYear2)
                {
                    if (selectCheck(myForm.graduationYear2))
                    {
                        missingElements += '-> graduation year (2) \n';
                    }
                }
            }
        }

        //Education fields set(3):  This set of fields is only required if a value is entered in anyone field
        if(myForm.degree3
            && (myForm.degree3.options[myForm.degree3.selectedIndex].value.length
            + myForm.major3.options[myForm.major3.selectedIndex].value.length
            + myForm.university3.value.length
            + myForm.graduationMonth3.options[myForm.graduationMonth3.selectedIndex].value.length
            + myForm.graduationYear3.options[myForm.graduationYear3.selectedIndex].value.length > 0))
        {
            if (myForm.degree3.options[myForm.degree3.selectedIndex].text != 'No Degree')
            {

                //degree3 select menu check
                if (selectCheck(myForm.degree3))
                {
                    missingElements += '-> degree (3) \n';
                }

                //major3 select menu check
                if(myForm.major3)
                {
                    if (selectCheck(myForm.major3))
                    {
                        missingElements += '-> major (3) \n';
                    }
                }

                //university3
                if(myForm.university3)
                {
			   		var strVal = myForm.university3.value;
					strVal = Trim(strVal);
					myForm.university3.value = strVal;
					
                    if(myForm.university3.value == '')
                    {
                        missingElements += '-> university (3) \n'
                    }
                }

                //graduationMonth3 select menu check
                if(myForm.graduationMonth3)
                {
                    if (selectCheck(myForm.graduationMonth3))
                    {
                        missingElements += '-> graduation month (3) \n';
                    }
                }

                //graduationYear3 select menu check
                if(myForm.graduationYear3)
                {
                    if (selectCheck(myForm.graduationYear3))
                    {
                        missingElements += '-> graduation year (3) \n';
                    }
                }
            }
        }
        //Skills & Certifications fields///////////////////////////////////////////////////
        //skill select menu check
        if(myForm.skill)
        {
            if (selectMultipleCheck(myForm.skill))
            {
                missingElements += '-> skills \n';
            }
        }

        
        //language select menu check
        //if (selectCheck(myForm.language))
        if (document.getElementById('language0'))
		{
			//If form manager feature used from browser, check if values are equal and reset
			if (document.getElementById('language0').selectedIndex == document.getElementById('language2').selectedIndex)
			{
				document.getElementById('language2').selectedIndex = 0;
			}
			if (document.getElementById('language0').selectedIndex == document.getElementById('language1').selectedIndex)
			{
				document.getElementById('language1').selectedIndex = 0;
			}
			if (document.getElementById('language1').selectedIndex == document.getElementById('language2').selectedIndex)
			{
				document.getElementById('language2').selectedIndex = 0;
			}
	        //check if primary language has selected value.
			if (selectCheck(document.getElementById('language0')))
	        {
	            missingElements += '-> primary language \n';
	        }			
		}

        //Referral Information fields///////////////////////////////////////////////////
        //referralSource select menu check
        if(myForm.referralSource)
        {
            if (selectCheck(myForm.referralSource))
            {
                missingElements += '-> referral information \n';
            }
        }

         //comment 
         if(myForm.comment)
         {
	   		var strVal = myForm.comment.value;
			strVal = Trim(strVal);
			myForm.comment.value = strVal;

		 	var intCharDiff;
			if (myForm.comment.value.length > 3000) {
			 	intCharDiff = myForm.comment.value.length - 3000;
			 	missingElements += '-> notes - comments: has exceeded the 3000 character limit by ' + intCharDiff + '\n'
			 }
         }

        //display alert or submit form/////////////////////////////////////////////////////
        if(missingElements.length > 0)
        {
            alert('The following form field(s) were missing or need revision:\n\n' + missingElements + '\nPlease complete or correct the form and submit again.');
            myForm.submit.value = 'Submit';
            return false;
        }else{

            return true;
        }


    }
//END Validate User Form////////////////////////////////////////////////////////////////////////



    //Check select drop down
    function selectCheck(fieldObject)
    {

        //alert(fieldObject.options.length);
        //return;

        rNoCheck=true;
        for (var i=0, j=fieldObject.options.length; i<j; i++)
        {
            if (fieldObject.selectedIndex != 0)
            {
                rNoCheck=false;
            }
        }

            return rNoCheck;
    }

    //Check select drop down with multiple attribute
    function selectMultipleCheck(fieldObject)
    {
        //alert(fieldObject.options.length);
        //return;

        rNoCheck=true;
        for (var i=0, j=fieldObject.options.length; i<j; i++)
        {
            if (fieldObject.options[i].selected)
            {
                rNoCheck=false;
            }
        }

            return rNoCheck;
    }


    /*/Radio Test/////////////////////////////////////////
        rField=document.applicantForm.Status;
        rLen=rField.length;
        rNoCheck=true;
        for (i=0; i<rLen; i++)
        {
            if (rField[i].checked)
            {
                //alert("Value is: \n\n" + rField[i].value);
                rNoCheck=false;
            }
        }

        if (rNoCheck )
        {
            //alert('You did not select any radio button choices');
            missingElements = '-> status \n';
        }
    //END Radio Test///////////////////////////////////*/

    //EMAIL VALIDATION
    function checkemail(str){
        
		//var filter=/^(\w+(?:\.\w+)*)[\.]*(\w+(?:\.\w+)*)@((?:\w+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		var filter=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/
        if (filter.test(str))
            return true;
        else{
            return false;
        }
		
    }
    //END EMAIL VALIDATION

    //SSN VALIDATION
    function checkssn(str){
        var filter=/^(\d{3})-(\d{2})-(\d{4})$/;
        if (filter.test(str))
            return true;
        else{
            return false;
        }
    }
    //END SSN VALIDATION

    //PHONE VALIDATION
    function checkphone(str){
        var filter=/^(\d{3})[\/.]?(\d{3})(.)?(\d{4})$/;
        if (filter.test(str))
            return true;
        else{
            return false;
        }
    }
    //END PHONE VALIDATION
	
	//DATE VALIDATION SIMPLE
    function checkdatesimple(str){
        var filter=/^(\d{2})[\/-]?(\d{2})(-)?(\d{4})$/;
        if (filter.test(str))
            return true;
        else{
            return false;
		}
    }
    //END DATE VALIDATION SIMPLE

    //DATE VALIDATION
        /*<!-- Original:  Sandeep Tamhankar (stamhankar@hotmail.com) --> 

        <!-- This script and many more are available free online at --> 
        <!-- The JavaScript Source!! http://javascript.internet.com --> 

        <!-- Begin
         Here's the list of tokens we support:
           m (or M) : month number, one or two digits.
           mm (or MM) : month number, strictly two digits (i.e. April is 04).
           d (or D) : day number, one or two digits.
           dd (or DD) : day number, strictly two digits.
           y (or Y) : year, two or four digits.
           yy (or YY) : year, strictly two digits.
           yyyy (or YYYY) : year, strictly four digits.
           mon : abbreviated month name (April is apr, Apr, APR, etc.)
           Mon : abbreviated month name, mixed-case (i.e. April is Apr only).
           MON : abbreviated month name, all upper-case (i.e. April is APR only).
           mon_strict : abbreviated month name, all lower-case (i.e. April is apr
                 only).
           month : full month name (April is april, April, APRIL, etc.)
           Month : full month name, mixed-case (i.e. April only).
           MONTH: full month name, all upper-case (i.e. APRIL only).
           month_strict : full month name, all lower-case (i.e. april only).
           h (or H) : hour, one or two digits.
           hh (or HH) : hour, strictly two digits.
           min (or MIN): minutes, one or two digits.
           mins (or MINS) : minutes, strictly two digits.
           s (or S) : seconds, one or two digits.
           ss (or SS) : seconds, strictly two digits.
           ampm (or AMPM) : am/pm setting.  Valid values to match this token are
                 am, pm, AM, PM, a.m., p.m., A.M., P.M.
        */
        // Be careful with this pattern.  Longer tokens should be placed before shorter
        // tokens to disambiguate them.  For example, parsing "mon_strict" should
        // result in one token "mon_strict" and not two tokens "mon" and a literal
        // "_strict".

        var tokPat=new RegExp("^month_strict|month|Month|MONTH|yyyy|YYYY|mins|MINS|mon_strict|ampm|AMPM|mon|Mon|MON|min|MIN|dd|DD|mm|MM|yy|YY|hh|HH|ss|SS|m|M|d|D|y|Y|h|H|s|S");

        // lowerMonArr is used to map months to their numeric values.

        var lowerMonArr={jan:1, feb:2, mar:3, apr:4, may:5, jun:6, jul:7, aug:8, sep:9, oct:10, nov:11, dec:12}

        // monPatArr contains regular expressions used for matching abbreviated months
        // in a date string.

        var monPatArr=new Array();
        monPatArr['mon_strict']=new RegExp(/jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec/);
        monPatArr['Mon']=new RegExp(/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/);
        monPatArr['MON']=new RegExp(/JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC/);
        monPatArr['mon']=new RegExp("jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",'i');

        // monthPatArr contains regular expressions used for matching full months
        // in a date string.

        var monthPatArr=new Array();
        monthPatArr['month']=new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/i);
        monthPatArr['Month']=new RegExp(/^January|February|March|April|May|June|July|August|September|October|November|December/);
        monthPatArr['MONTH']=new RegExp(/^JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER/);
        monthPatArr['month_strict']=new RegExp(/^january|february|march|april|may|june|july|august|september|october|november|december/);

        // cutoffYear is the cut-off for assigning "19" or "20" as century.  Any
        // two-digit year >= cutoffYear will get a century of "19", and everything
        // else gets a century of "20".

        var cutoffYear=50;

        // FormatToken is a datatype we use for storing extracted tokens from the
        // format string.

        function FormatToken (token, type) {
	        this.token=token;
	        this.type=type;
        }

        function parseFormatString (formatStr) {
	        var tokArr=new Array;
	        var tokInd=0;
	        var strInd=0;
	        var foundTok=0;

	        while (strInd < formatStr.length) {
		        if (formatStr.charAt(strInd)=="%" &&
			        (matchArray=formatStr.substr(strInd+1).match(tokPat)) != null) {
			        strInd+=matchArray[0].length+1;
			        tokArr[tokInd++]=new FormatToken(matchArray[0],"symbolic");
		        } else {
		
			        // No token matched current position, so current character should
			        // be saved as a required literal.
			
			        if (tokInd>0 && tokArr[tokInd-1].type=="literal") {
			
			        // Literal tokens can be combined.Just add to the last token.
			
			        tokArr[tokInd-1].token+=formatStr.charAt(strInd++);
			        }
			        else {
			        tokArr[tokInd++]=new FormatToken(formatStr.charAt(strInd++), "literal");
					}
		        }
			}
	        return tokArr;
        }

        /* buildDate does all the real work.It takes a date string and format string,
         tries to match the two up, and returns a Date object (with the supplied date
         string value).If a date string doesn't contain all the fields that a Date
         object contains (for example, a date string with just the month), all
         unprovided fields are defaulted to those characteristics of the current
         date. Time fields that aren't provided default to 0.Thus, a date string
         like "3/30/2000" in "%mm/%dd/%yyyy" format results in a Date object for that
         date at midnight.formatStr is a free-form string that indicates special
         tokens via the % character.Here are some examples that will return a Date
         object:

         buildDate('3/30/2000','%mm/%dd/%y') // March 30, 2000
         buildDate('March 30, 2000','%Mon %d, %y') // Same as above.
         buildDate('Here is the date: 30-3-00','Here is the date: %dd-%m-%yy')

         If the format string does not match the string provided, an error message
         (i.e. String object) is returned.Thus, to see if buildDate succeeded, the
         caller can use the "typeof" command on the return value.For example,
         here's the dateCheck function, which returns true if a given date is
         valid,and false otherwise (and reports an error in the false case):

         function dateCheck(dateStr,formatStr) {
         var myObj=buildDate(dateStr,formatStr);
         if (typeof myObj=="object") {
         // We got a Date object, so good.
         return true;
         } else {
         // We got an error string.
         alert(myObj);
         return false;
         }
         }

        */

        function buildDate(dateStr,formatStr) {
        // parse the format string first.
        var tokArr=parseFormatString(formatStr);
        var strInd=0;
        var tokInd=0;
        var intMonth;
        var intDay;
        var intYear;
        var intHour;
        var intMin;
        var intSec;
        var ampm="";
        var strOffset;

        // Create a date object with the current date so that if the user only
        // gives a month or day string, we can still return a valid date.

        var curdate=new Date();
        intMonth=curdate.getMonth()+1;
        intDay=curdate.getDate();
        intYear=curdate.getFullYear();

        // Default time to midnight, so that if given just date info, we return
        // a Date object for that date at midnight.

        intHour=0;
        intMin=0;
        intSec=0;

        // Walk across dateStr, matching the parsed formatStr until we find a
        // mismatch or succeed.

        while (strInd < dateStr.length && tokInd < tokArr.length) {

	        // Start with the easy case of matching a literal.
	        if (tokArr[tokInd].type=="literal") {
				//alert(dateStr.indexOf(tokArr[tokInd].token,strInd));
	    	    if (dateStr.indexOf(tokArr[tokInd].token,strInd)==strInd) {
	
		        // The current position in the string does match the format
	    	    // pattern.
	
				strInd+=tokArr[tokInd++].token.length;
	        	continue;
		        }
	    	    else {
	
	        	// ACK! There was a mismatch; return error.
	
		        return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
	           }
	        }

        // If we get here, we're matching to a symbolic token.
        switch (tokArr[tokInd].token) {
        case 'm':
        case 'M':
        case 'd':
        case 'D':
        case 'h':
        case 'H':
        case 'min':
        case 'MIN':
        case 's':
        case 'S':

        // Extract one or two characters from the date-time string and if
        // it's a number, save it as the month, day, hour, or minute, as
        // appropriate.

        curChar=dateStr.charAt(strInd);
        nextChar=dateStr.charAt(strInd+1);
        matchArr=dateStr.substr(strInd).match(/^\d{1,2}/);
        if (matchArr==null) {

	        // First character isn't a number; there's a mismatch between
	        // the pattern and date string, so return error.
	
	        switch (tokArr[tokInd].token.toLowerCase()) {
	        case 'd': var unit="day"; break;
	        case 'm': var unit="month"; break;
	        case 'h': var unit="hour"; break;
	        case 'min': var unit="minute"; break;
	        case 's': var unit="second"; break;
	        }
	        //return "bad " + unit + " \"" + curChar + "\" or \"" + curChar + nextChar + "\".";
	        return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
        }
        strOffset=matchArr[0].length;
        switch (tokArr[tokInd].token.toLowerCase()) {
	        case 'd': intDay=parseInt(matchArr[0],10); break;
	        case 'm': intMonth=parseInt(matchArr[0],10); break;
	        case 'h': intHour=parseInt(matchArr[0],10); break;
	        case 'min': intMin=parseInt(matchArr[0],10); break;
	        case 's': intSec=parseInt(matchArr[0],10); break;
        }
        break;
        case 'mm':
        case 'MM':
        case 'dd':
        case 'DD':
        case 'hh':
        case 'HH':
        case 'mins':
        case 'MINS':
        case 'ss':
        case 'SS':

        // Extract two characters from the date string and if it's a
        // number, save it as the month, day, or hour, as appropriate.

        strOffset=2;
        matchArr=dateStr.substr(strInd).match(/^\d{2}/);
        if (matchArr==null) {

        // The two characters aren't a number; there's a mismatch
        // between the pattern and date string, so return an error
        // message.

        switch (tokArr[tokInd].token.toLowerCase()) {
	        case 'dd': var unit="day"; break;
	        case 'mm': var unit="month"; break;
	        case 'hh': var unit="hour"; break;
	        case 'mins': var unit="minute"; break;
	        case 'ss': var unit="second"; break;
        }
        return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
        //return "bad " + unit + " \"" + dateStr.substr(strInd,2) + "\".";
        }
        switch (tokArr[tokInd].token.toLowerCase()) {
	        case 'dd': intDay=parseInt(matchArr[0],10); break;
	        case 'mm': intMonth=parseInt(matchArr[0],10); break;
	        case 'hh': intHour=parseInt(matchArr[0],10); break;
	        case 'mins': intMin=parseInt(matchArr[0],10); break;
	        case 'ss': intSec=parseInt(matchArr[0],10); break;
        }
        break;
        case 'y':
        case 'Y':

        // Extract two or four characters from the date string and if it's
        // a number, save it as the year.Convert two-digit years to four
        // digit years by assigning a century of '19' if the year is >=
        // cutoffYear, and '20' otherwise.

        if (dateStr.substr(strInd,4).search(/\d{4}/) != -1) {
			// Four digit year.
	
	        intYear=parseInt(dateStr.substr(strInd,4),10);
	        strOffset=4;
        }
        else {
        	if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {

       	 // Two digit year.

      	 intYear=parseInt(dateStr.substr(strInd,2),10);
       	 if (intYear>=cutoffYear) {
        	intYear+=1900;
        }
        else {
       	 intYear+=2000;
        }
       	 strOffset=2;
        }
        else {

        // Bad year; return error.

        //return "bad year \"" + dateStr.substr(strInd,2) + "\". must be two or four digits.";
        return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
           }
        }
        break;
        case 'yy':
        case 'YY':

        // Extract two characters from the date string and if it's a
        // number, save it as the year.Convert two-digit years to four
        // digit years by assigning a century of '19' if the year is >=
        // cutoffYear, and '20' otherwise.

        if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {

        // Two digit year.

        intYear=parseInt(dateStr.substr(strInd,2),10);
        if (intYear>=cutoffYear) {
    	    intYear+=1900;
        }
        else {
	        intYear+=2000;
        }
	        strOffset=2;
        } else {
    	    // Bad year; return error
			//return "bad year \"" + dateStr.substr(strInd,2) + "\". must be two digits.";
       		return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
        }
       	break;
        case 'yyyy':
        case 'YYYY':

        // Extract four characters from the date string and if it's a
        // number, save it as the year.

        if (dateStr.substr(strInd,4).search(/\d{4}/) != -1 && parseInt(dateStr.substr(strInd,4),10) > 1899) {

        // Four digit year.
        intYear=parseInt(dateStr.substr(strInd,4),10);
        strOffset=4;
        }
        else {

        // Bad year; return error.
        //return "bad year \"" + dateStr.substr(strInd,4) + "\". must be four digits.";
        return "\"" + dateStr + "\" does not conform to the expected format: mm-dd-yyyy" //+ formatStr;
        }
        break;
        case 'mon':
        case 'Mon':
        case 'MON':
        case 'mon_strict':

        // Extract three characters from dateStr and parse them as
        // lower-case, mixed-case, or upper-case abbreviated months,
        // as appropriate.

        monPat=monPatArr[tokArr[tokInd].token];
        if (dateStr.substr(strInd,3).search(monPat) != -1) {
        intMonth=lowerMonArr[dateStr.substr(strInd,3).toLowerCase()];
        }
        else {

        // Bad month, return error.

        switch (tokArr[tokInd].token) {
        case 'mon_strict': caseStat="lower-case"; break;
        case 'Mon': caseStat="mixed-case"; break;
        case 'MON': caseStat="upper-case"; break;
        case 'mon': caseStat="between Jan and Dec"; break;
        }
        return "bad month \"" + dateStr.substr(strInd,3) + "\". must be " + caseStat + ".";
        }
        strOffset=3;
        break;
        case 'month':
        case 'Month':
        case 'MONTH':
        case 'month_strict':

        // Extract a full month name at strInd from dateStr if possible.

        monPat=monthPatArr[tokArr[tokInd].token];
        matchArray=dateStr.substr(strInd).match(monPat);
        if (matchArray==null) {

        // Bad month, return error.

        return "can't find a month beginning at \"" + dateStr.substr(strInd) + "\".";
        }

        // It's a good month.

        intMonth=lowerMonArr[matchArray[0].substr(0,3).toLowerCase()];
        strOffset=matchArray[0].length;
        break;
        case 'ampm':
        case 'AMPM':
        matchArr=dateStr.substr(strInd).match(/^(am|pm|AM|PM|a\.m\.|p\.m\.|A\.M\.|P\.M\.)/);
        if (matchArr==null) {

        // There's no am/pm in the string.Return error msg.

        return "missing am/pm designation.";
        }

        // Store am/pm value for later (as just am or pm, to make things
        // easier later).

        if (matchArr[0].substr(0,1).toLowerCase() == "a") {

        // This is am.

        ampm = "am";
        }
        else {
        ampm = "pm";
        }
        strOffset = matchArr[0].length;
        break;
        }
        strInd += strOffset;
        tokInd++;
        }
        if (tokInd != tokArr.length || strInd != dateStr.length) {

        /* We got through the whole date string or format string, but there's
         more data in the other, so there's a mismatch. */
				
		dateStr = (dateStr.length < 1 ) ? "" : "\"" + dateStr + "\"";
		
		dateStr + " is either missing desired information or has more information than the expected format: " + formatStr;
        }

        // Make sure all components are in the right ranges.

        if (intMonth < 1 || intMonth > 12) {
        return "month must be between 01 and 12.";
        }
        if (intDay < 1 || intDay > 31) {
        return "day must be between 01 and 31.";
        }

        // Make sure user doesn't put 31 for a month that only has 30 days

        if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && intDay == 31) {
        return "month "+intMonth+" doesn't have 31 days!";
        }

        // Check for February date validity (including leap years)

        if (intMonth == 2) {

        // figure out if "year" is a leap year; don't forget that
        // century years are only leap years if divisible by 400

        var isleap=(intYear%4==0 && (intYear%100!=0 || intYear%400==0));
        if (intDay > 29 || (intDay == 29 && !isleap)) {
        return "february " + intYear + " doesn't have " + intDay +
        " days!";
           }
        }

        // Check that if am/pm is not provided, hours are between 0 and 23.

        if (ampm == "") {
        if (intHour < 0 || intHour > 23) {
        return "hour must be between 0 and 23 for military time.";
           }
        }
        else {

        // non-military time, so make sure it's between 1 and 12.

        if (intHour < 1|| intHour > 12) {
        return "hour must be between 1 and 12 for standard time.";
           }
        }

        // If user specified amor pm, convert intHour to military.

        if (ampm=="am" && intHour==12) {
        intHour=0;
        }
        if (ampm=="pm" && intHour < 12) {
        intHour += 12;
        }
        if (intMin < 0 || intMin > 59) {
        return "minute must be between 0 and 59.";
        }
        if (intSec < 0 || intSec > 59) {
        return "second must be between 0 and 59.";
        }
        return new Date(intYear,intMonth-1,intDay,intHour,intMin,intSec);
        }
        function dateCheck(dateStr,formatStr) {
        var myObj = buildDate(dateStr,formatStr);
        if (typeof myObj == "object")
		{
        // We got a Date object, so good.
		//return(myObj);
        return false;
        }
        else 
		{
	        // We got an error string.
	        //alert(myObj);
	        //return false;
			return(myObj);
           }
        }

    //END DATE VALIDATION

    //DELETE CHARACTER(S) FROM STRING
    function delChars(del, string) {
    var r = string.indexOf(del, string)
    var d = string.split(del)
    var e = d.join("")
    document.validForm.txt1.value = ""
    document.validForm.txt1.value = e
    }
    //END DELETE CHARACTER(S) FROM STRING

    //COMPARE DATES
    function compareDates(x,y)
    {   
        if(document.applicantForm.employedFromMonth1)
        {
            //x refers to the set of values
            //y determines the function call source: y is set to 1 when this function is called from another function; and is null if called and value is set to y
            var m1 = eval('document.applicantForm.employedFromMonth'+x+'.options[document.applicantForm.employedFromMonth'+x+'.selectedIndex].value');
            var y1 = eval('document.applicantForm.employedFromYear'+x+'.options[document.applicantForm.employedFromYear'+x+'.selectedIndex].value');
            var m2 = eval('document.applicantForm.employedToMonth'+x+'.options[document.applicantForm.employedToMonth'+x+'.selectedIndex].value');
            var y2 = eval('document.applicantForm.employedToYear'+x+'.options[document.applicantForm.employedToYear'+x+'.selectedIndex].value');
            var blnValidDates = true;

            if((m1 != '' && y1 != '') && (m2 != '' && y2 != '')){

                date1 = new Date( m1 + '/01/' + y1 );
                date2 = new Date( m2 + '/01/' + y2 );

                var dateDiff = ( Math.round( ( date2.getTime() - date1.getTime() ) / 86400000 ) );

                if(dateDiff < 0)
                {
                    blnValidDates = false;
                }
                if(y != null && y == '1')
                {
                    //return blnValidDates;
                    //alert(blnValidDates);
                }
                else
                {
                    if(!blnValidDates)
                    {
                        alert('The "to" date entered is before the "from" entered');
                        return;
                    }
                }
            }
            return blnValidDates;
        }
    }
    //END COMPARE DATES


    //RESET SECOND SELECTION
    function resetSelection(x,y)
    {
        var obj1 = eval('document.applicantForm.' + x);
        var obj2 = eval('document.applicantForm.' + y);

        if(obj1.options[obj1.selectedIndex].value == obj2.options[obj2.selectedIndex].value)
        {
            obj2.selectedIndex = 0;
        }
    }
    //END RESET SECOND SELECTION
    
    //CHECK MAXLENGTH
    function checkTextArea(obj,len)
    {
        if(obj)
        {
            var obj1 = obj;
            var maxLength = len;
            
            if(obj1.value.length > maxLength)
            {
                alert('You entered more than ' + maxLength + ' ('+obj1.value.length+')characters.\n Please reduce the text.');
                obj1.focus();
            }       
        }
    }
    
    //END CHECK MAXLENGTH ON TEXTAREA
	//TRIM string
	function LTrim(str)
	/*
	   PURPOSE: Remove leading blanks from our string.
	   IN: str - the string we want to LTrim
	*/
	{
	   var whitespace = new String(" \t\n\r");
	
	   var s = new String(str);
	
	   if (whitespace.indexOf(s.charAt(0)) != -1) {
	      // We have a string with leading blank(s)...
	
	      var j=0, i = s.length;
	
	      // Iterate from the far left of string until we
	      // don't have any more whitespace...
	      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
	         j++;
	
	      // Get the substring from the first non-whitespace
	      // character to the end of the string...
	      s = s.substring(j, i);
	   }
	   return s;
	}
	
	/*
	==================================================================
	RTrim(string) : Returns a copy of a string without trailing spaces.
	==================================================================
	*/
	function RTrim(str)
	/*
	   PURPOSE: Remove trailing blanks from our string.
	   IN: str - the string we want to RTrim
	
	*/
	{
	   // We don't want to trip JUST spaces, but also tabs,
	   // line feeds, etc.  Add anything else you want to
	   // "trim" here in Whitespace
	   var whitespace = new String(" \t\n\r");
	
	   var s = new String(str);
	
	   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
	      // We have a string with trailing blank(s)...
	
	      var i = s.length - 1;       // Get length of string
	
	      // Iterate from the far right of string until we
	      // don't have any more whitespace...
	      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
	         i--;
	
	
	      // Get the substring from the front of the string to
	      // where the last non-whitespace character is...
	      s = s.substring(0, i+1);
	   }
	
	   return s;
	}
	
	
	function Trim(str)
	/*
	   PURPOSE: Remove trailing and leading blanks from our string.
	   IN: str - the string we want to Trim
	
	   RETVAL: A Trimmed string!
	*/
	{
	   return RTrim(LTrim(str));
	}

	//END TRIM string

// End script hiding --> 

