// калькулируем данные
function calc(sid) {

    var resPrice;
	var  vlength,length;// Для пользователя/ системный
	var  vcomplect,complect;// Для пользователя/ системный
	var number = parseInt($('#productID').val());
	var rlength = parseInt($('#length_t').val());
	var rheight = parseInt($('#height_t').val());
	var rdepth = parseInt($('#depth_t').val());
	//alert(typeof( group_size ) != 'undefined');
	if (typeof( group_size ) != 'undefined'){
		var summ = parseInt(group_size[rlength][rdepth][rheight]);
	}else{
		// массива габаритов нет отталкиваемся от 
		// если это кровать
		test = $("#size_k0").val();
//		alert(typeof(test));
		if (typeof(test) != 'undefined'){
			summ = 0;
		}else{
			summ = parseInt($('input.product_price').val());
		}
	}
     <!--// Очищаем формат//-->
	resPrice = 0;
	 <!--//// определили значение//-->
	vlength = length = '';

     <!--//// проверяем данные select//-->
    $("select.addPrice").each(function() {
	if (!this.name.match('option_5')) {
		if (this.name.match('option_8') || this.name.match('option_9') || this.name.match('option_10')) {
			val = this.value;
			cnt=1;
			resPrice += val*cnt;
				addOptVal = this.value;
        	$(".cost" + this.name).html('' + addOptVal);
			 vlength += "("+$("#"+this.id+" option[value='"+val+"']").text() +" = "+(val*1)+" руб.), ";
			 length += this.name+(val*1)+"="+ $("#"+this.id+" option[value='"+val+"']").text()+"&";
			 

		}else{
			addOptVal = this.value;
        	$(".cost" + this.name).html('' + addOptVal);
			vlength += this.title+"=("+ this.value+"), ";
        	length += this.name+"="+ this.value+"&";
		}
	}
	
    });

	 <!--//// проверяем данные Radial, checkbox//-->
	 var i=0;
	 $("input.addPrice:checked").each(function() {
		
        var val, cnt, maxcnt;

		
			i++;
		switch (this.type)
		{
		
			case "radio":{
				
				val = $('#' + this.id).val();
				cnt=1;
				if (val > 0 && cnt > 0) { resPrice += val*cnt;}
				if (this.name.match('option_6')){
				
					vlength=vlength+ "Цвет профиля=("+this.value+"), ";
					length += this.name+'_'+this.id+"="+ this.value+"&";
					//$('#'+this.name+ '_textcolor').html(this.value); // рисуем в визуальном объекте
				}
				else{
					//if (this.name.match('option_')) alert('ddd');
					if (this.name.match('option_7')){
						
							vlength=vlength+ "Цвет дерева=("+this.value+"), ";
							length += this.name+'_'+this.id+"="+ this.value+"&";
						
						//length += this.name+'_'+this.id+"="+ this.value+"&";
						//$('#'+this.name+ '_textcolor').html(this.value); // рисуем в визуальном объекте
					}else{
						
						length += this.name+'_'+this.id+"="+ this.value+"&";
						if ($("#"+this.id).val())
							var text = parseInt($("#"+this.id).val()) +" руб";
						else	
							var text = "0 руб";
						
						vlength=vlength +$("#"+ this.id +"_label").text()+"=("+text+"), ";
					}
				}
			break;
			}
			case "checkbox":{
				val = $('#' + this.id).val();
				cnt = $("#" + this.id + '_count').val();
				if (val > 0 && cnt > 0) { resPrice += val*cnt;  }
				length += this.name+'_'+this.id+"="+ this.value+"&";
				vlength=vlength +$("#"+ this.id +"_label").text()+"=("+$("#" + this.id + '_count').val()+" шт. по " + $("#"+this.id).val() +"руб), ";
				//if (this.value!=val+'"'+cnt+'"')
				//this.value =val+'"'+cnt+'"';
			break;
			}

		}
    });
	$('#order_line_link').val(length);
	document.getElementById('order_line').value = vlength;
	setCookie('zzz',vlength);
	document.getElementById('order_cost').value = summ+parseInt(resPrice);

$("#price-prod").text((summ+parseInt(resPrice)) +'руб.');

	if (sid){
		var offset = $('#'+sid).offset();
		$("#div_summ").css('display','none');
		$("#div_summ").css('left',offset.left);
		$("#div_summ").css('top',offset.top-30);
		$("#div_summ").html( (summ+parseInt(resPrice)) +' руб.' );
		$("#div_summ").fadeIn(750);
		setTimeout(function(){ $("#div_summ").fadeOut() }, 3000);

		
	}
  

}

function setCookie(name, value)
{
   var today = new Date()
   var expires = new Date()
   expires.setTime(today.getTime() + 1000*24*60*60)
   document.cookie = name + "=" +escape(value)+ ((expires == null) ? "" : ("; expires=" +expires))+";path=/";
}

