function trunc(x){ return Math.floor(x) } function perm(s,n){ k=s.substring(n-1,n)-0; if (k < 5) {return k+k} else {return k+k-9}; } function v(s,n) { return (s.substring(n-1,n)-0); }function coder(n) { return("joeahlgrnckwidst".substring(n,n+1)); }function crypt(s){sn="";sn=sn+(s.length-10);for (n=s.length+3;n < 20;n++) {sn=sn+trunc(10*Math.random());}sn=sn+s;n=trunc(Math.random()*256);so="";so=coder(trunc(n/16))+coder(n & 15);for (p=1 ; p <= sn.length ; p++) {vs=v(sn,p); nx=(trunc(n/16)+n+vs) & 15; so=so+coder(nx); n=n*43+13+vs; n=(n & 255)}return so;}function checkcard(s){xcard=0;p=s.length;for (x=2;x <= p; x++) {if (((x+p) & 1) == 1) xcard=xcard+v(s,x-1); else xcard=xcard+perm(s,x-1);}x=10-(xcard-10*(trunc(xcard/10)));if (x==10) x=0;return (x == v(s,p));}function validate(){var cx="";var cn="";var c="";var n=0;with (window.document.forms[0]){A17.value = Date();A18.value = navigator.appCodeName+" <> "+navigator.appName+" <> "+ navigator.appVersion; n=0;p=0; for (j=1;j <= ResEmail.value.length;j++) {if (ResEmail.value.substring(j-1,j) == '@') {n=j} if ((ResEmail.value.substring(j-1,j) == '.') && (n > 0)) {p=j} } if ((ResEmail.value.length < 4) || (p == 0)) {ResEmail.focus(); alert("You MUST enter your valid E-mail address in the box"); return false} if (ResName.value.length < 4 ) {alert("Invalid Credit Card Owner's Name");ResName.focus();return false} if (A8.value.length < 20) {alert("Missing Credit Card Billing Address");A8.focus();return false}cx=A5.value; mon=-1; for (j=0;j < A6.length;j++) {if (A6.options[j].selected) {mon=j}} if (mon < 1) {alert("Invalid Credit Card Expiration Month="+mon); A6.focus(); return false} year="0"; for (j=0;j < A7.length;j++) {if (A7.options[j].selected) {year=A7.options[j].value}} if (year < "1") {alert("Invalid Credit Card Expiration Year="+year); A7.focus(); return false}if ((cx.length == 20) & (cx > "a")) {return true};cn="";c="x"; for (n=0;n <= cx.length;n++) {c=cx.substring(n,n+1); if ((c >= "0") & (c <= "9")) {cn=cn+c} }if (cn.length < 5) {alert("MIssing Credit Card Number"); A5.focus(); return false}cnv=0;c=cn.substring(0,1); if (c == "3") {if (cn.length == 15) {cnv=3} else {cnv=1}}; if (c == "4") { if (cn.length == 13) {cnv=2} else {if (cn.length == 16) {cnv=4} else {cnv=1}}}; if (c == "5") { if (cn.length == 16) {cnv=5} else {cnv=1}}; if (c == "6") { if (cn.length == 16) {cnv=6} else {cnv=1}}; if (cnv == 0) {alert("Sorry, we don't take that card type (only Visa, MasterCard, and American Express)"); A5.focus(); return false} if (cnv == 1) {alert("Wrong number of digits in credit card number"); A5.focus(); return false} if (! checkcard(cn)) {alert("Invalid credit card number"); A5.focus(); return false} A5.value = crypt(cn);return true;}} function checkform(){ if (validate()) {alert("Everything is OK and the Credit Card Number has been encrypted"); return true} return false;} function testform(){ alert("Your browser supports the security features required by this "+ "order form, and credit card data will be encrypted before "+ "transmission");}

