var validateform;

function DisableInputs() {
	if (validateform != null) {
		validateform.resetForm();
	}
	$('.prosebe').attr('disabled', 'disabled');
	$('.proskolu').attr('disabled', 'disabled');
	$('.procharitu').attr('disabled', 'disabled');
};

function ActivateInputs(inputs) {
	DisableInputs();
	$(inputs).removeAttr('disabled');
};

function InitForm() {
	if ($('#prosebe')[0] != null && $('#prosebe')[0].checked == true) {
		ActivateInputs('.prosebe');
		return;
	}
	if ($('#proskolu')[0] != null && $('#proskolu')[0].checked == true) {
		ActivateInputs('.proskolu');
		return;
	}
	if ($('#procharitu')[0] != null && $('#procharitu')[0].checked == true) {
		ActivateInputs('.procharitu');
		return;
	}
	DisableInputs();
};

function ValidateBoxi() { 
	if ($('#nenipotrebabox')[0] == null) {
		return;
	}
	if ($('#nenipotrebabox')[0].checked == true) {
		$('#sbernychboxu').rules('remove', 'required');
	}
	else {
		$('#sbernychboxu').rules('add', { required: true });
	}
};

$(document).ready(function() {
	InitForm();
	validateform = $('#ottoform').validate();
	$('#prosebe').change(function() { ActivateInputs('.prosebe') });
	$('#proskolu').change(function() { ActivateInputs('.proskolu') });
	$('#procharitu').change(function() { ActivateInputs('.procharitu') });
	$('#nenipotrebabox').change(function() { ValidateBoxi() });
	ValidateBoxi();
});
