/* Minification failed. Returning unminified contents.
(4,13): run-time error CSS1031: Expected selector, found '='
(4,13): run-time error CSS1025: Expected comma or open brace, found '='
(60,10): run-time error CSS1031: Expected selector, found 'QA2Next('
(60,10): run-time error CSS1025: Expected comma or open brace, found 'QA2Next('
(81,10): run-time error CSS1031: Expected selector, found 'OpenFooter('
(81,10): run-time error CSS1025: Expected comma or open brace, found 'OpenFooter('
(89,10): run-time error CSS1031: Expected selector, found 'CloseFooter('
(89,10): run-time error CSS1025: Expected comma or open brace, found 'CloseFooter('
(107,10): run-time error CSS1031: Expected selector, found 'StopSound('
(107,10): run-time error CSS1025: Expected comma or open brace, found 'StopSound('
(117,10): run-time error CSS1031: Expected selector, found 'CancelSubmission('
(117,10): run-time error CSS1025: Expected comma or open brace, found 'CancelSubmission('
(128,10): run-time error CSS1031: Expected selector, found 'ShowIntermediateEfficacyDisplay('
(128,10): run-time error CSS1025: Expected comma or open brace, found 'ShowIntermediateEfficacyDisplay('
(136,10): run-time error CSS1031: Expected selector, found 'CancelEfficacyIntermediate('
(136,10): run-time error CSS1025: Expected comma or open brace, found 'CancelEfficacyIntermediate('
(149,10): run-time error CSS1031: Expected selector, found 'ShowEfficacyDisplay('
(149,10): run-time error CSS1025: Expected comma or open brace, found 'ShowEfficacyDisplay('
(179,10): run-time error CSS1031: Expected selector, found 'ShowDialog('
(179,10): run-time error CSS1025: Expected comma or open brace, found 'ShowDialog('
(205,10): run-time error CSS1031: Expected selector, found 'ShowReferencesDialog('
(205,10): run-time error CSS1025: Expected comma or open brace, found 'ShowReferencesDialog('
(210,10): run-time error CSS1031: Expected selector, found 'CompleteRequest('
(210,10): run-time error CSS1025: Expected comma or open brace, found 'CompleteRequest('
(215,10): run-time error CSS1031: Expected selector, found 'SubmitRequestForm('
(215,10): run-time error CSS1025: Expected comma or open brace, found 'SubmitRequestForm('
(235,10): run-time error CSS1031: Expected selector, found 'ShowSubmissionForm('
(235,10): run-time error CSS1025: Expected comma or open brace, found 'ShowSubmissionForm('
(241,10): run-time error CSS1031: Expected selector, found 'ShowRequestConfirmation('
(241,10): run-time error CSS1025: Expected comma or open brace, found 'ShowRequestConfirmation('
(251,10): run-time error CSS1031: Expected selector, found 'ShowSafetyInformation('
(251,10): run-time error CSS1025: Expected comma or open brace, found 'ShowSafetyInformation('
(278,10): run-time error CSS1031: Expected selector, found 'AdjustBody('
(278,10): run-time error CSS1025: Expected comma or open brace, found 'AdjustBody('
(292,10): run-time error CSS1031: Expected selector, found 'OnLoad('
(292,10): run-time error CSS1025: Expected comma or open brace, found 'OnLoad('
(297,10): run-time error CSS1031: Expected selector, found 'OnResize('
(297,10): run-time error CSS1025: Expected comma or open brace, found 'OnResize('
(328,27): run-time error CSS1031: Expected selector, found '='
(328,27): run-time error CSS1025: Expected comma or open brace, found '='
(330,10): run-time error CSS1031: Expected selector, found 'FitMenu('
(330,10): run-time error CSS1025: Expected comma or open brace, found 'FitMenu('
(368,10): run-time error CSS1031: Expected selector, found 'OpenForm('
(368,10): run-time error CSS1025: Expected comma or open brace, found 'OpenForm('
(374,10): run-time error CSS1031: Expected selector, found 'OpenISI('
(374,10): run-time error CSS1025: Expected comma or open brace, found 'OpenISI('
(388,23): run-time error CSS1031: Expected selector, found '='
(388,23): run-time error CSS1025: Expected comma or open brace, found '='
(389,19): run-time error CSS1031: Expected selector, found ';'
(389,19): run-time error CSS1025: Expected comma or open brace, found ';'
(390,10): run-time error CSS1031: Expected selector, found 'RunISIScroller('
(390,10): run-time error CSS1025: Expected comma or open brace, found 'RunISIScroller('
(421,10): run-time error CSS1031: Expected selector, found 'CloseISI('
(421,10): run-time error CSS1025: Expected comma or open brace, found 'CloseISI('
(438,10): run-time error CSS1031: Expected selector, found 'FillDoctorInformation('
(438,10): run-time error CSS1025: Expected comma or open brace, found 'FillDoctorInformation('
(469,10): run-time error CSS1031: Expected selector, found 'FillCardInformation('
(469,10): run-time error CSS1025: Expected comma or open brace, found 'FillCardInformation('
(485,10): run-time error CSS1031: Expected selector, found 'CloseWordfinderDrawer('
(485,10): run-time error CSS1025: Expected comma or open brace, found 'CloseWordfinderDrawer('
(495,10): run-time error CSS1031: Expected selector, found 'OpenWordfinderDrawer('
(495,10): run-time error CSS1025: Expected comma or open brace, found 'OpenWordfinderDrawer('
(504,10): run-time error CSS1031: Expected selector, found 'ExecutePresentation('
(504,10): run-time error CSS1025: Expected comma or open brace, found 'ExecutePresentation('
(564,10): run-time error CSS1031: Expected selector, found 'LoadSection('
(564,10): run-time error CSS1025: Expected comma or open brace, found 'LoadSection('
(586,10): run-time error CSS1031: Expected selector, found 'CopyElementData('
(586,10): run-time error CSS1025: Expected comma or open brace, found 'CopyElementData('
(615,10): run-time error CSS1031: Expected selector, found 'SaveTrace('
(615,10): run-time error CSS1025: Expected comma or open brace, found 'SaveTrace('
(640,10): run-time error CSS1031: Expected selector, found 'SaveUrlTrace('
(640,10): run-time error CSS1025: Expected comma or open brace, found 'SaveUrlTrace('
(651,10): run-time error CSS1031: Expected selector, found 'SaveAnswerTrace('
(651,10): run-time error CSS1025: Expected comma or open brace, found 'SaveAnswerTrace('
(665,19): run-time error CSS1031: Expected selector, found '='
(665,19): run-time error CSS1025: Expected comma or open brace, found '='
(666,16): run-time error CSS1031: Expected selector, found '='
(666,16): run-time error CSS1025: Expected comma or open brace, found '='
(669,10): run-time error CSS1031: Expected selector, found 'GetILMState('
(669,10): run-time error CSS1025: Expected comma or open brace, found 'GetILMState('
(678,10): run-time error CSS1031: Expected selector, found 'SetILMState('
(678,10): run-time error CSS1025: Expected comma or open brace, found 'SetILMState('
(683,10): run-time error CSS1031: Expected selector, found 'SetAndExecuteState('
(683,10): run-time error CSS1025: Expected comma or open brace, found 'SetAndExecuteState('
(687,10): run-time error CSS1031: Expected selector, found 'IncrementAndExecuteState('
(687,10): run-time error CSS1025: Expected comma or open brace, found 'IncrementAndExecuteState('
(693,10): run-time error CSS1031: Expected selector, found 'DecrementAndExecuteState('
(693,10): run-time error CSS1025: Expected comma or open brace, found 'DecrementAndExecuteState('
(701,10): run-time error CSS1031: Expected selector, found 'LoadAndPlayAudio('
(701,10): run-time error CSS1025: Expected comma or open brace, found 'LoadAndPlayAudio('
(718,10): run-time error CSS1031: Expected selector, found 'AudioFinished('
(718,10): run-time error CSS1025: Expected comma or open brace, found 'AudioFinished('
(733,10): run-time error CSS1031: Expected selector, found 'ToggleMute('
(733,10): run-time error CSS1025: Expected comma or open brace, found 'ToggleMute('
(742,15): run-time error CSS1031: Expected selector, found '='
(742,15): run-time error CSS1025: Expected comma or open brace, found '='
(743,19): run-time error CSS1031: Expected selector, found '='
(743,19): run-time error CSS1025: Expected comma or open brace, found '='
(744,18): run-time error CSS1031: Expected selector, found '='
(744,18): run-time error CSS1025: Expected comma or open brace, found '='
(745,14): run-time error CSS1031: Expected selector, found '='
(745,14): run-time error CSS1025: Expected comma or open brace, found '='
(746,10): run-time error CSS1031: Expected selector, found 'InitDynamicMenus('
(746,10): run-time error CSS1025: Expected comma or open brace, found 'InitDynamicMenus('
(871,10): run-time error CSS1031: Expected selector, found 'ShowSafetyInfo('
(871,10): run-time error CSS1025: Expected comma or open brace, found 'ShowSafetyInfo('
(878,10): run-time error CSS1031: Expected selector, found 'IsMobile('
(878,10): run-time error CSS1025: Expected comma or open brace, found 'IsMobile('
(888,28): run-time error CSS1031: Expected selector, found '='
(888,28): run-time error CSS1025: Expected comma or open brace, found '='
(900,18): run-time error CSS1031: Expected selector, found '='
(900,18): run-time error CSS1025: Expected comma or open brace, found '='
(913,10): run-time error CSS1031: Expected selector, found 'getCookie('
(913,10): run-time error CSS1025: Expected comma or open brace, found 'getCookie('
(946,18): run-time error CSS1031: Expected selector, found '='
(946,18): run-time error CSS1025: Expected comma or open brace, found '='
(947,30): run-time error CSS1031: Expected selector, found '='
(947,30): run-time error CSS1025: Expected comma or open brace, found '='
(948,27): run-time error CSS1031: Expected selector, found '='
(948,27): run-time error CSS1025: Expected comma or open brace, found '='
(949,20): run-time error CSS1031: Expected selector, found '='
(949,20): run-time error CSS1025: Expected comma or open brace, found '='
(950,18): run-time error CSS1031: Expected selector, found '='
(950,18): run-time error CSS1025: Expected comma or open brace, found '='
(951,15): run-time error CSS1031: Expected selector, found '='
(951,15): run-time error CSS1025: Expected comma or open brace, found '='
(954,10): run-time error CSS1031: Expected selector, found 'SelectCard('
(954,10): run-time error CSS1025: Expected comma or open brace, found 'SelectCard('
(999,10): run-time error CSS1031: Expected selector, found 'CoverCards('
(999,10): run-time error CSS1025: Expected comma or open brace, found 'CoverCards('
(1014,10): run-time error CSS1031: Expected selector, found 'GetGameState('
(1014,10): run-time error CSS1025: Expected comma or open brace, found 'GetGameState('
(1027,10): run-time error CSS1031: Expected selector, found 'ResumeGameState('
(1027,10): run-time error CSS1025: Expected comma or open brace, found 'ResumeGameState('
(1040,10): run-time error CSS1031: Expected selector, found 'FinishCard('
(1040,10): run-time error CSS1025: Expected comma or open brace, found 'FinishCard('
(1062,8): run-time error CSS1031: Expected selector, found '='
(1062,8): run-time error CSS1025: Expected comma or open brace, found '='
(1063,10): run-time error CSS1031: Expected selector, found 'ResetMaitrix('
(1063,10): run-time error CSS1025: Expected comma or open brace, found 'ResetMaitrix('
(1102,10): run-time error CSS1031: Expected selector, found 'AnimateCards('
(1102,10): run-time error CSS1025: Expected comma or open brace, found 'AnimateCards('
(1124,10): run-time error CSS1031: Expected selector, found 'ContinueGame('
(1124,10): run-time error CSS1025: Expected comma or open brace, found 'ContinueGame('
(1171,10): run-time error CSS1031: Expected selector, found 'GetFlippedCardCount('
(1171,10): run-time error CSS1025: Expected comma or open brace, found 'GetFlippedCardCount('
(1192,10): run-time error CSS1031: Expected selector, found 'SaveGameStateToSubmitForm('
(1192,10): run-time error CSS1025: Expected comma or open brace, found 'SaveGameStateToSubmitForm('
(1204,10): run-time error CSS1031: Expected selector, found 'FlipCard('
(1204,10): run-time error CSS1025: Expected comma or open brace, found 'FlipCard('
(1217,10): run-time error CSS1031: Expected selector, found 'ProcessMatch('
(1217,10): run-time error CSS1025: Expected comma or open brace, found 'ProcessMatch('
(1332,10): run-time error CSS1031: Expected selector, found 'SetGlow('
(1332,10): run-time error CSS1025: Expected comma or open brace, found 'SetGlow('
 */
//DRL_SERVER <-- search on this to change between server and local 
//var baseURL = '/ValchlorILM'
//drllocal
var baseURL = ''




function AnswerQ2() {


    //if (sessionStorage.getItem('Answer2') == null || sessionStorage.getItem('Answer2') == 'undefined') {
    //    // at the start...
    //    sessionStorage.setItem('Answer2', '0');
    //}
    //var answ2 = parseInt(sessionStorage.getItem('Answer2'));
    var answ2 = 0;

    // var sliderVal = $("#bsa").val();
    var sliderVal = parseInt($("#bsa").val());
    if (sliderVal < 1 || sliderVal > 61) {
        answ2 |= 0x01;
        //window.location.href = baseURL + "/IdentifyQA2Incorrect1";
        //$('#menu-buttons').show();
        //return;
    }

    if ($('#qa2cb1')[0].checked || !$('#qa2cb2')[0].checked) {
        answ2 |= 0x02;
        //window.location.href = baseURL + "/IdentifyQA2Incorrect2";
        //$('#menu-buttons').show();
        //return;
    }



    // Both questions were answered correctly
    if (answ2 == 0) {
        window.location.href = baseURL + "/IdentifyQA2Correct";
        $('#menu-buttons').show();
        return;
    }

    // Store the state of the question's 2 answers
    sessionStorage.setItem('Answer2', answ2);

    if ((answ2 & 0x01) == 0x01) {
        window.location.href = baseURL + "/IdentifyQA2Incorrect1";
        $('#menu-buttons').show();
        return;
    }
    else if ((answ2 & 0x02) == 0x02) {
        window.location.href = baseURL + "/IdentifyQA2Incorrect2";
        $('#menu-buttons').show();
    }

}


function QA2Next() {

    if (sessionStorage.getItem('Answer2') == null || sessionStorage.getItem('Answer2') == 'undefined') {
        // Do nothing...
        return;
    }

    var answ2 = parseInt(sessionStorage.getItem('Answer2'));
    if ((answ2 & 0x02) == 0x02) {

        window.location.href = baseURL + "/IdentifyQA2Incorrect2";
        $('#menu-buttons').show();
        return;

    }

    window.location.href = baseURL + "/Treat";
    $('#menu-buttons').show();
}


function OpenFooter() {
    $(".footerExpand").css("display", "none");
    $(".footerClose").css("display", "block");
    $(".footerISI").css("height", "100%");
    $(".footerISI").show("slow");

}

function CloseFooter() {
    $(".footerExpand").css("display", "block");
    $(".footerClose").css("display", "none");
    $(".footerISI").css("height", "165px");
    $(".footerISI").show("slow");

}











function StopSound()
{
    var it = document.getElementById("audio-player");
    it.pause();
    it.currentTime = 0;
}




function CancelSubmission()
{
    //$('#submission-form').modal('hide');
    //$('body').removeClass('modal-open');
    //$('.modal-backdrop').remove();
    StopSound();
}



// display efficacy data at each word found
function ShowIntermediateEfficacyDisplay() {

    ShowDialog('efficacy-display-intermediate', baseURL + '/_EfficacyInfoIntermediate');
   // ShowDialog('efficacy-display', baseURL + '/_EfficacyInfo');


}

function CancelEfficacyIntermediate() {

    $('#efficacy-display-intermediate').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();


}




// display efficacy data at end of wordfinder game
function ShowEfficacyDisplay() {

    $('#menu-efficacy').addClass("nav-selected");

    var modalDescription = 'efficacy-display';

    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/_EfficacyInfo',
        type: 'GET',
        //   contentType: 'application/json; charset=utf-8',
        //data: '',
        success: function (dataObject) {
            $('#dynamic_modals').html(dataObject);
            $('#' + modalDescription).modal(
                {
                    backdrop: 'static',
                    //  keyboard: false
                }).on("hidden.bs.modal", function (event, ui) {
                    $('#' + modalDescription).remove();
                    $('body').removeClass('modal-open');
                  //  StopSound();
                });
            //  window.location.href = '#' + modalDescription;

        }
    });

}

function ShowDialog(modalDescription, url)
{
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: url,
        type: 'GET',
        //   contentType: 'application/json; charset=utf-8',
        //data: '',
        success: function (dataObject) {
            $('#dynamic_modals').html(dataObject);
            $('#' + modalDescription).modal(
                {
                    //backdrop: 'static',
                    //  keyboard: false
                }).on("hidden.bs.modal", function (event, ui) {
                    $('#' + modalDescription).remove();
                    $('body').removeClass('modal-open');
                   // StopSound();

                });
            //  window.location.href = '#' + modalDescription;

        }
    });
}

function ShowReferencesDialog() {

    ShowDialog('references-dialog', baseURL + '/References');
}

function CompleteRequest(form)
{
    SubmitRequestForm(form);
}

function SubmitRequestForm(form) {
    //form.submit(function () { var i = 9; console.log("hi"); });
    form.submit();
    //$("request-submission-form").submit(function () { alert('Eat Shit'); });

    return;
    //document.getElementById('').ch
    //var but = $('#request-submission-form');
    console.log('number of sub forms ' + form.length);
    if (form[0].checkValidity()) {
        console.log('passed validation');
        //    form.hide();
        //    form.submit();
         //setTimeout(ShowRequestConfirmation, 450);
        //  form.remove();
        return true;
    }
    console.log('failed validation');
    return false;
}
function ShowSubmissionForm() {

    console.log('show form');
    ShowDialog('submission-dialog', baseURL + '/SubmissionFormContainer');

}
function ShowRequestConfirmation() {

    // ensure the submission dialog is gone...(assuming that's where this was called from)
    $('#submission-form').modal('hide');
    $('body').removeClass('modal-open');
    $('.modal-backdrop').remove();
    ShowDialog('RequestConfirmation', baseURL + '/RequestConfirmation');

}

function ShowSafetyInformation() {
    var modalDescription = 'fullSafetyInfo';
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/SafetyInfo',
        type: 'GET',
        //   contentType: 'application/json; charset=utf-8',
        //data: '',
        success: function (dataObject) {
            $('#dynamic_modals').html(dataObject);
            $('#' + modalDescription).modal(
                {
                    //  backdrop: 'static',
                    //  keyboard: false
                }).on("hidden.bs.modal", function (event, ui) {
                    $('#' + modalDescription).remove();
                    $('body').removeClass('modal-open');
                    StopSound();
                });
            //  window.location.href = '#' + modalDescription;

        }
    });

}


function AdjustBody() {
    console.log("AdjustBody()")

    var tempHeight = $("#submit-partial").height();
    console.log("submit section height: " + tempHeight);

    tempHeight = $("#game-section").height();
    console.log("game section height: " + tempHeight);

    $("#submit-partial").css('height', tempHeight);
    //$("#submitform-partial").css('height', ($("#main-body-content").height() + 900) + 'px');

}

function OnLoad() {
    OnResize();
}


function OnResize()
{
    var docBody = $('body .container');
        var dWidth = docBody.innerWidth();
        var cardWidthFactor = 0;

    // Resize the card game
    var gameMaitrix = $('#game-maitrix');
    if (gameMaitrix.length > 0) {
        if (dWidth > 600) {
            cardWidthFactor = dWidth * .22;
        }
        else {
            cardWidthFactor = dWidth * .21;
        }
        //var dWidth = 60;
        $('.card').css('width', cardWidthFactor);
        $('.card').css('height', 1.18 * cardWidthFactor);
        $('.card-row').css('height', 1.2 * cardWidthFactor);
        $('.card-holder').css('margin-right', cardWidthFactor);
    }

    if (dWidth < 992)
    {

    }

    FitMenu(dWidth);

}

var lastValidMenuRowWidth = 0;

function FitMenu(dWidth) {
    var menuWidth;
    var totalWidth;
    if (dWidth < 768) {
        console.log('dWidth is:' + dWidth + 'px');
     //   return false;
    }
    totalWidth = $('#menu-row').width();
    if (totalWidth === undefined || totalWidth === null)
    {
        menuWidth = lastValidMenuRowWidth;
    }
    else if (dWidth < 768) {
        menuWidth = totalWidth;
    }
    else {
        menuWidth = (totalWidth / 4); // ensure there is enough room
        lastValidMenuRowWidth = menuWidth;

    }
    //var totalWidth = $('#menu-row').width();
  //  var totalWidth = $('#header-partial-section').width();
    //if (totalWidth > 992)
    //{
    //    menuWidth = (totalWidth / 4) + 5; // ensure there is enough room
    //}
    //else {

   // }

    $('#menu-container li').css('width', menuWidth);
   // $('#header-partial-section').css('width', menuWidth*4);

}




function OpenForm() {
    //document.getElementById("isi-drawer").style.height = "auto";
    //var ih = $('#isi-drawer').height;
    ShowSubmissionForm();
}

function OpenISI() {
    console.log('OpenISI()');
    var drawerBullets = $('#isi-drawer-bullets');
    drawerBullets.css("overflow-y", "scroll");
    drawerBullets.css("border", "1px #f2f2f2 inset");

  //  var contentHeight = $('isi-drawer-content').innerHeight;
    document.getElementById("isi-drawer").style.height = "545px";
    var ih = $('#isi-drawer').height;
    $('#isi-toggle-button').attr('src', baseURL + '/Content/images/Minus.png');

    //ShowSafetyInformation();
}

var isiScrollPosition = 0;
var timerReference;
function RunISIScroller()
{
    var drawerBullets = $('#isi-drawer-bullets');
    var drawerContainer = $('#isi-drawer-content');
    isiScrollPosition = drawerBullets.scrollTop();
    // startup a repeating timer
    timerReference = setInterval(function () {
        drawerBullets.scrollTop(isiScrollPosition);
        isiScrollPosition++;
    }, 200);
    //drawerBullets.on('scroll', function () {
    //    console.log('Event Fired');
    //});

    // Stop the autoscroll if the user touches...
    drawerBullets.on('mousedown', function (event) {
        console.log('ISI bullet mouse down Fired');

        // Test if user clicked scrollbar
        //var bulletsWidth = drawerBullets.prop("clientWidth");
        //if (event.offsetX >= bulletsWidth) {
        //    console.log("Stop isi Scroll...")
        //    clearInterval(timerReference);
        //}

        // Test if user clicks anywhere - then stop the auto scrolling
        clearInterval(timerReference);

    });
}
/* Set the width of the side navigation to 0 */
function CloseISI() {
    console.log('CloseISI()');
    // stop the repeating timer that is controlling slow ISI scrolling
    clearInterval(timerReference);
    var drawerBullets = $('#isi-drawer-bullets');
    // ensure first bullet is in view
    drawerBullets.animate({ scrollTop: 0 }, "normal");
    drawerBullets.css("overflow-y", "hidden");
    drawerBullets.css("border", "0px");
    drawerBullets.scrollTop = 0;
    document.getElementById("isi-drawer").style.height = "141px";
    var ih = $('#isi-drawer').height;
    $('#isi-toggle-button').attr('src', baseURL + '/Content/images/Plus.png');
}



function FillDoctorInformation(hcpName) {
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/HeaderHCPSection',
        type: 'POST',
        //   contentType: 'application/json; charset=utf-8',
        data: '',
        success: function (dataObject) {
            $('#header-partial-section').html(dataObject);
            $("#hcp-name").text(hcpName);
            //$('#header-partial-section1').html(dataObject);
            //$("#hcp-name_M").text(hcpName);
        }
    });
    $.ajax({
        url: baseURL + '/HeaderHCPSection_M',
        type: 'POST',
        //   contentType: 'application/json; charset=utf-8',
        data: '',
        success: function (dataObject) {
            //$('#header-partial-section').html(dataObject);
            //$("#hcp-name").text(hcpName);
            $('#header-partial-section1').html(dataObject);
            $("#hcp-name_M").text(hcpName);
        }
    });

}



function FillCardInformation() {
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/HeaderCardSection',
        type: 'POST',
        //   contentType: 'application/json; charset=utf-8',
        data: '',
        success: function (dataObject) {
            $('#header-partial-section').html(dataObject);
            $('#header-partial-section1').html(dataObject);
        }
    });

}

/* Set the width of the side navigation to 0 */
function CloseWordfinderDrawer() {
   // document.getElementById("word-finder-drawer").style.width = "0";
    $('.word-finder-drawer').css('width', '0');
    if ((gameState & 0x07) === 0x07)// are all the words (all three) found?
    {
        $('.word-finder-drawer').hide();
    }

}

function OpenWordfinderDrawer() {
//    document.getElementById("word-finder-drawer").style.width = "425px";
    $('.word-finder-drawer').css('width', '390px');
}





function ExecutePresentation(ilmState) {
    switch (ilmState) {
        case 0: // home page
            //oneTimeRun = true; // only a one-time run...don't increment the state
            $('#menu-buttons').hide();
            break;
        case 1:
            //oneTimeRun = true; // only a one-time run...don't increment the state
            window.location.href = baseURL + '/IdentifyQA1'
            LoadSection("/IdentifyQA1");
            $('#menu-buttons').show();
            break;
        case 2:
            LoadSection("/IdentifyQA1Correct");
            $('#menu-buttons').show();
            break;
        case 3:
            LoadSection("/IdentifyQA1Incorrect");
            $('#menu-buttons').show();
            break;
        case 4:
            LoadSection("/IdentifyQA2Presentation");
            $('#menu-buttons').show();
            break;
        case 5:
            LoadSection("/IdentifyQA2");
            $('#menu-buttons').show();
            break;
        case 6:
            LoadSection("/IdentifyQA2Correct");
            $('#menu-buttons').show();
            break;
        case 7:
            LoadSection("/IdentifyQA2Incorrect1");
            $('#menu-buttons').show();
            break;
        case 8:
            LoadSection("/IdentifyQA2Incorrect2");
            $('#menu-buttons').show();
            break;
        case 9:
            window.location.href = baseURL + '/Treat'
           // LoadSection("/Treat");
            $('#menu-buttons').show();
            break;
        case 10:
            window.location.href = baseURL + '/Support'
         //   LoadSection("/Support");
            $('#menu-buttons').show();
            break;
        case 11:
            LoadSection("/ThankYou");
            $('#menu-buttons').show();
            break;

    }

}


function LoadSection(pageUrl)
{

    //$('#section-content').load(baseURL + pageUrl);
    //return;

    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + pageUrl,
        type: 'GET',
        success: function (dataObject) {
            // To avoid flickering
            // Here we load the html into hidden div and wait for the content to finish loading. Then we copy that
            $('#page-cache').html(dataObject);
            $('#page-cache img').on('load', function () {
                console.log('...body content loaded');
                CopyElementData('section-content', $('#page-cache').html());
            });
        }
    });
}

function CopyElementData(elementId, objectData) {
    var element, newElement, parent;

    // Get the original element
    element = document.getElementById(elementId);

    // Assuming it exists...
    if (element) {
        // Get its parent
        parent = element.parentNode;

        // Create the new element
        newElement = document.createElement(elementId);

        // Set its ID and content
        newElement.id = elementId;
        newElement.innerHTML = objectData;
        

        // Insert the new one in front of the old one (this temporarily
        // creates an invalid DOM tree [two elements with the same ID],
        // but that's harmless because we're about to fix that).
        parent.insertBefore(newElement, element);

        // Remove the original
        parent.removeChild(element);
    }
}

function SaveTrace(traceId) {
    traceData = { 'id': traceId };
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/SaveTrace',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(traceData)
        //success: function (dataObject) {
        //    $('#dynamic_modals').html(dataObject);
        //    $('#' + modalDescription).modal(
        //        {
        //            backdrop: 'static',
        //            //  keyboard: false
        //        }).on("hidden.bs.modal", function (event, ui) {
        //            $('#' + modalDescription).remove();
        //            $('body').removeClass('modal-open');
        //            //  StopSound();
        //        });
        //    //  window.location.href = '#' + modalDescription;

        //}
    });

}
function SaveUrlTrace(traceId) {
    traceData = { 'traceType': 5, 'traceId': traceId }; // 5 represents a link
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/SaveTrace',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(traceData)
    });

}
function SaveAnswerTrace(traceId) {
    traceData = { 'traceType': 1, 'traceId': traceId }; // 1 represents an answer
    // To get a page to display in a specific div - in addition to the actual action call
    $.ajax({
        url: baseURL + '/SaveTrace',
        type: 'POST',
        contentType: 'application/json; charset=utf-8',
        data: JSON.stringify(traceData)
    });

}



var WorfinderDone = false;
var oneTimeRun = false;


function GetILMState() {
    if (sessionStorage.getItem('ILMState') == null || sessionStorage.getItem('ILMState') == 'undefined') {
        // at the start...
        sessionStorage.setItem('ILMState', '0');
    }
    return parseInt(sessionStorage.getItem('ILMState'));

}

function SetILMState(state) {
    sessionStorage.setItem('ILMState', state.toString());
}


function SetAndExecuteState(stateVal) {
    SetILMState(stateVal);
    ExecutePresentation(stateVal);
}
function IncrementAndExecuteState() {
    var state = GetILMState();
    state++;
    SetILMState(state);
    ExecutePresentation(state);
}
function DecrementAndExecuteState() {
    var state = GetILMState();
    if (state > 0) {
        state--;
    }
    SetILMState(state);
    ExecutePresentation(state);
}
function LoadAndPlayAudio(AudioPath) {
    console.log("User Selected: '" + AudioPath)
    var myAudio = document.getElementById("audio-player");
    var source = document.getElementById("audio-source");
    source.src = AudioPath;

    //    var audioPlayerBlock = $('#audio-player');
    //    audioPlayerBlock.find('#audio-source').attr('src', AudioPath);

    myAudio.load();
    console.log("new audio data loaded...");
    myAudio.pause();

    $('#play-button-image').prop('src', baseURL + "/Content/images/Pause.png");
    myAudio.play();

}
function AudioFinished() {
    $('#play-button-image').prop('src', baseURL + "/Content/images/Play.png");
    console.log("audio done...");
    if (oneTimeRun == true) {
        oneTimeRun = false;
        return;
    }
    IncrementAndExecuteState();
    //   var state = GetILMState();
    //   state++;
    //   SetILMState(state);
    //   ExecutePresentation(state);
}


function ToggleMute() {
    var muted = document.getElementById('background_audio').muted;
    if (muted == true) {
        document.getElementById('background_audio').muted = false;
    }
    else {
        document.getElementById('background_audio').muted = true;
    }
}
var didScroll = false;
var lastScrollPos = 0;
var curScrollPos = 0;
var floating = false;
function InitDynamicMenus() {
    // Hide Header on on scroll down
    //  var didScroll;
    var lastScrollTop = 10000; // set very high so that menu is visible if refreshed in the middle of the screen
    var minDelta = 2; // how much movement until header transitions
    var header = $('#app-header');
    var navbarHeight = header.outerHeight();
    var footerHeight = $('#bottom-menu').outerHeight();

    //$(window).scroll(function (event) {
    //    didScroll = true;
    //});

    //setInterval(function () {
    //    if (didScroll) {
    //        hasScrolled();
    //        didScroll = false;
    //    }
    //}, 250);

    $(window).scroll(function (event) {
        hasScrolled();
    });

    function hasScrolled() {
        return;// decided not to change the menu dynamically...
        var docBody = $('body .container');
        var dWidth = docBody.innerWidth();
        if (window.innerWidth < 768) {
            $('body').css('margin-top', '0px');
            header.removeClass('nav-float').addClass('nav-main');//.addClass('container');
            $('#company-logo-sm').hide();
            return false;
        }
        var st = $(this).scrollTop();
        var scrollVelocity = Math.abs(lastScrollTop - st);
        // Make sure they scroll more than delta
        //if (scrollVelocity <= minDelta)
        //    return;

        // If they scrolled down and are past the navbar, add class .nav-float.
        // This is necessary so you never see what is "behind" the navbar.
        // 400px minimum scroll before menu will automatically disappear...
        //if (st > lastScrollTop && st > navbarHeight) {// && st > navbarHeight) { 
            // Scroll Down
            // $('app-header').removeClass('nav-main').addClass('nav-float');
         //   header.removeClass('nav-main').addClass('nav-float');
        //    header.removeClass('nav-main').addClass('nav-float');
            //header.hide();
            //header_floating.show();
            //floating = true;




            //   $('footer').removeClass('nav-float').addClass('nav-main');
            //if (st >= ($(document).height() - footerHeight - navbarHeight))
            //if (st >= ($(document).height() - 1000)) {
            //    //     ShowFooter();
            //}
        //}
        //else if (st >= ($(document).height() - footerHeight - navbarHeight)) {
        //    //  HideFooter();
        //}
        // Keep the base menu only for about 20 pixels, then go to floating...or we'll lose site of 
        // top links...PI ect...
        if (st >= 0 && st < 20) {
            //header.addClass('nav-main').removeClass('nav-float').removeClass('container');
            header.addClass('nav-main').removeClass('nav-float');//.removeClass('container');
            $('body').css('margin-top', '0px');
          //  $('#company-logo-link').css('width', '100%');
            $('#company-logo-sm').hide();
            
        }
        else {
            $('body').css('margin-top', '120px');
            //header.addClass('nav-float').removeClass('nav-main').addClass('container');
            header.addClass('nav-float').removeClass('nav-main');//.addClass('container');
            $('#company-logo-sm').show();
            // header.removeClass('nav-float').addClass('nav-main');
            //header_floating.hide();
            //header.show();
            //floating = false;


            // HideFooter();
            // Scroll Up
            //if (st + $(window).height() < $(document).height()) {
            //    $('app-header').removeClass('nav-float').addClass('nav-main');
            //}
        }
        OnResize();

        lastScrollTop = st;
    }


    function ShowFooter() {

        //    $('#bottom-menu').css('background-color', 'red');
        $('#bottom-menu').css('bottom', '-110px');
        //$('#bottom-menu').css('bottom', '650px;');

        //     $('#bottom-menu').removeClass("footer-down");
        //     $('#bottom-menu').addClass("footer-up");

        //    $('footer').show();

    }

    function HideFooter() {
        //   $('#bottom-menu').css('background-color', '#1c4b5a');
        $('#bottom-menu').css('bottom', '-450px');
        //     $('#bottom-menu').removeClass("footer-up");
        //     $('#bottom-menu').addClass("footer-down");
        //   $('footer').hide();

    }




}


function ShowSafetyInfo()
{
    var elmnt = document.getElementById("isi-drawer-tab");
    elmnt.scrollIntoView();
}


function IsMobile() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
        return true;
    }    // device detection
    //if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
    //    || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(navigator.userAgent.substr(0, 4))) return true;

    return false;
}

var createShortLivedCookie = function (name, value, minutes) {
    var expires;
    if (minutes) {
        var date = new Date();
        date.setTime(date.getTime() + (minutes * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    }
    else {
        expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";
}
var createCookie = function (name, value, days) {
    var expires;
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    }
    else {
        expires = "";
    }
    document.cookie = name + "=" + value + expires + "; path=/";
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) {
                c_end = document.cookie.length;
            }
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

//string urlPath = "/Content/images/Cards";





/* Fade in images */

// Populate the safety info partial
//$.ajax({
//    url: '/TopicortSpray/_TopicortSprayDetail/',
//    success: function (data) { $('#main-bottom-content').html(data); }
//});

//   window.onunload = function () { };
//AdjustBody();


var cardsFlipped = 0;
var currentSelectedCardIndex = -1;
var lastSelectedCardIndex = -1;
var firstSelection = -1;
var canFlipCards = true;
var cardCount = 8;


function SelectCard(cardIndex, cardValue) {

    if (!canFlipCards) return false;

    console.log("SelectCard() - Index:" + cardIndex + ", value:" + cardValue);
    //   FlipCard(cardIndex);
    var elem = document.getElementById("card" + cardIndex);

    if (++cardsFlipped < 2) {
        if (firstSelection === cardIndex) return false;
        console.log("First Selection - CardsFlipped:" + cardsFlipped);
        firstSelection = cardIndex;
        // get the card's element
        if (elem.classList.contains('flip')) {
            // abort if already flipped
            return false;
        }

        currentSelectedCardIndex = cardValue;

        FlipCard(cardIndex);
    }
    else {
        console.log("Second Selection - CardsFlipped:" + cardsFlipped);
        setTimeout(function () {
            cardsFlipped = 0;
            // DO WE HAVE A MATCH?
            if (cardValue === currentSelectedCardIndex && cardIndex != firstSelection) {
                canFlipCards = false;

                setTimeout(function () {
                    ProcessMatch(cardIndex, cardValue); canFlipCards = true;
                }, 500);
                return false;
            }

            CoverCards();
        }, 500);
        FlipCard(cardIndex);
    }
    return false;
}



function CoverCards() {
    currentSelectedCardIndex = -1;
    var i = 0;
    var jam;
    for (i = 0; i < cardCount; i++) {
        jam = $('#cardfront' + i.toString())
        jam.css({ 'transform': 'rotateY(0deg)' });
        jam = $('#cardback' + i.toString())
        jam.css({ 'transform': 'rotateY(180deg)' });
    }
    ResumeGameState();
}



function GetGameState() {
    console.log("GetGameState()");
    // Get the game state (if it exists) from the session - if not exists - create an empty state n' save it...
    var gameState = sessionStorage.getItem('GameState');

    if (gameState == null || isNaN(gameState) || gameState === undefined) {
        // basically, nothing's happened in the game...
        gameState = 0x0000;
    }
    console.log("gameState: " + gameState.toString());
    return gameState
}

function ResumeGameState() {
    console.log("ResumeGameState");
    var i = 0;

    for (i = 0; i < cardCount; i++) {
        if (sessionStorage.getItem('card' + i.toString()) !== null) {
            console.log("Card:" + i + " - flip the state");
            // FlipCard(i);
            FinishCard(i);
        }
    }
}

function FinishCard(cardIndex) {
    console.log('finish card');
    if (!canFlipCards) return false;
    canFlipCards = false;


    var jam = $('#cardfront' + cardIndex.toString())
    jam.css({ 'transform': 'rotateY(-180deg)' });


    jam = $('#cardback' + cardIndex.toString())
    jam.css({ 'transform': 'rotateY(0deg)' });
    console.log(jam.find('img').attr('src'));
    jam.find('img').attr('src', baseURL + '/content/images/cards/cards-background' + cardIndex + '.png');
    console.log(jam.find('img').attr('src'));

    canFlipCards = true;


}


var ug = 0;
function ResetMaitrix() {

    console.log("ResetMaitrix");
        for (i = 0; i < cardCount; i++) {
            sessionStorage.removeItem('card' + i.toString());
            console.log("Card:" + i + " - Removed From cache");
        }
        sessionStorage.removeItem('GameState');
        gameState = 0x00;

    // call a controller to refill the card maitrix partial - with game 'match' page
    $.get(baseURL + "/Game/Maitrix", { 'id': 1 }, function (response) {





        setTimeout(function () {
           // sessionStorage.clear();

            //for (i = 0; i < cardCount; i++) {
            //    sessionStorage.removeItem('card' + i.toString());
            //    console.log("Card:" + i + " - Removed From cache");
            //    }
            //AdjustBody();
         //   window.location.href = "#main-body-content";
        }, 800);

    });

    CoverCards();
    ResumeGameState();


    return false;

}


function AnimateCards() {

    console.log("AnimateCards()");
    var i = 0;
    if (GetFlippedCardCount() > 0) {
        for (i = 0; i < cardCount; i++) {
            console.log("toggle hidden card" + i.toString());

            $("#card" + i.toString()).show();

        }

        return;
    }
    for (i = 0; i < cardCount; i++) {
        console.log("toggle hidden card" + i.toString());

        $("#card" + i.toString()).show(1500);

    }
}

function ContinueGame() {
    console.log("ContinueGame");

    // Are we done with the game?
    var flippedCards = GetFlippedCardCount();
    console.log("Total Flipped Cards: " + flippedCards.toString());

    // If we have all of the cards flipped, then the game is over...
    if (flippedCards > 15) {
        // call a controller to refill the card maitrix partial
        $.get(baseURL + "/Game/_MaitrixGameOverPartial", null, function (response) {
            $("#card-maitrix").html(response);
        });

        //window.location.href = "#main-body-content";
        return;
    }
    else {
        $.get(baseURL + "/Game/GetMaitrix", null, function (response) {
            $("#card-maitrix").html(response);
            ResumeGameState();
        });
    }


    // This is a 'funky' toggle operation. The whole issue here is if the same url is requested, nothing happens - like a 'GET'...so, we keep changing url ( argument of '0', and missing argument yeild same result)

    console.log("old continue url: " + window.location.href);



 //   window.location.href = 'success';

    //if (window.location.href.indexOf("Maitrix/#main-body-content") >= 0) {
    //    gamehref = "/Game/Maitrix/0/#main-body-content";
    //}
    //else {
    //    gamehref = "/Game/Maitrix/#main-body-content";
    //}

 //   console.log("New continue url: " + gamehref)
 //   window.location.href = gamehref;

    return false;

}

function GetFlippedCardCount() {
    var i = 0;
    var flippedCards = 0;

    // Count how many flipped cards we have so far...
    for (i = 0; i < cardCount; i++) {
        if (sessionStorage.getItem('card' + i) == 'isflipped') {
            flippedCards++;

            // show the underlying image for flipped cards




        }
    }

    console.log("Flipped Card Total: " + flippedCards.toString());
    return flippedCards;
}

function SaveGameStateToSubmitForm() {
    console.log("SaveGameStateToSubmitForm()");
    var gameState = GetGameState();
    // Save the state of the game to a hidden field within the submit partial (the game state value is set to a model property)
    document.getElementById('model-game-state').value = gameState;
    console.log("Submit()");
    $('#submit-input').click()
    console.log("Submit-click()");

}

// either show the card's back or show the underlying image - if there was a match
function FlipCard(cardIndex) {
    if (!canFlipCards) return false;
    canFlipCards = false;

    var jam = $('#cardfront' + cardIndex.toString())
    jam.css({ 'transform': 'rotateY(-180deg)' });
    jam = $('#cardback' + cardIndex.toString())
    jam.css({ 'transform': 'rotateY(0deg)' });
    canFlipCards = true;
}



function ProcessMatch(cardIndex, cardValue) {
    console.log("ProcessMatch()");
    // make a note of which cards are flipped for this match...
    sessionStorage.setItem('card' + firstSelection.toString(), 'isflipped');
    sessionStorage.setItem('card' + cardIndex.toString(), 'isflipped');

    // in case the game ends on a match - then we want to see the 'matched' page before going on to the 'game over' page
    var deferGameOver = false;

    var gameState = GetGameState();

    console.log("GameState: " + gameState.toString());

    var i = 0;
    var flippedCards = GetFlippedCardCount();
    console.log("Flipped Card Count: " + flippedCards.toString());

    console.log("ProcessMatch() - begin switch, cardValue: " + cardValue.toString());
    var pageImageVal = "None";
    switch (cardValue) {
        case "0":
            pageImageVal = baseURL+ "/Content/images/Cards/match0.png";
            deferGameOver = true;
            gameState |= 0x0002;
            ShowDialog('match1', baseURL + '/Match1');
            //this indicates the system to do nothing when this sound is done..
            oneTimeRun = true;
            LoadAndPlayAudio(baseURL + "/content/audio/prepopik-ilm-3.mp3");
            
            setTimeout(function () { SetAndExecuteState(40); }, 1000);
            break;
        case "1":
            pageImageVal = baseURL + "/Content/images/Cards/match1.png";
            deferGameOver = true;
            gameState |= 0x0004;
            ShowDialog('match2', baseURL + '/Match2');
            //this indicates the system to do nothing when this sound is done..
            oneTimeRun = true;
            LoadAndPlayAudio(baseURL + "/content/audio/prepopik-ilm-3.mp3");
            setTimeout(function () { SetAndExecuteState(42); }, 1000);
            break;
        case "2":
            pageImageVal = baseURL + "/Content/images/Cards/match2.png";
            deferGameOver = true;
            gameState |= 0x0008;
            ShowDialog('match3', baseURL + '/Match3');
            //this indicates the system to do nothing when this sound is done..
            oneTimeRun = true;
            LoadAndPlayAudio(baseURL + "/content/audio/prepopik-ilm-3.mp3");
            setTimeout(function () { SetAndExecuteState(44); }, 1000);
            break;
        case "3":
            pageImageVal = baseURL + "/Content/images/Cards/match3.png";
            deferGameOver = true;
            gameState |= 0x0010;

            ShowDialog('match4', baseURL + '/Match4');
            //this indicates the system to do nothing when this sound is done..
            oneTimeRun = true;
            LoadAndPlayAudio(baseURL + "/content/audio/prepopik-ilm-3.mp3");
            setTimeout(function () { SetAndExecuteState(46); }, 1000);

            break;
        default:
            if (flippedCards < cardCount) return;
            break;
    }






    console.log("ProcessMatch() - pageImageVal: " + pageImageVal);
    console.log("ProcessMatch() - begin get flipped card count");

    // HAVE WE...1) FLIPPED ALL THE CARDS -AND- 2) THE LAST MATCH DID NOT REQUIRE A NEW INFO DIALOG BEFORE GAME OVER
    if (flippedCards > 6) // && deferGameOver == false) 
    {

        // NOTE THE GAME IS OVER
        gameState |= 0x0001;
        //SAVE THE GAME'S STATE TO THE SESSION
        sessionStorage.setItem('GameState', gameState.toString());

        $('.card-game-over').prop('hidden', false);

        console.log("gameState: " + gameState.toString());
        canFlipCards = true;
        ResumeGameState();

        //SetAndExecuteState(4);

    }
    else // otherwise, show the game 'match' page
    {
        //          LoadAndPlayAudio(baseURL+ "/content/audio/horse.mp3");

        // SAVE THE GAME'S STATE TO THE SESSION
        sessionStorage.setItem('GameState', gameState.toString());

        console.log("gameState: " + gameState.toString());
        canFlipCards = true;
        ResumeGameState();

        
    }


   // window.location.href = "#main-body-content"

    return false;

}

function SetGlow(card1) {
    $('#' + card1).animate({
        backgroundColor: 'rgba(0, 150, 0, 0.3)'
    },
        function () {
            $('#glow').css({
                '-webkit-box-shadow': '0px 0px 5px 5px rgba(0, 150, 0, 0.3)',
                'box-shadow': '0px 0px 5px 5px rgba(0, 150, 0, 0.3)'
            });
        });

}

