
var zip_url = "";

function ShoppingCart_Add(id,caller)
{
   window.location.href='/shoppingcart.php?operator=add&operand=image&data=' + id + '&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_AddAll(caller)
{
   window.location.href='/shoppingcart.php?operator=addall&operand=result&data=null&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_Remove(id,caller)
{
   if(confirm("Do you really want to remove this image?"))
      window.location.href='/shoppingcart.php?operator=remove&operand=image&data=' + id + '&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_Clear(caller)
{
   if(confirm("Do you really want to remove all images?"))
      window.location.href='/shoppingcart.php?operator=clear&operand=self&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_Select(which,caller)
{
   window.location.href='/shoppingcart.php?operator=select&operand=self&data=' + which + '&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_Open(which,where)
{
   if(where=='self')
      window.location.href = '/shoppingcart.php?operator=browse&operand=cart&data=' + which;
   else
      window.open('/shoppingcart.php?operator=browse&operand=cart&data=' + which);
}

function ShoppingCart_Close()
{
   window.close();
}

function ShoppingCart_Zip(cart)
{
   window.open('/download.php?operator=start&operand=cart&data=' + cart,'','height=190,width=230,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
}

function ShoppingCart_BeginZipDownload(url)
{
   zip_url = url;

   window.setTimeout("ShoppingCart_DoZipDownload('" + url + "')",5000);
}

function ShoppingCart_DoZipDownload(url)
{
   window.location.href = url;
}

function ShoppingCart_CreateFeature(caller) {

   window.location.href = '/shoppingcart.php?operator=createfeature&operand=self&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_AddToFeature(caller) {

   window.location.href = '/shoppingcart.php?operator=addtofeature&operand=self&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_SubmitFeature() {

   var elements = frames['coverselectorframe'].document.coverform.elements;

   var cover = '';

   for(var i=0; i<elements.length; i++) {

      if(elements[i].name=="cover"&&elements[i].checked) {
          cover = elements[i].value;
      }
   }

   if(cover=='') {
      alert('Please select a cover image');
      return;
   }

   if(document.featureform.title.value=='') {
      alert('Please state a title for this feature');
      document.featureform.title.focus();
      return;
   } 

   document.featureform.cover.value = cover;

   document.featureform.submit();
   
}

function ShoppingCart_CancelFeatureCreation() {

   window.location.href = '/shoppingcart.php';
}

function ShoppingCart_SubmitAddToFeature() {

   document.featureform.submit();
}

function ShoppingCart_CancelFeatureAdd() {

   window.location.href = '/shoppingcart.php';
}

function ShoppingCart_CreateOffer(caller) {

   window.location.href = '/shoppingcart.php?operator=createoffer&operand=self&caller=' + encodeURIComponent(caller);
}

function ShoppingCart_SubmitOffer(caller) {

   if(document.offerform.receivers.value=='') {
      alert('Please enter at least one receiver');
      document.offerform.receivers.submit();
      return;
   }

   document.offerform.submit();
}

function ShoppingCart_CancelOfferCreation() {

   window.location.href = '/shoppingcart.php';
}

