function recalcPrice( cnt, price )
{
	var c = parseInt(document.getElementById( 'gf' + cnt ).number.value);

	if(c < 1 || isNaN(c))
	{
		c = 1;
		document.getElementById( 'gf' + cnt ).number.value = c;
	}

	document.getElementById( 'price' + cnt ).innerHTML = price * c;
}

function recalcSellPrice( itemId, price )
{
	var c = parseInt(g( 'number'+itemId ).value);

	if(c < 1 || isNaN(c))
	{
		c = 1;
		g( 'number'+itemId ).value = c;
	}

	document.getElementById( 'price' + itemId ).innerHTML = price * c;
}

function shopBuy( cnt)
{
	var c 		= parseInt(document.getElementById( 'gf' + cnt ).number.value);
	var good_id 	= parseInt(document.getElementById( 'gf' + cnt ).good_id.value);
	var shop_id 	= parseInt(document.getElementById( 'gf' + cnt ).shop_id.value);
	var user_id 	= parseInt(document.getElementById( 'gf' + cnt ).user_id.value);
	var buy     	= parseInt(document.getElementById( 'gf' + cnt ).buy.value);
	
	//alert("ref_shop.php?good_id="+good_id+"&shop_id="+shop_id+"&user_id="+user_id+"&number="+c+"&buy="+buy);
	if(c >= 1 && !isNaN(c) && !isNaN(good_id) && !isNaN(shop_id) && !isNaN(user_id) && !isNaN(buy))
	{
		shop.location.href="ref_shop.php?good_id="+good_id+"&shop_id="+shop_id+"&user_id="+user_id+"&number="+c+"&buy="+buy;
		
		//alert("ref_shop.php?good_id="+good_id+"&shop_id="+shop_id+"&user_id="+user_id+"&number="+c+"&buy="+buy);
	}
	else
		alert("Ошибка!");

   	//eventPreventDefault(evt);
}

function shopSell(itemId, is_cnt)
{
	var itemCnt = 1;

	if(is_cnt == 1)
	{
		var itemCnt = parseInt(g( 'number'+itemId ).value);
	}

	if(!isNaN(itemCnt) && itemCnt > 0)
	{
		location.href="location.php?sellItem="+itemId+"&cnt="+itemCnt;
	}
	else
	{
		alert('Неверный формат количества вещей.');
	}
}

function shopSellUnit(unitId)
{
	var unitCnt = parseInt(g( 'number'+unitId ).value);

	if(!isNaN(unitCnt) && unitCnt > 0)
	{
		location.href="location.php?sellUnit="+unitId+"&cnt="+unitCnt;
	}
}

function shopRepair(itemId)
{
	location.href="location.php?repairItem="+itemId;
}