/**
 * JS-Funktionen des Warenkorbs
 */
var tyShopBasket = {
	url : myty.basePath + '/modules/shop/handlers/ajaxHandler.php',
	count : 0,
	settings : {},
	callbacks : {
		onAddComplete : function(){},
		onLoadComplete : function(){}
	},
	addByForm : function(optionId,countFieldId){
		tyShopBasket.add(optionId,document.getElementById(countFieldId).value);
	},
	add : function(optionId,count){
		var data = {object:'tyShopBasket',action:'add',optionId:optionId,count:count};
		tyShopBasket.count += count;
		jQuery.getJSON(tyShopBasket.url,data,function(response){
			$('#tyShopBasketQuantity').text(response.count);
			$('#tyShopBasketSumTotalBrutto').text(response.totalBrutto.replace(/&euro;/,'€'));
			$('#tyShopBasketSumTotal').text(response.totalSum.replace(/&euro;/,'€'));
			tyShopBasket.callbacks.onAddComplete(response);
		});
	},
	loadBasket : function(){
		var data = {object:'tyShopBasket',action:'getBasket'};
		jQuery.getJSON(tyShopBasket.url,data,function(response){
			tyShopBasket.count = response.count;
			tyShopBasket.callbacks.onLoadComplete(response);
		} );
	},
	getCount : function(){return tyShopBasket.count;},
	configure : function(settings,callbacks) {
		this.settings = jQuery.extend(this.settings,settings);
		this.callbacks = jQuery.extend(this.callbacks,callbacks);
	}
}