jQuery(function($){
	var frm = $('#searchCatalogueForm');
	var price1 = document.getElementById("price1");
	var price2 = document.getElementById("price2");
	var setParams = $('#setParams');
	function check() {
		/* count selected options */
		var selectedCount = 0;
		var checkedCount = frm.find('input:checkbox:checked').length;
		var withTextCount = 0;
		
		frm.find('select').not('select[name=currency]').each(function(inx){
			var opts = $(this).find('option');
			var optInx = opts.index( opts.filter(':selected') );
			
			if (optInx > 0) {
				selectedCount++;
				return false;
			}
		});
		
		if (price1.value.length > 0) {
			withTextCount++;
		} else if (price2.value.length > 0) {
			withTextCount++;
		}
		
		if (! (selectedCount > 0 || checkedCount > 0 || withTextCount > 0)) {
			setParams.stop()
			.css({opacity:0, visibility : 'visible'})
			.animate({opacity:1}, 200)
			.animate({opacity:0}, 500)
			.animate({opacity:1}, 200)
			.animate({opacity:0}, 500)
			;
			return false;
		}
		
		return true;
	}
	
	
	frm.submit(function(){
		return check();
	});
	
	$('#submit_searchCatalogueForm').click(function(e){
		e.preventDefault();
		frm.submit();
	});

});
