

try {
	xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
		xmlhttp = false;
	}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	xmlhttp = new XMLHttpRequest();
}

function addToCart(ctr, artCode, blnService){
/*ctr: integer representing the item number on the page-> 1...n */

	//get data from page.
	var elAmount = document.getElementById("amount"+ctr);
	var elAdded = document.getElementById("added"+ctr);

	if(isNaN(elAmount.value) || elAmount.value == "" || !elAmount.value || elAmount.value == 0  )	return false;
	
	if (xmlhttp && artCode != "") {	
		
		if (isBusy){
			xmlhttp.onreadystatechange = function () {}
			xmlhttp.abort();
		}
		
		var locarray = window.location.href.split("/");
		locarray.pop();		
		var path = locarray.join("/");		
		url = path+"/addToCart_kctiel.asp?artcode="+artCode+"&aantal="+elAmount.value+"&service="+blnService;
	
		xmlhttp.open("GET", url, true);
		isBusy = true;
		
		
		xmlhttp.onreadystatechange = function () {
			if(xmlhttp.readyState == 4){
				isBusy = false;				
				elAdded.innerHTML = xmlhttp.responseText;
				if (blnOrderForm == true ) openOrderForm();								
				//self.close();
			
			}
		}
			
		xmlhttp.send(null);
	}


	//fake being busy, adding the article.
	//pause(500);
	elAdded.style.visibility = "visible";
}
