function SubmitForm(theForm, whatbutton, ListItem){
     if (whatbutton=="Add To Cart")
          theForm.action = "cart_display.asp?recalc=true&ListID="+ListItem
     else
          if (whatbutton=="Save Changes")
               theForm.action = "wishlist_display.asp?recalc=true"
          else
               theForm.action = "cart_display.asp?recalc=true"

     return Validate(theForm)
}

function Validate(theForm)
{
     var formlength = theForm.elements.length;
     for (i=0;i<formlength;i++){
//          alert (theForm.elements[i].name + "=" + theForm.elements[i].value);
          RE = new RegExp(".*Quantity")
//          alert (RE.test(theForm.elements[i].name));
          if (RE.test(theForm.elements[i].name)){
               if (theForm.elements[i].value==""){
                    alert ("Please Enter a quantity to purchase.");
                    theForm.elements[i].focus();
                    return false;
               }else{
                    var checkOK = "0123456789";
                    var checkStr = theForm.elements[i].value;
                    var allValid = true;
                    var decPoints = 0;
                    var allNum = "";
                    for (x = 0;  x < checkStr.length;  x++){
                         ch = checkStr.charAt(x);
                         for (j = 0;  j < checkOK.length;  j++)
                              if (ch == checkOK.charAt(j))
                                   break;
                         if (j == checkOK.length){
                              allValid = false;
                              break;
                         }
                         if (ch != ",")
                              allNum += ch;
                    }
                    if (!allValid){
                         alert("Please enter only digit characters in the Quantity field.");
                         theForm.elements[i].focus();
                         return (false);
                    }
               }
          }
     }

     return (true);
}
