
function productOrder( productID, amount)
{
 if ( productID && amount) {
  addToCart( productID, amount);
  removeProductInfo( productID);
  alertmessage("<div>Dit product is in de winkelwagen geplaats. Klik op <b><a href='winkelwagen.html'>verwerken</a></b> links onder om door te gaan met de bestelling.</div>");
 }
}

function productInfo( productID)
{
 tw = top.document.body.offsetWidth;
 th = top.document.body.offsetHeight;
 w = 430;
 h = 430;
 l = eval( (tw-w)/2);
 t = eval( 125);

 removeProductInfo( productID);

 // Create a new DIV at top level to contain the requested information.
 div = top.document.createElement('DIV');
 div.id = "div_productInfo";
 div.className = "productinfoblock";
 div.style.position = "absolute";
// div.style.height = h+"px"; // Automatic height
 div.style.width = w+"px";
 div.style.top = t+"px";
 div.style.left = l+"px";
 div.style.opacity = 0.95;
 div.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=97)";
 div.style.zIndex = 9998;
 top.document.body.appendChild( div);
 positionBlocks();

 var req = createXMLHTTPObject();
	if (!req) {
  // Create a hidden IFRAME at top level to retrieve requested information.
  iframe = top.document.createElement('IFRAME');
  iframe.id = "iframe_productInfo";
  iframe.style.position = "absolute";
  iframe.style.top = "100px";
  iframe.style.left = "100px";
  iframe.style.visibility = "hidden";
  iframe.src = "productinfo.php?ID="+productID;
  top.document.body.appendChild( iframe);
 }
 else {
  getServerHtml( "productinfo.php?ID="+productID,top.document.getElementById("div_productInfo"));
 }
}
function removeProductInfo( productID)
{
 div = top.document.getElementById("div_productInfo");
 if ( div) {
  top.document.body.removeChild( div);
 }
 iframe = top.document.getElementById("iframe_productInfo");
 if ( iframe) {
  top.document.body.removeChild( iframe);
 }
}

function _addToCart( productID, amount)
{
 var url = "carthandler.php?handling=add&productID="+productID+"&amount="+amount;
 if ( !getServerHtml(url, document.getElementById("temporarycontainershort"))) {
  // Create a hidden IFRAME at top level to retrieve requested information.
  iframe = top.document.createElement('IFRAME');
  iframe.id = "iframe_carthandler";
  iframe.style.position = "absolute";
  iframe.style.top = "100px";
  iframe.style.left = "100px";
  iframe.style.visibility = "hidden";
  iframe.src = url;
  top.document.body.appendChild( iframe);
 }
}

function setAmount( productID, amount)
{
 var req = createXMLHTTPObject();
	if (!req) {
  _addToCart( productID, amount);
  return;
 }
 getServerHtml( "carthandler.php?handling=set&productID="+productID+"&amount="+amount,null,showCartContents);
}
function addToCart( productID, amount)
{
 var req = createXMLHTTPObject();
	if (!req) {
  _addToCart( productID, amount);
  return;
 }
 getServerHtml( "carthandler.php?handling=add&productID="+productID+"&amount="+amount, null,function() {
  showCartContents();
 });
}
function showCartContents()
{
 getServerHtml( "carthandler.php?handling=readshort", top.document.getElementById("cartcontentsshort"));
 if ( top.document.getElementById("cartcontentslong")) {
  getServerHtml( "carthandler.php?handling=readlong", top.document.getElementById("cartcontentslong"));
  setCategoryTitle( "");
 }
}
function setPayment( paymentMethod)
{
 if ( paymentMethod == 2) { // Rembours
  document.getElementById('noTransportNeeded').checked = false;
  document.getElementById('noTransportImpossible').style.display = "none";
 }
 else {
  document.getElementById('noTransportImpossible').style.display = "block";
 }
 getServerHtml( "carthandler.php?handling=payment&method="+paymentMethod, top.document.getElementById("cartcontentslong"));
}

