function ajax_removeproduct(strURL)
{
    if (confirm('Weet u zeker dat u dit product uit uw kerstpakket wilt verwijderen?'))
    {
		Element.show('loadingmask');

		new Ajax.Request(strURL, {
			method: 'get',
			onComplete: function(transport) {
				ajax_updatepage();
			}
		});
    }
}

function ajax_addtocart(strURL)
{
    var xmlHttpReq = false;
    var self = this;

	Element.show('loadingmask');

    if ($('product_addtocart_form'))
	{
		$('product_addtocart_form').request({
			onComplete: function(){
				ajax_updatepage();
			}
		});
	}
	else
	{
		new Ajax.Request(strURL, {
			method: 'get',
			onComplete: function(transport) {
				ajax_updatepage();
			}
		});
	}
}


function ajax_updatepage()
{
	var reloadurl = 'http://www.kerstdis.nl/sidebarcart';

	new Ajax.Request(reloadurl, {
		method: 'get',
		onComplete: function(transport) {
			Element.hide('loadingmask');
			$('cart').innerHTML = transport.responseText;
			new Effect.Highlight('head', {startcolor: '#ffff99', endcolor: '#ffffff', duration: 3});
		}
	});
}

   window.onload = function() {
   // Make all the images draggables from draggables division.
   $A($('draggables').getElementsByTagName('img')).each(
      function(item) {
         new Draggable(
            item,
            {
               revert: true,
               ghosting: true
            }
         );
      }
   );

   Droppables.add(
     'dropContent2',
     {
        hoverclass: 'hoverActive',
        onDrop: moveItem
     }
  );
   // Set drop area by default  non cleared.
   $('dropContent2').cleared = false;
}
// The target drop area contains a snippet of instructional
// text that we want to remove when the first item
// is dropped into it.
function moveItem( draggable,droparea){
   if (!droparea.cleared) {
      droparea.cleared = true;
   }   

   document.getElementById('dummytekst').innerHTML = 'Product toegevoegd. U kunt producten blijven slepen.';
   
   drag_id = draggable.className;
   
   draggable.parentNode.removeChild(draggable);
	var productid = document.getElementById('productid' + drag_id).innerHTML;
	ajax_addtocart('http://www.kerstdis.nl/checkout/cart/add/product/' + productid);
}