function calculate() {
    var vt;
    var nt;
	var ukupno=parseInt(document.dropmsgform.ukupno1.value,10);
	var x=parseInt(parseInt(document.dropmsgform.dropmsgoption.selectedIndex,10));
	var snaga = parseInt(document.dropmsgform.osigurac.value,10)/parseInt(document.dropmsgform.tip_prikljucka.value,10);
	var tip=parseInt(document.dropmsgform.tip_prikljucka.value,10);
    document.dropmsgform.ukupno.value=ukupno;
	document.dropmsgform.cnt2.value=round(parseFloat(document.dropmsgform.osigurac.value,2)/tip);
	document.dropmsgform.cnt3.value=25.808;
	document.dropmsgform.textfield151.value=parseFloat(document.dropmsgform.cnt2.value*25.808,2);
	document.dropmsgform.textfield151.value=Math.round(document.dropmsgform.textfield151.value * 100) / 100;	
	var textfield151=parseFloat(document.dropmsgform.textfield151.value);
	//OBRACUNAVANJE
	//jednotarifno
	if (x<1)  {
	vt=parseInt(document.dropmsgform.ukupno1.value,10);
	nt=0;
	ukupno=vt;
	document.dropmsgform.ukupno.value=ukupno+parseFloat(document.dropmsgform.cnt2.value,2);
	document.dropmsgform.cenazvt.value='3.444';var cenazvt=document.dropmsgform.cenazvt.value;
	document.dropmsgform.cenaznt.value='0';var cenaznt=document.dropmsgform.cenaznt.value;
	document.dropmsgform.cenapvt.value='5.166';var cenapvt=document.dropmsgform.cenapvt.value;
	document.dropmsgform.cenapnt.value='0';var cenapnt=document.dropmsgform.cenapnt.value;
	document.dropmsgform.cenacvt.value='10.332';var cenacvt=document.dropmsgform.cenacvt.value;
	document.dropmsgform.cenacnt.value='0';var cenacnt=document.dropmsgform.cenacnt.value;
	
	if (ukupno<351) document.dropmsgform.zvt.value=vt;
	else document.dropmsgform.zvt.value=350;
	var zvt=document.dropmsgform.zvt.value;
	document.dropmsgform.znt.value=0;
	var znt=document.dropmsgform.znt.value;
	
	if (ukupno<1601) document.dropmsgform.pvt.value=ukupno-zvt;
	else document.dropmsgform.pvt.value=1250;
	document.dropmsgform.pnt.value=0;
	var pvt=document.dropmsgform.pvt.value;
	var pnt=document.dropmsgform.pnt.value;
	
	document.dropmsgform.cvt.value=vt-zvt-pvt;var cvt=document.dropmsgform.cvt.value;
	document.dropmsgform.cnt.value=0;var cnt=document.dropmsgform.cnt.value;
	}
	//dvotarifno
	if (x>=1) {
	vt=parseInt(document.dropmsgform.ukupno3.value,10);
	nt=parseInt(document.dropmsgform.ukupno2.value,10);
	ukupno=vt+nt;
	document.dropmsgform.ukupno.value=ukupno+parseFloat(document.dropmsgform.cnt2.value,2);
	document.dropmsgform.cenazvt.value='3.936';var cenazvt=document.dropmsgform.cenazvt.value;
	document.dropmsgform.cenaznt.value='0.984';var cenaznt=document.dropmsgform.cenaznt.value;
	document.dropmsgform.cenapvt.value='5.904';var cenapvt=document.dropmsgform.cenapvt.value;
	document.dropmsgform.cenapnt.value='1.476';var cenapnt=document.dropmsgform.cenapnt.value;
	document.dropmsgform.cenacvt.value='11.808';var cenacvt=document.dropmsgform.cenacvt.value;
	document.dropmsgform.cenacnt.value='2.952';var cenacnt=document.dropmsgform.cenacnt.value;
	if (ukupno<351) document.dropmsgform.zvt.value=vt;
	else document.dropmsgform.zvt.value=Math.round((vt/(vt+nt))*350);
	var zvt=document.dropmsgform.zvt.value;
	if (ukupno<351) document.dropmsgform.znt.value=nt;
	else document.dropmsgform.znt.value=Math.round((nt/(vt+nt))*350);
	var znt=document.dropmsgform.znt.value;
	
	if (ukupno<1601) document.dropmsgform.pvt.value=vt-zvt;
	else document.dropmsgform.pvt.value=Math.round((vt/(vt+nt))*1250);
	var pvt=document.dropmsgform.pvt.value;
	if (ukupno<1601) document.dropmsgform.pnt.value=nt-znt;
	else document.dropmsgform.pnt.value=Math.round((nt/(vt+nt))*1250);
	var pnt=document.dropmsgform.pnt.value;
	
	document.dropmsgform.cvt.value=vt-zvt-pvt;var cvt=document.dropmsgform.cvt.value;
	document.dropmsgform.cnt.value=nt-znt-pnt;var cnt=document.dropmsgform.cnt.value;
	}
	//DUT
	if (x>=2)  {
	vt=parseInt(document.dropmsgform.ukupno4.value,10);
	nt=0;
	ukupno=vt;
	document.dropmsgform.ukupno.value=ukupno+parseFloat(document.dropmsgform.cnt2.value,2);
	document.dropmsgform.cenazvt.value='0.984';var cenazvt=document.dropmsgform.cenazvt.value;
	document.dropmsgform.cenaznt.value='0';var cenaznt=document.dropmsgform.cenaznt.value;
	document.dropmsgform.cenapvt.value='1.476';var cenapvt=document.dropmsgform.cenapvt.value;
	document.dropmsgform.cenapnt.value='0';var cenapnt=document.dropmsgform.cenapnt.value;
	document.dropmsgform.cenacvt.value='2.952';var cenacvt=document.dropmsgform.cenacvt.value;
	document.dropmsgform.cenacnt.value='0';var cenacnt=document.dropmsgform.cenacnt.value;
	if (ukupno<351) document.dropmsgform.zvt.value=vt;
	else document.dropmsgform.zvt.value=350;
	var zvt=document.dropmsgform.zvt.value;
	document.dropmsgform.znt.value=0;
	var znt=document.dropmsgform.znt.value;
	
	if (ukupno<1601) document.dropmsgform.pvt.value=ukupno-zvt;
	else document.dropmsgform.pvt.value=1250;
	document.dropmsgform.pnt.value=0;
	var pvt=document.dropmsgform.pvt.value;
	var pnt=document.dropmsgform.pnt.value;
	
	document.dropmsgform.cvt.value=vt-zvt-pvt;var cvt=document.dropmsgform.cvt.value;
	document.dropmsgform.cnt.value=0;var cnt=document.dropmsgform.cnt.value;
	}
	//OBRACUNAVANJE

	document.dropmsgform.textfield8.value=round(parseFloat(cenazvt)*parseFloat(zvt),2);var textfield8=parseFloat(document.dropmsgform.textfield8.value);
	document.dropmsgform.textfield9.value=round(parseFloat(cenaznt)*parseFloat(znt),2);var textfield9=parseFloat(document.dropmsgform.textfield9.value);
	document.dropmsgform.textfield10.value=round(parseFloat(cenapvt)*parseFloat(pvt),2);var textfield10=parseFloat(document.dropmsgform.textfield10.value);
	document.dropmsgform.textfield11.value=round(parseFloat(cenapnt)*parseFloat(pnt),2);var textfield11=parseFloat(document.dropmsgform.textfield11.value);
	document.dropmsgform.textfield12.value=round(parseFloat(cenacvt)*parseFloat(cvt),2);var textfield12=parseFloat(document.dropmsgform.textfield12.value);
	document.dropmsgform.textfield13.value=round(parseFloat(cenacnt)*parseFloat(cnt),2);var textfield13=parseFloat(document.dropmsgform.textfield13.value);
	document.dropmsgform.textfield15.value=round(round((95.83+textfield8+textfield9+textfield10+textfield11+textfield12+textfield13+textfield151),2)*0.18,2);
	var pdv=parseFloat(document.dropmsgform.textfield15.value,2);
	document.dropmsgform.textfield14.value=round(95.83+textfield8+textfield9+textfield10+textfield11+textfield12+textfield13+textfield151+pdv+round(document.dropmsgform.televizija.value,2),2);
}

function round(number,X) {
// rounds number to X decimal places, defaults to 2
X = (!X ? 2 : X);
return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}

function brisanje() {
    // Get the user's input from the form. Assume it is all valid.
    // Convert interest from a percentage to a decimal, and convert from
    // an annual rate to a monthly rate. Convert payment period in years
    // to the number of monthly payments.
    document.dropmsgform.vt.value='0';document.dropmsgform.cenazvt.value='';document.dropmsgform.textfield11.value='';
	document.dropmsgform.nt.value='0';document.dropmsgform.cenaznt.value='';document.dropmsgform.textfield12.value='';
	document.dropmsgform.ukupno.value='';document.dropmsgform.cenapvt.value='';document.dropmsgform.textfield13.value='';
	document.dropmsgform.zvt.value='';document.dropmsgform.cenapnt.value='';document.dropmsgform.textfield14.value='';
	document.dropmsgform.znt.value='';document.dropmsgform.cenacvt.value='';document.dropmsgform.textfield15.value='';
	document.dropmsgform.pvt.value='';document.dropmsgform.cenacnt.value='';
	document.dropmsgform.pnt.value='';document.dropmsgform.textfield8.value='';
	document.dropmsgform.cvt.value='';document.dropmsgform.textfield9.value='';
	document.dropmsgform.cnt.value='';document.dropmsgform.textfield10.value='';
	}

