<!--
function calculate(itemFld, uiFld, priceFld, costFld, qtytotalFld, totalpriceFld) {

   var inputValue = 0;
   var baseValue = 0;

   if (!itemFld.type) {
      alert ("Cannot calculate total price!\nForm requires JavaScript 1.1 capability.\n\nCharges will be detailed in your confirmation message");
   }
   if (itemFld.type == "select-one") {
      inputValue = itemFld.options[itemFld.selectedIndex].value;
      baseValue = itemFld.options[0].value;
   } else
   {
      inputValue = itemFld.value;
      baseValue = 0;
   }
   newprice = ((inputValue - baseValue) / uiFld.value) * priceFld.value;
   totalpriceFld.value = formatCurrency(totalpriceFld.value - costFld.value);
   qtytotalFld.value = inputValue;
   costFld.value = formatCurrency(newprice);
   totalpriceFld.value = formatCurrency(parseFloat(totalpriceFld.value) + parseFloat(costFld.value));
   return ("$" + totalpriceFld.value);
}

function formatCurrency(num) {
   num = num.toString().replace(/\$|\,/g,'');
   if(isNaN(num)) num = "0";
      cents = Math.floor((num*100+0.5)%100);
   num = Math.floor((num*100+0.5)/100).toString();
   if(cents < 10) cents = "0" + cents;
      for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
         num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
   return (num + "." + cents);
}

function updatemajordomo(form) {
   
   if (form.majordomo.selectedIndex == 0) {
      form.majordomo.value = 1;
      form.seemonthlytotal.value = calculate(form.majordomo,
                                             form.majordomo_ui,
                                             form.majordomo_price,
                                             form.majordomo_cost,
                                             form.majordomo_total,
                                             form.monthlytotal);
      alert ("You entered a Majordomo list name without selecting the option!\nThe Majordomo option has been selected for you.");
   }
}

function updateparkdomain(form) {
   
   if (form.parkdomain.value == 0) {
      form.parkdomain.value = 1;
      form.seesetuptotal.value = calculate(form.parkdomain,
                                           form.parkdomain_ui,
                                           form.parkdomain_price,
                                           form.parkdomain_cost,
                                           form.parkdomain_total,
                                           form.setuptotal);
      alert ("You entered a domain name without selecting the option!\nThe park domain option has been selected for you.");
   }
}

function updateccname(form) {
   
   if ((form.ccname.value.length == 0) || (form.firstname.value.length != 0) && (form.lastname.value.length != 0))
         form.ccname.value = form.firstname.value + " " + form.lastname.value;
}

function validateform(form) {
   
   var name = "";
   var domain = "";
   var illegal = new Array();

   if (form.alias.value > form.email.value) {
      alert ("You have more email aliases than email addresses!\nPlease verify your options.")
      form.alias.focus();
      return (false);
   }
   if (form.autoresponder.value > form.email.value) {
      alert ("You have more email autoresponders than email addresses!\nPlease verify your options.")
      form.autoresponder.focus();
      return (false);
   }
   if (form.group.value > form.email.value) {
      alert ("You have more email groups than email addresses!\nPlease verify your options.")
      form.group.focus();
      return (false);
   }
   if ((form.majordomo.selectedIndex != 0) || (form.majordomoname.value.length != 0)) {
      name = form.majordomoname.value;
      illegal = name.match(/[^a-zA-Z0-9-]/g)
      if (name.length == 0) {
         alert ("Your Majordomo list name is required to complete your account setup.");
         form.majordomoname.focus();
         return (false);
      } else if (illegal != null) {
         alert ("Your Majordomo list name can only contain letters, numbers and/or dash (-) characters.");
         form.majordomoname.focus();
         return (false);
      }
   }
   if ((form.parkdomain.value == 1) || (form.domainname.value.length != 0)) {
      domain = form.domainname.value;
      illegal = domain.match(/[^a-zA-Z0-9-]/g)
      if (domain.length == 0) {
         alert ("Your domain name is required to complete your account setup.");
         return (false);
      } else if ((domain.indexOf(".com") != -1) || (domain.indexOf(".net") != -1) || (domain.indexOf(".org") != -1)) {
         alert ("Your domain name must not include the top level domains .com, .net and .org.");
         return (false);
      } else if (illegal) {
         alert ("Your domain name can only contain letters, numbers and/or dash (-) characters: " + illegal);
         return (false);
      }
      form.domainname.focus();
   }
   if ((form.login.value.length == 0) || (form.login.value.length >= 7)) {
      alert ("Your login name is required to complete your account setup.\nMaximum length is 6 characters");
      form.login.focus();
      return (false);
   }
   if ((form.password.value.length < 6) || (form.password.value.length > 10)) {
      alert ("Your password must be between 6 and 10 characters.");
      form.password.value = "";
      form.confirmpassword.value = "";
      form.password.focus();
      return (false);
   }
   if ((form.password.value != form.confirmpassword.value)) {
      alert ("Your passwords do not match!");
      form.password.value = "";
      form.confirmpassword.value = "";
      form.password.focus();
      return (false);
   }
   if (form.firstname.value.length == 0) {
      alert ("Your first name is required to complete your account setup.");
      form.firstname.focus();
      return (false);
   }
   if (form.lastname.value.length == 0) {
      alert ("Your last name is required to complete your account setup.");
      form.lastname.focus();
      return (false);
   }
   if (form.address.value.length == 0) {
      alert ("Your street address is required to complete your account setup.");
      form.address.focus();
      return (false);
   }
   if (form.city.value.length == 0) {
      alert ("Your city is required to complete your account setup.");
      form.city.focus();
      return (false);
   }
   if (form.state.selectedIndex == 0) {
      alert ("Your state is required to complete your account setup.");
      form.state.focus();
      return (false);
   }
   if (form.zipcode.value.length == 0) {
      alert ("Your zip code is required to complete your account setup.");
      form.zipcode.focus();
      return (false);
   }
   if (form.phone.value.length == 0) {
      alert ("Your phone number is required to complete your account setup.");
      form.phone.focus();
      return (false);
   }
   if (form.emailto.value.length == 0) {
      alert ("Your email address is required to complete your account setup.");
      form.emailto.focus();
      return (false);
   }
   if (form.emailtoconfirm.value.length == 0) {
      alert ("Your email address is required to complete your account setup.");
      form.emailtoconfirm.focus();
      return (false);
   }
   if (form.emailto.value != form.emailtoconfirm.value) {
      alert ("Your email addresses don't match.");
      form.emailto.focus();
      return (false);
   }
   if (form.cctype.selectedIndex == 0) {
      alert ("Your payment method is required to complete your account setup.");
      form.cctype.focus();
      return (false);
   }
   if (form.cctype.selectedIndex != 5)
   {
      if (form.ccnum.value.length == 0) {
         alert ("Your credit card number is required to complete your account setup.");
         form.ccnum.focus();
         return (false);
      }
      if (form.ccexpmo.selectedIndex == 0) {
         alert ("Your credit card expiration month is required to complete your account setup.");
         form.ccexpmo.focus();
         return (false);
      }
      if (form.ccexpyr.selectedIndex == 0) {
         alert ("Your credit card expiration year is required to complete your account setup.");
         form.ccexpyr.focus();
         return (false);
      }
   }
   if ((form.ccaddress.value.length != 0) ||
       (form.cccity.value.length != 0) ||
       (form.ccstate.selectedIndex != 0) ||
       (form.cczipcode.value.length != 0))
   {
      if ((form.ccaddress.value.length == 0) ||
          (form.cccity.value.length == 0) ||
          (form.ccstate.selectedIndex == 0) ||
          (form.cczipcode.value.length == 0))
      {
         alert ("Please complete credit card address if different from personal address.");
         form.ccaddress.focus();
         return (false);
      }
   }
   if (form.signature.value.length == 0) {
      alert ("Your electronic signature is required to complete your account setup.");
      form.signature.focus();
      return (false);
   }
   d = new Date();
   form.signdate.value = d.toGMTString();
   return (true);
}

//
// Validate the provided CC
//
var nacho=false;
var burrito=false;
var cctype="";
var ccnum="";
var ccexp="";

function runVerification(formName) {

   // first make sure they even entered all the shtuff
   if (formName.cctype.selectedIndex == 0) {
      alert ("You didn't select a Credit Card.");
      formName.cctype.focus();
      return false;
   }
   if (!formName.ccnum.value) {
      alert ("You didn't enter a credit card number.");
      formName.ccnum.focus();
      return false;
   }
   if ((formName.ccexpmo.selectedIndex == 0) ||
       (formName.ccexpyr.selectedIndex == 0)) {
      alert ("You didn't select a credit card expiration date.");
      formName.ccexpmo.focus();
      return false;
   } else
   {
      formName.ccexp.value = formName.ccexpmo.options[formName.ccexpmo.selectedIndex].value + formName.ccexpyr.options[formName.ccexpyr.selectedIndex].value;
   }

   // nacho returns a true if the cc format is good
   // burrito return a true if the cc expiration date is good (and not
   //      already past)
   nacho=ccformatValidate(formName);
   if (nacho) {
      burrito=ccexpdateValidate(formName);
      if (burrito)
         return true;
      alert("Warning! Your credit card has expired.");
      formName.ccexpmo.focus();
      return false;
   } else
   {
      alert("Warning! Credit card is invalid!");
      formName.ccnum.focus();
      return false;
   }
}

function ccformatValidate(formName) {

   if (formName.cctype.selectedIndex == 1) cctype="visa";
   if (formName.cctype.selectedIndex == 2) cctype="mastercard";
   if (formName.cctype.selectedIndex == 3) cctype="amex";
   if (formName.cctype.selectedIndex == 4) cctype="discover";

   // get the "clean" version of the cc number, only numbers
   var ccnum=GimmeNumbers(formName.ccnum.value);

   // check for correct card number length
   if (ccnum.length<13) return false;

   if (ccnum.length!=16 && cctype=="discover") return false;
   if (ccnum.length!=16 && cctype=="mastercard") return false;
   if (ccnum.length!=15 && cctype=="amex") return false;
   if (ccnum.length!=13 && ccnum.length!=16 && cctype=="visa") return false;

   // check first number to verify card type
   var ccdigit=ccnum.substring(0,1);
   if (cctype=="amex" && ccdigit!="3") return false;
   if (cctype=="visa" && ccdigit!="4") return false;
   if (cctype=="mastercard" && ccdigit!="5") return false;
   if (cctype=="discover" && ccdigit!="6") return false;

   // make an array and fill it with the individual digits of the cc number
   ccnumchk=new Array;
   for (splits=0; splits<ccnum.length; splits++) {
      ccnumchk[splits]=ccnum.substring(splits, splits+1);
   }

   // perform the weird mathematical method (some base 10 stuff) to
   //      convert the number to a two digit number
   //      for those of you who aren't as familiar with the js operators
   //      i'll comment some of the math lines...well, really just one
   var skemp=0;
   for (splits=0; splits<ccnum.length; splits++) {
      if (splits%2==0) {      // if splits is an even number...
                              //      more specifically, if splits
                              //      divided by two has no
                              //      remainder (ya' know, remainder
                              //      one of those math things :),
                              //      then perform this block
         ccnumchk[splits]=ccnumchk[splits]*2;
         if (ccnumchk[splits]>=10) ccnumchk[splits]=ccnumchk[splits]-9;
      }
      // play a js trick to switch ccnumchk[splits] to a number
      //      variable instead of a string
      ccnumchk[splits]++; ccnumchk[splits]--;
      skemp=skemp + ccnumchk[splits].valueOf();
   }

   if (skemp%10!=0) {return false;} // if the resulting number isn't base
                                    //     10, they're lying to ya...
                                    //     or they mistyped...same thing
   else {
      formName.ccnum.value=ccnum;
      return true;
   }
}

function ccexpdateValidate(formName) {
   // clean up the expiration date...becuase invariably people will not
   //      follow directions and put some weird delimeter in there
   var ccexp=GimmeNumbers(formName.ccexp.value);
   var expmonth=0;
   var expyear=0;
   var realmonth=0;
   var realyear=0;

   // start with the intuitive - length
   //      since dates have to be between 3 chars long (399) and 6 chars
   //      long (121998) anything else needs to be tossed
   if (ccexp.length<3 || ccexp.length>6) return false;
   if (ccexp.length==3) {
      expmonth=ccexp.substring(0,1);
      expyear=ccexp.substring(1,3);
   }
   if (ccexp.length==4) {
      // this bit here is for those people who put a zero in front
      //      of a single number (like 04 instead of 4)
      if (ccexp.substring(0,1)=="0") {
         expmonth=ccexp.substring(1,2);
         expyear=ccexp.substring(2,4);
      } else {
         expmonth=ccexp.substring(0,2);
         expyear=ccexp.substring(2,4);
      }
   }
   if (ccexp.length==5) {
      expmonth=ccexp.substring(0,1);
      expyear=ccexp.substring(1,5);
   }
   if (ccexp.length==6) {
      expmonth=ccexp.substring(0,2);
      expyear=ccexp.substring(2,6);
   }

   // make sure month is a valid value
   if (expmonth<1 || expmonth>12) return false;

   // make sure months and years are numbers and not a strings
   expmonth++; expmonth--;
   expyear++; expyear--;

   // convert years to a standard 4 digit format
   if (ccexp.length==3 || ccexp.length==4) expyear=expyear+1900;

   // check the date
   timeisit=new Date();
   realmonth=timeisit.getMonth();
   realmonth++;
   realyear=timeisit.getYear();

   // because of the way js works with dating, every year until 2000 is
   //      represented by the year minus 1900, but at 2000 and on, is
   //      represented as is...weird...2000 "bug" shtuff...
   if (realyear<2000) realyear=realyear+1900;

   // compare expiration values with current ones
   if (expyear==realyear) {
      if (expmonth<realmonth) return false;
   }
   if (expyear<realyear) return false;

   // make expmonth and expyear strings again so we can make a string
   //      to pass to a cgi to process authorization
   expmonth+=""; expyear+="";
   if (expmonth.length==1) expmonth="0"+expmonth;
   ccexp=expmonth.substring(0,expmonth.length);
   ccexp+=expyear.substring(0,4);
   formName.ccexp.value=ccexp;

   return true;
}

function GimmeNumbers(loadedText) {     // this function removes everything but numbers
   var cleanText="";

   // make sure input is a string
   loadedText+="";

   for (skimp=0; skimp<loadedText.length; skimp++) {
      if (loadedText.substring(skimp,skimp+1)>="0" && loadedText.substring(skimp, skimp+1)<="9") cleanText+=loadedText.substring(skimp, skimp+1);
   }
   return cleanText;
}

//
// returns the SSL server root path
// https://cognac.site-secure.net/w3hosts/shared/virtual/basic.html
//
function sslroot()
{
   var end = 0;
   var pos = 0;
   var root = new String("");
   var locStr = new String (document.location);
   var start = locStr.indexOf("https://");
   if (start != -1) {
      pos = start;
      for (x = 4; x != 0 && end != -1; x--) {
         end = locStr.indexOf("/", pos);
         pos = end+1;
      }
      root = locStr.substring(start, end+1);
   }
   return(root);
}

//
// returns the referrer root path
// http://www.w3hosts.com/shared/index.html
//
function refroot()
{
   var end = 0;
   var pos = 0;
   var root = new String("");
   var locStr = new String (document.referrer);
   var start = locStr.indexOf("http://");
   if (start != -1) {
      pos = start;
      for (x = 3; x != 0 && end != -1; x--) {
         end = locStr.indexOf("/", pos);
         pos = end+1;
      }
      root = locStr.substring(start, end+1);
   }
   return(root);
}

//
// returns the referrer path to the new document
// http://www.w3hosts.com/shared/virtual/basic.html
//
function refloc(loc)
{
   var locStr = new String (refroot() + loc);
   return(locStr);
}

//-->