var obj = new Object(), id = '';

if (readCookie("first") == null)
{
	$("div.box-content-right").each(function() {
		if ($(this).parent().attr("id") != "block_")
		{
			$(this).before('<div class="minmax"></div>');
			id = $(this).attr("id");
			if ($(this).css("display") == 'block')
			{
				createCookie("box_" + id, "block");
			}
			else
			{
				createCookie("box_" + id, "none");
			}
		}
	});
	createCookie("first", "foo");
}
else
{
	$("div.box-content-right").each(function() {
		if ($(this).parent().attr("id") != "block_")
		{
			id = $(this).attr("id");
			if (readCookie("box_" + id) == "block")
			{
				$(this).before('<div class="minmax" style="background-position: 0px -15px;"></div>');
			}
			else
			{
				$(this).before('<div class="minmax" style="background-position: 0px 0px;"></div>');
			}
			$(this).css("display", readCookie("box_" + id));
			$(this).next().css("display", readCookie("box_" + id));
		}
	});
}

$("div.minmax").each(function() {
	$(this).click(function() {
		obj = $(this).next();
		id = obj.attr("id");
		if (obj.css("display") == "block")
		{
			$(this).css("backgroundPosition", "0px 0px");
			obj.slideUp("slow");
			obj.next().hide();
			createCookie("box_" + id, "none");
		}
		else
		{
			$(this).css("backgroundPosition", "0px -15px");
			obj.slideDown("slow");
			obj.next().show();
			createCookie("box_" + id, "block");
		}
	});
});


