function checkEmpNumber(empNumber) {
	
	var errMsg = '';
	var checkDigit;		//the last digit of the employee number
	var remainingNum;	//the first five digits
	var strNum;
	var num;
	var totalNum = 0;
	var i;
	//check if the employee number is the right length
	if(empNumber.length != 6) {
		errMsg = 'Please enter a valid employee number';
	}
	
	if(errMsg == '') {
		//note - multiplying the strings by 1 converts them
		//to numbers
		
		//to calculate the check digit:
		//first drop the last digit from the number (because that's
		//what we are trying to calculate
		checkDigit = empNumber.charAt(5) * 1;
		remainingNum = empNumber.substring(0,5);

		//reverse the remaining numbers
		remainingNum = reverseNum(remainingNum);
		//multiply all the digits in odd positions (the first digit, the third digit, etc) by 2
		for(i=0;i<=4;i=i+2) {
			strNum = remainingNum.charAt(i);

			//convert the string to a number
			num = strNum * 1;

			//multiply the number by 2
			num = num * 2;

			//if the number is greater than 9, subtract nine from it
			if(num > 9) { num = num - 9; }
			//add the number to the total
			totalNum = totalNum + num;
		}

		//add the even numbered digits (the second, and fourth) to the number
		//you got in the previous step
		totalNum = totalNum + ((remainingNum.charAt(1))*1) +((remainingNum.charAt(3))*1);

		//the check digit is the amount you need to add to that number to make a multiple
		//of 10.  So if you got 68 in the previous step, the check digit would be 2.
		totalNum = totalNum + checkDigit;
		if(totalNum % 10 != 0) {
			errMsg = "Please supply a valid number";
		}
	}
	//if no error message is set,then return true,
	//otherwise show an error message and display the message
	if(errMsg != '') {
		return false
	}	
	else {
		return true;
	}
}

//function to reverse a string
function reverseNum(number) {
	var i;
	var x=0;
	var subnumbers = new Array();
	var newNumber = '';
	
	for(i=number.length-1;i>=0;i--) {
		subnumbers[x] = number.charAt(i);
		x++;
	}
	
	for(i=0;i<subnumbers.length;i++) {
		newNumber = newNumber + subnumbers[i];
	}
	return newNumber;
}

