	function toggleBuyImg(id) {

		var oBuyImg = document.getElementById('buyImg'+id);
		var oWait = document.getElementById('divWait'+id);
		//oBuyImg.style.display = "none";

		oBuyImg.style.display = "none";
		oWait.style.display = "block";


		if ( oBuyImg.src.indexOf("add") > 0 )
			xAction = "add";
		else
			xAction = "remove";
					
		document.forms['Form1']['articleid'].value = id;
		document.forms['Form1']['ajaxaction'].value = xAction;

		postForm('Form1', true, function (req) { displayResponseToggleBuyImg(req, id); });

	}
	
	
	function displayResponseToggleBuyImg(xmlHttpRequest, id) {
		var oBuyImg = document.getElementById('buyImg'+id);
		var oWait = document.getElementById('divWait'+id);
		var xResponse = xmlHttpRequest.responseText.trim();

		//alert(xResponse);
		//alert(oBuyImg.src);
		
		if ( xResponse.indexOf('Error') > 0 ) {
			alert("Error saving adding to cart");
		} else {
			oBuyImg.src = "images/"+ xResponse + "-trolley-es-180.gif";
			oWait.style.display = "none";
			oBuyImg.style.display = "block";
		}
	
	}
	
	String.prototype.trim = function () {
	  return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
	};	

