 function ShowAdvanced(){

 	  if($("#search_more_btn").hasClass('open')){
		$("#search_more_btn").html('расширенный поиск');
		$("#search_more_btn").removeClass('open');
		$("#search_more_btn").addClass('close');

		//$("#search_advanced").removeClass('expand open');

		$("#search_advanced").slideUp("slow");
		//$("#search_more_btn").addClass('expand');

	  }
 	  else{
		$("#search_more_btn").html('простой поиск');
		$("#search_more_btn").addClass('open');
		$("#search_more_btn").removeClass('close');

		//$("#search_advanced").removeClass('expand');

		$("#search_advanced").slideDown("slow");

		//$("#search_more_btn").addClass('expand open');

	  }



 }

 function ShowMoreCats(id, active){
	$("#more_cats").html('Загрузка...');
 	$("#more_cats").load("/?page=cats_ajax&action=getfor&id="+id+"&active="+active);
 	$("#more_cats").slideDown("slow");
 }

 function SelectSubcat(val, id, active, onfinish){

 jQuery.get("/?page=cats_ajax&action=havechildren&id="+val, function(data){
  	if(data=='1'){
    $("#subcat_div"+id).html('Загрузка...');
 	$("#subcat_div"+id).load("/?page=cats_ajax&action=getfor&id="+val+"&active="+active, function(){
   	if(typeof(onfinish)=='function') onfinish();
 });
 	$("#subcat_div"+id).slideDown("slow");
  	}
  });
   }
 

 $(document).ready(function(){ 
 $("select").change(ButtonChecker).change();          		
 $("input").change(ButtonChecker).change(); 		
});

function ButtonChecker(){
var need_show=false; 
 
$("select").each(function () {
	if(($(this).val()!="-1")&&($(this).val()!="")){
		need_show=true;									
	}
});
$("input[name='name']").each(function () {
	if($(this).val()!=""){
		need_show=true;						
	}
});
$("input[name='down_price']").each(function () {
	if($(this).val()!=""){
		need_show=true;						
	}
});
$("input[name='up_price']").each(function () {
	if($(this).val()!=""){
		need_show=true;						
	}
});

if(need_show){
				$('#clear_more').show();
			}else{
				$('#clear_more').hide();
}

}

function ClearMore(){
$("select").each(function () {
	$(this).val("-1");
});
$("input[name='down_price']").each(function () {
	$(this).val('');
});
$("input[name='up_price']").each(function () {
	$(this).val('');
});
$("input[name='name']").each(function () {
	$(this).val('');
});
$("#more_cats").hide();
$('#clear_more').hide();
}
