$(document).ready( function() {

	if (typeof initSteetView=="function") {
		initSteetView();
	}

	$('.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');
					});
			});
	});

});