result = ean.substring(0,1) + String.fromCharCode(65 + 1*ean.substring(1,1)); first = ean.substring(0,1); for (i=3; i<=7; i++) { in_a = false; switch (i) { case 3: if(first == 0 | first == 1 | first == 2 | first == 3) in_a = true; break; case 4: if(first == 0 | first == 4 | first == 7 | first == 8) in_a = true; break; case 5: if(first == 0 | first == 1 | first == 4 | first == 5 | first == 9) in_a = true; break; case 6: if(first == 0 | first == 2 | first == 5 | first == 6 | first == 7) in_a = true; break; case 7: if(first == 0 | first == 3 | first == 6 | first == 8 | first == 9) in_a = true; break; } if (in_a) { result = result + String.fromCharCode(65 + 1*ean.substring((i-1), i)); } else { result = result + String.fromCharCode(75 + 1*ean.substring((i-1), i)); } } result = result + '*'; for (i=8; i<=13; i++) { result = result + String.fromCharCode(97 + 1*ean.substring((i-1), i)); } result = result + '+';