function restart() { TL=parseFloat(document.f.tl.value); ST=parseInt(document.f.st.value,10); SP=parseInt(document.f.sp.value,10); STh=Math.round(ST/100-0.5); STm=ST-STh*100; TL2=parseFloat(document.f.tl2.value); ST2=parseInt(document.f.st2.value,10); TL3=parseFloat(document.f.tl3.value); ST3=parseInt(document.f.st3.value,10); ST2h=Math.round(ST2/100-0.5); ST2m=ST2-ST2h*100; ST3h=Math.round(ST3/100-0.5); ST3m=ST3-ST3h*100; if (isNaN(TL)|TL<0) { alert('Feil i timelønnen!'); return } if (isNaN(ST)|ST<0|STh>24|STm>59) { alert('Feil i starttidspunktet! '); return } if (isNaN(SP)|SP<0|SP>99) { alert('Feil i skatteprosenten! '); return } if (isNaN(TL2)|TL2<0) { alert('Feil i tillegg 1!'); return } if (isNaN(ST2)|ST2<0|ST2h>24|ST2m>59) { alert('Feil i starttidspunktet for tillegg 1! '); return } if (isNaN(TL3)|TL3<0) { alert('Feil i tillegg 2!'); return } if (isNaN(ST3)|ST3<0|ST324|ST3m>59) { alert('Feil i starttidspunktet for tillegg 2! '); return } if (STh<10) {STh = '0'+STh;} if (STm<10) {STm = '0'+STm;} if (ST2h<10) {ST2h = '0'+ST2h;} if (ST2m<10) {ST2m = '0'+ST2m;} if (ST3h<10) {ST3h = '0'+ST3h;} if (ST3m<10) {ST3m = '0'+ST3m;} document.f.tl.value=TL; document.f.st.value=STh+''+STm; document.f.sp.value=SP; document.f.tl2.value=TL2; document.f.st2.value=ST2h+''+ST2m; document.f.tl3.value=TL3; document.f.st3.value=ST3h+''+ST3m; update(); } function update() { TL=parseFloat(document.f.tl.value); ST=parseInt(document.f.st.value,10); SP=parseInt(document.f.sp.value,10); STh=Math.round(ST/100-0.5); STm=ST-STh*100; TL2=parseFloat(document.f.tl2.value); ST2=parseInt(document.f.st2.value,10); TL3=parseFloat(document.f.tl3.value); ST3=parseInt(document.f.st3.value,10); ST2h=Math.round(ST2/100-0.5); ST2m=ST2-ST2h*100; ST3h=Math.round(ST3/100-0.5); ST3m=ST3-ST3h*100; var tid = new Date() msnow = tid.getTime(); tid.setHours(STh); tid.setMinutes(STm); tid.setSeconds(0); msstart = tid.getTime(); msd=msnow-msstart; tid.setHours(ST2h); tid.setMinutes(ST2m); tid.setSeconds(0); msstart2 = tid.getTime(); msd2=msnow-msstart2; if (msd2<0) { msd2=0 } tid.setHours(ST3h); tid.setMinutes(ST3m); tid.setSeconds(0); msstart3 = tid.getTime(); msd3=msnow-msstart3; if (msd3<0) { msd3=0 } if ((msd3>0)&(msd2>0)) { msd2=0 } hd=msd/1000/60/60; hd2=msd2/1000/60/60; hd3=msd3/1000/60/60; kr=Math.round((TL*hd+TL2*hd2+TL3*hd3)*(100-SP)/100*100)/100; if (Math.round(kr)==kr) { kr = kr+'.00' } else { if (Math.round(kr*10)==kr*10) { kr = kr+'0' } } document.f.tjent.value=kr; document.title='kr '+kr+' tjent!'; document.all["n0"].style.width=Math.ceil(kr/10); id = setTimeout("update()",1000); }