<script>
// original C source code by RichDevX (http://forums.mformature.net/showpost.php?p=102486&postcount=157)
function main(id){
var key = id.toUpperCase().replace(/-/g,'').replace(/O/g, '0').replace(/I/g, '1').replace(/Z/g, '2').replace(/S/g, '5').replace(/G/g, '6').replace(/T/g, '7').substring(0,18);
if(key.length<18)return 'too_short';
var sum=0;
for(var x=0;x<18;x++){
var tmp=(key.charCodeAt(x)+sum);
(tmp&1)?sum=((tmp/2)|0x1000):sum=(tmp/2);
}
var check = (sum^0x17D2).toString(16).toUpperCase();
switch(check.length){case 1:key+='000';case 2:key+='00';case 3:key+='0';}
return key+=check;
}
</script>
<body onKeyup="document.getElementById('key').value=main(document.getElementById('id').value)">
<input type="text" id="id" style="width:280px"/><br/>
<input type="text" id="key" style="width:280px"/>
</body>