<!-- FILTER TABS -->
function setActiveTab(activeTab)
{
	if (typeof activeTab != "object")
	{
		activeTab = $('tab_' + activeTab);
	}

	if ($(activeTab))
	{
		if (typeof ClickTaleExec == 'function') ClickTaleExec("setActiveTab($('" + activeTab.id + "'))");

		$('tabs').select('li').each(function(tab)
		{
			tab.removeClassName('active');
			$(tab.readAttribute('id') + '_content').hide();
		});

		$(activeTab).addClassName('active');
		$(activeTab.id + '_content').show();
	}
}

function toggleFilters(id)
{
	$$('input[type="checkbox"]' + (Object.isUndefined(id)?'[parent!=""]':'[parent="'+id+'"]')).each(function(child)
	{
		var parent = child.readAttribute('parent');

		if (($(parent).checked) || ($(parent).disabled))
		{
			$(child).disable();
		}
		else
		{
			$(child).enable();
		}

		if ((!Object.isUndefined(id)) || ($(parent).checked && Object.isUndefined(id)))
		{
			$(child).checked = $(parent).checked;
		}
	});
}

function removeFilter(id, action)
{
	if ($('tab_' + id + '_content'))
	{
		$('tab_' + id + '_content').select('input').each(function(el)
		{
			el.checked = false;
		});

		if (id == 'category')
		{
			goTo();
		}
		else
		{
			goTo(document.location.href);
		}
	}
}

<!-- PAGER / FILTER -->
function goTo(url)
{
	$('list').hide();
	$('loading').show();

	$('searchForm').order_by.value = $$('input:checked:enabled[type="radio"][name="order_by"]').first().value;
	$('searchForm').sort.value = $F('sort');

	if (url != undefined)
	{
		$('searchForm').action = url;
	}
	$('searchForm').submit();

	window.scrollTo(0,0);
}

function goToAjax(url)
{
	new Ajax.Updater
	(
		{
			success : 'list'
		},
		url,
		{
			parameters :
			{
				'arrival'    : $F('arrival'),
				'departure'  : $F('departure'),
				'order_by'   : $$('input:checked:enabled[type="radio"][name="order_by"]').first().value,
				'sort'       : $F('sort'),
				'zone[]'     : $$('input:checked:enabled[type="checkbox"][name="zone[]"]').pluck('value'),
				'category[]' : $$('input:checked:enabled[type="checkbox"][name="category[]"]').pluck('value'),
				'facility[]' : $$('input:checked:enabled[type="checkbox"][name="facility[]"]').pluck('value'),
				'ajax'       : true
			},
			onCreate : function()
			{
				$('list').hide();
				$('loading').show();
				$('filter-submit').fade({ duration: 0.2 });
			},
			onComplete : function()
			{
				$('list').show();
				$('loading').hide();
			}
		}
	);

	window.scrollTo(0,0);
}

<!-- INIT -->
if ((hash = document.location.hash.replace('#', '')) != "")
{
	setActiveTab(hash);
}

document.observe('dom:loaded', function()
{

	toggleFilters();

	$$('input[type="checkbox"]').each(function(box)
	{
		box.observe('click', function(e)
		{
			$('filter-submit').appear({ duration: 0.2 });
		});

		if ((box.readAttribute('parent') != null) && box.readAttribute('parent').empty())
		{
			box.observe('click', function(e)
			{
				toggleFilters(this.id);
			});
		}
	});

	$('submit').observe('click', function(e)
	{
		$('list').hide();
		$('loading').show();
		$('searchForm').order_by.value = 'price';
		$('searchForm').sort.value = 'ASC';
		$('searchForm').submit();

		e.stop();
	});

	// Hacer clickables las celdas de habitaciones del listado
	$$('table.roomslist td').each(function(element) {
		element.onclick = function() { document.location.href = element.up('li').down('a[rel=keyword]').href + '#prices' }
		element.onmouseover = function() { element.up('tr').addClassName('hover') }
		element.onmouseout = function() {element.up('tr').removeClassName('hover') }
	});
});