/** 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
with a class name of "fup" and an id that matches the id of the toggling element. So, for , the node that would be toggled is
*/ function Followupper() { if (!Followupper._I) { Followupper.prototype.construct = function() { if (!this.followups) { return false; } var getFup = function(id) { return $(["fup", id].join(":")); }; var hideOthers = function(e) { e = e || window.event; var node = e.target || e.srcElement; var others = document.getElementsByName(node.name); var len = others.length; for (var i = 0; i < len; i++) { // hide nodes that are auto-shown. removeClass(others[i], "autoshow"); if (others[i].id == node.id) { continue; } else { var fup = getFup(others[i].id); if (fup) { hide(fup); } else { log("couldn't find " + others[i].id); } } } }; var handleRadio = function(e) { e = e || window.event; var node = e.target || e.srcElement; var fup = getFup(node.id); if (fup) { if (node.checked) { materialize(fup); } else { spiritualize(fup, true); } } else { log("There is no fup with id " + node.id); } }; var handleCheckbox = function(e) { e = e || window.event; var node = e.target || e.srcElement; var fup = getFup(node.id); if (fup) { if (node.checked) { materialize(fup); } else { spiritualize(fup, true); } } }; var unclickOtherButtons = function(node) { var name = node.name; if (name) { var others = getElementsByDir(document, name); var olen = others.length; for (var i = 0; i < olen; i++) { if (others[i].id == node.id) { continue; } others[i].clicked = false; spiritualize(others[i], true); } } }; var handleLink = function(e) { e = e || window.event; var node = e.target || e.srcElement; var fup = getFup(node.id); if (fup) { node.clicked = !node.clicked; if (node.clicked) { materialize(fup) } else { spiritualize(fup, true); } } stopEvent(e); return false; }; var handleImg = function(e) { e = e || window.event; var node = e.target || e.srcElement; var fup = getFup(node.id); if (fup) { node.clicked = !node.clicked; if (!node.visible) { materialize(fup); } else if (node.visible) { spiritualize(fup, true); } } stopEvent(e); return false; }; var divs = this.followups; for (var j = divs.length - 1; j > -1; j--) { var style = getStyle(divs[j]); style.display = "none"; style.visibility = "visible"; var id = divs[j].id.split(":"); id.shift(); id = id.join(":"); var control = $(id); if (control) { switch (control.nodeName.toLowerCase()) { case "a": log("The case is 'a'"); log("Adding handleLink listener to " + control.id); addListener(control, "click", handleLink, false); break; case "input": log("The case is input"); switch (control.type.toLowerCase()) { case "radio": // If this is checked already as the page loads, then auto-show the followup // all other radio buttons in this group need to hide this one var radios = document.getElementsByName(control.name); var rlen = radios.length; for (var k = 0; k < rlen; k++) { if (radios[k].id == control.id) { continue; } addListener(radios[k], "click", hideOthers, false); } addListener(control, "click", handleRadio, false); if (control.checked) { materialize(divs[j]); } break; case "checkbox": addListener(control, "click", handleCheckbox, false); if (control.checked) { materialize(divs[j]); } break; case "image": // javascript doesn't grok input type="image" addListener(control, "click", handleImage, false); break; }; case "select": break; case "textarea": break; case "img": log("The case is img"); var images = getElementsByName("img", control.name); var ilen = images.length; for (var k = 0; k < ilen; k++) { images[k].clicked = false; if (images[k].id == control.id) { continue; } addListener(images[k], "click", hideOthers, false); } addListener(control, "click", handleImg, false); break; }; } } }; Followupper._I = 1; } if (webapp.isIE()) { var me = this; var exploreTheInternet = function() { me.init(); } setTimeout(exploreTheInternet, 0); } else { this.init(); } }; Followupper.prototype = new Revealer(); function TableFolder() { if (!TableFolder._I) { TableFolder.prototype.construct = function() { if (!this.folders) { log("No folders on this page."); return false; } log("Starting TableFolder"); var rows = {}; var getControl = function(node) { var id = node.id.split(":"); id = id.pop(); return $(id); }; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var fold = node.fold; var style = getStyle(fold); if (fold.visible) { log("hiding row"); style.display = "none"; var cells = fold.cells; var clen = cells.length; for (var i = 0; i < clen; i++) { var style = getStyle(cells[i]); style.display = "none"; } } else { log("showing row"); style.display = "block"; var cells = fold.cells; var clen = cells.length; for (var i = 0; i < clen; i++) { var style = getStyle(cells[i]); style.display = "block"; } } /* if (fold.visible) { // put the row back in the map //rows[node.id] = removeRow(fold); log("removing row"); } else { var row = rows[node.id]; // find where to put this in the table log("adding row"); var tr = findParentNode(node, "tr"); var table = findParentNode(node, "table"); var newRow = table.insertRow(tr.rowIndex + 1); var len = row.childNodes.length; var nodes = row.childNodes; for (var i = 0; i < len; i++) { if (nodes[i] && nodes[i].nodeName == "TD") { newRow.appendChild(nodes[i]); } } newRow.className = "fold"; newRow.id = ["fold", node.id].join(":"); } */ fold.visible = !fold.visible; }; var removeRow = function(row) { log("Removing table row"); return row.parentNode.removeChild(row); }; var attachRow = function(id) { if (rows.id) { return rows.id; } }; var nodes = this.folders; var len = nodes.length; for (var i = 0; i < len; i++) { var control = getControl(nodes[i]); if (control) { control.fold = nodes[i]; control.fold.visible = false; //rows[control.id] = removeRow(control.fold); } addListener(control, "click", handleClick, false); } }; TableFolder._I = 1; } this.init(); }; log("Hitting TableFolder.prototype = new Revealer()"); TableFolder.prototype = new Revealer(); /** This is kind of like the Followupper, but it works on
tags instead of form input controls. */ function Expander() { //log("In Expander()"); if (!Expander._I) { Expander.prototype.construct = function() { if (!this.expanders) { //log("No expanders on this page."); return false; } var getNext = function(node) { return nextSibling(node); }; var fixIE = function(node) { var style = getStyle(node); style.border = "0"; style.backgroundColor = "transparent"; }; var expand = function(node, fast) { setClass(node, "expanded"); if (webapp.isIE()) { fixIE(node); } if (!fast) { materialize(getNext(node)); } else { show(getNext(node)); } }; var contract = function(node, fast) { setClass(node, "collapsed"); if (!fast) { spiritualize(getNext(node), true); } else { hide(getNext(node)); } }; var handle = function(e) { e = e || window.event; var node = e.target || e.srcElement; if (!node.clicked) { expand(node); } else { contract(node); } node.clicked = !node.clicked; }; var lists = this.expanders; //getElementsByClassName(document.body, "expandable", "dl"); var len = lists.length; for (var i = 0; i < len; i++) { var dts = lists[i].getElementsByTagName("dt"); var dlen = dts.length; for (var j = 0; j < dlen; j++) { if (i == 0) { // Pop the first one open unless it really, truly wants to stay shut. if (!lists[i].className.match(/autohide/i)) { dts[j].clicked = true; expand(dts[j]); } } else { if (lists[i].className.match(/autoshow/i)) { dts[j].clicked = true; expand(dts[j], true); } else if (lists[i].className.match(/autohide/i)) { contract(dts[j], true); } else { dts[j].clicked = false; } } addListener(dts[j], "click", handle, false); } } }; Expander._I = 1; } this.init(); }; Expander.prototype = new Revealer(); /** This is in the same family as Followupper and Expander. This one will show/hide a block on a mouse over. Usage: 1. Give the that you want to cause something to appear an id that looks like "roller:my_cat_is_funny" and a class name of "roller". The class name is only important if you want the to have a display: block; you can leave it off if you want to, but it might be frustrating for the user. 2. Give the
that you want to appear a class name of "rolled" and an id that looks like "rolled:my_cat_is_funny". */ function Roller() { //log("In Roller()"); if (!Roller._I) { Roller.prototype.showTimeout = null; Roller.prototype.hideTimeout = null; Roller.prototype.construct = function() { if (!this.rollers) { //log("No rollers on this page."); return false; } var handleMouseover = function(e) { e = e || window.event; var node = e.target || e.srcElement; var t = setTimeout( function() { materialize(node.rolled); }, 250 ); }; var handleMouseout = function(e) { e = e || window.event; var node = e.target || e.srcElement; var t = setTimeout( function() { spiritualize(node.rolled, true); }, 500 ); }; //var divs = getElementsByClassName(document.body, "rolled", "div"); var divs = this.rollers; var dlen = divs.length; for (var i = 0; i < dlen; i++) { var div = divs[i]; var id = div.id; if (!id) { continue; } id = id.split(":"); id.shift(); var roller = $(["roller", id].join(":")); if (roller) { roller.rolled = div; addListener(roller, "mouseover", handleMouseover, false); addListener(roller, "mouseout", handleMouseout, false); } }; }; Roller._I = 1; } this.init(); }; log("Hitting Roller.prototype = new Revealer()"); Roller.prototype = new Revealer(); function Martyr() { //log("In Martyr()"); if (!Martyr._I) { Martyr.prototype.construct = function() { if (!this.martyrs) { //log("No martyrs on this page."); return false; } var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; //var fup = $(node.id.split(":")[1]); var fup = $(["martyr", node.id].join(":")); if (fup) { kill(node); materialize(fup); focusFirst(fup); } stopEvent(e); return false; }; var ulen = this.martyrs.length; var unsaved = this.martyrs; for (var i = 0; i < ulen; i++) { // Find the node that toggles this thing var id = unsaved[i].id; if (id) { //var martyr = $(["martyr", id].join(":")); var martyr = $(id.split(":")[1]); //id); if (martyr) { addListener(martyr, "click", handleClick, false); } } } }; Martyr._I = 1; } this.init(); }; log("Hitting Martyr.prototype = new Revealer()"); Martyr.prototype = new Revealer(); /** Dynamically places an HTML element on the page. @param e The event that started the flyout. @param func A optional function to run when killing the flyout. */ function Flyout(e, func) { log("In Flyout()"); if (!e) { return false; } this.event = e; this.id = "flyout"; this.headerId = "flyout-header"; this.contentId = "flyout-content"; this.imgSrc = "/cscommerce/images/icons/close.png"; this.imgAlt = "[close]"; this.imgId = "close-flyout"; this.header = null; this.content = null; this.ieStyleSet = false; if (!Flyout._I) { Flyout.prototype.init = function() { kill($(this.id)); this.build(); }; Flyout.prototype.setStyle = function(property, value) { var style = getStyle($(this.id)); style[property] = value; log(style[property] + " " + value); this.ieStyleSet = true; }; Flyout.prototype.setHeader = function(node) { var header = $(this.headerId); if (header) { this.header = header; header.appendChild(node); header.appendChild(this.getCloseButton()); } }; Flyout.prototype.fixIE = function() { var node = $(this.id); var style = getStyle(node); if (webapp.isIE() && this.ieStyleSet) { style.width = "auto"; var dt = node.getElementsByTagName("dt")[0]; var dd = node.getElementsByTagName("dd")[0]; var dtStyle = getStyle(dt); var ddStyle = getStyle(dd); dtStyle.width = new Pixel().get(node.offsetWidth - 20); ddStyle.width = "auto"; } else { style.width = "250px"; } style.border = "0"; style.zoom = "1.0"; style.backgroundColor = "transparent"; var ie = new InternetExplorer(); ie.wreckSelects(node); ie.unwreckSelects(node); ie.fixFlyout(node); }; Flyout.prototype.getCloseButton = function() { var img = document.createElement("img"); img.id = this.imgId; img.name = this.imgId; img.src = this.imgSrc; img.alt = this.imgAlt; var me = this; img.onclick = function() { var node = $(me.id); if (webapp.isIE()) { var ie = new InternetExplorer(); ie.wreckSelects(); } kill(node); if (isFunction(func)) { func(); } }; return img; }; Flyout.prototype.setStandardHeader = function() { this.setHeader(this.getCloseButton()); }; Flyout.prototype.setContent = function(dom) { var content = $(this.contentId); if (content) { content.appendChild(dom); if (webapp.isIE()) { var ie = new InternetExplorer(); ie.fixFlyout($(this.id)); } } }; Flyout.prototype.clear = function() { var content = $(this.contentId); if (content) { clear(content); } }; Flyout.prototype.build = function() { var dl = document.createElement("dl"); dl.id = "flyout"; var dt = document.createElement("dt"); dt.id = "flyout-header"; dl.appendChild(dt); var dd = document.createElement("dd"); dd.id = "flyout-content"; dl.appendChild(dd); document.body.appendChild(dl); this.position(); }; Flyout.prototype.position = function() { var e = this.event || window.event; var node = e.target || e.srcElement; var xy = getCoordinates(e); var style = getStyle($(this.id)); for (var i in xy) { xy[i] = [xy[i], "px"].join(""); } style.top = xy.y; style.left = xy.x; }; Flyout.prototype.cleanup = function() { var style = getStyle($(this.id)); }; Flyout.prototype.show = function(func) { var style = getStyle($(this.id)); if (!this.header) { this.setStandardHeader(); } materialize($(this.id), func); if (webapp.isIE()) { this.fixIE(); } /*new SIFRDaddy();*/ }; Flyout._I = 1; } this.init(); }; /** Dynamically styles a graph. This relies on HTML that looks like the following:
20:30
20

30

The span will not be shown, but its contents are used to determine the width of the smaller bar. If the width of the smaller bar covers the

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 menus bleeding through it if there are any underneath it. There needs to be a function that calculates the perimeter of the box and then hides all selects that are within that boundary. */ RatingsRetriever.prototype.fixInternetExplorerSelects(); } else { var div = document.createElement("div"); div.appendChild(document.createTextNode(xhr.responseText)); document.body.appendChild(div); } } } }; xhr.send(null); return false; }; } }; RatingsRetriever.prototype.buildList = function(json) { var dl = document.createElement("dl"); for (var i = 0; i < json.length; i++) { if (typeof json[i] == "object") { var stars = document.createElement("dt"); var dt = document.createElement("dt"); var dd = document.createElement("dd"); var j = 0; do { var img = document.createElement("img"); img.alt = "Star"; img.src = "/cscommerce/images/star-full-blue.gif"; stars.appendChild(img); j += 1; } while (j < json[i].value); if (j < RatingsRetriever.prototype.STARS) { for (var k = j; k < RatingsRetriever.prototype.STARS; k++) { var img = document.createElement("img"); img.alt = "Empty Star"; img.src = "/cscommerce/images/star-empty-blue.gif"; stars.appendChild(img); } } var span = document.createElement("span"); addText(span, json[i].displayName); addClass(span, "ratings-title"); dt.appendChild(span); dt.appendChild(document.createTextNode([" (", json[i].rateDate, ")"].join(""))); dd.appendChild(document.createTextNode(json[i].longDescription)); dl.appendChild(stars); dl.appendChild(dt); dl.appendChild(dd); } } return dl; }; RatingsRetriever.prototype.buildEndNotification = function(startIndex, id) { var dl = document.createElement("dl"); var dt = document.createElement("dt"); dt.appendChild(document.createTextNode("There are no more ratings to display.")); dl.appendChild(dt); return dl; }; RatingsRetriever.prototype.updateList = function(startIndex, id) { var flyout = $("flyout-content"); if (!flyout) { return false; } var old_dl = flyout.getElementsByTagName("dl")[0]; var xhr = new XHR(); var url = ["/cscommerce/utils/GetRatings.jsp?startIndex=", parseInt(startIndex), "&action=getRatings&id=", id].join(""); xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var actual_length = 0; var json = xhr.responseText.parseJSON(); if (json) { actual_length = json.length; if (old_dl) { var new_dl = RatingsRetriever.prototype.buildList(json); old_dl.parentNode.replaceChild(new_dl, old_dl); } } else { old_dl.parentNode.replaceChild(RatingsRetriever.prototype.buildEndNotification(startIndex, id), old_dl); } var ul = flyout.getElementsByTagName("ul")[0]; if (ul) { var new_list = RatingsRetriever.prototype.buildPaginator(startIndex, id, actual_length); ul.parentNode.replaceChild(new_list, ul); } else { flyout.appendChild(RatingsRetriever.prototype.buildPaginator(startIndex, id, actual_length)); } RatingsRetriever.prototype.fixInternetExplorerSelects(); } } }; }; RatingsRetriever.prototype.buildPaginator = function(startIndex, id, listLength) { var addBack = (startIndex <= 1) ? false : true; var addNext = (listLength < RatingsRetriever.prototype.NUM_RATINGS) ? false : true; var back = document.createElement("a"); var next = document.createElement("a"); back.href = "#"; next.href = "#"; back.id = ["back", id].join(":"); next.id = ["next", id].join(":"); back.appendChild(document.createTextNode("Back")); next.appendChild(document.createTextNode("Next")); var buttons = [back, next]; var ul = document.createElement("ul"); var li_back = document.createElement("li"); var li_next = document.createElement("li"); li_back.appendChild(back); li_next.appendChild(next); if (addBack) { ul.appendChild(li_back); } if (addNext) { ul.appendChild(li_next); } next.onclick = function() { data = this.firstChild.data; data = "Loading"; startIndex += 10; RatingsRetriever.prototype.updateList(startIndex, id); return false; }; back.onclick = function() { startIndex -= 10; RatingsRetriever.prototype.updateList(startIndex, id); return false; }; return ul; }; RatingsRetriever.prototype.fixInternetExplorerSelects = function() { var bd = new BrowserDetector(); if (bd.isIE() && bd.getVersion() < 7) { // Sigh. //RatingsRetriever.prototype.unfixInternetExplorerSelects(); var flyout = $("flyout"); if (!flyout) { return false; } var ie = new InternetExplorer(); ie.wreckSelects(flyout); ie.unwreckSelects(flyout); /* var body = document.getElementsByTagName("body")[0]; // get the coordinates of the corners var pixel = new Pixel(); var coords = {}; coords.top = { x : flyout.offsetLeft, y : flyout.offsetTop }; coords.bottom = { x : flyout.offsetLeft, y : coords.y + flyout.offsetHeight }; coords.width = flyout.offsetWidth; coords.height = flyout.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 = "ie-hide-select"; } } } */ } }; RatingsRetriever.prototype.unfixInternetExplorerSelects = function() { 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, ""); } } }; RatingsRetriever.prototype.removeFlyout = function() { var div = $("flyout"); if (div) { div.parentNode.removeChild(div); } }; RatingsRetriever._I = 1; } this.init(); }; RatingsRetriever.prototype = new LinkListener(); function HelpListener() { if (!HelpListener._I) { HelpListener.prototype.respond = function() { var links = this.helps; for (var i = links.length - 1; i > -1; i--) { links[i].onclick = function(e) { e = e || window.event; var flyout = new Flyout(e); var xhr = new XHR(); var qsp = new QueryStringParser(this.href); var target = qsp.get("help"); var url = ["/cscommerce/utils/GetHelp.jsp?help=", target].join(""); xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var node = document.createElement("div"); node.innerHTML = xhr.responseText; var div = node.getElementsByTagName("div")[0]; div = kill(div); flyout.setHeader(div); flyout.setContent(node); flyout.show(); } } }; return false; xhr.send(null); }; } }; HelpListener._I = 1; } this.init(); }; HelpListener.prototype = new LinkListener(); /** Listens for clicks to the "CPNI" link */ function CpniListener() { if (!CpniListener._I) { CpniListener.prototype.respond = function() { var handleClick = function(e) { var resurrect = function() { var wrapper = $("wrapper"); removeClass(wrapper, "ghost"); }; var flyout = new Flyout(e, resurrect); var xhr = new XHR(); var url = "/cscommerce/utils/CpniInformation.jsp"; xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var wrapper = $("wrapper"); if (wrapper) { if (!LinkListener.prototype.browserDetector.isIE()) { addClass(wrapper, "ghost"); } } var node = document.createElement("div"); node.innerHTML = xhr.responseText; var div = node.getElementsByTagName("div")[0]; div = kill(div); flyout.setContent(div); flyout.show(); } } }; stopEvent(e); return false; }; var links = this.cpnis; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; CpniListener._I = 1; } this.init(); }; CpniListener.prototype = new LinkListener(); /** Listens for clicks to the "Reset PIN" link */ function resetPinListener() { if (!resetPinListener._I) { resetPinListener.prototype.respond = function() { var handleClick = function(e) { var resurrect = function() { var wrapper = $("wrapper"); removeClass(wrapper, "ghost"); }; var flyout = new Flyout(e, resurrect); var xhr = new XHR(); var url = "/cscommerce/utils/ResetPin.jsp"; xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var wrapper = $("wrapper"); if (wrapper) { if (!LinkListener.prototype.browserDetector.isIE()) { addClass(wrapper, "ghost"); } } var node = document.createElement("div"); node.innerHTML = xhr.responseText; var div = node.getElementsByTagName("div")[0]; div = kill(div); //flyout.setHeader(div); //flyout.setContent(node); flyout.setContent(div); flyout.show(); } } }; stopEvent(e); return false; }; var links = this.resetPins; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; resetPinListener._I = 1; } this.init(); }; resetPinListener.prototype = new LinkListener(); /** Listens for clicks to the "Enter Pin" button */ function pinListener() { if (!pinListener._I) { pinListener.prototype.respond = function() { var handleClick = function(e) { var resurrect = function() { var wrapper = $("wrapper"); removeClass(wrapper, "ghost"); }; var flyout = new Flyout(e, resurrect); var xhr = new XHR(); var url = "/cscommerce/utils/EnterPin.jsp"; xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var wrapper = $("wrapper"); if (wrapper) { if (!LinkListener.prototype.browserDetector.isIE()) { addClass(wrapper, "ghost"); } } var node = document.createElement("div"); node.innerHTML = xhr.responseText; //var header = node.getElementsByTagName("span")[0]; var div = node.getElementsByTagName("div")[0]; div = kill(div); //flyout.setHeader(div); //flyout.setContent(node); flyout.setContent(div); flyout.show(); } } }; stopEvent(e); return false; }; var links = this.pins; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; pinListener._I = 1; } this.init(); }; pinListener.prototype = new LinkListener(); /** Listens for clicks to the "change zip code" link */ function ZipListener() { if (!ZipListener._I) { ZipListener.prototype.respond = function() { var handleClick = function(e) { var resurrect = function() { var wrapper = $("wrapper"); removeClass(wrapper, "ghost"); }; var flyout = new Flyout(e, resurrect); var xhr = new XHR(); var url = "/cscommerce/utils/SetLocation.jsp"; xhr.open("GET", url, true); xhr.send(null); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { if (xhr.status == 200) { var wrapper = $("wrapper"); if (wrapper) { if (!LinkListener.prototype.browserDetector.isIE()) { addClass(wrapper, "ghost"); } } var node = document.createElement("div"); node.innerHTML = xhr.responseText; var div = node.getElementsByTagName("div")[0]; div = kill(div); flyout.setHeader(div); flyout.setContent(node); flyout.show(); { // this block is here because IE won't focus on this input by its id. No idea why. var f = $("flyout"); var input = f.getElementsByTagName("input"); for (var i = 0; i < input.length; i++) { if (input[i].type && input[i].type.match(/text/i)) { input[i].focus(); break; } } } } } }; stopEvent(e); return false; }; var links = this.zips; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; ZipListener._I = 1; } this.init(); }; ZipListener.prototype = new LinkListener(); /** Listens for clicks to print friendly links. */ function PrintFriendlyListener() { if (!PrintFriendlyListener._I) { PrintFriendlyListener.prototype.respond = function() { var openWindow = function(nodeList) { var w = window.open("", "w"); }; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; if (node.id) { var chunks = node.id.split(":"); if (chunks.length == 2) { var action = chunks[0]; var location = chunks[1]; switch (action) { case "popup": location = [location, ".jsp"].join(""); location = webapp.getURL(["/popups/", location].join("")); var w = window.open(location, "w"); break; } stopEvent(e); return false; } } try { var target = node.id.split("for:"); target = $(target[target.length - 1]); openWindow(target); } catch (ex) { } stopEvent(e); return false; }; var links = this.printFriendlies; for (var i = links.length - 1; i > -1; i--) { addListener(links[i], "click", handleClick, false); } }; PrintFriendlyListener._I = 1; } this.init(); }; PrintFriendlyListener.prototype = new LinkListener(); function InputFocuser() { this.firsts = [ "location-required", "forgot-password-npa", "firstName" ]; this.found = false; if (!InputFocuser._I) { InputFocuser.prototype.init = function() { for (var i in this.firsts) { var node = $(this.firsts[i]); if (node) { this.found = true; node.focus(); break; } } } InputFocuser.prototype.worked = function() { return this.found; }; InputFocuser._I = 1; } this.init(); }; function FocusSearch() { if (!FocusSearch._I) { FocusSearch.prototype.init = function() { var inputFocuser = new InputFocuser(); if (!inputFocuser.worked()) { var search = $("search"); if (search) { var inputs = search.getElementsByTagName("form")[0].getElementsByTagName("input"); for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].type && inputs[i].type.match(/text/i)) { inputs[i].focus(); break; } } } } }; FocusSearch._I = 1; } this.init(); }; /** Activates the "Print" link. */ function Printer() { if (!Printer._I) { Printer.prototype.init = function() { var links = document.getElementsByTagName("a"); for (var i = links.length - 1; i > -1; i--) { if (links[i].id) { if (links[i].id == "print") { var printer = links[i]; printer.onclick = function() { Printer.prototype.setImage(); window.print(); return false; }; } } } this.startOtherPrinters(); }; Printer.prototype.setImage = function() { // TO DO: replace the text of the link in the header with an image // so that it will show up on the printed sheet. }; Printer.prototype.startOtherPrinters = function() { var links = getElementsByClassName(document, "print", "a"); var noImageLinks = getElementsByClassName(document, "noImagePrintLink", "a"); for (var i = links.length - 1; i > -1; i--) { links[i].onclick = function() { Printer.prototype.setImage(); window.print(); return false; }; } for (var i = noImageLinks.length - 1; i > -1; i--) { noImageLinks[i].onclick = function() { Printer.prototype.setImage(); window.print(); return false; }; } }; Printer._I = 1; } this.init(); }; /** Disables links contained in a

  • or with a className of "current". */ function LinkDisabler() { if (!LinkDisabler._I) { LinkDisabler.prototype.init = function() { var handleClick = function(e) { e = e || window.event; stopEvent(e); return false; }; var currents = getElementsByClassName(document, "current", ["li", "td"]); var clen = currents.length; for (var i = 0; i < clen; i++) { var as = currents[i].getElementsByTagName("a"); var alen = as.length; for (var j = 0; j < alen; j++) { addListener(as[j], "click", handleClick, false); } } }; LinkDisabler._I = 1; } this.init(); }; /** Listens for clicks to $("logout") and creates a form to log the user out. */ function Logout() { if (!Logout._I) { Logout.prototype.init = function() { var link = $("logout"); if (!link) { return false; } var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var xhr = new XHR(); var url = webapp.getURL("/utils/Logout.jsp"); xhr.open("GET", url, false); xhr.send(null); var div = $("fake-logout"); if (div) { kill(div); } div = document.createElement("div"); div.id = "fake-logout"; updateInnerHTML(div, xhr.responseText); document.body.insertBefore(div, document.body.firstChild); var form = div.getElementsByTagName("form")[0]; if (form) { var handleSubmit = function(event) { event = event || window.event; var node = event.target || event.srcElement; stopEvent(event); return false; }; var inputs = form.getElementsByTagName("input"); for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].type == "submit") { inputs[i].click(); stopEvent(e); return false; } } }; stopEvent(e); return false; }; addListener(link, "click", handleClick, false); }; Logout._I = 1; } this.init(); }; /** Disallow text input on numeric classes. */ function TextBlocker() { this.disableText = function(e) { e = e || window.event; var node = e.target || e.srcElement; if (node.value.length > 0 && !node.value.match(/^\d+$/)) { node.value = node.value.replace(/[^\d]/g, ""); } }; if (!TextBlocker._I) { TextBlocker.prototype.init = function() { var inputs = document.getElementsByTagName("input"); for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].className.match(/numeric/i)) { addListener(inputs[i], "keyup", this.disableText, false); } } }; TextBlocker._I = 1; } this.init(); }; /** Removes spaces from inputs of type creditcard. */ function CreditCardFormatter() { this.removeSpaces = function(e) { var value = []; var chunks = this.value.split(""); for (var i in chunks) { if (chunks[i].match(/\d/)) { value.push(chunks[i]); } } this.value = value.join(""); }; if (!CreditCardFormatter._I) { CreditCardFormatter.prototype.init = function() { var inputs = document.getElementsByTagName("input"); for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].className.match(/creditcard/i)) { addListener(inputs[i], "keyup", this.removeSpaces, false); } } }; CreditCardFormatter._I = 1; } this.init(); }; /** Automatically tabs to the next input box when the box's length is equal to its maxlength attribute. */ function AutoTabber() { if (!AutoTabber._I) { AutoTabber.prototype.init = function() { var next = function(e) { e = e || window.event; var node = e.target || e.srcElement; if (e.keyCode == 9 || e.keyCode == 16) { // tab and shift keys, horribly irritating to tab back and then be tabbed forward again stopEvent(e); return false; } var maxlength = node.maxLength; if (node.value.length == maxlength) { var sibling = nextTwin(node); if (sibling) { sibling.focus(); } stopEvent(e); return false; } }; var groups = getElementsByClassName(document, "auto-tab"); for (var i = groups.length - 1; i > -1; i--) { var inputs = groups[i].getElementsByTagName("input"); for (j = 0; j < inputs.length; j += 1) { addListener(inputs[j], "keyup", next, false); } } }; AutoTabber._I = 1; } this.init(); }; function FormResetter() { if (!FormResetter._I) { FormResetter.prototype.init = function() { var handleClick = function(e) { try { e = e || window.event; var node = e.target || e.srcElement; node.form.reset(); stopEvent(e); return false; } catch (x) { log(x); stopEvent(e); return false; } }; var forms = document.getElementsByTagName("form"); var flen = forms.length; for (var i = 0; i < flen; i++) { var resets = getElementsByClassName(forms[i], "form-reset", "input"); var rlen = resets.length; for (var j = 0; j < rlen; j++) { addListener(resets[j], "click", handleClick, false); } } }; FormResetter._I = 1; } this.init(); }; function Relistener() { this.functions = [ RatingsRetriever, HelpListener, ZipListener, ClickLearn, BigImage ]; if (!Relistener._I) { Relistener.prototype.init = function() { for (var func in this.functions) { new this.functions[func](); } }; Relistener._I = 1; } this.init(); }; function FormListener() { if (!FormListener._I) { FormListener.prototype.init = function() { var handleSubmit = function(e) { e = e || window.event; var form = e.target || e.srcElement; if (!form.nodeName.match(/form/i)) { form = form.form; if (!form.nodeName.match(/form/i)) { form = findParentNode(form, "form"); } } var submits = getElementsByAttribute(form, "type", "submit"); var images = getElementsByAttribute(form, "type", "image"); var inputs = []; for (var i = submits.length - 1; i > -1; i--) { inputs.push(submits[i]); } for (var i = images.length - 1; i > -1; i--) { inputs.push(images[i]); } var defaultButton = null; for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i].className && inputs[i].className.match(/default/i)) { defaultButton = inputs[i]; break; } } if (defaultButton) { for (var i = inputs.length - 1; i > -1; i--) { if (inputs[i] == defaultButton) { continue; } else { if (inputs[i].getAttribute("name")) { inputs[i].removeAttribute("name") } } } var input = document.createElement("input"); input.setAttribute("name", defaultButton.getAttribute("name")); input.setAttribute("value", defaultButton.getAttribute("value")); input.setAttribute("type", "hidden"); form.appendChild(input); if (defaultButton.type.match(/image/i)) { var xy = ["x", "y"]; for (var i = 0; i < xy.length; i++) { var input = document.createElement("input"); var inputName = [defaultButton.getAttribute("name"), ".", xy[i]].join(""); input.setAttribute("name", inputName); input.setAttribute("value", 1); input.setAttribute("type", "hidden"); form.appendChild(input); } } removeListener(form, "submit", handleSubmit, false); form.submit(); } }; var cancelSubmit = function(e) { e = e || window.event; var form = e.target || e.srcElement; if (!e.clientX || !e.clientY || e.clientX == 0 || e.clientY == 0) { return false; } if (!form.nodeName.match(/form/i)) { form = form.form; if (!form.nodeName.match(/form/i)) { form = findParentNode(form, "form"); } } removeListener(form, "submit", handleSubmit, false); } var forms = document.getElementsByTagName("form"); var flen = forms.length; for (var i = 0; i < flen; i++) { addListener(forms[i], "submit", handleSubmit, false); var submits = getElementsByAttribute(forms[i], "type", "submit"); var images = getElementsByAttribute(forms[i], "type", "image"); var inputs = []; for (var j = submits.length - 1; j > -1; j--) { inputs.push(submits[j]); } for (var j = images.length - 1; j > -1; j--) { inputs.push(images[j]); } for (var j = inputs.length - 1; j > -1; j--) { addListener(inputs[j], "click", cancelSubmit, false); } } }; FormListener._I = 1; } this.init(); }; function SelectorList(select) { this.className = null; if (!SelectorList._I) { SelectorList.prototype.init = function(select) { var si = select.selectedIndex; var div = document.createElement("div"); div.className = "SelectorList"; if (this.className) { div.className = [div.className, this.className].join(" "); } var ul = document.createElement("ul"); ul.selectID = select.id; ul.className = "ReplacementSelect"; var opts = select.options; var length = opts.length; for (var j = 0; j < length; j++) { var li = document.createElement("li"); if (j == si) { li.className = "selected"; } li.appendChild(document.createTextNode(opts[j].firstChild.data)); ul.appendChild(li); } ul.clicked = false; var ItemClick = function() { this.className = "selected"; var select = $(this.parentNode.selectID); if (select) { select.selectedIndex = this.position; } this.parentNode.className = this.parentNode.className.replace(/ActiveSelect/, ""); }; var ListClick = function() { this.clicked = !this.clicked; if (this.clicked) { this.className = [this.className, "ActiveSelect"].join(" "); var items = this.getElementsByTagName("li"); var length = items.length; for (var j = 0; j < length; j++) { items[j].className = items[j].className.replace(/selected/, ""); items[j].position = j; items[j].addEventListener("click", ItemClick, false); } } }; ul.addEventListener("click", ListClick, false); div.appendChild(ul); return div; }; } return this.init(select); }; function SelectStyler() { if (!SelectStyler._I) { SelectStyler.prototype.init = function() { var selects = document.body.getElementsByTagName("select"); var length = selects.length; for (var i = 0; i < length; i++) { var selectorList = new SelectorList(selects[i]); selectorList.style.zIndex = length - i; selects[i].parentNode.appendChild(selectorList); } }; SelectStyler._I = 1; } this.init(); }; //Excuse this ugly code in the miidle of all this great javascript function makeFlyout(e) { var flyout = new Flyout(e); var targ; if (!e) var e = window.event; if (e.target) targ = e.target; else if (e.srcElement) targ = e.srcElement; if (targ.nodeType == 3) // defeat Safari bug targ = targ.parentNode; //now we have the target var targetId = new String(targ.id); var startId = targetId.indexOf('['); var stopId = targetId.lastIndexOf("]"); var productId = targetId.substring(startId+1, stopId); var msgId = "msg["+productId+"]"; var node = document.createElement("div"); log($(msgId).innerHTML); node.innerHTML = $(msgId).innerHTML; flyout.setContent(node); flyout.show(); return false; }; function setup_flyout(dom) { addListener(dom, "click", makeFlyout ,false); }; function setup_flyoutmakers() { var pipeLinks = document.getElementsByName("pipeLink"); for(var i = 0; i < pipeLinks.length; ++i) { setup_flyout(pipeLinks[i]); } }; function SelectStyler() { this.selects = []; this.lists = []; this.positions = []; this.isWrecked = false; if (!SelectStyler._I) { SelectStyler.prototype.init = function() { var bd = new BrowserDetector(); if (bd.isIE()) { this.isWrecked = true; } this.selects = document.getElementsByTagName("select"); this.hideSelects(); this.makeLists(); this.activateLists(); }; SelectStyler.prototype.hideSelects = function() { var slen = this.selects.length; for (var i = 0; i < slen; i++) { var select = this.selects[i]; var style = getStyle(select); var position = { "x" : style.left, "y" : style.top, "h" : select.offsetHeight, "w" : select.offsetWidth }; this.positions.push(position); style.display = "none"; } }; SelectStyler.prototype.position = function(node, i) { var style = getStyle(node); style.cssFloat = "left"; //style.position = "absolute"; style.top = this.positions[i].y; style.left = this.positions[i].x; style.width = [this.positions[i].w, "px"].join(""); style.zIndex = 10000 - i; var div = document.createElement("br"); var divStyle = getStyle(div); divStyle.clear = "left"; divStyle.border = "1px solid red"; node.parentNode.appendChild(div); //this.addProp(node); }; SelectStyler.prototype.makeLists = function() { var slen = this.selects.length; for (var i = 0; i < slen; i++) { var select = this.selects[i]; var options = this.selects[i].options; var ol = document.createElement("ol"); ol.className = "select-styler"; ol.expanded = false; var olen = options.length; for (var j = 0; j < olen; j++) { var li = document.createElement("li"); if (j == 0) { li.className = "select-styler-active"; } li.appendChild(document.createTextNode(options[j].firstChild.data)); ol.appendChild(li); } this.lists.push(ol); var div = document.createElement("div"); div.className = "select-styler-container"; var divStyle = getStyle(div); divStyle.position = "relative"; div.appendChild(ol); select.parentNode.appendChild(div); this.position(ol, i); } }; SelectStyler.prototype.addProp = function(list) { var div = document.createElement("div"); div.className = "select-styler-prop"; var style = getStyle(div); style.height = [list.offsetHeight, "px"].join(""); list.parentNode.appendChild(div); return div; }; SelectStyler.prototype.changeProp = function(list) { var prop = getElementsByClassName(list.parentNode, "select-styler-prop", "div")[0]; if (!prop) { prop = this.addProp(list); } var style = getStyle(prop); style.height = [list.offsetHeight, "px"].join(""); }; SelectStyler.prototype.changeProp2 = function(item) { var parent = findParentNode(item, "div"); var prop = getElementsByClassName(parent, "select-styler-prop", "div")[0]; var style = getStyle(prop); style.height = [item.offsetHeight + 5, "px"].join(""); }; SelectStyler.prototype.activateLists = function() { var handleMouseover = function(e) { e = e || window.event; var node = e.target || e.srcElement; addClass(node, "select-styler-hover"); }; var handleMouseout = function(e) { e = e || window.event; var node = e.target || e.srcElement; removeClass(node, "select-styler-hover"); }; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var parent = findParentNode(node, "ol"); if (parent.expanded) { parent.className = "select-styler"; var items = parent.getElementsByTagName("li"); for (var i = items.length - 1; i > -1; i--) { items[i].className = items[i].className.replace(/last/, ""); addListener(items[i], "mouseover", handleMouseover, false); addListener(items[i], "mouseout", handleMouseout, false); } } else { parent.className = "select-styler-expanded"; var items = parent.getElementsByTagName("li"); items[items.length - 1].className = "last"; for (var i = items.length - 1; i > -1; i--) { removeListener(items[i], "mouseover", handleMouseover, false); removeListener(items[i], "mouseout", handleMouseover, false); } } var items = parent.getElementsByTagName("li"); var ilen = items.length; for (var i = 0; i < ilen; i++) { if (items[i] == node) { parent.select.selectedIndex = i; } items[i].className = ""; } node.className = "select-styler-active"; parent.expanded = !parent.expanded; //SelectStyler.prototype.changeProp2(node); }; var olen = this.lists.length; for (var i = 0; i < olen; i++) { var list = this.lists[i]; list.select = this.selects[i]; var items = list.getElementsByTagName("li"); var ilen = items.length; for (var j = 0; j < ilen; j++) { addListener(items[j], "click", handleClick, false); } } }; SelectStyler._I = 1; } this.init(); }; function SelectStyler2() { this.selects = []; if (!SelectStyler2._I) { SelectStyler2.prototype.init = function() { var bd = new BrowserDetector(); if (bd.isIE()) { this.selects = getElementsByClassName(document.body, "long-select", "select"); this.redo(); this.listen(); } }; SelectStyler2.prototype.redo = function() { var slen = this.selects.length; for (var i = 0; i < slen; i++) { var select = this.selects[i]; var height = select.offsetHeight; var parent = select.parentNode; var div = document.createElement("div"); var prop = document.createElement("div"); var propStyle = getStyle(prop); propStyle.height = [height, "px"].join(""); var clear = document.createElement("div"); var clearStyle = getStyle(clear); clearStyle.display = "inline"; addClass(div, "ie-select-div"); div.appendChild(prop); div.appendChild(parent.removeChild(select)); div.appendChild(clear); parent.appendChild(div); } }; SelectStyler2.prototype.listen = function() { var hideSelects = function(node) { var width = node.offsetWidth; var height = node.offsetHeight; var selects = document.getElementsByTagName("select"); } var handleMousedown = function(e) { e = e || window.event; var node = e.target || e.srcElement; node.expanded = !node.expanded; var style = getStyle(node); style.width = "auto"; addListener(node, "click", handleClick, false); }; var handleChange = function(e) { e = e || window.event; var node = e.target || e.srcElement; var style = getStyle(node); style.width = [node.width, "px"].join(""); removeListener(node, "click", handleClick, false); }; var handleClick = function(e) { e = e || window.event; var node = e.target || e.srcElement; var style = getStyle(node); if (node.expanded) { style.width = "auto"; } else { style.width = [node.width, "px"].join(""); } }; var slen = this.selects.length; for (var i = 0; i < slen; i++) { var select = this.selects[i]; select.expanded = false; select.width = select.offsetWidth; addListener(select, "mousedown", handleMousedown, false); addListener(select, "change", handleChange, false); } }; } this.init(); }; var windowLoad = function() { var functions = [ Followupper, Expander, //SelectStyler, SelectStyler2, Roller, Martyr, Grapher, RatingsRetriever, Logout, HelpListener, ZipListener, CpniListener, ClickLearn, BigImage, FocusSearch, Printer, PrintFriendlyListener, LinkDisabler, AutoTabber, FormResetter, FormListener, pinListener, resetPinListener, Popup, Review, Grandfather, setup_flyoutmakers ]; for (var i in functions) { new functions[i](); } }; addListener(window, "load", windowLoad, false);