/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Jim Stiles | www.jdstiles.com */



// -- function buat set number format  ------------------------------------------------- //
	function FormatCurrency(objNum)
	{
	    var num = objNum.value;
	    var ent, dec;
		
	    if (num != '' && num != objNum.oldvalue)
	    {
	          num = MoneyToNumber(num);
	          if (isNaN(num))
	          {
				if (objNum.oldvalue) {
	                objNum.value = objNum.oldvalue;
				}
				else {
					objNum.value = '';
				}
	          } else {
	                var ev = (navigator.appName.indexOf('Netscape') != -1)?Event:event;
	                if (ev.keyCode == 190 || !isNaN(num.split('.')[1]))
	                {
	                      objNum.value = AddCommas(num.split('.')[0])+'.'+num.split('.')[1];
	                }
	                else
	                {
	                      objNum.value = AddCommas(num.split('.')[0]);
	                }
	                objNum.oldvalue = objNum.value;
	          }
	    }
	}
	
	function MoneyToNumber(num)
	{
	    return (num.replace(/,/g, ''));
	    
	}
	
	function AddCommas(num)
	{
	    numArr=new String(num).split('').reverse();
	    for (i=3;i<numArr.length;i+=3)
	    {
	          numArr[i]+=',';
	    }
	    return numArr.reverse().join('');
	}

function startCalc(){
  interval = setInterval("calc()",1);
}
function calc(){
  one = document.autoSumForm.nilai1.value;
  two = document.autoSumForm.nilai2.value; 
  jum = (one * 1) + (two * 1);
  three = (jum * 1) * 0.1 ;
 
  document.autoSumForm.oneBox.value = (one * 1);
  document.autoSumForm.twoBox.value = (two * 1);
  
  if (jum <= '200000')
  {
	  document.autoSumForm.thirdBox.value = (one * 1) + (two * 1) + 30000;
	  document.autoSumForm.fourBox.value = 30000;
  }else if (jum >= '3000000')
	{
	document.autoSumForm.thirdBox.value = (one * 1) + (two * 1) + 300000;
	document.autoSumForm.fourBox.value = 300000;
	}
	else
  {
    document.autoSumForm.thirdBox.value = (one * 1) + (two * 1) + (three * 1);
	document.autoSumForm.fourBox.value = (three * 1);
  }
  document.autoSumForm.oneBox.focus();
  document.autoSumForm.twoBox.focus();
  document.autoSumForm.thirdBox.focus();
  document.autoSumForm.fourBox.focus();
}
function stopCalc(){
  clearInterval(interval);
}


function startCalc2(){
  interval = setInterval("calc2()",1);
}
function calc2(){

  enol = document.autoSumForm.nilai0.value;
  siji = document.autoSumForm.nilai2.value;
  loro = document.autoSumForm.nilai4.value; 

  document.autoSumForm.nolBox2.value = (enol * 1);
  document.autoSumForm.oneBox2.value = (siji * 1);
  document.autoSumForm.twoBox2.value = (loro * 1);

  document.autoSumForm.thirdBox2.value = (enol * 1) + (siji * 1) + (loro * 1);
  
  document.autoSumForm.nolBox2.focus();
  document.autoSumForm.oneBox2.focus();
  document.autoSumForm.twoBox2.focus();
  document.autoSumForm.thirdBox2.focus();
}
function stopCalc2(){
  clearInterval(interval);
}

