<!-- 
var sendReq = getXmlHttpRequestObject();
var receiveReq = getXmlHttpRequestObject();
var receiveReqInfoBox = getXmlHttpRequestObject();

function getXmlHttpRequestObject() {
  if (window.XMLHttpRequest) {
    return new XMLHttpRequest();
  } else if(window.ActiveXObject) {
    return new ActiveXObject("Microsoft.XMLHTTP");
  } else {
    getObject('p_status').innerHTML = 'Status: Cound not create XmlHttpRequest Object. Consider upgrading your browser.';
  }
}
function getCartText() {
  if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
    receiveReq.open("GET", CartLink, true);
    receiveReq.onreadystatechange = handleReceiveCart;
    receiveReq.send(null);
  }
  if (typeof(_gaq) !== 'undefined') {
    _gaq.push(['_trackPageview', '/tgeshop/' + CartLink]);
  }
}

function getCartInfoBoxText() {
  var current_url = document.URL;
  var match_url_cart = current_url.match(/shopping_cart\.php/i);
  if (match_url_cart == null) {
    if (receiveReqInfoBox.readyState == 4 || receiveReqInfoBox.readyState == 0) {
      receiveReqInfoBox.open("GET", CartLinkBox, true);
      receiveReqInfoBox.onreadystatechange = handleReceiveCartInfoBox;
      receiveReqInfoBox.send(null);
      statusobj = getObject('p_status_box');
      statusobj.innerHTML = image_loading;
      centerItem(statusobj, getObject('divTagCartBox'));
    }
  }
}

function hideCart() {
  var cartobj = getObject('divTagCart');
  cartobj.innerHTML = '';
}

function sendCartChangeQty(iElementId, product_id, qty) {
  statusobj = getObject('p_status');
  if (typeof iElementId == "string" && iElementId.length > 0) {
    var element = getObject(iElementId);
    if (element) {
    } else {
      statusobj.innerHTML = 'Status: Das angeforderte Element wurde nicht gefunden.';
    }
  }
  
   //Verify entered quantity is number
  if (isNaN(element.value)) {
    statusobj.innerHTML = 'Bitte geben Sie eine Zahl ein.';
    getCartText();
    return;
  } else {
    statusobj.innerHTML = '';
  }
  // check if Quantity drops below 0
  if (Number(element.value) + Number(qty) <= 0) {
    //Call function to delete item
    sendCartRemoveItem(iElementId, product_id);
    return;
  }
  
  if (sendReq.readyState == 4 || sendReq.readyState == 0) {
    sendReq.open("POST", CartLink, true);
    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sendReq.onreadystatechange = handleSendCart; 
    
    var param = 'quantity=' + (Number(element.value) + Number(qty));
    param += '&products_id=' + product_id;
    statusobj.innerHTML = image_loading;
    centerItem(statusobj, false, 1);
    sendReq.send(param);
  }              
}

function sendCartAddProduct(product_id) {
  if (sendReq.readyState == 4 || sendReq.readyState == 0) {
    sendReq.open("POST", CartLink, true);
    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sendReq.onreadystatechange = handleSendCart; 
    
    var param = 'quantity=1';
    param += '&products_id=' + product_id;
    param += '&addproduct=true';
    statusobj = getObject('p_status_box');
    statusobj.innerHTML = image_loading;
    centerItem(statusobj, false, 1);
    sendReq.send(param);
  }              
}

function sendCartChangeShipping(country_id, address_id) {
  var current_url = document.URL;
  var match_url = current_url.match(/order_info\.php|create_account\.php|checkout.*\.php/i);
  var match_url_cart = current_url.match(/shopping_cart\.php/i);
  if (sendReq.readyState == 4 || sendReq.readyState == 0) {
    sendReq.open("POST", CartLink, true);
    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sendReq.onreadystatechange = handleSendCart; 
    if (match_url == null) {
      statusobj = getObject('p_status')
      statusobj.innerHTML = image_loading;
      centerItem(statusobj, false, 1);
    }
    if (match_url_cart == null) {
      statusobj = getObject('p_status_box');
      statusobj.innerHTML = image_loading;
      centerItem(statusobj, false, 1);
    }
    if (address_id != '') {
      var param = 'address_id=' + address_id;
    } else {
      var param = 'country_id=' + country_id;
    }
    sendReq.send(param);
  }
}


function sendCartChangePayment(payment_id) {
  var current_url = document.URL;
  var match_url = current_url.match(/checkout_payment\.php/i);

  if (sendReq.readyState == 4 || sendReq.readyState == 0) {
    sendReq.open("POST", CartLink, true);
    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sendReq.onreadystatechange = handleSendCart; 
    if (match_url == null) {
      statusobj = getObject('p_status')
      statusobj.innerHTML = image_loading;
      centerItem(statusobj, false, 1);
    }
    var param = 'payment_id=' + payment_id;
    sendReq.send(param);
  }    
}

function sendCartRemoveItem(iElementId, product_id) {
  statusobj = getObject('p_status')
  if (typeof iElementId == "string" && iElementId.length > 0) {
    var element = getObject(iElementId);
    if (element) {
      //alert("name=" + element.name + " - id=" + element.id);
      //return;
    } else {
      statusobj.innerHTML = 'Status: Das angeforderte Element wurde nicht gefunden.';
      return;
    }
  }
    
  var fRet;
  fRet = confirm('Soll dieses Produkt aus dem Warenkorb entfernt werden?');
  if (fRet == false) {
    getCartText();
    return;
  }
  
  if (sendReq.readyState == 4 || sendReq.readyState == 0) {
    sendReq.open("POST", CartLink, true);
    sendReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    sendReq.onreadystatechange = handleSendCartRemoveItem; 
    
    statusobj.innerHTML = image_loading;
    centerItem(statusobj, false, 1);
    var param = 'products_id=' + product_id;
    param += '&cart_delete=Yes'; 
    sendReq.send(param);
  }              
}

function handleSendCart() {
  var current_url = document.URL;
  var match_url = current_url.match(/order_info\.php|create_account\.php|checkout.*\.php/i);

  if (sendReq.readyState == 4 && sendReq.status == 200){
    if (match_url == null) {
      getCartText();
    }
    getCartInfoBoxText();
  }
}

function handleReceiveCart() {
  //Check to see if the XmlHttpRequests state is finished.
  if (receiveReq.readyState == 4) {
    //Set the contents of our span element to the result of the asyncronous call.
    cartobj = getObject('divTagCart')
    cartobj.innerHTML = receiveReq.responseText;
    centerItem(cartobj);
  }
  statusobj = getObject('p_status')
  statusobj.innerHTML = '';
}

function handleReceiveCartInfoBox() {
  if (receiveReqInfoBox.readyState == 4) {
    getObject('divTagCartBox').innerHTML = receiveReqInfoBox.responseText;
    getObject('p_status_box').innerHTML = '';
  }
}

function handleSendCartRemoveItem() {
  if (sendReq.readyState == 4 && sendReq.status == 200){
    getCartText();
    getCartInfoBoxText();
  }
}      

function absLeft(el) {
  return (el.offsetParent) ? el.offsetLeft+absLeft(el.offsetParent) : el.offsetLeft;
}

function absTop(el) {
  return (el.offsetParent) ? el.offsetTop+absTop(el.offsetParent) : el.offsetTop;
}


function centerItem(cartobj, parentobj, layer) {
  
  // mozilla/netscape/opera/IE7+
  if (typeof window.innerWidth != 'undefined') {
      window_width = window.innerWidth,
      window_height = window.innerHeight
      scroll_top = window.pageYOffset
  
  // IE6 in standards compliant mode (valid doctype as the first line in the document)
  } else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
      window_width = document.documentElement.clientWidth,
      window_height = document.documentElement.clientHeight
      scroll_top = document.documentElement.scrollTop
      
  // older IE
  } else {
      window_width = document.getElementsByTagName('body')[0].clientWidth,
      window_height = document.getElementsByTagName('body')[0].clientHeight
      scroll_top = document.getElementsByTagName('body')[0].scrollTop
      str_px = "px";
  }
  
  var cartobj_width  = cartobj.offsetWidth;
  var cartobj_height = cartobj.offsetHeight;
  var cartobj_top  = 0;
  var cartobj_left = 0;
  var z_id = 2;
  
  if (layer > 0) z_id = layer;
  
  if (typeof(parentobj) == "object") {
    cartobj_left = absLeft(parentobj) + parentobj.offsetWidth/2 - cartobj_width/2;
    cartobj_top  = absTop(parentobj) + parentobj.offsetHeight/2 - cartobj_width/2;
    getObject('divTagCartBox').style.zIndex = 1;
    getObject('p_status').style.zIndex = 10;
  } else {
    cartobj_top  = Math.max((window_height / 2) - (cartobj_height / 2), 0) + scroll_top;
    cartobj_left = (window_width  / 2) - (cartobj_width  / 2);
  }
  cartobj.style.left = cartobj_left + 'px';
  cartobj.style.top  = Math.max(cartobj_top, 0) + 'px';
  cartobj.style.zIndex = z_id;
}

function getObject(name) { 
   var ns4 = (document.layers) ? true : false; 
   var w3c = (document.getElementById) ? true : false; 
   var ie4 = (document.all) ? true : false; 

   if (ns4) return eval('document.' + name); 
   if (w3c) return document.getElementById(name); 
   if (ie4) return eval('document.all.' + name); 
   return false; 
}

var selected;
function rowOverEffect(object) {
  if (object.className == 'moduleRow') object.className = 'moduleRowOver';
}

function rowOutEffect(object) {
  if (object.className == 'moduleRowOver') object.className = 'moduleRow';
}

//-->
