
function popUp(subType,subPrice,trialDays,showUser) {
  var displayHeader = "<html><head><title>Choices</title></head><body bgcolor=#ffffee leftmargin=10 onBlur='window.close()'><table width=90% align=center><tr><td><font size=3 face=Arial color=#696969>\n";
  var displayFooter = "</font></td></tr></table></body></html>\n";
  var typeText = "none";

  if(subType=="annual"){
    typeText = "<b>Annual - sustained subscription $" +subPrice+ "</b> per year. Automatically renewed annually until you cancel or change your subscription.";
    if(showUser=="all" || showUser=="coupon") typeText = typeText + "<p>If you are applying a coupon discount, it will be applied to your first payment only. All remaining charges will be at the regular rate.</p>";
  }
  if(subType=="month"){
    typeText = "<b>Monthly - sustained subscription $" +subPrice+ "</b> per month. Automatically renewed monthly until you cancel or change your subscription.";
    if(showUser=="all" || showUser=="coupon"){
      typeText = typeText + "<p>Please note: All coupon offers apply to ANNUAL SUBSCRIPTIONS ONLY</p>";
    }
  }
  if(showUser=="all" || showUser=="free") typeText = typeText + "<p>If you are testing a 14-DAY FREE TRIAL SUBSCRIPTION, your card will not be charged and your billing period will not start for " +trialDays+ " days. You may cancel your subscription at any time.</p>";

  Show=window.open("", "displayChoice",
    "width=500,height=250, top=175, left=125, scrollbars=yes");
  Show.window.moveTo(125,175);
  Show.document.open();
  Show.document.write(displayHeader);
  Show.document.write(typeText);
  Show.document.write(displayFooter);
  Show.document.close();
  if(Show.opener==null) Show.opener=window;
}

function coupon_OK(){
  if(!document.subscribe.subscr_type[0].checked) {
    document.subscribe.subscr_type[0].checked = true;
    alert("Coupon offers apply to ANNUAL SUBSCRIPTIONS ONLY.");
    document.subscribe.coupon.focus();
    document.subscribe.coupon.value="";
  }
}

function no_Switch(){
  if(document.subscribe.subscr_type[1].checked){
    document.subscribe.coupon.value="";
  }
}

function unCheck(){
  document.subscribe.cholder_same.checked = false;
}

function isEmail (s){
  var i = 1;
  var sLength = s.length;
  while ((i < sLength) && (s.charAt(i) != "@")) {i++}
  if ((i >= sLength) || (s.charAt(i) != "@")) return false;
  else i += 2;
  while ((i < sLength) && (s.charAt(i) != ".")) {i++}
  if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
  else return true;
}

function testLength(p,ln){
  var pLength = p.length;
  if(pLength < ln) return false;
  else return true;
}

 function no_quotes(){
   if(document.all&&event.keyCode==34 || document.all&&event.keyCode==92 || document.all&&event.keyCode==39 || document.all&&event.keyCode==59 ){
    event.keyCode="";
     alert("No quotes, apostrophes, backslashes or semi-colons please");
   }
 }

document.onkeypress=no_quotes


function checkInputs(form) {
  var Passed = true;
  var errMsg = "";
  var tempMsg = "";
  var errPoint = 0;
  var tempCnt = 0;
  var errCnt = 0;

  // passwords

  tempCnt=0;

  if(!form.elements['pswrd[1]'].value){
    errMsg = "No CONFIRM PASSWORD\n\n";
    Passed = false;
    errPoint = 'pswrd[0]';
    errCnt++;
    tempCnt++;
  }
  else if(form.elements['pswrd[1]'].value != form.elements['pswrd[0]'].value){
    errMsg = "PASSWORD and Confirmation do not match\n\n";
    Passed = false;
    errPoint = 'pswrd[0]';
    errCnt++;
  }

  if(!form.elements['pswrd[0]'].value){
    errMsg = "No PASSWORD\n\n" + errMsg;
    Passed = false;
    errPoint = 'pswrd[0]';
    errCnt++;
    tempCnt++;
  }
  else if(!testLength(form.elements['pswrd[0]'].value,6)){
    errMsg = "PASSWORD must contain 6 to 20 characters\n\n" + errMsg;
    Passed = false;
    errPoint = 'pswrd[0]';
    errCnt++;
  }
  if(tempCnt==2) errMsg = "No PASSWORDS entered\n\n";

  // email address

  if(!form.elements['cust[email]'].value){
      // cust[email]
    errMsg = "Subscriber E-MAIL address\n\n" + errMsg;
    errPoint = 'cust[email]';
    Passed = false;
    errCnt++;
  }
  else {
    if(!isEmail(form.elements['cust[email]'].value)){
      errMsg = "Invalid EMAIL ADDRESS " + form.elements['cust[email]'].value + "\n\n" + errMsg;
      errPoint = 'cust[email]';
      Passed = false;
      errCnt++;
    }
  }


  // subscriber inputs

  tempMsg = errMsg;
  tempCnt = 0;
  // country index
  cIdx = form.elements['cust[country]'].selectedIndex;

  if(cIdx == 0){
      // cust[country]
    tempMsg = "Subscriber COUNTRY \n\n" + tempMsg;
    errPoint ='cust[country]';
    Passed = false;
    errCnt++;
    tempCnt++;
  }
  
  if(cIdx == 1 || cIdx == 2 || cIdx == 43 || cIdx == 230) {
    //check for zip if country is US or Canada
    if(!form.elements['cust[zip]'].value){
      tempMsg = "Please enter POSTAL/ZIP CODE for US or Canada \n\n" + tempMsg;
      errPoint = 'cust[zip]';
      Passed = false;
      errCnt++;
      tempCnt++;
    }
  }

  if(!form.elements['cust[state]'].value){
      // cust[state]
    tempMsg = "Subscriber STATE or PROVINCE \n\n" + tempMsg;
    errPoint = 'cust[state]';
    Passed = false;
    errCnt++;
    tempCnt++;
  }
  if(!form.elements['cust[city]'].value){
      // cust[city]
    tempMsg = "Subscriber CITY \n\n" + tempMsg;
    Passed = false;
    errPoint = 'cust[city]';
    errCnt++;
    tempCnt++;
  }
  if(!form.elements['cust[addr]'].value){
      // cust[addr]
    tempMsg = "Subscriber ADDRESS \n\n" + tempMsg;
    Passed = false;
    errPoint = 'cust[addr]';
    errCnt++;
    tempCnt++;
  }
  if(!form.elements['cust[lname]'].value){
      // cust[lname]
    tempMsg = "Subscriber LAST NAME \n\n" + tempMsg;
    Passed = false;
    errPoint = 'cust[lname]';
    errCnt++;
    tempCnt++;
  }
  if(!form.elements['cust[fname]'].value){
      // cust[name]
    tempMsg = "Subscriber FIRST NAME \n\n" + tempMsg;
    Passed = false;
    errPoint = 'cust[fname]';
    errCnt++;
    tempCnt++;
  }
  if(tempCnt >= 6) errMsg = "No Subscriber Information entered\n\n" + errMsg;
  else errMsg = tempMsg;

  if(!Passed){
    if(errCnt >= 9)
      errMsg = "In order to proceed to the next step,\nplease complete this form.\n\n";
    else
      errMsg = "The following information is missing or incomplete:\n______________________________________    \n\n" + errMsg;
    alert(errMsg);
    form.elements[errPoint].focus();
  }
  return Passed;
}
