﻿$(document).ready(function() {
	$("input[mask=positive]").format({ precision: 2, allow_negative: false, autofix: true });
	//$("#basketGuid").sSelect();
	//	$.ui.dialog.defaults.bgiframe = true;
	//TODO
	$('#destinationBasket').dialog(
					{ buttons: { "Mégse": function() { $(this).dialog("close"); } },
						resizable: false, width: 500, title: DestinationBasketChooser_Title,
						modal: true, autoOpen: false
					});
	$('#destinationBasket').dialog('close');
	$('#newBasketId').change(function() {
		setHiddenFields('operation', 'showBasket');
		if ($(this).closest('form').length > 0) {
			return submitClosest($(this));
		}
	});
	

	$("input[name='moveDestinationBasket']").click(function() {
		//alert(this.outerHTML);
		var selecteds = getSeletedIds();
		if (selecteds.length > 0) {
			$('#selectedproduct').val(selecteds);
			$('#destinationBasket').dialog('open');
		} else {
			alert(SelectAProduct);
		}
		return false;
	});
})

function getSeletedIds() {
	var ret = "";
	var pCheck = $("input[id^='select_']");
	for (i = 0; i < pCheck.length; i++) {
		if (pCheck[i].checked) {
			pid = pCheck[i].id.split("_")[1];

			var pQuan = $("input[id^='quantities_" + pid + "']");

			ret += pid + "=" + pQuan.val() + ";";
		}
	}
	//alert(ret);
	return ret;
}

function selectCheckbox(isCheck) {
	//	alert(ff.ll.l);
	var pCheck = $("input[name^='select_']");
	for (i = 0; i < pCheck.length; i++) {
		pCheck[i].checked = isCheck == 1 ? true : false;
	}
	return false;
}
