var  priceCalculation = function(){
	
	var dvere_variant=0;
	var cats = {}
	
	cats["vlozka"]=0;
	cats["kovanie"]=0;
	cats["zarubna"]=0;
	cats["priezor"]=0;
	cats["retiazka"]=0;
	cats["prah"]=0;
	cats["tesnenie"]=0;
	cats["doplnok"]=0;
	cats["povrch"]=0;
	
	
	var format = function (nStr,prefix){
		 var prefix = prefix || '';
		    nStr += '';
		    x = nStr.split('.');
		    x1 = x[0];
		    x2 = x.length > 1 ? ',' + x[1] : '';
		    var rgx = /(\d+)(\d{3})/;
		    while (rgx.test(x1))
		        x1 = x1.replace(rgx, '$1' + '.' + '$2');

		    return prefix + x1 + x2;
	}

	return {
		
		calculate : function(catIndex, item){
			
			var priceStr = item.value;
			var priceStrValid = priceStr.replace(',','.');
			var priceStrValid = priceStrValid.replace(' ','');					
			var priceNumber = Math.round(Number(priceStrValid));
			
			//alert(catIndex+'|'+priceNumber);
			
			if(catIndex=='dvere'){
				dvere_variant=priceNumber;
			}else{						
				cats[catIndex]=isNaN(priceNumber) ? 0 : priceNumber;
			}
			
			this.displayPrice();														
		},
		displayPrice : function (){				
			
			var price=0;				
			for (var key in cats){			
				price = price + cats[key];
			}
			
			
			$('#doorPriceSum').val(format(dvere_variant));										
			$('#compPriceSum').val(format(price));					
			
			$('#orient_cena_zostavy').html(format(price));
			$('#orient_cena_dveri').html(format(dvere_variant));														
			$('#orient_cena_zostavy_all').html(format(dvere_variant+price));				
		
		}			
	}
	
	
	
}();