function AddCart( series, item, name, price, image )
{
  // Request the confirmation to add to the cart
  var add = confirm( "Add this Monskey to your cart?" );

  if( add == true )
  {
    // Use AJAX to add this to the users cart

    // Set the backend filename to process
    var filename = 'cart_ajax_add.php';

    // Create the parameter list
    var params = "series=" + series + "&item=" + item + "&name=" + name + "&price=" + price + "&image=" + image;

    // Process the AJAX POST request
    AJAX_POST( filename, params );

    // Update the form when the AJAX process finishes
    xmlhttp.onreadystatechange = function()
    {
      if( (xmlhttp.readyState == 4) && (xmlhttp.status == 200) )
      {
        // Reserved for post AJAX code
      }
    }

  } // if add = true

} 

function RemoveItem( i )
{
  // Make sure that they want to remove the item
  var remove = confirm( "Are you sure you want to remove this item from your cart?" );

  if( remove )
    window.location = "remove-" + i + '.html'

}

function UpdateCart( i )
{
  // Get the new value of the cart
  var quantity = document.getElementById('cart_qty_' + i).value;

  if( quantity > 0 )
    window.location = "update-" + i + "-" + quantity + '.html'
}

function VerifyCart()
{
  // Initialize the validform 
  var ValidForm = true;

  // Get the email address
  var vc_EmailAddress = document.getElementById( 'vc_EmailAddress' ).value;

  // Check the integrity of the email address
  if( vc_EmailAddress.length == 0 )
  {
    alert( 'You must provide an email address' );
    ValidForm = false;
  }
  else if( vc_EmailAddress.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1 )
  {
    alert( 'You must provide a valid email address' );
    ValidForm = false;
  }

  // Only submit the form if the email address has been provided
  if( ValidForm )
    document.getElementById('ShoppingForm').submit();

}


function Message( i )
{
  if( i == 1 )
    alert( 'Out of Stock\n\nSeries 1 Revival Coming Soon!' );
  else if( i == 2 )
    alert( 'Out of Stock' );

  return true;
}
    
