// JavaScript Document
//-----------------------------------------------------------------
function Calculator(){ this.propositions={}; }
Calculator.prototype.addProposition = function (prop){
this.propositions[prop.name]=prop;
}
Calculator.prototype.getTotal = function(){
var total = 0;
for(var ii in this.propositions)
total += this.propositions[ii].getValue();
return total;
}
Calculator.prototype.getProposition = function(s){
return this.propositions[s] || null;
}
//-----------------------------------------------------------------
function Proposition(name, quantity){
this.name = name;
this.quantity = quantity;
}
Proposition.prototype.getValue = function(){
return this.quantity;
}
Proposition.prototype.setQuantity = function(q){ this.quantity = q; }
//-----------------------------------------------------------------
var myCalculatorJa = new Calculator();
myCalculatorJa.addProposition(new Proposition("V1ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V2ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V3ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V4ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V5ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V6ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V7ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V8ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V9ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V10ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V11ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V12ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V13ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V14ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V15ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V16ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V17ja", 1, 0));
myCalculatorJa.addProposition(new Proposition("V18ja", 1, 0));

var myCalculatorNee = new Calculator();
myCalculatorNee.addProposition(new Proposition("V1nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V2nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V3nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V4nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V5nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V6nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V7nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V8nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V9nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V10nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V11nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V12nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V13nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V14nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V15nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V16nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V17nee", 1, 0));
myCalculatorNee.addProposition(new Proposition("V18nee", 1, 0));
//-----------------------------------------------------------------
function calculate(button){
var
frm=button.form,
V1ja=frm.elements["V1"][0].checked ? 1 : 0,
V1nee=frm.elements["V1"][1].checked ? 1 : 0;
V2ja=frm.elements["V2"][0].checked ? 1 : 0,
V2nee=frm.elements["V2"][1].checked ? 1 : 0;
V3ja=frm.elements["V3"][0].checked ? 1 : 0,
V3nee=frm.elements["V3"][1].checked ? 1 : 0;
V4ja=frm.elements["V4"][0].checked ? 1 : 0,
V4nee=frm.elements["V4"][1].checked ? 1 : 0;
V5ja=frm.elements["V5"][0].checked ? 1 : 0,
V5nee=frm.elements["V5"][1].checked ? 1 : 0;
V6ja=frm.elements["V6"][0].checked ? 1 : 0,
V6nee=frm.elements["V6"][1].checked ? 1 : 0;
V7ja=frm.elements["V7"][0].checked ? 1 : 0,
V7nee=frm.elements["V7"][1].checked ? 1 : 0;
V8ja=frm.elements["V8"][0].checked ? 1 : 0,
V8nee=frm.elements["V8"][1].checked ? 1 : 0;
V9ja=frm.elements["V9"][0].checked ? 1 : 0,
V9nee=frm.elements["V9"][1].checked ? 1 : 0;
V10ja=frm.elements["V10"][0].checked ? 1 : 0,
V10nee=frm.elements["V10"][1].checked ? 1 : 0;
V11ja=frm.elements["V11"][0].checked ? 1 : 0,
V11nee=frm.elements["V11"][1].checked ? 1 : 0;
V12ja=frm.elements["V12"][0].checked ? 1 : 0,
V12nee=frm.elements["V12"][1].checked ? 1 : 0;
V13ja=frm.elements["V13"][0].checked ? 1 : 0,
V13nee=frm.elements["V13"][1].checked ? 1 : 0;
V14ja=frm.elements["V14"][0].checked ? 1 : 0,
V14nee=frm.elements["V14"][1].checked ? 1 : 0;
V15ja=frm.elements["V15"][0].checked ? 1 : 0,
V15nee=frm.elements["V15"][1].checked ? 1 : 0;
V16ja=frm.elements["V16"][0].checked ? 1 : 0,
V16nee=frm.elements["V16"][1].checked ? 1 : 0;
V17ja=frm.elements["V17"][0].checked ? 1 : 0,
V17nee=frm.elements["V17"][1].checked ? 1 : 0;
V18ja=frm.elements["V18"][0].checked ? 1 : 0,
V18nee=frm.elements["V18"][1].checked ? 1 : 0;

myCalculatorJa.getProposition("V1ja").setQuantity(V1ja);
myCalculatorNee.getProposition("V1nee").setQuantity(V1nee);
myCalculatorJa.getProposition("V2ja").setQuantity(V2ja);
myCalculatorNee.getProposition("V2nee").setQuantity(V2nee);
myCalculatorJa.getProposition("V3ja").setQuantity(V3ja);
myCalculatorNee.getProposition("V3nee").setQuantity(V3nee);
myCalculatorJa.getProposition("V4ja").setQuantity(V4ja);
myCalculatorNee.getProposition("V4nee").setQuantity(V4nee);
myCalculatorJa.getProposition("V5ja").setQuantity(V5ja);
myCalculatorNee.getProposition("V5nee").setQuantity(V5nee);
myCalculatorJa.getProposition("V6ja").setQuantity(V6ja);
myCalculatorNee.getProposition("V6nee").setQuantity(V6nee);
myCalculatorJa.getProposition("V7ja").setQuantity(V7ja);
myCalculatorNee.getProposition("V7nee").setQuantity(V7nee);
myCalculatorJa.getProposition("V8ja").setQuantity(V8ja);
myCalculatorNee.getProposition("V8nee").setQuantity(V8nee);
myCalculatorJa.getProposition("V9ja").setQuantity(V9ja);
myCalculatorNee.getProposition("V9nee").setQuantity(V9nee);
myCalculatorJa.getProposition("V10ja").setQuantity(V10ja);
myCalculatorNee.getProposition("V10nee").setQuantity(V10nee);
myCalculatorJa.getProposition("V11ja").setQuantity(V11ja);
myCalculatorNee.getProposition("V11nee").setQuantity(V11nee);
myCalculatorJa.getProposition("V12ja").setQuantity(V12ja);
myCalculatorNee.getProposition("V12nee").setQuantity(V12nee);
myCalculatorJa.getProposition("V13ja").setQuantity(V13ja);
myCalculatorNee.getProposition("V13nee").setQuantity(V13nee);
myCalculatorJa.getProposition("V14ja").setQuantity(V14ja);
myCalculatorNee.getProposition("V14nee").setQuantity(V14nee);
myCalculatorJa.getProposition("V15ja").setQuantity(V15ja);
myCalculatorNee.getProposition("V15nee").setQuantity(V15nee);
myCalculatorJa.getProposition("V16ja").setQuantity(V16ja);
myCalculatorNee.getProposition("V16nee").setQuantity(V16nee);
myCalculatorJa.getProposition("V17ja").setQuantity(V17ja);
myCalculatorNee.getProposition("V17nee").setQuantity(V17nee);
myCalculatorJa.getProposition("V18ja").setQuantity(V18ja);
myCalculatorNee.getProposition("V18nee").setQuantity(V18nee);

frm.elements["resultja"].value = myCalculatorJa.getTotal();
frm.elements["resultnee"].value = myCalculatorNee.getTotal();
}
