var obj = new Object(), id = ''; if (readCookie("first") == null) { $("div.box-header-right").each(function() { if ($(this).parent().attr("id") != "block_") { $(this).before('
'); id = $(this).attr("id"); if ($(this).css("display") == 'block') { createCookie("box_" + id, "block"); } else { createCookie("box_" + id, "none"); } } }); createCookie("first", "foo"); } else { $("div.box-header-right").each(function() { if ($(this).parent().attr("id") != "block_") { id = $(this).attr("id"); if (readCookie("box_" + id) == "block") { $(this).before('
'); } else { $(this).before('
'); } $(this).css("display", readCookie("box_" + id)); $(this).next().css("display", readCookie("box_" + id)); $(this).next().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.next().slideUp("slow"); obj.next().next().slideUp("slow"); obj.slideUp("slow"); createCookie("box_" + id, "none"); } else { $(this).css("backgroundPosition", "0px -15px"); obj.slideDown("slow"); obj.next().next().slideDown("slow"); obj.next().slideDown("slow"); createCookie("box_" + id, "block"); } }); });