/* cart validation */
Cart = {
  
  /* 
   * This method will validate the fields and set the error on the page.
   */
  validate:function() {
    
    frm = $('cartForm');
    $('error').innerHTML = ""; // clear it out
    
    var arr_text = $A(frm.elements);
    var error = "";
    var invalid_items = false;
    var re = new RegExp("[^0-9]+");
    
    arr_text.each(function(node) {

       if (node.getAttribute('name').indexOf('item_') > -1) {
         
         Element.setStyle(node, {"background-color":""});
         if (re.test(node.value) == true) {
           Element.setStyle(node, {"background-color":"#FAFFCF"});
           invalid_items = true;
         }
              
       }
    });
    
    if (invalid_items == true) {

        $('error').innerHTML = "Please enter a valid quantity for the items below.";
        return(false);
    }
    
    return(true);
  }
  
  
  
  
}
