/*
  file:   js/cart.js
  vers:   1.0 (2006-09-06)
  desc:common shopping cart functions

  copyright 2006 Geoffrey Whaite, all rights reserved
*/

/*
  func:   add_to_cart
  desc:   elink function to add a product to the shopping cart; prompts the user
          for the number of items to add to the cart then calls the 'add_to_cart'
          href with parameters set to identify the product and number of items
  params: class_id = id of the product class of the product to add
          prod_id = id of the product in the product class to add to the cart
          prod_name = the name of the product, used when prompting for the number
                      of items to add to the cart
          arguments[3] = optional href parameter to override the default 'add_to_cart.php'
*/
function add_to_cart( class_id, prod_id, prod_name )
{
//  var n = prompt( "How many of item '" + prod_name + "' do\nyou want to add to the shopping cart?", "1" );
//  if ( n != null )
//  {
//    var n_items = parseInt(n);
//    if ( n_items > 0 )
//    {
      var href = "", n_items = 1;
      if ( arguments.length > 3 )  href = arguments[3];
      if ( href == "" )  href = "add_to_cart.php";
      href += "?class_id=" + class_id + "&prod_id=" + prod_id + "&n_items=" + n_items;
      location.href = href;
//    }
//    else // if ( n_items > 0 )
//    {
//      alert( "You must enter a number greater than zero for the number of items." );
//    }
//  } // if ( n != null )
} // function add_to_cart()
