$('#theme').ajaxStart(function() {
		 $(this).attr('disabled','disabled');
		 $('#format').attr('disabled','disabled');
		 $('#doptheme').attr('disabled','disabled');
		 $('#costcode').attr('disabled','disabled');
	});
	$('#theme').ajaxStop(function() {
		 $(this).removeAttr('disabled');
		 $('#format').removeAttr('disabled');
		 $('#doptheme').removeAttr('disabled');
		 $('#costcode').removeAttr('disabled');
});

$.ajaxSetup({
		scriptCharset: "utf-8" ,
		cache: false
});


//смена основной тематики
function ChangeFilterMainTheme(){

	UpdateCategory();
	UpdateDopTheme();
	UpdateCostCode($('#costcode').val(),$('#pr_th').val(),$('#theme').val(),$('#doptheme').val(),$('#format').val());
	UpdateFormat();
}

//смена категории
function ChangeFilterCategory(){
	
	UpdateDopTheme();
	UpdateCostCode($('#costcode').val(),$('#pr_th').val(),$('#theme').val(),$('#doptheme').val(),$('#format').val());
	UpdateFormat();
	
}

//смена доп. тематики
function ChangeFilterDopTheme(){

	UpdateCostCode($('#costcode').val(),$('#pr_th').val(),$('#theme').val(),$('#doptheme').val(),$('#format').val());
	UpdateFormat();

}


function InitFilterDopTheme(id,theme,category,costcode,format){
	
	$.post('ajax/filter.html',{name:'doptheme',id:id,theme:theme,category:category,costcode:costcode,format:format},function(data) {
		$('#doptheme').html(data);
	});	

}

function UpdateDopTheme(){

	$.post('ajax/filter.html',{name:'doptheme',id:$("#doptheme").val(),theme:$('#pr_th').val(),category:$('#theme').val(),costcode:$('#costcode').val(),format:$("#format").val()},function(data) {
		$('#doptheme').html(data);
	});

}

function InitFilterCategory(id,theme,doptheme,costcode,format){
	
	$.post('ajax/filter.html',{name:'category',id:id,theme:theme,doptheme:doptheme,costcode:costcode,format:format},function(data) {
		$('#theme').html(data);
	});
}

function UpdateCategory(){

	$.post('ajax/filter.html',{name:'category',id:$("#theme").val(),theme:$('#pr_th').val(),doptheme:$('#doptheme').val(),costcode:$('#costcode').val(),format:$("#format").val()},function(data) {
		$('#theme').html(data);
	});
}

function InitFilterFormat(id,theme,category,doptheme,costcode){
	
	$.post('ajax/filter.html',{name:'format',id:id,theme:theme,category:category,doptheme:doptheme,costcode:costcode},function(data) {
		$('#format').html(data);
	});

}

function UpdateFormat(){
	$.post('ajax/filter.html',{name:'format',id:$("#format").val(),theme:$('#pr_th').val(),category:$('#theme').val(),doptheme:$('#doptheme').val(),costcode:$('#costcode').val()},function(data) {
		$('#format').html(data);
	});
}

function UpdateCostCode(id,theme,category,doptheme,format){

	$.post('ajax/filter.html',{name:'costcode',id:id,theme:theme,category:category,doptheme:doptheme,format:format},function(data) {
		$('#costcode').html(data);
	});
}






