function ValidateThis(theForm)
{

  if (theForm.FName.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.FName.focus();
    return (false);
  }

  if (theForm.FName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"First Name\" field.");
    theForm.FName.focus();
    return (false);
  }

  if (theForm.FName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"First Name\" field.");
    theForm.FName.focus();
    return (false);
  }

  if (theForm.LName.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.LName.focus();
    return (false);
  }

  if (theForm.LName.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Last Name\" field.");
    theForm.LName.focus();
    return (false);
  }

  if (theForm.LName.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Last Name\" field.");
    theForm.LName.focus();
    return (false);
  }

  if (theForm.EmailAddress.value == "")
  {
    alert("Please enter a value for the \"Email Address\" field.");
    theForm.EmailAddress.focus();
    return (false);
  }

  if (theForm.Phone.value == "")
  {
    alert("Please enter a value for the \"Contact Phone Number\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length < 10)
  {
    alert("Please enter at least 10 characters in the \"Contact Phone Number\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.Phone.value.length > 13)
  {
    alert("Please enter at most 13 characters in the \"Contact Phone Number\" field.");
    theForm.Phone.focus();
    return (false);
  }

  if (theForm.BillAddress.value == "")
  {
    alert("Please enter a value for the \"Bill to Street Address\" field.");
    theForm.BillAddress.focus();
    return (false);
  }

  if (theForm.BillAddress.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Bill to Street Address\" field.");
    theForm.BillAddress.focus();
    return (false);
  }

  if (theForm.BillAddress.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Bill to Street Address\" field.");
    theForm.BillAddress.focus();
    return (false);
  }
  
  if (theForm.BillState.value == "0")
  {
    alert("Please enter a value for the \"Bill to State\" field.");
    theForm.BillState.focus();
    return (false);
  }

  if (theForm.BillCity.value == "")
  {
    alert("Please enter a value for the \"Bill to City\" field.");
    theForm.BillCity.focus();
    return (false);
  }

  if (theForm.BillCity.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Bill to City\" field.");
    theForm.BillCity.focus();
    return (false);
  }

  if (theForm.BillCity.value.length > 50)
  {
    alert("Please enter at most 50 characters in the \"Bill to City\" field.");
    theForm.BillCity.focus();
    return (false);
  }

  if (theForm.BillZip.value == "")
  {
    alert("Please enter a value for the \"Bill to Zip\" field.");
    theForm.BillZip.focus();
    return (false);
  }

  if (theForm.BillZip.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"Bill to Zip\" field.");
    theForm.BillZip.focus();
    return (false);
  }

  if (theForm.BillZip.value.length > 12)
  {
    alert("Please enter at most 12 characters in the \"Bill to Zip\" field.");
    theForm.BillZip.focus();
    return (false);
  }

  if (! isCardOK(theForm.CCNumber))
  {
    ///alert("Please enter a value for the \"Credit Card Number\" field.");
    //theForm.CCNumber.focus();
    return (false);
  }

  if (theForm.CreditCard.selectedIndex < 0)
  {
    alert("Please select one of the \"Credit Card\" options.");
    theForm.CreditCard.focus();
    return (false);
  }

  if (theForm.CCNumber.value == "")
  {
    alert("Please enter a value for the \"Credit Card Number\" field.");
    theForm.CCNumber.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.CCNumber.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Credit Card Number\" field.");
    theForm.CCNumber.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"CCNumber\" field.");
    theForm.CCNumber.focus();
    return (false);
  }

  if (theForm.CCMonth.selectedIndex < 0)
  {
    alert("Please select one of the \"Credit Card Month Expiration\" options.");
    theForm.CCMonth.focus();
    return (false);
  }

  if (theForm.CCYear.selectedIndex < 0)
  {
    alert("Please select one of the \"Credit Card Year\" options.");
    theForm.CCYear.focus();
    return (false);
  }
  return (true);
}

function isCardOK(cardNo) {
     var a=""
     a=cardNo.value
   
        isCreditCard = false ;
        lCard=a.length-1 ;
 if (a.length>0)       {
        lC=a.substr(lCard,1) ;
        cStat=0 ;
        for (i=(lCard-1);i>=0; --i)
			{
            tempChar= a.substr(i,1) ;
            d= parseInt(tempChar);
            b=lCard % 2
           if ((lCard % 2) == 1)
                tempV=d*(1+((i+1) % 2)) ;
            else 
               tempV=d*(1+(i % 2)) ;
           
            if (tempV < 10)
                cStat = cStat + tempV  ;
            else 
                cStat = cStat + tempV - 9 ;
        }
        cStat = (10-(cStat % 10)) % 10 ;
        x = parseInt(lC)
        if (parseInt(lC) == cStat ){
          return true ;}
        else{
          cinfo.CCNumber.focus();
          alert("Credit Card Number is not entered correctly");
          cinfo.CCNumber.select();
          return (false);
         }
         }
 }
 function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
