function update_stoim( basketCount )
{
//	summ = document.getElementById(id).innerHTML;
	summ = parseFloat(0);
	for (i=1; i<= basketCount; i++) {
		if (isNaN(parseInt(document.getElementById('col_'+i).value))) {
			col=0;
		} else {
			col=parseInt(document.getElementById('col_'+i).value);
		}

		document.getElementById('col_'+i).value = col;

		price = document.getElementById('pricePrecision_'+i).value;
		price = price.replace(',', '.', 'gi');
		price = price.replace(' ', '', 'gi');
		price = price.replace('&nbsp;', '', 'gi');

		stoim = parseFloat(price);
		summ += col*stoim;
		stoim = col*stoim;
		setStoim(stoim, 'stoim_'+i);
	}
//	alert(summ);
	if( summ > 0) {
		setTotalSumm( summ, 'st');
	}
}

function setStoim(stoim, id)
{
//	stoim = String(Math.round(stoim *100));
//	while (stoim.length < 3) {
//		stoim = 0 + stoim;
//	}
//	stoim = stoim.substring(0, stoim.length-2) + ',' + stoim.substring(stoim.length-2, stoim.length);
	
	var nf = new NumberFormat(stoim);
	nf.setPlaces(2);
	nf.setSeparators(true, '\u00a0', ',');
//	alert(nf.toFormatted() + '\u00a0р.' );
	document.getElementById(id).innerHTML = nf.toFormatted() + '\u00a0р.';
}

function setTotalSumm( summ, id) {
/*
	summ = String(Math.round(summ*100));
	while (summ.length < 3) {
		summ = 0 + summ;
	}
	document.getElementById(id).innerHTML = summ.substring(0, summ.length-2) + ',' + summ.substring(summ.length-2, summ.length);
*/
	var nf = new NumberFormat(summ);
	nf.setPlaces(2);
	nf.setSeparators(true, '\u00a0', ',');
//	alert(nf.toFormatted() + '\u00a0р.' );
	document.getElementById(id).innerHTML = nf.toFormatted();
}

function checkData()
{
	errors = new Array();

	emptyGoods = true;
	for (i=1; i<= basketCount; i++) {
		if (isNaN(parseInt(document.getElementById('col_'+i).value))) {
			col=0;
		} else {
			col=parseInt(document.getElementById('col_'+i).value);
		}
		if (col != 0) {
			emptyGoods = false;
		}
	}

	if (emptyGoods) {
		errors[errors.length] = 'Не выбрано ни одного товара';
	}

/*
	warehouse = document.getElementById('warehouse').value;

	if (warehouse == '' || warehouse ==0) {
		errors[errors.length] = 'Не выбран склад';
	}
*/
	if (errors.length > 0) {
		alert('Обнаружены следующие ошибки:\n' + errors.join('\n'));
		return false;
	} else {
		return true;
	}

}

