// calcul retraite

function effacerRetraite(){
window.document.forms["retraite"].points.value ="";
window.document.forms["retraite"].revenu.value ="";
window.document.forms["retraite"].trimestres.value ="";
window.document.forms["retraite"].complement.value ="";
window.document.forms["retraite"].totalRetraite.value ="";
x=0;
a2="";
b2="";
c2="";
d2="";
total=0;
}

a="";
a2="";
b="";
b2="";
c="";
c2="";
d="";
d2=""
total=""
var pointcompl=1.055;	// valeur du point au 1/01/2007
var point73=11.45971;	// valeur du point d'avant 1973 en 2007

function checkPoints (a) {

   a=(window.document.forms["retraite"].points.value);
      for  (i = 0; i < a.length; i++) {
        if (a.charAt (i) == ',')
           a2 += '.';
         else
          a2 += a.charAt (i);
          }
    	return a2 ;
        }

function checkRevenu (b) {
   b=(window.document.forms["retraite"].revenu.value);
      for (i = 0; i < b.length; i++) {
        if (b.charAt (i) == ',')
           b2 += '.';
        else
          b2 += b.charAt (i);
          }
    	return b2 ;
        }

function checkTrimestres (c) {
   c=(window.document.forms["retraite"].trimestres.value);
      for (i = 0; i < c.length; i++) {
        if (c.charAt (i) == ',')
           c2 += '.';
        else
          c2 += c.charAt (i);
          }
    	return c2;
    }


function checkComplement (d) {
    d=(window.document.forms["retraite"].complement.value);
       for (i = 0; i < d.length; i++) {
        if (d.charAt (i) == ',')
           d2 += '.';
        else
          d2 += d.charAt (i);
          }
        return d2;
    }



function calculRetraite () {

if ((a2=="") || (a2=="0")) {
	valid=confirm ("Vous n'avez pas cotisé avant 1973.\n Dans le cas contraire, cliquez sur 'Annuler'");
	if(valid==false){ alert ("Remplissez le 1er champ")
        } else  {x =((b2/100*50) * (c2/158) + (d2*pointcompl)).toString();
        dec = x.indexOf(".");
	euros = x.substring(0,dec);
	cents = x.substring(dec+1,dec+3);
	cents = (cents.length < 2) ? cents + "0" : cents;
	total = euros + "." + cents;

window.document.forms["retraite"].totalRetraite.value=total;
        }
        }
else if  ((b2=="") || (b2=="0")) {alert ("Vous devez obligatoirement remplir le 2ème champ")}

else if  ((c2=="") || (c2=="0")) {alert ("Vous devez obligatoirement remplir le 3ème champ")}

else if  ((d2=="") || (d2=="0")) {valid=confirm ("Vous n'avez pas de points de retraite complémentaire.\n Dans le cas contraire, cliquez sur 'Annuler'");
	if (valid==false) {alert ("Remplissez le dernier champ")
        } else {x =((a2*point73) + (b2/100*50) * (c2/158)).toString();

	dec = x.indexOf(".");
	euros = x.substring(0,dec);
	cents = x.substring(dec+1,dec+3);
	cents = (cents.length < 2) ? cents + "0" : cents;
	total = euros + "." + cents;

	window.document.forms["retraite"].totalRetraite.value=total;
        }
} else  {
x =((a2*point73) + (b2/100*50) * (c2/158) + (d2*pointcompl)).toString();

dec = x.indexOf(".");
euros = x.substring(0,dec);
cents = x.substring(dec+1,dec+3);
cents = (cents.length < 2) ? cents + "0" : cents;
total = euros + "." + cents;

window.document.forms["retraite"].totalRetraite.value=total;
}
}




