productCompareCommands = new Array(2); productCompareCommands[0] = '/user/add_item_to_comparison.cmd'; productCompareCommands[1] = '/catalog/compare_items.jsp'; function addProdToCompare(frm, divIdToUpdate){ var url = productCompareCommands[0]; var pars = "formName=compareItemsForm" + "&productId=" + $("input[@name=productId]").val() + "&dest=" + $("input[@name=dest]").val(); var divToUpdate = "#" + divIdToUpdate; $.ajax({ type: "POST", url: url, data: pars, dataType: "html", success: function(data) { $(divToUpdate + " *").remove(); $(divToUpdate).html(""); $(divToUpdate).append(data); $(divToUpdate).show(); return true; }, error: function() { return false; } }); } var clInterval; function showCompareList(){ var url = productCompareCommands[1]; var pars = 'formName=compareItemsForm'; var divToUpdate = "#compare-layer-items"; $.ajax({ type: "POST", url: url, data: pars, dataType: "html", success: function(data) { $(divToUpdate + " *").remove(); $(divToUpdate).html(""); $(divToUpdate).append(data); $(divToUpdate).show(); return true; }, error: function() { return false; } }); clInterval = setInterval( "adjustCompareList();" , 100); setTimeout(function() { clearInterval(clInterval); }, 1000); adjustCompareList(); } function adjustCompareList() { divToUpdate = "#compare-layer-items"; adjustDivLocation(divToUpdate); } function comparePopup(e) { showHideComparePopup('hide'); objPopup = document.getElementById("compare-layer"); posX = null; posY = null; getDocMode = true; var bWindowOffsets = getScrollXY(); var bWindowViewport = getViewportSize(); if (e.pageX || e.pageY) { posX = e.pageX; posY = e.pageY; } else if (e.clientX || e.clientY) { if (getDocMode == true) { posX = e.clientX + document.documentElement.scrollLeft; posY = e.clientY + document.documentElement.scrollTop; } else { posX = e.clientX + document.body.scrollLeft; posY = e.clientY + document.body.scrollTop; } } if (posX + objPopup.offsetWidth > bWindowViewport[1]) { objPopup.style.left = posX - objPopup.offsetWidth + "px"; } else { objPopup.style.left = posX + "px"; } objPopup.style.top = posY - objPopup.offsetHeight + "px"; return false; } function showHideCompare(objState) { if (objState == "show") { document.getElementById("compare-layer-items").style.visibility = "visible"; } else { document.getElementById("compare-layer-items").style.visibility = "hidden"; } } function showHideComparePopup(objState) { if (objState == "show") { document.getElementById("compare-layer").style.visibility = "visible"; document.getElementById("compare-layer").style.display = ""; } else { document.getElementById("compare-layer").style.visibility = "hidden"; document.getElementById("compare-layer").style.display = "none"; } } function removeCompareBox(prodId){ var cBoxName = "checkbox_" + prodId; var oCb = document.getElementById(cBoxName); if (oCb) oCb.checked = false; toggleCompareBox(prodId); } function toggleCompareBox(prodId, formName){ var cBoxName = "checkbox_" + prodId; var oCb = document.getElementById(cBoxName); if (oCb) { var link = document.getElementById("compare_" + prodId); if (link) { if (oCb.checked) link.innerHTML = "Compare Items"; else link.innerHTML = "Compare Items"; } } } function compareItem(productId, event) { document.compareItemsForm.dest.value='/catalog/compare_pop.jsp'; document.compareItemsForm.productId.value = productId; addProdToCompare(document.compareItemsForm, 'compare-layer'); comparePopup(event); return false; }