function showCompare(i,session) { $.post("http://www.spep.com/istore/spep.htmldb_istore_sections.compareItems2mombile",{sess:session,item:i}, function(data) { if (data !== "") { $("#htmldbDialog").html(data); var w = $("#compareItemsTable").width() + 25; $("#htmldbDialog").dialog({ width:w }); if (w == 25) { w = $("#compareItemsTable").width() + 25; $("#htmldbDialog").dialog({ width:w }); } $("#htmldbDialog").dialog("option","position","center"); $("#htmldbDialog").dialog("option", "title", "Item Comparison"); $("#htmldbDialog").dialog({ close: function(event, ui) { if ( event.originalEvent && $(event.originalEvent.target).closest(".ui-dialog-titlebar-close").length ) { $("#htmldbDialog").dialog("option", "title", ""); showCompare("-1"); $(".compareflag").removeAttr("checked"); } } }); } }); } $(function() { $(".compareflag").click(function(el) { var sessNum; if (getCookie("productsCookie")===""){ sessNum = Math.floor((Math.random() * 1000000) + 1); setCookie("productsCookie",sessNum,1); } else { sessNum = getCookie("productsCookie"); } itemId=$(this).attr("itemid"); $("#catDebug").html("test"+itemId+" - "+this.checked); if (!this.checked) { itemId = "-" + itemId; } showCompare(itemId,sessNum); }); }); showCompare("",""); function getCookie(cname) { var name = cname + "="; var ca = document.cookie.split(";"); for(var i=0; i