﻿$j(document).ready(function () {


    //makes entire button div clickable to href of inner A tag
    $j(".navItemContainer > a").each(function (i, el) {
        var href = $j(el).attr("href");
        $j(el).closest("div").click(function () {
            window.location = href;
        });
    });



    $j('.activeListItem').toggle(
                function () {
                    $j('.activeListItem').next().children(0).slideUp('fast');
                },
                function () {
                    $j('.activeListItem').next().children(0).slideDown('fast');
                }
            );
    $j('.railListItem').mouseover(function () {
        $j(this).addClass('activeListRailItem');
    });
    $j('.railListItem').mouseout(function () {
        $j(this).removeClass('activeListRailItem');
    });

    $j('.railListInnerItem').mouseover(function () {
        $j(this).addClass('activeListRailItemInner');
    });

    $j('.railListInnerItem').mouseout(function () {
        $j(this).removeClass('activeListRailItemInner');
    });
    $j('.railListInnerItemChildren li.regularFont').mouseover(function () {
        $j(this).addClass('railInnerItemChildHover');
    });
    $j('.railListInnerItemChildren li.regularFont').mouseout(function () {
        $j(this).removeClass('railInnerItemChildHover');
    })
    $j('.railDDContainer').toggle(
                function () {
                    $j(this).next().hide();
                    $j('.activeRailDDNav div.arrowBlueUp', this).addClass('arrowBlueDn');
                    $j('.activeRailDDNav div.arrowBlueDn', this).removeClass('arrowBlueUp');
                    $j(this).css('margin-bottom', '20px');
                },
                function () {
                    $j(this).next().show();
                    $j('.activeRailDDNav div.arrowBlueDn', this).addClass('arrowBlueUp');
                    $j('.activeRailDDNav div.arrowBlueUp', this).removeClass('arrowBlueDn');
                    $j(this).css('margin-bottom', '0px');
                }
            );

    $j('.activeRailInnerDDNav').toggle(
                function () {
                    $j(this).next().hide();
                    $j('div.arrowBlueSmlUp', this).addClass('arrowBlueSmlDn');
                    $j('div.arrowBlueSmlDn', this).removeClass('arrowBlueSmlUp');
                },
                function () {
                    $j(this).next().show();
                    $j('div.arrowBlueSmlDn', this).addClass('arrowBlueSmlUp');
                    $j('div.arrowBlueSmlUp', this).removeClass('arrowBlueSmlDn');
                }
            );
    $j('.contentSectionInner div.expandUp, .contentSectionInner div.expandDn').click(function () {
        if ($j(this).attr('class') == 'expandUp') {
            $j(this).next().next().slideUp('fast');
            $j(this).removeClass('expandUp');
            $j(this).addClass('expandDn');
        } else {
            $j(this).next().next().slideDown('fast');
            $j(this).removeClass('expandDn');
            $j(this).addClass('expandUp');
        }
    });

    $j('.saveCartButton a').overlay({
        top: 150,
        closeOnClick: false,
        onClose: function (event) {
            var modalCloseButton = $j('.modalCloseButton').length;
            if (modalCloseButton != 0) {
                location.reload();
            }
        },
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });

    $j('.getDepositReq a').overlay({
        top: 10,
        closeOnClick: false,
        onClose: function (event) {
            var modalCloseButton = $j('.modalCloseButton').length;
            if (modalCloseButton != 0) {
                location.reload();
            }
        },
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });

    $j('.comingSoonButton a').overlay({
        top: 90,
        closeOnClick: false,
        onClose: function (event) {
            var thankyoupage = $j('.thankyou').length;
            if (thankyoupage != 0) {
                location = location.href.replace("notify=1", "notify=0");
            }
        },
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });

    $j('.removeAccountButton a').overlay({
        top: 150,
        closeOnClick: false,
        onClose: function (event) {
            var modalCloseButton = $j('.modalCloseButton').length;
            if (modalCloseButton != 0) {
                location.reload();
            }
        },
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });

    $j('a[rel="#modalPartnerPlan"]').overlay({
        top: 150,
        closeOnClick: false,
        onClose: function (event) {
            var modalCloseButton = $j('.modalCloseButton').length;
            if (modalCloseButton != 0) {
                location.reload();
            }
        },
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });
    $j('a[rel="#updateNotification"]').overlay({
        top: 150,
        closeOnClick: false,
        mask: {
            color: '#807F83',
            loadSpeed: 200,
            opacity: 0.9,
            zIndex: 9999
        }
    });
});

function closeNotificationOverlay() {
    $j('a[rel="#updateNotification"]').overlay().close();
}
//setInterval("CallKeepAlive()", 300000);
//function CallKeepAlive() {
//    $j.post("/keepalive.aspx", null, function () {
//    });
//}
