webma.sztjozsef={};webma.sztjozsef.calculator={};webma.sztjozsef.calculator.Product=function(A){this.id=(new Date()).getTime()+"";this.group=A.group;this.surface=A.surface;this.type=A.type;this.label=A.label};webma.sztjozsef.calculator.Product.prototype.getWeight=function(){return parseInt(this.surface,10)*new Number(this.type,10)};webma.sztjozsef.calculator.Product.prototype.getPrice=function(){var A=420;return this.getWeight()*A};webma.sztjozsef.calculator.Cart=function(){this._content=[[],[],[]]};webma.sztjozsef.calculator.Cart.prototype.add=function(A,C){if(typeof this._content[C]=="undefined"){return false}var B=this._content[C];B[B.length]=A;return true};webma.sztjozsef.calculator.Cart.prototype.remove=function(E,D){if(typeof this._content[D]=="undefined"){return false}var C=this._content[D],A=C.length,B;for(B=0;B<A;B++){if(typeof C[B]==="undefined"){continue}if(C[B].id==E){delete C[B]}}return false};webma.sztjozsef.calculator.Cart.prototype.showBySlot=function(H){if(typeof this._content[H]=="undefined"){return }var J=this._content[H],G=J.length,D,C,I,E,B,A=document.getElementById("kalkulator_total"+H),F=this;A.innerHTML="";document.getElementById("kalkulator_plaintotal"+H).innerHTML="";for(D=0;D<G;D++){if(typeof J[D]==="undefined"){continue}E=webma.sztjozsef.calculator.formatPrice(J[D].getPrice());C=document.createElement("button");C.setAttribute("type","button");C.className="remove-button";C.innerHTML="tétel törlése";webma.util.addEvent(C,"click",(function(K){return function(){F.remove(J[K].id,H);F.show(H)}})(D));I=document.createElement("p");I.innerHTML=J[D].surface+" m<sup>2</sup> <em>"+J[D].label+"</em> <strong>"+E+" Ft + ÁFA</strong>";A.appendChild(I);I.appendChild(C);document.getElementById("kalkulator_plaintotal"+H).innerHTML+=J[D].surface+" m2 "+J[D].label+" "+E+" Ft + ÁFA\n"}};webma.sztjozsef.calculator.Cart.prototype.getTotal=function(){var F,C,E,G,D=0,B=0,A=3;for(G=0;G<A;G++){F=this._content[G],C=F.length;for(E=0;E<C;E++){if(typeof F[E]==="undefined"){continue}D+=F[E].getPrice();B+=F[E].getWeight()}}return{price:D,weight:B}};webma.sztjozsef.calculator.Cart.prototype.show=function(B){if(typeof B!=="undefined"){this.showBySlot(B)}var A=this.getTotal();document.getElementById("kalkulator_anyagmunkadijosszesen").value=webma.sztjozsef.calculator.formatPrice(A.price);document.getElementById("kalkulator_anyagmennyisegosszesen").value=A.weight};webma.sztjozsef.calculator.formatPrice=function(B){B=B.toString().replace(/\$|\,/g,"");if(isNaN(B)){B="0"}B=Math.floor(B*100+0.50000000001);B=Math.floor(B/100).toString();for(var A=0;A<Math.floor((B.length-(1+A))/3);A++){B=B.substring(0,B.length-(4*A+3))+" "+B.substring(B.length-(4*A+3))}return B};webma.sztjozsef.calculator.makeWidget=function(){var C=webma.sztjozsef.calculator,D,B=3,E=new C.Cart(),A;for(D=0;D<B;D++){webma.util.addEvent(document.getElementById("kalkulator_hozzaad"+D),"click",(function(F){return function(){var G=document.getElementById("kalkulator_szigetelendofelulet"+F).value,I=document.getElementById("kalkulator_befujtvastagsagerteksuruseg"+F).value;if(!(new Number(G)>0)||!(new Number(G.replace(/,/,".")))){alert("Kérjük, adja meg a szigetelendő felület méretét!");return }if(I==""){alert("Kérjük, válassza ki a megfelelő befújt vastagság–λ érték–sűrűség értéket!");return }var H=document.getElementById("kalkulator_befujtvastagsagerteksuruseg"+F).options;A=new C.Product({group:document.getElementById("kalkulator_legend"+F).innerHTML,surface:document.getElementById("kalkulator_szigetelendofelulet"+F).value,type:document.getElementById("kalkulator_befujtvastagsagerteksuruseg"+F).value,label:H[H.selectedIndex].innerHTML});E.add(A,F);E.show(F)}}(D)))}}