/* 
 *  @copyright Copyright (c) 2010, comVision
 */

$(document).ready(function() {


	$('div.filters div.filter_option div.option p span[rel]').click(function () {

/*		if( $( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked') != undefined &&
			$( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked') != false )
			$( 'input[name="'+$(this).attr('rel')+'"]' ).removeAttr('checked');
		else $( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked', 'checked');*/

		if( $( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked') == undefined ||
			$( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked') == false )
			$( 'input[name="'+$(this).attr('rel')+'"]' ).attr('checked', 'checked');

		$(this).parents('form').submit();
	});

	$('.showall').click( function () {

		var height_old = $(this).parent().parent().css('height');
		$(this).parent().parent().css('height', 'auto');

		$(this).css('display', 'none');
		$('.all[rel="'+$(this).attr('rel')+'"]' ).css('display', 'block');

		var height_new = $(this).parent().parent().height();

		$(this).parent().parent().css('height', height_old);
		$(this).parent().parent().animate( {height: height_new}, 200, 'linear' );

	});

	$('div.filters div.filter_option > div.label').click( function () {

		if( $(this).parent().hasClass('active') == true )
		{
			$(this).parent().find('div.option').animate( {height: 0}, 200, 'linear', function(){
				$(this).parent().removeClass('active');
				$(this).css('display', 'none');
			});
		}
		else
		{
			var div_option = $(this).parent().find('div.option');
			div_option.css('height', 'auto');
			var height = div_option.height();

			div_option.css('display', 'block');
			div_option.css('height', 0);
			$(this).parent().addClass('active');

			$(this).parent().find('div.option').animate( {height: height}, 200, 'linear', function(){
				$(this).parent().addClass('active');
			});
		}
	});
});

