/**
 * ---------------------- Subversion Information ------------------------------
 * ****************************************************************************
 * $Date: 2009-04-13 14:30:14 -0700 (Mon, 13 Apr 2009) $
 * $Rev: 523 $
 * $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 2008
 */

$(document).ready( function() {

	$('.caption img').each( function () {
			var width = $(this).width() + 'px';
			$(this).parent('.caption').css('width', width);
	});

	$('blockquote').prepend('<div class="prewrap">'+'</div><div class="wrap">').append('</div><div class="postwrap">'+'</div>');
	$('hr').wrap('<div class="hr"></div>');

	$('legend').each( function() {
		val = $(this).text();
		$(this).after('<h5 class="legend">' + val + '</h5>');
		$(this).html('');
	});

	$('.collapsible').each(function() {

			ishidden = $.cookie($(this).attr('id'));

			if(ishidden=='visible') {
				$('#'+$(this).attr('id')).removeClass('closed');
			} else if(ishidden=='hidden') {
				$(this).addClass('closed').children('.content').hide();
			} else {
				$('#'+$(this).attr('id')+'.closed').children('.content').hide();
			}

			$('.trigger', this).css('cursor','pointer').attr('title','Click to Toggle this Panel');

			$('.trigger', this).click( function() {

					val = $(this).parents('dl').attr('id');

					$(this).next('.content:visible').each(function() {
						$.cookie(val,'hidden');
						$(this).slideUp();
						$(this).parents('dl').addClass('closed');
					});

					$(this).next('.content:hidden').each(function() {
						$.cookie(val,'visible');
						$(this).slideDown();
						$(this).parents('dl').removeClass('closed');
					});
			});
	});


	$('.idx-dataset>span:odd').addClass('odd');

});
