var app;
CostCalculator=function(A,G,D,B,F,C){if(!A||!G||!D||!B||!F||!C){return 
}this.field1=A;
this.field2=G;
this.price=D;
this.field1Name=B;
this.field2Name=F;
this.selectedProduct=C;
this.field1.onchange=this.scope(this.getPrice);
this.field2.onchange=this.scope(this.getPrice);
if(window.XMLHttpRequest){this.xmlhttp=new XMLHttpRequest()
}else{if(window.ActiveXObject){try{this.xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
}catch(E){this.xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
}}}this.getPrice()
};
CostCalculator.prototype.readstateChange=function(){if(this.xmlhttp.readyState==4&&this.xmlhttp.status==200){this.fillPrice(this.xmlhttp.responseXML)
}};
CostCalculator.prototype.init=function(){var B=new CostCalculator(document.getElementById("houseType"),document.getElementById("persons"),document.getElementById("price1"),"houseType","persons",document.getElementById("selectedProduct"));
var A=new CostCalculator(document.getElementById("electricityConsumption"),document.getElementById("gasConsumption"),document.getElementById("price2"),"electricityConsumption","gasConsumption",document.getElementById("selectedProduct"))
};
CostCalculator.prototype.getPrice=function(){try{this.xmlhttp.open("GET",window.location.protocol+"//"+window.location.host+"/system/productresponder.jsp?"+this.field1Name+"="+this.field1.value+"&"+this.field2Name+"="+this.field2.value+"&selectedProducts="+this.selectedProduct.value,true);
this.resetPrice();
this.xmlhttp.onreadystatechange=this.scope(this.readstateChange);
this.xmlhttp.send(null)
}catch(A){alert(A)
}};
CostCalculator.prototype.fillPrice=function(C){if(C!=null){var E=C.getElementsByTagName("label");
var D=C.getElementsByTagName("price");
if((E!=null)&&(D!=null)&&(E.length>0)&&(D.length>0)){var B=E[0];
var A=D[0];
if((B!=null)&&(A!=null)){this.setPrice(this.getValue(B),this.getValue(A))
}else{this.setMessage("Uw maandlasten kunnen niet berekend worden.")
}}else{this.setMessage("Uw maandlasten kunnen niet berekend worden.")
}}else{this.setMessage("Algemene foutmelding: geen geldige XML gevonden. Geen response")
}};
CostCalculator.prototype.resetPrice=function(){this.price.innerHTML='<p class="price"><em>Uw maandlasten worden bepaald.</em></p>'
};
CostCalculator.prototype.setMessage=function(A){this.price.innerHTML='<p class="price"><em>'+A+"</em></p>"
};
CostCalculator.prototype.setPrice=function(A,B){this.price.innerHTML='<p class="price">'+A+"&nbsp;<strong>"+B+"</strong></p>"
};
CostCalculator.prototype.getValue=function(A){var B=(A.firstChild)?A.firstChild.nodeValue:A.nodeValue;
B=B.replace(/^\s+/g,"");
B=B.replace(/\s+$/g,"");
return B
};
CostCalculator.prototype.scope=function(B){var A=this;
return function(){return B.apply(A,arguments)
}
};