﻿function ShowWindow() {
    document.getElementById("PopUpWin").style.display = "block";
    document.getElementById("InnerPopUp").style.display = "block";
}

function ClosePopUp() {
    document.getElementById("PopUpWin").style.display = "none";
    document.getElementById("InnerPopUp").style.display = "none";
}

function SetPopupText(textSwitch) {
    if (textSwitch == "1") {
        document.getElementById("PopUpText").innerHTML = "For the best browsing & shopping experience, we encourage you to log in.";
        document.getElementById("CancelX2").style.display = "block";
    }
    else if (textSwitch == "2") {
        document.getElementById("CancelX2").style.display = "none";
        document.getElementById("PopUpText").innerHTML = "Due to the size of your shopping cart, you must use an account to continue.";
    }
}

var cartPopUpPostBack = false;

$(document).ready(function () {

    // this is for updating the location of the top menu if window is resized
    $(window).resize(function () {
        if ($('#topNav').css('position') == "fixed") {
            var windowWidth = $(window).width();
            var menuDiv = document.getElementById("header");
            var coordinates = findPos(menuDiv);
            var menuWidth = $("#topNav").width();
            var correctWidth = (parseInt(coordinates[0]));
            if (self.pageYOffset > 5 || document.documentElement.scrollTop > 5) {
                $('#topNav').css('right', correctWidth);
            } else if (self.pageYOffset < 5 || document.documentElement.scrollTop < 5) {
                $('#topNav').css('position', 'absolute');
                $('#topNav').css('right', 0);
            }
        }
    });

    // call the plugin on the desired form
    $("#aspnetForm").slideLock({

        // set the options - all are given, not all are required
        labelText: "Slide to Unlock:",
        noteText: "Proves you're human :)",
        lockText: "Locked",
        unlockText: "Unlocked",
        iconURL: "/Images/chrome/arrow_right.png",
        inputID: "sliderInput",
        onCSS: "#333",
        offCSS: "#aaa",
        inputValue: 1,
        saltValue: 9,
        checkValue: 10,
        js_check: "js_check",
        submitID: "#ctl00_Feedback1_Submit"
    });

    //Examples of how to assign the ColorBox event to elements
    $("a[rel='lightbox']").colorbox({ opacity: ".6" }); //all links with rel='lightbox' and image as child apply to this, background gets .6 opacity for body

});

// the following function is called if cookie is set from verticalmenu.cs
// it makes all the triangles for parent menu items show a drop down triangle if parent is expanded
function showExpandedArrowsDown() {
    var node = ob_getFirstNodeOfTree();
    while (node != null) {
        if (ob_hasChildren(node)) {
            var dropDownElement = $(node.firstChild.firstChild);
            dropDownElement.removeClass('menuBulletDown');
            dropDownElement.addClass('menuBullet');
        }
        node = ob_getNodeDown(node, false);
    }

    var allExpandedNodesList = ob_getExpanded(null, false); // gets all expanded id's from menu
    var arrayIds = allExpandedNodesList.split(",");
    for (i = 0; i < arrayIds.length; i++) {
        if (arrayIds[i] != "") {
            var dropDownElement = $(document.getElementById(arrayIds[i]).firstChild.firstChild);
            dropDownElement.removeClass('menuBullet').addClass('menuBulletDown');
        }
    }
}
