var $f = jQuery.noConflict();
$f(document).ready(function(){



$f(function () {
	$f("#select1").change(function () {
		chek_price(this,'#price');
	}).change();
	$f("#select2").change(function () {
		chek_pred(this,'#predmeti');
	}).change();
});




});


function chek_price(item,name) {
	var kolpred = parseInt($f("#kolpred").val());
	var str = "";
	$f(item.children).each(function () {
		if(this.selected){
			str = $f(this).val();
		}
	});
	if(str=="") str=0;
	$f("#kolprice").val(parseInt(str));
	$f(name).html(parseInt(str)*parseInt(kolpred));
}

function chek_pred(item,name) {
	var str = "";
	var tmp = 0;
	var price = parseInt($f("#kolprice").val());
	$f("#kolpred").val("1");
	$f(item.children).each(function () {
		if(this.selected){
			str += $f(this).val() + " <br>";
			tmp ++;
		}
	});
	$f("#kolpred").val(tmp);
	$f("#price").html(tmp*price);
	$f(name).html(str);
}

