	function isNumeric(sText){
	   var ValidChars = "0123456789.";
	   var IsNumber=true;
	   var Char;
	 
	   for (i = 0; i < sText.length && IsNumber == true; i++){ 
		  Char = sText.charAt(i); 
		  if (ValidChars.indexOf(Char) == -1){
			 IsNumber = false;
		  }
	   }
	   return IsNumber;
	}

	function checkSmall (strChip){
		var Asec = "ABC"
		/*var Bsec = "AB"*/
		var Bsec = "ABC"
		var Csec = "ABCDEFGH"
		var First, Second, Rest
		
		if (strChip.length != 7){
			return 100;
		}else{
			First = (strChip.toUpperCase()).substring(0,1);
			Second = (strChip.toUpperCase()).substring(1,2);
			Rest = (strChip.toUpperCase()).substring(2,7);
			
			switch (First){
				case "A": 
					if (Asec.indexOf(Second) == -1){
						return 102;
					}
					break;
				case "B": 
					if (Bsec.indexOf(Second) == -1){
						return 102;
					}
					break;
				case "C":
					if (Csec.indexOf(Second) == -1){
						return 102;	
					}
					break;
				default : 
					return 101;
			}
			if (!isNumeric(Rest)) {
				return 103;
			}else{
				return 0;
			}
		}
	}

	function checkCharacter(strChip){
		var ch, i
		var cc = 0
		
		for (i=1;i<=6;i++){
			ch = (strChip.toUpperCase()).substring(i-1,i)
			if (ch.charCodeAt(0)>47 && ch.charCodeAt(0)<58) {
				cc = cc + (ch.charCodeAt(0)-48)
			}else{
				cc = cc + (ch.charCodeAt(0)-55)
			}
		}
		
		return (cc- (Math.floor(cc/29)*29))
	}

	function checkBig(strChip){
		var First, Second, Third, Fourth, Fifth, Sixth, Seventh
		var TestChar1 = "DEFGHKMNPRSTVWYZ"
		var TestChar2 = "ABCDEFGHKMNPRSTVWXYZ"
		var TestChar3 ="0123456789"
		var TestChar456 = "ABCDEFGHKMNPRSTVWXYZ0123456789"
		var ChCtrl = "97BN4XSVE56AWYM1TPK8H2GDCF3R"
		
		if (strChip.length != 7){
			return 100;
		}else{
			First = (strChip.toUpperCase()).substring(0,1);
			Second = (strChip.toUpperCase()).substring(1,2);
			Third = (strChip.toUpperCase()).substring(2,3);
			Fourth = (strChip.toUpperCase()).substring(3,4);
			Fifth = (strChip.toUpperCase()).substring(4,5);
			Sixth = (strChip.toUpperCase()).substring(5,6);
			Seventh = (strChip.toUpperCase()).substring(6,7);
			
			if (TestChar1.indexOf(First) == -1){
				return 1;	
			}else{
				if (TestChar2.indexOf(Second) == -1){
					return 2;	
				}else{
					if (TestChar3.indexOf(Third) == -1){
						return 3;
					}else{
						if (TestChar456.indexOf(Fourth) == -1){
							return 4;	
						}else{
							if (TestChar456.indexOf(Fifth) == -1){
								return 5;
							}else{
								if (TestChar456.indexOf(Sixth) == -1){
									return 6;
								}else{
									switch (Seventh) {
										case "Z":
											if (checkCharacter(strChip) == 0){
												return 0;
											}else{
												return 7;
											}
											break;
										default:
											if ((ChCtrl.indexOf(Seventh)+1) == checkCharacter(strChip)){
												return 0;
											}else{
												return 7;
											}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	function checkChip(strChip) {
		var First, x
		
		First = (strChip.toUpperCase()).substring(0,1);
		
		if (First >="A" && First<="C") {
			return checkSmall(strChip)
		}else{
			return checkBig(strChip)
		}
	}
