$(document).ready( function() {
							
							
/*
	$('body').append('<div class="idb-dev-out" style="font-size:9px; position:absolute; top:0; left:0; background:white; text-align:left; z-index:4000; border:1px solid lime;"></div>');
	function debug(a) {

		$(".idb-dev-out").prepend('<br />' + a);
	}
	*/
	
	
	

	
		function resetSelects(k){
		$('.jqHead select').each(function(i){
			if(i != k){
				$(this).children('option').eq(0).attr('selected', 'selected');
			}
		});
	}
	
	//resetSelects();
	
	
	 $('.jqHead input').click(function() {
	 	$('.grdList_detail.on').hide().attr('class', 'grdList_detail');
		$('.grdList tr[class!=grdList_detail]').show();
		
		$('.grdList .grd.on').removeAttr('class');
		
		$('.jqHead select option:selected').removeAttr('selected');
		$('.jqHead select').each(function(){
			$(this).children('option').eq(0).attr('selected', 'selected');
		});
	 	$(this).fadeOut('fast');
	 	return false;
    });
	
	

	$('.jqHead select').each( function(i) {


		csb = $(this);
		
		
		
		

		csbOption = $(this).children('option');

			
			
		csb.change( function() {
			
			
			resetSelects(i);
			selId = $(this).attr('id');
			
			
			
			affTd = '.grdList td.'+selId;
			
			
			
			
			sel = $(this).children("option:selected").val();
			if (selId == 'we_anzahl_zimmer')sel = sel.replace('.', ',');
			
			$('.grdList_detail.on').hide().attr('class', 'grdList_detail');
			$('.zs').hide();
			
			if (sel != $(this).children().eq(0).val() ){
				if (selId == 'we_flaeche_wohn'){
					
					wflWanted = sel.split('.');
					
					$(affTd).each(function(){
						
						wflLocal = $(this).text();
						wflLocal = Number(wflLocal.replace(',', '.'));
						
						if (wflLocal >= wflWanted[0] && wflLocal <= wflWanted[1] ){
							$(this).parent().show().removeAttr('class');
							zsId = $(this).parent().attr('id');
							zsIdJQ = '#'+zsId + '_zs';
							$(zsIdJQ).show();
							
						} else {
							$(this).parent().hide();
						}
					});
					
				}else{
					
					$(affTd).each(function(){
						if ($(this).text() == sel){
							$(this).parent().show().removeAttr('class');
							
							zsId = $(this).parent().attr('id');
							zsIdJQ = '#'+zsId + '_zs';
							
							$(zsIdJQ).show();
							
						} else {
							$(this).parent().hide();
						}
					});
					
				}
				$('.jqHead input').fadeIn();
			} else {
				$('.grdList_detail.on').hide().attr('class', 'grdList_detail');
				$('.grdList tr[class!=grdList_detail]').show();
				$('.jqHead input').fadeOut();
			}
			
		});
		
		
		
		
	
	});
});
