function createRequestObject()
{
	if (window.XMLHttpRequest) {
		try {
			return new XMLHttpRequest();
		} catch (e){}
	} else if (window.ActiveXObject) {
		try {
			return new ActiveXObject('Msxml2.XMLHTTP');
		} catch (e){
			try {
				return new ActiveXObject('Microsoft.XMLHTTP');
			} catch (e){}
		}
	}
	return null;
}

function itemAddedToSlip()
{
	try {
		if (this.readyState == 4) {
			if (this.status == 200) {
				if (this.responseXML && this.responseXML.getElementsByTagName('status').item(0).firstChild.nodeValue == 'ok') {
					document.getElementById('slipCountDiv').innerHTML = this.responseXML.getElementsByTagName('count').item(0).firstChild.nodeValue;
					var offer_id = this.responseXML.getElementsByTagName('offer_id').item(0).firstChild.nodeValue;
					document.getElementById('offer' + offer_id + 'ToCartDiv').style.display = 'none';
					document.getElementById('offer' + offer_id + 'InCartDiv').style.display = 'inline';
				}
			} else {
				//alert("Не удалось получить данные:\n" + req.statusText);
			}
		}
	}
	catch( e ) {
	}
}


function addToSlip(id, session_id)
{
	var req = createRequestObject();
	if (req) {
		req.open("POST", '/cgi-bin/slip/add.pl')
		req.send("offer_id=" + id + "&sessionid=" + session_id);
		req.onreadystatechange = itemAddedToSlip;
	}
}
