function createXHR() {
	var request = false;
	
	try { request = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (err2) {
		try { request = new ActiveXObject('Microsoft.XMLHTTP');
		} catch (err3) { 
		try {  request = new XMLHttpRequest();
			} catch (err1) { 
				request = false;
			}
		}
	}
	
	return request;

}

function update_cart( action, item_ID, item_quantity, item_cost, item_options ) {
	
	var xhr = createXHR();
	var url = 'rsc/blog_update_cart.ajax.php';
	
	var update_full_cart = function() {
		var xhr2 = createXHR();
		var url2 = 'rsc/blog_update_cart_full.ajax.php';
	
		xhr2.open('GET',url2);
		xhr2.onreadystatechange = function() {
			if (xhr2.readyState == 4 && xhr2.status == 200) {
				$('cart_full_contents').innerHTML = xhr2.responseText; // update the div with the returned HTML
			}
		};
		xhr2.send(null);
	}
	
	url = url + '?action=' + action + '&item_ID=' + item_ID + '&item_cost=' + item_cost + '&item_quantity=' + item_quantity;
	
	for (var name in item_options ) {
		url = url + '&' + name + '=' + item_options[name];
	}
	
	xhr.open('GET',url);
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && xhr.status == 200) {
			$('cart_middle').innerHTML = xhr.responseText; // update the div with the returned HTML
		}
	};
	xhr.send(null);
	
	setTimeout( update_full_cart, 600 );

}
