﻿function Media2() {
    var div = document.getElementById("videoWrapper");
    if (div == null) {
        return;
    }
    //div.style.display = "block";
    var overlay = document.getElementById("overlay");
    if (overlay == null) {
        return;
    }
    if (overlay.style.display != "none") {
        overlay.style.display = "none";
    }
    else {
        overlay.style.display = "block";
    }
}
function Media(bool) {
    var div = document.getElementById("videoWrapper");
    if (div == null) {
        return;
    }
    var overlay = document.getElementById("overlay");
    if (overlay == null) {
        return;
    }
    if (bool) {
        overlay.style.display = "none";
        HidePlayer();
    }
    else {
        overlay.style.display = "block";
    }
}
function HidePlayer() {
    var div = document.getElementById("mainImage");
    if (div == null) {
        return;
    }
    div.style.display = "block";
    var flash = document.getElementById("videoWrapper");
    if (flash == null) {
        return;
    }
    flash.style.display = "none";
    flash.innerHTML = "<div id='mainVideo'></div>";
}
function PlayYouTube() {
    var div = document.getElementById("mainImage");
    if (div == null) {
        return;
    }
    div.style.display = "none";
    var flash = document.getElementById("videoWrapper");
    if (flash == null) {
        return;
    }
    flash.style.display = "block";

    var input = document.getElementById("youtubeUrl");
    var url = "http://www.youtube.com/v/" + input.value + "&autoplay=1&rel=0";
    
    swfobject.embedSWF(url, "mainVideo", "240", "240", "9.0.0");
}
function StockChecker() {
    var ddl = document.getElementById("ctl00_ContentBody_prod_ddl");
    if (ddl != null) {
        var selected = ddl.value;
        if (selected == "OTS") {
            alert("We're sorry, the product you have selected is out of stock.");
            return false;
        }
    }
    var qty = document.getElementById("ctl00_ContentBody_prod_txtQuantity");
    if (qty == null) {
        return false;
    }
    var num = qty.value;
    if (num != "" && parseInt(num) < 1) {
        qty.value = "1";
        return true;
        //alert("Please input a valid quantity.");
        //return false;
    }
    return true;
}
function OpenWindow(url, small) {
    var x = 620;
    var y = 550;
    if (small) {
        x = 260;
        y = 260;
    }
    var gWin = window.open(url,'GraphicWindow','width='+x+',height='+y+',resizable=1,scrollbars=1');
}
function SwitchOverlay(hovering, imagepath) {
    if (isIE6) {
        return;
    }
    var overlay = document.getElementById("overlay");
    if (hovering) {
        overlay.src = imagepath + "youtube_overlay_hover.png";
    }
    else {
        overlay.src = imagepath + "youtube_overlay.png";
    }
}
function PopUp(id) {
    if (StockChecker()) {
        var div = document.createElement("div");
        div.id = "popupOverlay";
        document.body.appendChild(div);
        var container = "ctl00_ContentBody_prod_";
        var url = "/precart2.aspx?ITEM_ID=" + id;

        new Ajax.Request(url,
        {
            method: 'post',
            parameters: {
                "ddl": (($(container + "ddl") == null) ? null : $(container + "ddl").value),
                "txtQuantity": (($(container + "txtQuantity") == null) ? null : $(container + "txtQuantity").value),
                "txtTitle": (($(container + "txtTitle") == null) ? null : $(container + "txtTitle").value),
                "txtPersonalize": (($(container + "txtPersonalize") == null) ? null : $(container + "txtPersonalize").value)
            },
            onSuccess: function(response) {
                var win = 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 }
                });
                win.setDestroyOnClose();
                win.setHTMLContent(response.responseText);
                win.setZIndex(1500);
                win.showCenter();
                OmniFunction();
                RRFunction();
            }
        });
    }
}
function CloseWindow() {
    var div = document.getElementById("popupOverlay");
    if (div != null) {
        div.parentNode.removeChild(div);
    }
    Windows.closeAll();
}