/*
**     JavaScript Source Code
**     Created by Kalin Ganev
**     <KalinGanev [AT] Gmail (DOT) com>
**     Date Created:  2009-03-31
**     Last Modified: 2009-04-04
*/





function handleResponseAddProductsToCart () {
	if (4 == gobj_httpRequest.readyState) {
		try {
			window.eval(gobj_httpRequest.responseText);
			if (window.reloadCart) {
				// It's "Order preview" page (function reloadCart is defined).
				// Reloading content of shopping cart:
				window.reloadCart();
			}
		} catch (e) {
			// A server error arose.
			if (DEBUG) {
				window.alert('An error arose while contacting server!' + '\nDebug Information:\n' + e + '\n' + gobj_httpRequest.responseText);
			}
		}
	}
}


function /*void*/ addProductItemToCart (int_idProductItem, int_quantity) {
	// Adding language parameter to get parameters:
	// Sending a request to server using AJAX technology:
	gobj_httpRequest.open('get', BASE + 'ajax/cart_add/?productitem_id=' + int_idProductItem
			+ '&quantity=' + int_quantity + LANG_PAR_EFFECTIVE_AMP_SIMPLE, true);
	gobj_httpRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	gobj_httpRequest.onreadystatechange = handleResponseAddProductsToCart;
	gobj_httpRequest.send(null);
}


/** Called upon Ajax response after adding product(s) to shopping cart. */
function /*void*/ updatePanelShoppingCartInfo (str_htmlContent) {
	if (document.getElementById('ShoppingCartInfo')) {
		document.getElementById('ShoppingCartInfo').innerHTML = str_htmlContent;
	}
}


