var cfg = {
	init: function(housetype, fueltype, placementtype, hotwater, solarsystem) {
		$('#'+housetype).attr('checked', 'checked');
		$('#'+fueltype).attr('checked', 'checked');
		$('#'+placementtype).attr('checked', 'checked');
		$('#'+hotwater).attr('checked', 'checked');
		$('#'+solarsystem).attr('checked', 'checked');
		this.refreshForm('');
		
		$('#result_housetype').html($('#'+housetype+' ~ label').html());
		$('#result_fueltype').html($('#'+fueltype+' ~ label').html());
		$('#result_placementtype').html($('#'+placementtype+' ~ label').html());
		$('#result_hotwater').html($('#'+hotwater+' ~ label').html());
		$('#result_solarsystem').html($('#'+solarsystem+' ~ label').html());		
	},

	refreshForm: function(elem) {
		if ($('#fueltype_oil').attr('checked')) {
			$('#placementtype_standing').attr('checked', 'checked');
			$('#placementtype_hanging ~ label').addClass('off');
			$('#placementtype_hanging').attr('disabled', 'disabled');			
		} else {
			$('#placementtype_hanging ~ label').removeClass('off');
			$('#placementtype_hanging').removeAttr("disabled");
		}
		
		if ($('#hotwater_none').attr('checked')) {
			$('#solarsystem_cwu').removeAttr('checked');
			$('#solarsystem_cwu ~ label').addClass('off');
			$('#solarsystem_cwu').attr('disabled', 'disabled');			
		} else {
			$('#solarsystem_cwu ~ label').removeClass('off');
			$('#solarsystem_cwu').removeAttr("disabled");
		}
	},
	
	checkForm: function() {	
		var warning = '';
		if ($("input[name=housetype]:checked").length == 0) {
			warning = warning + '<p>Podaj rodzaj obiektu.</p>';
		}
		if ($("input[name=fueltype]:checked").length == 0) {
			warning = warning + '<p>Podaj rodzaj paliwa.</p>';
		}
		if ($("input[name=placementtype]:checked").length == 0) {
			warning = warning + '<p>Podaj typ urządzenia.</p>';
		}
		if ($("input[name=hotwater]:checked").length == 0) {
			warning = warning + '<p>Podaj oczekiwany poziom komfortu ciepłej wody użytkowej.</p>';
		}
		if ($("input[name=solarsystem]:checked").length == 0) {
			warning = warning + '<p>Podaj oczekiwany poziom wpomagania przez system solarny.</p>';
		}
		if (warning != '') {
			$('#localWarning').html('<h2>Brak, lub błędnie wprowadzone dane</h2>' + warning);			
			$('#localWarning').show('fast');
		} else {
			dtrch.sendForm('myForm');
		}
	}
}
