// JavaScript Document
function ParseProvision(sText)
{
   
   var Text2 = new Array(3);
   
   var NewText;
   if(sText.length>1)
   {
    sText = sText.replace(/,/, '.');
   }
   
   return sText;
}
   

function revaluate() 
{
 if(document.getElementById('calc_price'))
 {
   var vat_tax = 0.22;
   var court_tax = 200;
   var tax5 = 200;
   var provision = 3;
   var notarial_tax; 
   
   var price = document.getElementById('calc_price').value; 
   var stamp_duty = price * 0.02;
  
   if(price < 3000)
    notarial_tax = 100;
   else if(price < 10000)
    notarial_tax = 100 + 0.03*(price - 3000);
   else if(price < 30000)
    notarial_tax = 310 + 0.02*(price - 10000);
   else if(price < 60000)
    notarial_tax = 710 + 0.01*(price - 30000);
   else if(price < 1000000)
    notarial_tax = 1010 + 0.005*(price - 60000);
   else if(price < 2000000)
    notarial_tax = 4770 + 0.002*(price - 1000000);
   else if(price > 2000000)
    notarial_tax = 6770 + 0.0025*(price - 2000000);
   
   if(notarial_tax > 10000)
    notarial_tax = 10000;
   
   document.getElementById('calc_notarial_tax').value = notarial_tax;
   
   /*var provision_per = ParseProvision(document.getElementById('calc_provision_per').value);*/
   var provision_per = '3';
   
   var notarial_vat_tax = parseInt(notarial_tax) * vat_tax;

   provision = (parseFloat(provision_per)* parseInt(price))/100;
     
   document.getElementById('calc_stamp_duty').value = parseInt(stamp_duty);
   document.getElementById('calc_vat_tax').value = parseInt(notarial_vat_tax); 
   document.getElementById('calc_court_tax').value = parseInt(court_tax);
   document.getElementById('calc_tax5').value = tax5;
   /*document.getElementById('calc_provision').value = provision;*/
   //SUM
   var sum_add = parseInt(stamp_duty) + parseInt(notarial_tax) + parseInt(notarial_vat_tax)
    + parseInt(court_tax) + parseInt(tax5) + parseInt(provision); 
   document.getElementById('calc_sum_add').value = sum_add;
   
   var sum = parseInt(sum_add) + parseInt(price);
   
   document.getElementById('calc_sum').value = sum; 
 } 
}
