window.addEvent('domready', function()
{
	/* hide filter if possible */
	$$('.global_listing .filters').each(function(obj)
	{
		listing = $(obj).getParent().getNext();
		if(listing.hasClass('listing'))
		{
			//looking good
			pagescode = listing.getFirst();
			if(pagescode.hasClass('pagescode'))
			{
				//try to find addoptions
				addoptions = pagescode.getFirst();
				if(addoptions.hasClass('addoptions'))
				{
					//ok we know we have a filter and we are in addoptions,
					//and add the show/hide toggle link
					
					var filtertoggle = new Element('a', 
					{
						id: 	'filtertoggle',
						'href':	'#',
						'html': 'Filter anzeigen',
						'events': 
						{
							'click': function(el)
							{
								//toggles
								new Fx.Slide(obj).toggle();

								//change text
								if(this.get('html') == 'Filter anzeigen')
								{
									this.set('html', 'Filter ausblenden');
								}
								else
								{
									this.set('html', 'Filter anzeigen');
								}

								return false;
							}
						}
					});
					
					filtertoggle.inject(addoptions, 'top');

					//hide filter
					new Fx.Slide(obj).hide();

					obj.setStyle('display', 'block');
				}
			}
		}
	/*
		zoneid = index.get('id').match('adzone-([0-9]*)');
	*/
	});

});