check=Array(164,"d",
            134,"d",
            265,1,
            265,2,
            265,3,
            265,4,
            265,5,
            353,4,
            353,7,
            443,0,
            443,6,
            443,8);


saved=true;
mCurrentrate=parent.header.eval('mCurrentrate');
mDollar=parent.header.eval('mDollar');
mSterling=parent.header.eval('mSterling');
if (mCurrentrate==mSterling) { document.regform.Currency[1].checked=false; document.regform.Currency[0].checked=true; }
if (mCurrentrate==mDollar) { document.regform.Currency[0].checked=false; document.regform.Currency[1].checked=true; }

if(parent.header.eval('userInfo.correct')) {      // if correct information has been entered previously
disgard(); }                                      // load previous values to screen



var errfound = false;
//function to validate by length
function ValidLength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function ValidEmail(item) {
   if (!ValidLength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
errfound = true;
}



function save() {

parent.header.eval('userInfo.name="'+document.regform.Name.value+'";');
parent.header.eval('userInfo.ad1="'+document.regform.Delivery_line1.value+'";');
parent.header.eval('userInfo.ad2="'+document.regform.Delivery_line2.value+'";');
parent.header.eval('userInfo.ad3="'+document.regform.Delivery_line3.value+'";');
parent.header.eval('userInfo.postcode="'+document.regform.postcode.value+'";');
parent.header.eval('userInfo.email="'+document.regform.Email_address.value+'";');
parent.header.eval('userInfo.extra="'+document.regform.Extra.value+'";');
parent.header.eval('userInfo.required="'+document.regform.Required_date.value+'";');
parent.header.eval('userInfo.correct=true;');

if(document.regform.Currency[1].checked==true) { parent.header.eval('mCurrentrate=mDollar; dCurrentsymbol=dDollar;'); }
if(document.regform.Currency[0].checked==true) { parent.header.eval('mCurrentrate=mSterling; dCurrentsymbol=dSterling;'); }
if(document.regform.Shipping[0].checked==true) { parent.header.eval('mPostMethod="local"; mPnp=mPnpGB;'); }
if(document.regform.Shipping[1].checked==true) { parent.header.eval('mPostMethod="int";   mPnp=mPnpINT;'); }
}

function disgard() { // revert to last saved values
document.regform.Name.value            =parent.header.eval('userInfo.name');
document.regform.Delivery_line1.value  =parent.header.eval('userInfo.ad1');
document.regform.Delivery_line2.value  =parent.header.eval('userInfo.ad2');
document.regform.Delivery_line3.value  =parent.header.eval('userInfo.ad3');
document.regform.postcode.value  =parent.header.eval('userInfo.postcode');
document.regform.Email_address.value   =parent.header.eval('userInfo.email');
document.regform.Extra.value           =parent.header.eval('userInfo.extra');
document.regform.Required_date.value   =parent.header.eval('userInfo.required');

if (parent.header.eval('mPostMethod')=="local") { document.regform.Shipping[1].checked=false; document.regform.Shipping[0].checked=true; }
if (parent.header.eval('mPostMethod')=="int") { document.regform.Shipping[0].checked=false; document.regform.Shipping[1].checked=true; }
if (mCurrentrate==mSterling) { document.regform.Currency[1].checked=false; document.regform.Currency[0].checked=true; }
if (mCurrentrate==mDollar) { document.regform.Currency[0].checked=false; document.regform.Currency[1].checked=true; }
}

function creditTypeCheck() {
for (i=0; i<4; i++ ) {
if(document.regform.cardType[i].checked) { a=i+1; }
}

st=creditFormat();

b=(st.length % 10);
c=st.charAt(0);
d=st.charAt(1);

dat=a+""+b+c;
correct=false;
for (i=0; i<12; i++) {
if(dat==check[i*2]) {
if(d  ==check[(i*2)+1]) { correct=true; } 

if(check[(i*2)+1]=="d") { correct=true; } 
} 

}
alert(correct);
}




function creditFormat() {
st=document.regform.creditString.value;
len=document.regform.creditString.value.length;

creditNew="";
for(i=0; i<len; i++ ) {
ch=st.charAt(i);
if((ch>0) || (ch==0)) {
if(ch!=" ") {creditNew+=ch; } }
}
return creditNew;
}

