

	var complectation = false;

	function loip_cart_recount() {
		
		document.getElementById("cartForm").submit();
		
	}
	
	function loip_cart_sendOrder() {
		
		var lang = getLang();
		if (confirm("После отправки заказ будет невозможно изменить.\n\nПродолжить?")) {
			
			document.location = "/" + lang + "/order/send?comment=" + escape(document.getElementById("comment").value);
			
		}
		
	}
	
	function loip_cart_descript_exp(id, action) {
	
		var link = document.getElementById(id + '_link');
		var desc = document.getElementById(id + '_desc');
		var tr   = document.getElementById(id + '_tr');
	
		if (action == 1) {
		
			desc.style.display = '';
			link.innerHTML = "<img src='/admin/ui/actions/node_collapse.gif' border='0' class='expand'>";
			if (tr.className == 'cartEven') { tr.className = 'cartEvenB'; }
			if (tr.className == 'cartOdd')  { tr.className = 'cartOddB';  }
		
		} else {
		
			desc.style.display = 'none';
			link.innerHTML = "<img src='/admin/ui/actions/node_expand.gif' border='0' class='expand'>";
			if (tr.className == 'cartEvenB') { tr.className = 'cartEven'; }
			if (tr.className == 'cartOddB')  { tr.className = 'cartOdd';  }
		
		}
	
	}
	
	function loip_cart_descript(id) {
	
		var desc = document.getElementById(id + '_desc');
		
		if (desc.style.display == 'none') {

			loip_cart_descript_exp(id, 1);
			
		} else {
		
			loip_cart_descript_exp(id, 0);
		
		}
	
	}





	function loip_cart_addProduct(id, type, order) {
		
		if (!order) order = 'id' + Math.floor(Math.random()*1000000000);
		
		document.getElementById('cartOut').innerHTML = "<img src='/admin/ui/loading_upload.gif'>";
		
		JsHttpRequest.query(
			'/modules/_loip/cart/addproduct.php', // backend
			{
				id: id,
				type: type,
				orderid: order
			},
			function(res, text) { // ONREADYSTATE
				
				document.getElementById('cartOut').innerHTML = unescape(res.num);
				alert("Товар \"" + unescape(res.html) + "\" добавлен в корзину.");
				
			}
		);
		
	}

	function loip_cart_addProdComplect(id) {
		
		window.orderid = 'id' + Math.floor(Math.random()*1000000000);
		
		document.getElementById('cartOut').innerHTML = "<img src='/admin/ui/loading_upload.gif'>";
		
		if (complectation) {
			
			var num = 0;
			
			for (var i=0; i < complectation.length; i++) {
				
				num = document.getElementById(complectation[i] + '_num').value;
				if (parseInt(num) > 0) loip_cart_addComplect(complectation[i], id);
				
			}
			
		}
		
		loip_cart_addProduct(id, 'self', orderid);
		
	}
	
	function loip_cart_addComplect(id, src) {
		
		var num = parseInt(document.getElementById(id + '_num').value);
		
		JsHttpRequest.query(
			'/modules/_loip/cart/addprodcomplect.php', // backend
			{
				id: id,
				src: src,
				orderid: orderid,
				num: num
			},
			function(res, text) { // ONREADYSTATE
				
				return true;
				
			}
		);
		
	}

