var system_price=0;
var system_price2=0;

var thermo_price=0;
var thermo_price2=0;

var com1=0;
var com2=0;


function CheckThermo()
{
	var tid = $('#thermo').val();
	if (tid == 0) {
		$('#thdesc').fadeOut();
	}
	else {
		var url = '/ajax/?section=th&tid=' + tid + '&callback=?';
		
		$.getJSON(
			url,
			function (data) {
				if (data.code == '200') {
					$('#thdesc div.text').html('<b>' + data.item.title + '</b><br>' + data.item.text);
					$('#thdesc span.price').html(data.item.iprice);
					$('#thdesc span.price2').html(data.item.iprice2);
					if (data.item.photo != '') {
						$('#thdesc td.img').html('<img src="/files/Image/catalog/thumb-' + data.item.photo + '">');
					}
					$('#thdesc').fadeIn();
					thermo_price = parseFloat(data.item.price);
					thermo_price2 = parseFloat(data.item.price2);
					Total();
				}
				else {
					alert(data.body);
				}
			}
		);
	}
}

function System(sid, price, price2)
{
	system_price = parseFloat(price);
	system_price2 = parseFloat(price2);
	Total();
}

function Com(el, cid, price, price2)
{
	if ($(el).attr('checked')) {
		com1 += parseFloat(price);
		com2 += parseFloat(price2);
	}
	else {
		com1 -= parseFloat(price);
		com2 -= parseFloat(price2);
	}
	Total();
}

function Total()
{
	var total1 = system_price + thermo_price + com1;
	$('#total-1').html(total1);
	var total2 = system_price2 + thermo_price2 + com2;
	$('#total-2').html(total2);
}

function CheckOrder()
{
	if (system_price <= 0) {
		alert('Выберите систему');
		return(false);
	}
}
