/**
 * ---------------------- Subversion Information ------------------------------
 * ****************************************************************************
 * $Date: 2009-07-30 10:59:10 -0700 (Thu, 30 Jul 2009) $
 * $Rev: 692 $
 * $Author: steven $
 *
 * SVN URL of this file
 * $HeadURL: http://hal/svn/cms/trunk/idx/inc/js/jquery/jquery.global.docready.js $
 * ****************************************************************************
 *
 * @copyright Real Estate Webmasters 2004 - 2009
 */

$(document).ready( function() {

	$('form legend').each( function() {
		val = $(this).text();
		$(this).after('<h5 class="legend">' + val + '</h5>');
		$(this).html('');
	});

	$('#refine-search dl.collapsible').each(function() {

        ishidden = $.cookie($(this).attr('id'));

        if (ishidden=='visible') {
            $('#' + $(this).attr('id')).removeClass('closed');
        } else if (ishidden=='hidden') {
            $(this).addClass('closed').children('dd.content').hide();
        } else {
            $('#' + $(this).attr('id') + '.closed').children('dd.content').hide();
        }

        $('dt.trigger', this).css('cursor','pointer').attr('title', 'Click to Toggle this Panel');

        $('dt.trigger', this).click( function() {

            val = $(this).parents('dl').attr('id');

            $(this).next('dd.content:visible').each(function() {
                $.cookie(val,' hidden');
                $(this).slideUp();
                $(this).parents('dl').addClass('closed');
            });

            $(this).next('dd.content:hidden').each(function() {
                $.cookie(val, 'visible');
                $(this).slideDown();
                $(this).parents('dl').removeClass('closed');
            });

        });

	});

});
