// JavaScript Document
var httpRequest_DWK = false;
var WK_del_url = "http://"+ window.location.hostname +"/includes/del_cart.php";
function WKDel(e_id, g_id, w_id, action) {
   httpRequest_DWK = false;
   if(window.XMLHttpRequest)  // Mozilla, Safari,...
       httpRequest_DWK = new XMLHttpRequest();
   else if(window.ActiveXObject) { // IE
       try {
           httpRequest_DWK = new ActiveXObject("Msxml2.XMLHTTP");
    }
       catch (e) {
           try {
               httpRequest_DWK = new ActiveXObject("Microsoft.XMLHTTP");
     }
           catch (e) {}
       }
   }
   if(!httpRequest_DWK) 
      return false;
   httpRequest_DWK.onreadystatechange = function() {
	  if(httpRequest_DWK.readyState == 4) {
         if(httpRequest_DWK.status == 200) 
			handleHttpResponse_Del_E_WK(httpRequest_DWK.responseText, e_id, g_id, action);
       else
          return false;
         }
    else
       return false;
   }
   var anzahl = parseInt(document.getElementById('eg_anz_'+e_id+'_'+g_id).innerHTML);
   if(anzahl<=1){ var action = 'del'; 
   		if(document.getElementById('gesamtpreistable')){
		SCI();
		}
   }
   if(document.getElementById('eg_anz_'+e_id+'_'+g_id)){
	   document.getElementById('eg_anz_'+e_id+'_'+g_id).innerHTML = "<img src='http://"+ window.location.hostname +"/images/loading.gif' alt='wird geladen' />";
   }
   httpRequest_DWK.open('get', WK_del_url+'?e_id='+e_id+'&g_id='+g_id+'&w_id='+w_id+'&action='+action, false);
   httpRequest_DWK.send(null);

}

function handleHttpResponse_Del_E_WK(content, e_id, g_id, action) {
	if(action=='del'){
		var TBody = document.getElementById('div_einh_'+e_id+'_'+g_id);
		TBody.style.display = 'none';
	}
	if(action=='remove'){
   	  document.getElementById('eg_anz_'+e_id+'_'+g_id).innerHTML = content;
	}
}