function null_add(t_v)
{
	t_v=t_v + "";
	if(t_v.substring(t_v.length - 2,t_v.length-1)==".") t_v=t_v + "0";
	else
	{
		if(t_v.substring(t_v.length - 3,t_v.length-2)!=".") t_v=t_v + ".00";
	}
	return t_v;
}

function pereschet_total(val,znak)
{
	basket = document.getElementById('basket2');
	if(znak=="+") t_v=parseFloat(basket.price_total.value)+parseFloat(val);
	if(znak=="-") t_v=parseFloat(basket.price_total.value)-parseFloat(val);
	if(znak=="")
	{
		t_v=parseFloat(basket.price_total.value)+parseFloat(val);
	}
	t_v=Math.round(t_v*100)/100;
	basket.price_total.value=t_v;
}

function pereschet(tt,obg,numb)
{
	basket = document.getElementById('basket2');
	eval('t_v=tt.value*basket.'+obg+'_am_'+numb+'.value');
	t_v=Math.round(t_v*100)/100;
	t_v=t_v + "";
	//t_v=null_add(t_v);
	eval('basket.'+obg+'_sum_'+numb+'.value=t_v');
//	basket.target="basket_frame";
	basket.submit();
}


function change_price(obg,todo,numb)
{
	tt=document.getElementById(obg+'_'+numb);
	tt_fin=document.getElementById(obg+'_fin_'+numb);
	am_tt=document.getElementById(obg+'_am_'+numb);
	if(todo=="+")
	{
		eval (tt.value ++);
		eval (tt_fin.value ++);
		pereschet_total(am_tt.value,"+");
		pereschet(tt,obg,numb);
	}
	if(todo=="-" && tt.value>0)
	{
		eval (tt.value --);
		eval (tt_fin.value --);
		pereschet_total(am_tt.value,"-");
		pereschet(tt,obg,numb);
	}
	if(todo=="")
	{
		eval (tt.value);
		razn_val=(tt.value-tt_fin.value)*am_tt.value;
		eval (tt_fin.value=tt.value);
		pereschet_total(razn_val,"");
		pereschet(tt,obg,numb);
	}
}
