или я ошибся вот полный код
$(document).ready(function(){
$('#calc_metric').mask('9?999999', {placeholder: ''});
$('.calc-result').hide();
var select = {'RoomType':0,'RemontType':0,'HouseType':0,'Metric':0,'coefficientCalcMaterials':0};
var jsonData = $('#calc-data').val();
jsonData = eval('(' + jsonData + ')');
select.coefficientCalcMaterials = $('#coefficientCalcMaterials').val();
$('input:radio[name=roomType]').each(function(){
if ($(this).prop('checked')){
var selected = $(this).attr('item');
select.RoomType = jsonData.RoomType[selected].coefficient;
initCarousel(selected);
}
});
$('.calc-room-type-item').click(function(){
$('input:radio', this).attr('checked', 1);
$('input:radio', this).change();
//method ??
});
$('input:radio').change(function(){
var hidden = false;
switch ($(this).attr('name')){
case 'roomType':
select.RoomType = $(this).val();
var id = $(this).attr('item');
if (select.RoomType == 0){
$('#b-calc-content-hidden').html(jsonData.RoomType[id].text);
hidden = true;
}
initCarousel(id);
break;
case 'remontType':
select.RemontType = $(this).val();
break;
case 'houseType':
select.HouseType = $(this).val();
break;
}
if (hidden){
$('.b-calc-content-hidden').show();
$('.b-calc-content').hide();
}else{
$('.b-calc-content-hidden').hide();
$('.b-calc-content').show();
}
Calc();
});
$('#calc_metric').on("keyup",function(){
Calc();
});
$('#calc_metric').change(function(){
Calc();
});
function Calc(){
select.Metric = $('#calc_metric').val();
var price = Math.round(select.RoomType * select.RemontType * select.HouseType * select.Metric);
var priceMat = Math.round(price * (100 - select.coefficientCalcMaterials)/100);
if (price != 0 && !isNaN(price)){
$('#calc-result').html(numberFormatCalc(price));
$('#calc-result-mat').html(numberFormatCalc(priceMat));
$('#calc-result-full').html(numberFormatCalc(price+priceMat));
$('.calc-result').show();
}else{
$('.calc-result').hide();
}
}
function numberFormatCalc(priceString){
var a = priceString.toString().split('');
var mod = a.length%3;
for (i in a){
if ((i+1)%3 == mod){
a[i] = a[i] + ' ';
}
}
return a.join('');
}
function initCarousel(id){
items = jsonData.RoomType[id];
if (typeof items != 'undefined'){
if (items.gallery.length > 0){
$('#gallery_slider').html();
var html = '';
for (i in items.gallery){
html = html +
'<li><a class="single_3" rel="carousel-group" href="'+ items.gallery[i]['med_src'] +'"><img src="' + items.gallery[i]['min_src'] + '" alt="' + items.gallery[i]['title'] + '" height="160px" /></a></li>' +
'';
}
$('#gallery_slider').html(html);
$('#gallery_slider img:last').ready(function(){
setTimeout( startCarousel, 50 );
$('.b-calc-carousel').show();
});
}
}
}
function startCarousel () {
$("#gallery_slider").carouFredSel({
circular: false,
auto : false,
width : '100%',
height: 200,
align : 'false',
prev : {
button : "#foo2_prev",
key : "left",
items: 1
},
next : {
button : "#foo2_next",
key : "right",
items: 1
}
});
}
});