
// show invoice
function showInvoice(url) {
  var invoice =  window.open (url, "invoice", "menubar=yes,status=yes,location=yes,width=720,height=800,toolbar=yes,scrollbars=yes,resizable=yes");
  invoice.focus();
} 


// load products by brand
function loadProductsByBrand(id, p) {
  var content = Ext.get('content');
  // get code
  Ext.Ajax.request({
    url: 'plugin/shop/products',
    method: 'post',
    success: function(o, s, r) {
      content.update(o.responseText);
    },
    failure: function() {
      alert('Es ist ein Fehler aufgetreten!');
    },
    params: {brand: id, p: p || 1}
  });
  return false;
} 


// load products
function loadProducts(id, p) {
  var content = Ext.get('content');
  // get code
  Ext.Ajax.request({
    url: 'plugin/shop/products',
    method: 'post',
    success: function(o, s, r) {
      content.update(o.responseText);
    },
    failure: function() {
      alert('Es ist ein Fehler aufgetreten!');
    },
    params: {id: id, p: p || 1}
  });
  return false;
} 


// buy product
function addToCart(pid, id) {
  var content = Ext.get('content');
  // get code
  Ext.Ajax.request({
    url: 'app/'+pid+'/add',
    method: 'post',
    success: function(o, s, r) {
      var el = Ext.get('top').child('.basket');
      var r  = Ext.decode(o.responseText);
      el.update('WARENKORB ('+r.count+')');
      el.highlight("000000", {
        attr: "color", 
        easing: 'easeIn',
        duration: 1
      });
    },
    failure: function() {
      alert('Es ist ein Fehler aufgetreten!');
    },
    params: {id: id}
  });
  return false;
} 


// buy product
function addToWishlist(pid, id) {
  // get code
  Ext.Ajax.request({
    url: 'app/'+pid+'/add',
    method: 'post',
    success: function(o, s) {
      var el = Ext.get('top').child('.wishlist a');
      var r  = Ext.decode(o.responseText);
      el.update('Meine Wunschliste ('+r.count+')');
      el.highlight("ff0000", {
        attr: "color", 
        easing: 'easeIn',
        duration: 1
      });
    },
    failure: function() {
      alert('Es ist ein Fehler aufgetreten!');
    },
    params: {id: id}
  });
  return false;
}



function checkCart(f, id, h) {
  var check = document.forms[f].elements['accept'].checked;
  var paym  = document.forms[f].elements['payment[method]'];
  if(!check || (!paym[0].checked && !paym[1].checked && !paym[2].checked)) {
    showContent(id, false, h);
    return false;
  }
  return true;
}


