function cal_rec() {
    var a = parseInt(document.getElementsByName("CA_Amount")[0].value);
    var i = parseFloat(document.getElementsByName("CA_interest")[0].value);
    var n = parseInt(document.getElementsByName("CA_No_Of_Payment")[0].value);
    var w=document.getElementsByName("ac_type")[0].value; if(w=="W")w=48;if(w=="D")w=365;if(w=="M") w=12;
    var tot=a*n;
    var tot_i=i*tot/100*n/w;
    var mv = parseInt(tot_i+tot);
    document.getElementsByName("Mature_Value")[0].value=mv;
   }
 function cal_FD() {
    var a = parseInt(document.getElementsByName("CA_Amount")[0].value);
    var i = parseFloat(document.getElementsByName("CA_interest")[0].value);
    var n = parseInt(document.getElementsByName("CA_No_Of_Payment")[0].value);
    //var sum = a*n;
    //var int=parseInt(i/100*a*n);
    //var int=parseInt((i/100*a*n)/12);
    var int=parseInt((i/100*a*n)/12);
    var mv = int+a;
    document.getElementsByName("Mature_Value")[0].value=mv;
   }
 function cal_Re_md() {
   //var today = new Date(2009, 1, 2);
   var today = new Date(document.getElementsByName("date_today")[0].value);
   var w=document.getElementsByName("ac_type")[0].value; if(w=="W")w=4;if(w=="D")w=30;if(w=="M") w=1;
   var lapse = parseInt(document.getElementsByName("CA_No_Of_Payment")[0].value/w);
   var kkkk= today.setMonth(today.getMonth()+lapse);
   var kkkk= new Date(new Date(today).setMonth(today.getMonth()+1));
   var yyyy = kkkk.getFullYear();
   var dd = kkkk.getDate();
   var mm = kkkk.getMonth()+1;
   document.getElementsByName("date_mature")[0].value=yyyy+"-"+mm+"-"+dd;
 }
 function cal_FD_md() {
   //var today = new Date(2009, 1, 2);
   var today = new Date(document.getElementsByName("date_today")[0].value);
   var kkkk= today.setMonth(today.getMonth()+document.getElementsByName("CA_No_Of_Payment")[0].value);
   var kkkk= new Date(new Date(today).setMonth(today.getMonth()+1));
   var yyyy = kkkk.getFullYear();
   var dd = kkkk.getDate();
   var mm = kkkk.getMonth();
   document.getElementsByName("date_mature")[0].value=yyyy+"-"+mm+"-"+dd;
 }
 function cal_loan_type() {
   var w=document.getElementsByName("ac_type")[0].value; if(w=="W")w="weeks"; else if(w=="D")w="Days"; else w="Months";
   document.getElementById("DWM").innerHTML=w;
 }
 
 function cal_loan() {
    var w=document.getElementsByName("ac_type")[0].value; if(w=="W")w=48; else if(w=="D")w=365; else w=12;
    var a = parseInt(document.getElementsByName("CA_Amount")[0].value);
    var i = parseFloat(document.getElementsByName("CA_interest")[0].value);
    var n = parseInt(document.getElementsByName("CA_No_Of_Payment")[0].value);
    //var sum = a*n;
    //var int=parseInt(i/100*a*n);
    //var int=parseInt((i/100*a*n)/w);
    var int=parseInt(i/100*a);
    var mv = int+a;
    document.getElementsByName("CA_installment")[0].value=parseInt(mv/n);
    document.getElementsByName("Mature_Value")[0].value=parseInt(mv);
   }