/** Convenience function for document.getElementById. @param what The id of the node you want */ function $(what) { if (document.getElementById) { return document.getElementById(what); } else if (document.all) { return document.all[what]; } else if (document.layers) { return document.layers[what]; } return null; }; function firstElementSetFocus(){ var select = document.getElementsByName("firstElement"); if (select.length < 1){ return false; } select[0].focus(); } /** Gradually shows a node in good browsers. On IE, the node just appears instantly. @param node The Node to show. */ function materialize(node, func) { var zero = 0; var os = getOpacities(); var style = getStyle(node); var x = style.left, y = style.top; var checkPosition = function() { var win = new Window(); var screen = {}; var object = {}; screen.width = win.getWidth(); screen.height = win.getHeight(); object.left = parseInt(style.left); object.right = object.left + node.offsetWidth; object.top = parseInt(style.top); object.bottom = object.top + node.offsetHeight; var scroll = {}; scroll.width = win.getScrollWidth(); scroll.height = win.getScrollHeight(); var current = {}; current.height = screen.height + scroll.height; current.width = screen.width + scroll.width; if (object.bottom > current.height) { var delta = object.bottom - current.height; style.top = [parseInt(style.top) - delta, "px"].join(""); } if (object.right > current.width) { var delta = object.right - current.width; style.left = [parseInt(style.left) - delta, "px"].join(""); } }; style.opacity = zero; style.display = "block"; style.visibility = "visible"; var i = 0; var firstrun = true; if (webapp.isIE()) { checkPosition(); } else { var showInterval = setInterval( function() { if (i >= 10) { style.opacity = "1.0"; clearInterval(showInterval); return true; } else { if (firstrun) { checkPosition(); firstrun = false; } style.opacity = os[i += 1]; return false; } }, 15 ); } node.visible = true; if (typeof func == "function") { log("running some function"); func(); } }; /** Causes a node to gradually fade out and die in good browsers. On IE, the node is just removed. @param node The Node to remove. */ function spiritualize(node, keep) { var zero = 0; var one = 1; var os = getOpacities(); os.reverse(); var style = getStyle(node); var hideFollowups = function(node) { var followups = getElementsByClassName(node, "fup"); var len = followups.length; for (var i = 0; i < len; i++) { var fup = followups[i]; clearControls(fup); var fupstyle = getStyle(fup); fupstyle.display = "none"; } }; var i = 0; if (webapp.isIE()) { style.display = "none"; } else { var hideInterval = setInterval( function() { if (i >= 10) { if (!keep) { node.parentNode.removeChild(node); } style.display = "none"; hideFollowups(node); clearInterval(hideInterval); return true; } else { style.opacity = os[i += 1]; return false; } }, 15, node ); } node.visible = false; }; /** Immediately hides a node. */ function hide(node) { var style = getStyle(node); style.display = "none"; }; /** Immedately shows a node. */ function show(node) { var style = getStyle(node); style.display = "block"; style.opacity = "1.0"; style.visibility = "visible"; }; function Revealer() { this.body = null; this.followups = []; this.expanders = []; this.rollers = []; this.martyrs = []; this.folders = []; if (!Revealer._I) { Revealer.prototype.init = function() { this.body = document.getElementsByTagName("body")[0]; var classNames = [ { klass : "fup", tag: ["div", "tr", "select"] }, { klass : "expandable", tag : "dl" }, { klass : "rolled", tag: "div" }, { klass : "martyr", tag : "div" }, { klass : "fold", tag : "tr" } ]; var nodes = getElementsByManyClassNames(this.body, classNames); this.martyrs = nodes.martyr; this.followups = nodes.fup; this.expanders = nodes.expandable; this.rollers = nodes.rolled; this.folders = nodes.fold; this.construct(); } Revealer._I = 1; } }; /** Toggles followups. Usage: The followup element must be contained in a
30
at all, then the
is removed and put outside of the larger bar. */ function Grapher() { log("In Grapher()"); this.hs = []; this.vs = []; if (!Grapher._I) { Grapher.prototype.init = function() { var gs = getElementsByClassName(document, "grapher", "div"); var glen = gs.length; for (var i = 0; i < glen; i++) { var type = gs[i].className.split(""); switch (type[type.length - 1]) { case "h": this.hs.push(gs[i]); break; case "v": this.vs.push(gs[i]); break; } } var hlen = this.hs.length; for (var i = 0; i < hlen; i++) { var g = this.hs[i]; var span = g.getElementsByTagName("span")[0]; var div = g.getElementsByTagName("div")[0]; var p = g.getElementsByTagName("p")[0]; if (!span || !div || !p) { continue; } var ratio = data(span).split(":"); var style = getStyle(div); var dwidth = Math.floor(ratio[0] * 100 / ratio[1]); style.width = [dwidth, "%"].join(""); var width = {}; width.container = g.offsetWidth; width.graph = div.offsetWidth; width.p = p.offsetWidth; if ((width.container - width.graph) < width.p) { p = kill(p); var span = document.createElement("span"); var t = document.createElement("table"); t.insertRow(0); t.rows[0].insertCell(0); t.rows[0].insertCell(1); var pn = parentNode(g); g = kill(g); t.rows[0].cells[0].appendChild(g); addText(t.rows[0].cells[1], data(p)); pn.appendChild(t); } } }; Grapher._I = 1; } this.init(); }; /** Top level prototype for objects that respond to clicks on tags with certain rel attributes. The objects that are chained to this object will refer to the appropriate array of links before handling any events. This will also cut down on the number of times that the DOM must be traversed on a new page load. */ function LinkListener() { this.ratings = []; this.clicklearns = []; this.helps = []; this.zips = []; this.cpnis = []; this.pins = []; this.resetPins = []; this.printFriendlies = []; this.bigImages = []; this.popups = []; this.reviews = []; this.cartPopups = []; this.grandfathers = []; if (!LinkListener._I) { LinkListener.prototype.browserDetector = new BrowserDetector(); LinkListener.prototype.init = function() { var deadLink = function(e) { e = e || window.event; var node = e.target || e.srcElement; stopEvent(e); return false; }; var links = document.getElementsByTagName("a"); for (var i = links.length - 1; i > -1; i--) { if (links[i].rel) { switch(links[i].rel) { //case "rating": //this.ratings.push(links[i]); //break; ***check facebox.js for changes case "help": this.helps.push(links[i]); break; case "clicklearn": this.clicklearns.push(links[i]); break; case "zip": this.zips.push(links[i]); break; case "cpni": this.cpnis.push(links[i]); break; case "pin": this.pins.push(links[i]); break; case "resetPin": this.resetPins.push(links[i]); break; case "printfriendly": this.printFriendlies.push(links[i]); break; //case "big-image": //this.bigImages.push(links[i]); //break; ***check facebox.js for changes case "popup": this.popups.push(links[i]); break; case "review": this.reviews.push(links[i]); break; case "cartpopup": this.cartPopups.push(links[i]); break; case "grandfather": this.grandfathers.push(links[i]); break; } } if (links[i].href.match(/#$/)|| links[i].href.indexOf("javascript:null") != -1) { addListener(links[i], "click", deadLink, false); } } this.respond(); }; LinkListener.prototype.relisten = function() { this.init(); }; LinkListener._I = 1; } }; function Popup() { this.name = "cspopup"; this.width = "width=775"; this.height = "height=520"; this.menubar = "menubar=no"; this.location = "location=no"; this.resizeable = "resizeable=yes"; this.scrollbars = "scrollbars=no"; this.status = "status=no"; this.args = [this.width, this.height, this.menubar, this.location, this.resizeable, this.scrollbars, this.status].join(","); if (!Popup._I) { Popup.prototype.window = null; Popup.prototype.respond = function() { var popup = this; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var id = node.id; try { id = id.split(":")[1]; section = node.id.split(":")[2]; repositoryId = node.id.split(":")[3]; movieType = node.id.split(":")[4]; if (!id) { throw ("Bad id format"); } var args = []; args.push(["productId", id]); args.push(["section", section]); args.push(["id", repositoryId]); args.push(["movieType", movieType]); for (var i in args) { args[i] = args[i].join("="); } args = args.join("&"); var url = [webapp.getURL("/products/common/product_demo.jsp"), args].join("?"); var w = window.open(url, popup.name, popup.args); w.focus(); } catch (ex) { log(ex); } finally { stopEvent(e); return false; } }; var popups = this.popups; var plen = popups.length; for (var i = 0; i < plen; i++) { addListener(popups[i], "click", handleClick, false); } } Popup._I = 1; } this.init(); }; Popup.prototype = new LinkListener(); function CartPopup() { this.name = "cspopup"; this.width = "width=775"; this.height = "height=520"; this.menubar = "menubar=no"; this.location = "location=no"; this.resizeable = "resizeable=yes"; this.scrollbars = "scrollbars=no"; this.status = "status=no"; this.args = [this.width, this.height, this.menubar, this.location, this.resizeable, this.scrollbars, this.status].join(","); if (!CartPopup._I) { CartPopup.prototype.window = null; CartPopup.prototype.respond = function() { var popup = this; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var id = node.id; try { id = id.split(":")[1]; if (!id) { throw ("Bad id format"); } var page = [id, "jsp"].join("."); var url = webapp.getURL(["/popups/", page].join("")); var w = window.open(url, popup.name, popup.args); w.focus(); } catch (ex) { log(ex); } finally { stopEvent(e); return false; } }; var cartPopups = this.cartPopups; var plen = cartPopups.length; for (var i = 0; i < plen; i++) { addListener(cartPopups[i], "click", handleClick, false); } }; CartPopup._I = 1; } this.init(); }; CartPopup.prototype = new LinkListener(); /** Finds tags with a rel of "clicklearn" and creates popup windows. */ function ClickLearn() { if (!ClickLearn._I) { ClickLearn.prototype.respond = function() { var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; stopEvent(e); return false; }; var links = this.clicklearns; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; ClickLearn._I = 1; } this.init(); }; ClickLearn.prototype = new LinkListener(); function Grandfather() { if (!Grandfather._I) { Grandfather.prototype.respond = function() { var handleClick = function(e) { var e = e || window.event; var node = e.target || e.srcElement; var id = node.id.split(":")[1]; if (id) { var xhr = new XHR(); var url = webapp.getURL(["/utils/IsGrandfathered.jsp?productId=", id].join("")); xhr.open("GET", url, false); xhr.send(null); var json = xhr.responseText.parseJSON(); if (json.grandfathered) { switch (json.grandfathered) { case "true": if (!confirm("ATTENTION: This service is no longer available for subscription. If you remove it now, you will not be able to add it again. To keep this service, select \"Cancel.\" To remove this service, select \"OK.\"")) { stopEvent(e); return false; } break; case "false": // It's ok to remove a non-grandfathered feature. break; } } } }; var links = this.grandfathers; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; Grandfather._I = 1; } this.init(); }; Grandfather.prototype = new LinkListener(); /** Finds tags with a rel of "clicklearn" and creates popup windows. */ function BigImage() { if (!BigImage._I) { BigImage.prototype.respond = function() { var handleClick = function(e) { var e = e || window.event; var node = e.target || e.srcElement; var flyout = new Flyout(e); flyout.setStyle("width", "auto"); if (!node.nodeName.match(/^a$/i)) { node = findParentNode(node, "a"); } var href = [node.href, "d=1"].join("&"); var xhr = new XHR(); xhr.open("GET", href, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var json = xhr.responseText.parseJSON(); var img = document.createElement("img"); img.src = json.url; img.alt = ""; flyout.setContent(img); flyout.setStyle("width", "auto"); flyout.show(); } } }; stopEvent(e); return false; }; var links = this.bigImages; for (var i = links.length - 1; i > -1; i--) { log(links[i].nodeName); addListener(links[i], "click", handleClick, false); } }; BigImage._I = 1; } this.init(); }; BigImage.prototype = new LinkListener(); /** Finds tags with a rel of "clicklearn" and creates popup windows. */ function Review() { this.stars = []; if (!Review._I) { Review.prototype.productId = ""; Review.prototype.flyout = null; Review.prototype.respond = function() { var review = this; var nodeDataValue, titleContent, descriptionContent = ""; var setFocusOnce, starClicked, starMsgActive, titleMsgActive, descMsgActive, isCancel = false; var starClickedIndex, archiveCharLength, descriptionCharLength = 0; var descriptionCharLimit = 250; var productRatingDescription = new Array("","Wouldn't recommend it","Not my Favorite","Pretty good","Really like it","Love it!"); var handleReadReviewClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var my_rating = $(["my-rating", Review.prototype.productId].join(":")); if (my_rating) { var xhr = new XHR(); var url = webapp.getURL(["/utils/GetMyReview.jsp?productId=", Review.prototype.productId].join("")); xhr.open("GET", url, false); xhr.send(null); updateInnerHTML(my_rating, xhr.responseText.trim()); } }; var handleStarMouseover = function (e) { e = e || window.event; var node = e.target || e.srcElement; var end = node.id.split("-")[1]; for (var i = 1; i <= end; i++) { var star = $(["star", i].join("-")); if (star) { star.src = star.src.replace(/empty/, "full"); } } var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ if(starClicked && starClickedIndex <= end){ ratingDescription.innerHTML = productRatingDescription[end]; }else if(!starClicked){ ratingDescription.innerHTML = productRatingDescription[end]; } } return false; }; var handleStarMouseout = function (e) { e = e || window.event; var node = e.target || e.srcElement; var end = node.id.split("-")[1]; var starsLength = review.getStars().length; var counter = 0; for (var i = end; i <= starsLength; i++) { var star = $(["star", i].join("-")); if (star && !starClicked) { star.src = star.src.replace(/full/, "empty"); if(counter == 0){ var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ ratingDescription.innerHTML = productRatingDescription[i-1]; counter++; } } } } if(starClicked){ for (var i = starsLength; i > starClickedIndex; i--) { var star = $(["star", i].join("-")); if (star) { star.src = star.src.replace(/full/, "empty"); } } var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ ratingDescription.innerHTML = productRatingDescription[starClickedIndex]; } } return false; }; var handleStarClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; node.clicked = true; node.src = node.src.replace(/empty/, "full"); starClicked = true; var rating = node.id.split("-")[1]; starClickedIndex = rating; for (var i = 10; i > starClickedIndex; i--) { var star = $(["star", i].join("-")); if (star) { star.src = star.src.replace(/full/, "empty"); } } var slot = $("star-rating"); if (slot) { slot.value = rating; var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ ratingDescription.innerHTML = productRatingDescription[starClickedIndex]; } } }; var activateStars = function(nodes) { var slen = nodes.length; for (var i = 0; i < slen; i++) { nodes[i].stars = nodes; addListener(nodes[i], "mouseover", handleStarMouseover, false); addListener(nodes[i], "mouseout", handleStarMouseout, false); addListener(nodes[i], "click", handleStarClick, false); } }; var handleTextAreaFocus = function(e) { e = e || window.event; var node = e.target || e.srcElement; if(!setFocusOnce){ node.value = ""; setFocusOnce = true; } }; var handleTextAreaOnInput = function(e){ e = e || window.event; var node = e.target || e.srcElement; if(e.type == "input" || e.type == "keyup" || e.type == "paste"){ if(e.type=="paste"){ nodeDataValue = window.clipboardData.getData("Text"); nodeDataValue = node.value + nodeDataValue; }else{ nodeDataValue = node.value; } descriptionContent = nodeDataValue + " "; var cnt = 0; var indexOfChar = 0; var tempContent = ""; var breakLoop = false; var data = new Array(); data = descriptionContent.split(" "); for(var i = 0; i < data.length; i++){ for(var j = 0; j < data[i].length; j++){ if(cnt < descriptionCharLimit){ cnt++; }else{ breakLoop = true; indexOfChar = j; break; } } if(breakLoop){ for(var k = 0;k <= i; k++ ){ if(k == i){ tempContent = tempContent + data[k].substring(0, indexOfChar); break; } tempContent = tempContent + data[k] + " "; } node.value = tempContent; descriptionContent = tempContent; if(e.type == "paste"){ return false; } break; } } var counter = $(["counter"]); if(counter){ counter.innerHTML = descriptionCharLimit - cnt; } descriptionCharLength = cnt; } }; var handlePreviewSubmit = function(e){ e = e || window.event; var node = e.target || e.srcElement; if (!node.nodeName.match(/form/i)) { node = node.form; } var nodes = []; var inputs = node.getElementsByTagName("input"); var selects = node.getElementsByTagName("select"); var textareas = node.getElementsByTagName("textarea"); for (var i = inputs.length - 1; i > -1; i--) { nodes.push(inputs[i]); } for (var i = selects.length - 1; i > -1; i--) { nodes.push(selects[i]); } for (var i = textareas.length - 1; i > -1; i--) { nodes.push(textareas[i]); } var qs = ""; for (var i = nodes.length - 1; i > -1; i--) { qs = [qs, nodes[i].name, "=", nodes[i].value, "&"].join(""); } var xhr = new XHR(); var url = node.action; xhr.open("POST", url, false); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send(qs); Review.prototype.flyout.clear(); var p = document.createElement("p"); var header = document.createElement("h1"); header.className = "displayHeader"; var div = document.createElement("div"); header.appendChild(document.createTextNode("Thank you!")); div.appendChild(document.createTextNode("Your review has been successfully submitted to Cellular South for approval. All approved reviews will be posted to the site within 10 days from submission.")); p.appendChild(header); p.appendChild(div); Review.prototype.flyout.setContent(p); var closeHeader = document.getElementById("flyout-header"); if(closeHeader){ var a = document.createElement("a"); var image = document.createElement("img"); image.src = "/cscommerce/images/icons/close.png"; var bold = document.createElement("b"); a.setAttribute('href', '#'); a.onclick = function() { var flyout = document.getElementById("flyout"); if(flyout){ if (webapp.isIE()) { var ie = new InternetExplorer(); ie.wreckSelects(); } //Reset Variables isCancel = false; titleMsgActive = false; descMsgActive= false; starMsgActive = false; starClicked = false; descriptionCharLength = 0; kill(flyout); } return false; }; bold.appendChild(document.createTextNode("Close")); a.appendChild(image); a.appendChild(document.createTextNode(" ")); a.appendChild(bold); closeHeader.appendChild(a); /* May use later if QA do not like the original design. var close = document.getElementsByName("close-flyout"); if(close){ if(webapp.isIE()){ close.style.right = "45px"; } for(var i =0; i < close.length; i++){ if(i == 0){ close[i].id = "review-close-flyout"; close[i].style.display="block"; break; } } }*/ } var myRatingDiv = $(["my-rating", Review.prototype.productId].join(":")); myRatingDiv.innerHTML = " "; if(myRatingDiv){ for(var i = 1; i <= 5; i++){ var img = document.createElement("img"); var space = document.createTextNode(" "); if(i <= starClickedIndex){ img.src = "/cscommerce/images/star-full.gif"; }else{ img.src = "/cscommerce/images/star-empty.gif"; } myRatingDiv.appendChild(img); myRatingDiv.appendChild(space); } } }; var handleEdit = function(e){ e = e || window.event; var node = e.target || e.srcElement; Review.prototype.flyout.clear(); var xhr = new XHR(); var url = webapp.getURL("/fragments/review_fragment.jsp"); xhr.open("GET", url, false); xhr.send(null); var div = document.createElement("div"); div.innerHTML = xhr.responseText.trim(); Review.prototype.flyout.setContent(div); attachBehavior(div); for (var i = 0; i <= starClickedIndex; i++) { var star = $(["star", i].join("-")); if (star) { star.src = star.src.replace(/empty/, "full"); } } var setStars = $("star-rating"); /*Set hidden value*/ if(setStars){ setStars.value = starClickedIndex; var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ ratingDescription.innerHTML = productRatingDescription[starClickedIndex]; } } var rTitle = $(["reviewTitle"]); if(rTitle){ rTitle.value = titleContent; } var textDescription = $(["textDescription"]); if(textDescription){ textDescription.value = descriptionContent; } var counter = $(["counter"]); if(counter){ counter.innerHTML = descriptionCharLimit - descriptionCharLength; } stopEvent(e); return false; }; var handleCancel = function(e){ var flyout = document.getElementById("flyout"); if(flyout){ if (webapp.isIE()) { var ie = new InternetExplorer(); ie.wreckSelects(); } isCancel = true; //Reset Variables titleMsgActive = false; descMsgActive= false; starMsgActive = false; starClicked = false; descriptionCharLength = 0; kill(flyout); } }; var handlePreview = function(e) { e = e || window.event; var node = e.target || e.srcElement; if (!node.nodeName.match(/form/i)) { node = node.form; } if(!isCancel){ var starMsg = document.getElementById("starMsg"); var titleMsg = document.getElementById("titleMsg"); var descriptionMsg = document.getElementById("descriptionMsg"); if(!starClicked && !starMsgActive){ starMsg.style.display = "block"; starMsgActive = true; }else if(starClicked){ starMsg.style.display = "none"; starMsgActive = false; } var reviewTitle = $(["reviewTitle"]); if(reviewTitle){ var title = reviewTitle.value; if(title.length == 0 && !titleMsgActive){ titleMsg.style.display = "block"; titleMsgActive = true; }else if(title.length > 0){ titleMsg.style.display = "none"; titleMsgActive = false; titleContent = reviewTitle.value; } } if(descriptionCharLength == 0 && !descMsgActive){ descriptionMsg.style.display = "block"; descMsgActive = true; }else if(descriptionCharLength > 0){ descriptionMsg.style.display = "none"; descMsgActive = false; } if(!titleMsgActive && !descMsgActive && !starMsgActive){ Review.prototype.flyout.clear(); var xhr = new XHR(); var url = webapp.getURL(["/utils/GetDisplayReviewFragment.jsp?productId=", Review.prototype.productId].join("")); xhr.open("GET", url, false); xhr.send(null); var div = document.createElement("div"); div.innerHTML = xhr.responseText.trim(); Review.prototype.flyout.setContent(div); for (var i = 0; i <= starClickedIndex; i++) { var star = $(["star", i].join("-")); if (star) { star.src = star.src.replace(/empty/, "full"); } } var setStars = $("star-rating"); /*Set hidden value*/ if(setStars){ setStars.value = starClickedIndex; var ratingDescription = $(["productRatingDescription"]); if(ratingDescription){ ratingDescription.innerHTML = productRatingDescription[starClickedIndex]; } } var dTitle = $(["displayTitle"]); if(dTitle){ dTitle.innerHTML = titleContent; var setTitle = $("title"); if(setTitle){ setTitle.value = titleContent; } } var descContent = $(["displayDesc"]); if(descContent){ descContent.innerHTML=descriptionContent; var setContent = $("text"); if(setContent){ setContent.value = descriptionContent; } } var confirmButton = document.getElementById("confirm"); if(confirmButton){ addListener(confirmButton, "click", handlePreviewSubmit, false); } var editButton = document.getElementById("edit"); if(editButton){ addListener(editButton, "click", handleEdit, false); } } } isCancel = false; stopEvent(e); return false; }; var activateTextArea = function(node) { addListener(node, "focus", handleTextAreaFocus, false); if(webapp.isIE()){ addListener(node, "paste", handleTextAreaOnInput, false); addListener(node, "keyup", handleTextAreaOnInput, false); }else{ addListener(node, "input", handleTextAreaOnInput, false); } }; var activateCancelBtn = function(node) { addListener(node, "click", handleCancel, false); }; var activateForm = function(node) { addListener(node, "submit", handlePreview, false); }; var attachBehavior = function(node) { var stars = node.getElementsByTagName("img"); if (stars) { review.setStars(stars); activateStars(stars); } var textarea = node.getElementsByTagName("textarea")[0]; if (textarea) { activateTextArea(textarea); } var iForm = node.getElementsByTagName("form")[0]; if (iForm) { var inputs = iForm.getElementsByTagName("input"); if(inputs){ for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].id.match(/cancel/i)) { activateCancelBtn(inputs[i]); break; } } } } var form = node.getElementsByTagName("form")[0]; if (form) { activateForm(form); } }; var handleClick = function(e) { var e = e || window.event; var node = e.target || e.srcElement; if (!node.nodeName.match(/^a$/i)) { node = findParentNode(node, "a"); } Review.prototype.productId = node.productId; if (!node.clicked) { var flyout = new Flyout(e); Review.prototype.flyout = flyout; flyout.setStyle("width", "350px"); var id = node.id.split(":")[1]; var xhr = new XHR(); var url = webapp.getURL(["/utils/GetReviewFragment.jsp?productId=", id].join("")); xhr.open("GET", url, false); xhr.send(null); var div = document.createElement("div"); div.innerHTML = xhr.responseText.trim(); attachBehavior(div); flyout.setContent(div); flyout.show(); var flyoutHeader = document.getElementById("flyout-header"); if(flyoutHeader){ flyoutHeader.style.textAlign = "right"; } var close = document.getElementsByName("close-flyout"); if(close){ for(var i =0; i < close.length; i++){ close[i].style.display="none"; } } } node.clicked = true; stopEvent(e); return false; }; var links = this.reviews; for (var i = links.length - 1; i > -1; i--) { links[i].productId = links[i].id.split(":")[1]; addListener(links[i], "click", handleClick, false); } }; Review.prototype.highlightStars = function(stars) { for (var i in stars) { this.stars.push(stars[i]); } }; Review.prototype.setStars = function(stars) { for (var i in stars) { this.stars.push(stars[i]); } }; Review.prototype.getStars = function() { return this.stars; }; Review._I = 1; } this.init(); }; Review.prototype = new LinkListener(); function InternetExplorer() { if (!InternetExplorer._I) { InternetExplorer.prototype.SELECT_CLASS_NAME = "ie-hide-select"; InternetExplorer.prototype.init = function() { }; InternetExplorer.prototype.forceFlyoutWidths = function(node) { if (!node) { return; } var style = getStyle(node); }; InternetExplorer.prototype.unwreckSelects = function(node) { var coords = {}; coords.top = { x : node.offsetLeft, y : node.offsetTop }; coords.bottom = { x : node.offsetLeft, y : coords.y + node.offsetHeight }; coords.width = node.offsetWidth; coords.height = node.offsetHeight; // now get all the selects and see where they are on the page var selects = getNodes("select"); for (var i = selects.length - 1; i > -1; i -= 1) { var sel = selects[i]; var parent = sel.offsetParent; var left = sel.offsetLeft; var top = sel.offsetTop; left += parent.offsetLeft; top += parent.offsetTop; while (parent = parent.offsetParent) { left += parent.offsetLeft; top += parent.offsetTop; } var bottom = top + sel.offsetHeight; if (left >= coords.top.x && left <= coords.top.x + coords.width) { if ((top >= coords.top.y && top <= coords.top.y + coords.height) || (bottom >= coords.top.y && bottom <= coords.top.y + coords.height)) { sel.className = this.SELECT_CLASS_NAME; } } } }; InternetExplorer.prototype.wreckSelects = function(node) { var selects = document.getElementsByTagName("select"); var pattern = /ie-hide-select/; for (var i = selects.length - 1; i > -1; i -= 1) { if (selects[i].className.match(pattern)) { selects[i].className = selects[i].className.replace(pattern, ""); } } }; InternetExplorer.prototype.fixFlyout = function(node) { if (!node) { return; } var width = node.offsetWidth; var style = getStyle(node); style.width = [width, "px"].join(""); }; InternetExplorer._I = 1; } }; /** Looks for tags with a rel attribute equal to "rating". Clicking on them will retrieve the ratings for that product. */ function RatingsRetriever() { this.width = "270px"; if (!RatingsRetriever._I) { RatingsRetriever.prototype.STARS = 5; RatingsRetriever.prototype.NUM_RATINGS = 10; RatingsRetriever.prototype.respond = function() { var ratingLinks = this.ratings; for (var i = ratingLinks.length - 1; i > -1; i--) { ratingLinks[i].onclick = function(e) { e = e || window.event; var flyout = new Flyout(e); var addNextButton = false; var addBackButton = false; var frag = document.createElement("div"); var xhr = new XHR(); var id = this.id.split(":")[1]; var url = ["/cscommerce/utils/GetRatings.jsp?startIndex=1&action=getRatings&id=", id].join(""); xhr.open("GET", url, true); var me = this; xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var startIndex = 1; var json = xhr.responseText.parseJSON(); if (json) { frag.appendChild(RatingsRetriever.prototype.buildList(json)); frag.appendChild(RatingsRetriever.prototype.buildPaginator(startIndex, id, json.length)); flyout.setContent(frag); flyout.show(); flyout.setStyle("width", "270px"); /* There is a HORRIBLE bug in IE < 7 in which a