//Calculates the check digit for an ISBN number.
function ISBN(strISBN)
{
	var temp;
	var ckDigit
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strISBN;
	
	while (i < number.length)  {		//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp=parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }

	//This next line computes a check digit.  If modulo 11 produces a remainder then the remainder is subtracted
	// from 11, to produce the check digit.  When the result equals 10, it is exchanged the the Roman Numeral X.
	ckDigit = ( (digits[0] *10) + (digits[1] * 9) + (digits[2] * 8) + (digits[3] * 7) + (digits[4] * 6) + (digits[5] * 5) + (digits[6] * 4) + (digits[7] * 3) + (digits[8] * 2) ) % 11;
	if (ckDigit != 0)  {
		ckDigit = 11 - ckDigit;  }

	if (ckDigit == 10)  {
		ckDigit = "X";  }
		
	return ckDigit;
}

//Calculates the check digit for an UCC/EAN-8, UCC/EAN-13 and UCC/EAN-14 number and .
function EAN(strEAN)
{
	var temp;
	var ckDigit;
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strEAN;

	while (i < number.length)  {		//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp=parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }
	
	if (i == 12) {	// If i = 13 then calculate a checkdigit for an EAN/UCC-13.
	
		ckDigit = ( (digits[0] + digits[2] + digits[4] + digits[6] + digits[8] + digits[10] ) + ( (digits[1] + digits[3] + digits[5] + digits[7] + digits[9] + digits[11] ) *3) ) % 10;
		if (ckDigit != 0)  {
			ckDigit = 10 - ckDigit;  }
		
		return ckDigit; }
	
	if (i == 7) {	// If i = 7 then calculate a checkdigit for an EAN/UCC-8.
	
		ckDigit = ( ( (digits[0] + digits[2] + digits[4] + digits[6] ) *3) + ( digits[1] + digits[3] + digits[5] ) ) % 10;
		if (ckDigit != 0)  {
			ckDigit = 10 - ckDigit;  }
		
		return ckDigit; }

	if (i == 13) {	// If i = 13 then calculate a checkdigit for an EAN/UCC-14.
	
		ckDigit = ( ( (digits[0] + digits[2] + digits[4] + digits[6] + digits[8] + digits[10] + digits[12] ) *3) + ( digits[1] + digits[3] + digits[5] + digits[7] + digits[9] + digits[11] ) ) % 10;
		if (ckDigit != 0)  {
			ckDigit = 10 - ckDigit;  }
		
		return ckDigit; }
}

//Calculates the check digit for a Bookland EAN number.
//Function receives the ISBN number and "978" is added during the calculation.
function bl_EAN(strISBN)
{
	var temp;
	var ckDigit;
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strISBN;

	while (i < number.length)  {	//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp = parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }
	
	//This next line computes a check digit.  If modulo10 produces a remainder then the remainder
	// is subtracted from 10, to produce the check digit.
	
	ckDigit = ( (9 + 8 + digits[1] + digits[3] + digits[5] + digits[7] ) + ( (7 + digits[0] + digits[2] + digits[4] + digits[6] + digits[8] ) * 3) ) % 10;
	if (ckDigit != 0)  {
		ckDigit = 10 - ckDigit;  }
		
	temp = "978" + digits[0] + digits[1] + digits[2] + digits[3] + digits[4] + digits[5] + digits[6] + digits[7] + digits[8] + ckDigit;
	return temp;
}

//Calculates the check digit for a SSCC number.
function SSCC(strSSCC)
{
	var temp;
	var ckDigit;
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strSSCC;

	while (i <= number.length)  {		//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp = parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }

	//This next line computes a check digit.  If modulo 10 produces a remainder then the remainder
	// is subtracted from 10, to produce the check digit.
	ckDigit = ( ( (digits[0]+digits[2]+digits[4]+digits[6]+digits[8]+digits[10]+digits[12]+digits[14]+digits[16] ) * 3 ) + (digits[1]+digits[3]+digits[5]+digits[7]+digits[9]+digits[11]+digits[13]+digits[15] ) ) % 10;
	if (ckDigit != 0)  {
		ckDigit = 10 - ckDigit;  }
		
	return ckDigit;
}

//Calculates the check digit for a UPC-A number.
function UPC(strUPC)
{
	var temp;
	var ckDigit;
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strUPC;

	while (i <= number.length)  {		//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp = parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }

	//This next line computes a check digit.  If modulo 10 produces a remainder then the remainder
	// is subtracted from 10, to produce the check digit.
	ckDigit = ( ( (digits[0]+digits[2]+digits[4]+digits[6]+digits[8]+digits[10]) * 3 ) + (digits[1]+digits[3]+digits[5]+digits[7]+digits[9] ) ) % 10;
	if (ckDigit != 0)  {
		ckDigit = 10 - ckDigit;  }

	return ckDigit;
}

//Calculates the check digit for a Bill of Lading number.
function BOL(strBOL)
{
	var temp;
	var ckDigit;
	var number = new String();
	var digits = new Array( );
	var i = 0;

	number = strBOL;

	while (i < number.length)  {		//This while statement seperates the string
		temp = number.charAt(i);	//into characters then turns the characters into
		temp=parseInt(temp);		//integers.  The integers are then put into an array.
		digits[i] = temp;
		i++;  }

alert(i);

		ckDigit = ( (digits[0] + digits[2] + digits[4] + digits[6] + digits[8] + digits[10] + digits[12] + digits[14] ) + ( (digits[1] + digits[3] + digits[5] + digits[7] + digits[9] + digits[11] + digits[13] + digits[15] ) *3) ) % 10;
		if (ckDigit != 0)  {
			ckDigit = 10 - ckDigit;  }
		
		return ckDigit;
}