function showOrderTip(goodCode,clickedElement)
{
	new Insertion.Before(clickedElement,
	'<div id="ordertipdiv'+goodCode+'" class="ordertip">'+
	'<form id="ordertipform'+goodCode+'" onsubmit="sendOrderTip(\''+goodCode+'\'); return false;">'+
	'<span class="summa" id="ordertipsumma'+goodCode+'">+0 руб.</span><br />'+
	'<input id="ordertipcount'+goodCode+'" type="text" class="count" value="0" name="order[goods]['+goodCode+'][addcount]" onkeyup="recalcOrderTip(\''+goodCode+'\');" onchange="recalcOrderTip(\''+goodCode+'\');">'+
	'<input type="submit" class="submit" value="&raquo;"></form></div>');
}

function recalcOrderTip(goodCode)
{
	var count = parseInt($('ordertipcount'+goodCode).value)*1;
	if(isNaN(count)) count = 0;
	if(count<0) count*=-1;
	$('ordertipcount'+goodCode).value = count;
	var price = parseFloat($('ordertipprice'+goodCode).value);
	var summa = Math.round(count*price*100)/100;
	$('ordertipsumma'+goodCode).update('+'+summa+' руб.');
}

function sendOrderTip(goodCode)
{
	var count = parseInt($('ordertipcount'+goodCode).value);
	if(count<=0) {
		$('ordertipdiv'+goodCode).remove();
		return;
	}
	var data = Form.serialize($('ordertipform'+goodCode));
	new Ajax.Updater('top_order_shortinfo','/order/?ajax=1',{
						parameters: data
					});
	$('ordertipdiv'+goodCode).remove();
	
}


function recalcOrderForm(goodCode)
{
	var count = parseInt($('orderformcount'+goodCode).value)*1;
	if(isNaN(count)) count = 0;
	if(count<0) count*=-1;
	$('orderformcount'+goodCode).value = count;
	var price = parseFloat($('orderformprice'+goodCode).value);
	var summa = Math.round(count*price*100)/100;
	$('orderformsumma'+goodCode).update(summa);
}

