
var shopTimerStack = new Array();

function shopChanged(ell, itemUid) 
{
	shopClearTimeout(ell.id);
	shopSetTimerById(ell.id, setTimeout(function() {shopBasketSetOrderedBoxes(itemUid, ell.value);}, 1000));
}

function shopClearTimeout(ellId) 
{
	if (obj = shopGetTimerById(ellId)) {
		clearTimeout(obj.timer);
	}
}

function shopGetTimerById(ellId)
{
	for (i in shopTimerStack) {
		obj = shopTimerStack[i];
		if (obj.id == ellId) {
			return obj;
		}
	}
}

function shopSetTimerById(ellId, timerObj)
{
	if (obj = shopGetTimerById(ellId)) {
		obj.timer = timerObj;
	} else {
		shopTimerStack[shopTimerStack.length] = { id:ellId, timer:timerObj };
	}
}


function shopBasketSetOrderedItems(uid, orderedQuantity) {
	shopBasketSetOrderedQuantity(uid, orderedQuantity, 0);
}

function shopBasketSetOrderedBoxes(uid, orderedQuantity) {
	shopBasketSetOrderedQuantity(uid, 0, orderedQuantity);
}

function shopBasketDelete(uid) {
	shopBasketSetOrderedQuantity(uid, 0, 0);
}

function shopBasketSetOrderedQuantity(uid, itemQuantity, boxQuantity) 
{
	$.ajax( {
		url : "/modules/shop/data_request/basket_update.php",
		type : "GET",
		data : {
			mode : "setOrderedQuantity",
			uid : uid,
			cntItem : itemQuantity,
			cntBox : boxQuantity
		},
		dataType : "html",
		success : function(data) {
			shopBasketUpdateView(data);
		},
		error : function() {
			alert("error");
		},
		cache : false
	});
}

function shopBasketUpdateView(data) {
	//$("#shopBasketStatusPanel").html(data);
	//$("#shopBasketStatusPanelFloat").html(data);

	vclStdSend('shopBasketShortInfo', {__VCLUID:'shopBasketShortInfo', className:'shopBasketShortInfo'});
	//$("#shopBasketShortInfo").load('/lib/data_request/vcl.php?className=shopBasketShortInfo');
	//$("#shopBasketOrderFormForBox").load('/lib/data_request/vcl.php?className=shopBasketOrderFormForBox');
	
}

