
function set_select(list,pid) {
	var i=0;
	var j=1;
	while (list.options[i] && j) {
		if (list.options[i].value==pid) {
			list.selectedIndex=i;
			j=0;
		}
		i++;
	}
}

function mk_currency_number(val)
{
	val=(Math.round(100*val)/100).toString();
	if (val.match(/\.\d\d$/)) {
	} else if (val.match(/\.\d$/)) {
		val+="0";
	} else {
		val+=".00";
	}
	return val;
}

function update_summ(inp)
{
	var tr=$(inp.parentNode.parentNode);
	if (inp.value=="") {
		$(".summ",tr).text("");
		return;
	}
	var val=mk_currency_number(inp.value*$(".price",tr).text())
	$(".summ",tr).text(val);
	update_totals();
}

function update_totals()
{
	var total=0;
	$("tr .summ").each(function(index) {
		if ($(this).text()=="") return;
		total+=1*$(this).text();
	});
	var val=mk_currency_number(total);
	$(".total").text(val);
}

function input_focus(inp)
{
	if (inp.value=="") {
		inp.value="1";
		update_summ(inp);
	}
	$(inp.parentNode.parentNode).addClass("hl");
}

function input_blur(inp)
{
	update_summ(inp);
	$(inp.parentNode.parentNode).removeClass("hl");
}

function cart_submit_check()
{
	var frm=document.forms.frm;
	frm.mode.value='cart_save';
	return 1;
}


