var $ = jQuery;
$(function() {

	// Изменения базовых параметров дисциплины
    $(".AddDiscipline").click(function(){
    	$(this).attr("disabled", true);
    	var main = $(".main_content");
		var BonusRate = main.find(".BonusRate").prop("checked");
		$.post(
			URLdir + 'handler/map/AddDiscipline',
			{
				'Grade': main.find('.SelectGrade').val(),
				'SubjectID': main.find('.SelectSubject').val(),
				'BonusRate': BonusRate,
				'ExamType': main.find('input:radio[name=ExamType]:checked').val(),
				'LectionCount': main.find('.InputLectionCount').val(),
				'PracticeCount': main.find('.InputPracticeCount').val(),
				'FacultyID': main.find('.SelectFaculty').val()
			},
			function(data){
				data = $.parseJSON(data);
				if(data.success === true) {
					$(this).hide();
					EventInspector_ShowMsg('Дисциплина добавлена', 'success');
					setTimeout('location.replace("'+URLdir+'discipline/structure/'+data.DisciplineID+'")',1000); 
				} else {
					$(this).removeAttr('disabled');
					EventInspector_ShowMsg('Ошибка при добавление дисциплины', 'error');
				}
			}
		);
    });
});