function Media(a) { var c = document.getElementById("videoWrapper"); if (c == null) { return } var b = document.getElementById("overlay"); if (b == null) { return } if (a) { b.style.display = "none"; HidePlayer() } else { b.style.display = "block" } } function HidePlayer() { var b = document.getElementById("mainImage"); if (b == null) { return } b.style.display = "block"; var a = document.getElementById("videoWrapper"); if (a == null) { return } a.style.display = "none"; a.innerHTML = "<div id='mainVideo'></div>" } function PlayYouTube() { var d = document.getElementById("mainImage"); if (d == null) { return } d.style.display = "none"; var c = document.getElementById("videoWrapper"); if (c == null) { return } c.style.display = "block"; var a = document.getElementById("youtubeUrl"); var b = "http://www.youtube.com/v/" + a.value + "&autoplay=1&rel=0"; swfobject.embedSWF(b, "mainVideo", "240", "240", "9.0.0") } function StockChecker() { var d = document.getElementById("ctl00_ContentBody_prod_ddl"); if (d != null) { var b = d.value; if (b == "OTS") { alert("We're sorry, the product you have selected is out of stock."); return false } } var c = document.getElementById("ctl00_ContentBody_prod_txtQuantity"); if (c == null) { return false } var a = c.value; if (a != "" && parseInt(a) < 1) { c.value = "1"; return true } return true } function OpenWindow(c, d) { var a = 620; var e = 550; if (d) { a = 260; e = 260 } var b = window.open(c, "GraphicWindow", "width=" + a + ",height=" + e + ",resizable=1,scrollbars=1") } function SwitchOverlay(c, b) { if (isIE6) { return } var a = document.getElementById("overlay"); if (c) { a.src = b + "youtube_overlay_hover.png" } else { a.src = b + "youtube_overlay.png" } } function __doPostBack(d, c) { }
function PopUp(d) {
    if (StockChecker()) {
        var c = document.createElement("div");
        c.id = "popupOverlay";
        document.body.appendChild(c);
        var a = "ctl00_ContentBody_prod_";
        var b = "/precart2.aspx?ITEM_ID=" + d;
        var optionImage = "";
        var prodDiv = document.getElementById("productItem");
        if (prodDiv != null) {
            var ddls = prodDiv.getElementsByTagName("select");
            if (ddls.length > 0) {
                var dropdown = ddls[0];
                var selected = dropdown.options[dropdown.selectedIndex].value;
                if (selected.indexOf("media") > 0) {
                    matchDropdown(dropdown);
                    var container = document.getElementById("mainImage");
                    if (container != null) {
                        var imgs = container.getElementsByTagName("img");
                        if (imgs.length > 0) {
                            var img = imgs[0];
                            optionImage = img.src;
                        }
                    }
                }
            }
        }

        new Ajax.Request(b, {
            method: "post",
            parameters: {
                ddl: (($(a + "ddl") == null) ? null : $(a + "ddl").value),
                txtQuantity: (($(a + "txtQuantity") == null) ? null : $(a + "txtQuantity").value),
                txtTitle: (($(a + "txtTitle") == null) ? null : $(a + "txtTitle").value),
                txtPersonalize: (($(a + "txtPersonalize") == null) ? null : $(a + "txtPersonalize").value),
                txtOptionImage: optionImage
            },
            onSuccess: function (e) {
                var f = new Window({
                    className: "dialog",
                    title: "",
                    recenterAuto: true,
                    top: 180,
                    height: 500,
                    width: 485,
                    resizable: false,
                    closable: false,
                    minimizable: false,
                    maximizable: false,
                    draggable: false,
                    showEffect: Effect.BlindDown,
                    hideEffect: Effect.SwitchOff,
                    showEffectOptions: { duration: 1.5}
                });
                f.setDestroyOnClose();
                f.setHTMLContent(e.responseText);
                f.setZIndex(1500); 
                f.showCenter();
                OmniFunction();
                RRFunction()
            }
        })
    }
} 
function PopUpEmail(d) { var c = document.createElement("div"); c.id = "popupOverlay"; document.body.appendChild(c); var a = "ctl00_ContentBody_prod_"; var b = "/emailBIS.aspx?ITEM_ID=" + d; new Ajax.Request(b, { method: "post", parameters: { ddl: (($(a + "ddl") == null) ? null : $(a + "ddl").value) }, onSuccess: function (e) { var f = new Window({ className: "dialog", title: "", recenterAuto: true, top: 180, height: 500, width: 485, resizable: false, closable: false, minimizable: false, maximizable: false, draggable: false, showEffect: Effect.BlindDown, hideEffect: Effect.SwitchOff, showEffectOptions: { duration: 1.5} }); f.setDestroyOnClose(); f.setHTMLContent(e.responseText); f.setZIndex(1500); f.showCenter() } }) } function CloseWindow() { var b = document.getElementById("popupOverlay"); if (b != null) { b.parentNode.removeChild(b) } Windows.closeAll(); var a = document.getElementById("ctl00_ContentBody_prod_txtQuantity"); if (a != null) { a.value = "" } } function disableEnterKey(f) { var b; if (window.event) { b = window.event.keyCode } else { b = f.which } if (b != 13) { return true } else { var d = location.pathname.substring(1); var a = d.indexOf("p/"); if (a > 0) { if (!isNaN(parseInt(d))) { var c = d.substring(0, a); PopUp(c); return false } } return false } } function getOmniEvents() { var b = "scAdd"; var a = document.getElementById("userHasCart"); if (a != null && a.innerHTML == "false") { b += ",scOpen" } return b } function flipMe(c) { var b = c.options[c.selectedIndex].text.toLowerCase(); var a = "out of stock"; if (b.indexOf(a) > 0) { document.getElementById("ATC").style.display = "none"; document.getElementById("NBS").style.display = "" } else { document.getElementById("ATC").style.display = ""; document.getElementById("NBS").style.display = "none" } } function SubmitBIS() { var a = "/BISThankyou.aspx"; new Ajax.Request(a, { method: "post", parameters: { txtEmail: (($("txtEmail") == null) ? null : $("txtEmail").value), chkOptIn: (($("chkOptIn") == null) ? null : $("chkOptIn").checked), hIID: (($("hIID") == null) ? null : $("hIID").value), hOID: (($("hOID") == null) ? null : $("hOID").value) }, onSuccess: function (d) { var i = document.getElementById("txtEmail"); var b = document.getElementById("optInSpan"); if (i != null) { var j = i.parentNode; var g = document.getElementsByTagName("h2")[0]; g.innerHTML = "Thank You"; var e = document.createElement("p"); e.innerHTML = "You will be notified when the product comes back in stock."; e.style.color = "#000000"; j.insertBefore(g, i); j.insertBefore(e, i); j.removeChild(i); j.removeChild(b); var h = j.getElementsByTagName("div"); if (h != null) { h = h[0]; if (h != null) { var k = h.getElementsByTagName("a"); if (k != null) { var f = k[0]; var c = k[1]; if (f != null) { f.innerHTML = f.innerHTML.replace("Cancel", "Close") } if (c != null) { c.parentNode.removeChild(c) } } } } } }, onFailure: function (d) { var c = document.getElementById("txtEmail"); if (c != null) { var e = c.parentNode; var f = document.createElement("h3"); f.innerHTML = "We're Sorry"; f.style.color = "#000000"; var b = document.createElement("p"); b.innerHTML = "There was an error processing your request.  Please try again later."; b.style.color = "#000000" } } }) };


function changeTab(sender) {
    if (sender.id != "selectedTab") {
        var current = document.getElementById("selectedTab");
        if (current != null) {
            current.id = "";
            var hiding = document.getElementById(current.className);
            if (hiding != null) {
                hiding.style.display = "none";
            }
        }

        var clicked = document.getElementById(sender.className);
        if (clicked != null) {
            clicked.style.display = "block";
        }
        sender.id = "selectedTab";
    }
}
function selectTab(tabClass, header) {
    var current = document.getElementById("selectedTab");
    var headers = current.parentNode.getElementsByTagName("h3");
    for (var i = 0; i < headers.length; i++) {
        if (headers[i].className == tabClass) {
            changeTab(headers[i]);
        }
    }
    window.location.href = header;
}
function readReviews() {
    selectTab("reviewTab", "#ReviewHeader");
}
function readQuestions() {
    selectTab("qaTab", "#QAHeader");
}
function selectItem(sender) {
    if (sender != null && sender.innerHTML != null) {
        var current = document.getElementById("selectedicon");
        while (current != null) {
            current.id = "";
            current = document.getElementById("selectedicon");
        }
        sender.id = "selectedicon";
        matchImage(sender);
    }
}
function runFlash(sender, url, height, width) {
    selectItem(sender);
    var flash = document.createElement("div");
    flash.id = "flashcontainer";
    var container = document.getElementById("mainImage");
    if (container == null) { return; }
    container.innerHTML = "";
    container.appendChild(flash);

    swfobject.embedSWF(url, "flashcontainer", width, height, "9.0.0", null, null, { wmode: "transparent" });
}
function loadImage(sender, detailId) {
    selectItem(sender);
    var p = null;
    var link = document.createElement("a");
    var img = document.createElement("img");
    var detail = document.getElementById("detail" + detailId);
    var container = document.getElementById("mainImage");
    if (container == null) { return; }
    container.innerHTML = "";
    if (detail != null) {
        img.src = detail.value;
    }
    detail = document.getElementById("detailalt" + detailId);
    if (detail != null) {
        img.alt = detail.value;
    }
    var zoomId = document.getElementById("zoom" + detailId);
    if (zoomId != null && zoomId.value != "") {
        var zoom = document.getElementById("zoom" + zoomId.value);
        if (zoom != null) {
            link.onclick = function () { window.open(zoom.value, 'zoomimage', 'height=750,width=750,toolbar=0,menubar=0,location=0'); };
            link.style.cursor = "pointer";
            p = document.createElement("p");
            p.innerHTML = "Click on image to zoom";
        }
    }
    link.appendChild(img);
    container.appendChild(link);
    if (p != null) {
        container.appendChild(p);
    }
}
function playYouTube(sender, url, height, width) {
    var path = "http://www.youtube.com/v/" + url + "&autoplay=1&rel=0";
    runFlash(sender, path, height, width);
}
function initiateFirstImage() {
    var mainImage = document.getElementById("mainImage");
    if (mainImage == null) { return; }
    var parent = mainImage.parentNode;
    if (parent == null) { return; }
    var divs = parent.getElementsByTagName("div");
    if (divs.length > 1) {
        var gallery = divs[1];
        if (gallery != null && gallery.className == "gallery") {
            var first = gallery.getElementsByTagName("a")[0];
            if (first != null) {
                var action = first.onclick;
                try {
                    action();
                }
                catch (e) {
                    var fnc = new Function(action);
                    fnc();
                }
                first.id = "selectedicon";
                var prodDiv = document.getElementById("productItem");
                if (prodDiv != null) {
                    var ddls = prodDiv.getElementsByTagName("select");
                    if (ddls.length > 0) {
                        var dropdown = ddls[0];
                        dropdown.onchange = function(){ matchDropdown(dropdown);};
                    }
                }
            }
        }
    }
}
function matchImage(sender) {
    var parent = sender.parentNode;
    var id = parent.id.replace("mg", "");
    var prodDiv = document.getElementById("productItem");
    if (prodDiv != null) {
        var ddls = prodDiv.getElementsByTagName("select");
        if (ddls.length > 0) {
            var dropdown = ddls[0];
            var index = getDDLIndex(dropdown, id);
            if(index > -1) {
                dropdown.onchange = null;
                dropdown.selectedIndex = index;
                dropdown.onchange = function(){ matchDropdown(dropdown);};
            }
        }
    }
}
function getDDLIndex(ddl, id) {
    for (var i = 0; i < ddl.options.length; i++) {
        var value = parseValue(ddl.options[i].value);
        if (value.length > 0) {
            if (value == id) {
                return i;
            }
        }
    }
    return -1;
}
function parseValue(original) {
    if (original.indexOf("media") > -1) {
        var parts = original.split('~');
        for(var i = 0; i < parts.length; i++) {
            var item = parts[i];
            if (item.indexOf("media") > -1) {
                var value = item.replace("media", "");
                return value;
            }
        }
    }
    return "";
}
function matchDropdown(sender) {
    var selected = sender.options[sender.selectedIndex].value;
    var value = parseValue(selected);
    if(value.length > 0) {
        var current = document.getElementById("mg" + value);
        if(current != null) {
            var links = current.getElementsByTagName("a");
            if (links.length > 0) {
                var current = document.getElementById("selectedicon");
                if (current != null) {
                    current.id = "";
                }
                var action = links[0].onclick;
                try {
                    action();
                }
                catch (e) {
                    var fnc = new Function(action);
                    fnc();
                }
                links[0].id = "selectedicon";
            }
        }
    }
}
