function AddToCart(strURL, strField) {
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			(self.xmlHttpReq.responseText);
			updatepage(self.xmlHttpReq.responseText, strField, strURL);
		}
	}
	self.xmlHttpReq.send(getquerystring(strField));
}

function getquerystring(strField) {
	document.getElementById("cart").innerHTML = '<img src="/assets/images/loader.gif" style="padding-top:10px;" />';
	var up = strField.replace("product_", "up_");
	up = up.replace("rec_", "up_");
	document.getElementById(up).innerHTML = '<span style="font-size:11px;font-weight:bold;font-style:italic;color:#862323">updating...</span>';
	var word = document.getElementById(strField).value;
	qstr = 'w=' + escape(word) + '&p=' + strField;
	return qstr;
}

function updatepage(str, strField, strURL){
	var up = strField.replace("product_", "up_");
	up = up.replace("rec_", "up_");
	document.getElementById(up).innerHTML = '';
	document.getElementById("cart").innerHTML = str;
	document.getElementById(strField).value = '';
	if (str) {
		GetField(strField, strURL);
	}
	else {
		window.location = document.location.href;
	}
	totalCart(strField);
}

function GetField(strField, strURL) {
	var xmlHttpReq = false;
	var self = this;
	// Mozilla/Safari
	if (window.XMLHttpRequest) {
		self.xmlHttpReq = new XMLHttpRequest();
	}
	// IE
	else if (window.ActiveXObject) {
		self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
	}
	self.xmlHttpReq.open('POST', strURL, true);
	self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	self.xmlHttpReq.onreadystatechange = function() {
		if (self.xmlHttpReq.readyState == 4) {
			updateField(self.xmlHttpReq.responseText, strField);
		}
	}
	self.xmlHttpReq.send(getfieldstring(strField));
}

function getfieldstring(strField) {
	var word = document.getElementById(strField).value;
	qstr = 't=' + strField;
	return qstr;
}

function updateField(str2, strField){
	document.getElementById(strField).value = str2;
}

