﻿$(document).ready(function () {

    //SIDE NAV -----------------------------------
    //HIDE ALL 
    $('.s2Nav').hide();
    $('.s3Nav').hide();

    if ($('.s3').hasClass('active')) {
        var s3Nav = $('.active').parent('.s3Nav');
        var s2Nav = $(s3Nav).parent('.s2Nav');
        $(s2Nav).show();
        $(s3Nav).show();

    } else if ($('.s2').hasClass('active')) {
        var s3Nav = $('.active').next('.s3Nav');
        var s2Nav = $('.active').parent('.s2Nav');
        $(s2Nav).show();
        $(s3Nav).slideDown(500);

    } else if ($('.active').length <= 0) {
        if ($('.s1.open').length >= 0)
            $('.s1.open').siblings('.s2Nav').show();

        if ($('.s2.open').length >= 0)
            $('.s2.open').next('.s3Nav').show();
    } else {
        $('.active').next('.s2Nav').slideDown(500);
    }

    //SIDE NAV END --------------------------------


    //MODAL
    //$("#sample").modal({ 
    //    opacity: 80,
    //    overlayCss: { backgroundColor: "#fff"},
    //    overlayClose: true
    //});

    // MAS - Alternate Rules table row colors
    $('#MAS_pageRules table tr:even').css("background-color", "#f7f0d8");
    $('#rules-table tr:even').css("background-color", "#f7f0d8");
    $('#ctl00_MainContent_gvCodes tr:even').css("background-color", "#f7f0d8");

    //MAS - Landing Page

    $('#extraCodes input').each(function (index) {
        if ($(this).val() != "") {
            showCodes();
            return;
        }
    });


    $('#btn_addCode').click(function () {
        showCodes();
        return false;
    });
    $('#sweepstakes_form input[type="text"]').addClass('typeText');


    function showCodes() {
        $('#extraCodes').show(500);
        $('#btn_addCode').fadeOut(300);
    }


    /* PRIVACY MODAL */
    $('#btn_privacy').hover(function () {
        $('#privacyModal').stop(true,true).fadeIn(300);
    }, function () {
        //$('#privacyModal').fadeOut(400);
    });

    $('#privacyModal,#btn_privacy').hover(function () {

    }, function () {
        $('#privacyModal').stop(true, true).delay(300).fadeOut(300);
    });

});
