Citation :
function getVPM(taux_annuel, VI, premier_loyer, NPER, option_achat, type)
{
taux = Math.pow(1 + tabTaux[taux_annuel] / 100, 0.0833333333333) - 1;
VA = VI - VI / 100 * tabPremierLoyer[premier_loyer];
VC = (0 - VI / 100) * tabOptionAchat[option_achat];
VPM = taux * (VC + VA * Math.pow(1 + taux, tabDuree[NPER])) / ((1 + taux * type) * (1 - Math.pow(1 + taux, tabDuree[NPER]))) * -1;
duree.text = tabDuree[NPER];
interet.text = tabTaux[taux_annuel] + " %";
investissement.text = VI + " EUR";
apport.text = tabPremierLoyer[premier_loyer] + " %";
apport_expl.text = VI / 32000 * 200 * tabPremierLoyer[premier_loyer] + " EUR";
var __reg2 = VPM.toString().lastIndexOf("." );
if (__reg2 > -1) {
VPM = VPM.toString().slice(0, __reg2 + 3);
}
valeur.text = VPM + " EUR";
}
function showElement(element, elementState)
{
if (elementState == 0) {
element.enabled = 0;
element._alpha = 15;
return undefined;
}
element.enabled = 1;
element._alpha = 100;
}
tabTaux = Array();
tabTaux[0] = 2.99;
tabTaux[1] = 3.75;
tabTaux[2] = 4.49;
tabTaux[3] = 4.99;
tabTaux[4] = 5.25;
tabTaux[5] = 5.50;
tabTaux[6] = 5.75;
tabTaux[7] = 6.00;
tabTaux[8] = 6.25;
tabTaux[9] = 6.50;
tabDuree = Array();
tabDuree[0] = 24;
tabDuree[1] = 36;
tabDuree[2] = 48;
tabDuree[3] = 60;
tabPremierLoyer = Array();
tabPremierLoyer[0] = 0;
tabPremierLoyer[1] = 5;
tabPremierLoyer[2] = 10;
tabPremierLoyer[3] = 15;
tabPremierLoyer[4] = 20;
tabPremierLoyer[5] = 24.995;
tabOptionAchat = Array("0" );
dTaux = 0;
dVI = 32000;
dVI2 = 20000;
dPremierLoyer = 0;
dDuree = 0;
dOptionAchat = 0;
showElement(duree_moins, 0);
showElement(option_moins, 0);
showElement(apport_moins, 0);
showElement(interet_moins, 0);
duree_plus.onRelease = function ()
{
dDuree = dDuree + 1;
showElement(duree_moins, 1);
if (dDuree == tabDuree.length - 1) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
duree_moins.onRelease = function ()
{
dDuree = dDuree - 1;
showElement(duree_plus, 1);
if (dDuree == 0) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
interet_plus.onRelease = function ()
{
dTaux = dTaux + 1;
showElement(interet_moins, 1);
if (dTaux == tabTaux.length - 1) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
interet_moins.onRelease = function ()
{
dTaux = dTaux - 1;
showElement(interet_plus, 1);
if (dTaux == 0) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
apport_plus.onRelease = function ()
{
dPremierLoyer = dPremierLoyer + 1;
showElement(apport_moins, 1);
if (dPremierLoyer == tabPremierLoyer.length - 1) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
apport_moins.onRelease = function ()
{
dPremierLoyer = dPremierLoyer - 1;
showElement(apport_plus, 1);
if (dPremierLoyer == 0) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
option_plus.onRelease = function ()
{
dOptionAchat = dOptionAchat + 1;
showElement(option_moins, 1);
if (dOptionAchat == tabOptionAchat.length - 1) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
option_moins.onRelease = function ()
{
dOptionAchat = dOptionAchat - 1;
showElement(option_plus, 1);
if (dOptionAchat == 0) {
showElement(this, 0);
}
else {
showElement(this, 1);
}
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
}
;
getVPM(dTaux, dVI, dPremierLoyer, dDuree, dOptionAchat, 0);
|