/* +----------------------------------------------------------------------+
 * | AJAX Shopping Cart                                                   |
 * | Africa Cafe Ceramics                                                 |
 * | Active Ice http://activeice.co.za                                    |
 * +----------------------------------------------------------------------+
 */

/**
*
* @params none
*
* @constructor
*/
function cart() {
	
	this.AJAX_DIR = SITE_PATH + "/public/aicart/";
	this.debug = 0;
	
}

/**
* Add a product to the cart by quantity
*
* @param id  Range ID
* @param id  Shape ID
* @param id  Quantity ID
* @param id  Colour
* @return void
*/
cart.prototype.add = function(rid,sid) {
	
	var qty = ( arguments[2] ) ? arguments[2] : '';
	var color_id = ( arguments[3] )? arguments[3]: '';
	
	if ( this.debug ) alert( this.AJAX_DIR + "ai_cart.php?a=add&item=" + rid + "|" + sid + "|" + qty + "|" + color_id );
	
	ajax_response = doAJAX( this.AJAX_DIR + "ai_cart.php?a=add&item=" + rid + "|" + sid + "|" + qty + "|" + color_id );
	
	if ( this.debug ) alert(ajax_response);

}

/**
* Delete an item from cart
*
* @param id : Range ID
* @param id : Shape ID
* @return void
*/
cart.prototype._delete = function(rid,sid) {
	
	var redirect = ( arguments[2] ) ? arguments[2] : 0;
	
	if ( this.debug ) alert( this.AJAX_DIR + "ai_cart.php?a=delete&item=" + rid + "|" + sid );
	
	ajax_response = doAJAX( this.AJAX_DIR + "ai_cart.php?a=delete&item=" + rid + "|" + sid );
	
	if ( this.debug ) alert(ajax_response);
	
	if ( redirect ) window.location.href = window.location.href;
}

/*
* Create cart
*/
if ( typeof( cart ) != "object" )
	cart = new cart();
