/*
 * SimpleModal Basic Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2008 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: basic.js 132 2008-05-23 16:05:17Z emartin24 $
 *
 */

jQuery(document).ready(function() {

    if (jQuery.getQueryString({ id: "quiz", defaultvalue: "-1" }) != "-1") {
        jQuery('#ModalContent').modal(
            {
                onShow: function() { jQuery('#swfContainer').hide(); },
                onClose: function() { jQuery('#swfContainer').show(); jQuery.modal.close(); }
            }
        );
    }

    jQuery('#ShowModal').click(function(e) {
        e.preventDefault();
        jQuery('#ModalContent').modal(
            {
                onShow: function() { jQuery('#swfContainer').hide(); },
                onClose: function() { jQuery('#swfContainer').show(); jQuery.modal.close(); }
            }
        );
    });
});
function CheckAnswers() {
    var CorrectAnswerCount = 0;
    var ResultMessage;
    
    // Highlight the correct answers
    if (jQuery("input[name='Understand']:checked").val() == "30%") {
        jQuery("#LabelForRadio1").addClass("CorrectAnswer");
        CorrectAnswerCount++;
    }
    else
        jQuery("#LabelForRadio1").addClass("IncorrectAnswer");

    if (jQuery("input[name='Engage']:checked").val() == "Coaching") {
        jQuery("#LabelForRadio5").addClass("CorrectAnswer");
        CorrectAnswerCount++;
    }
    else
        jQuery("#LabelForRadio5").addClass("IncorrectAnswer");

    if (jQuery("input[name='Reward']:checked").val() == "30%") {
        jQuery("#LabelForRadio8").addClass("CorrectAnswer");
        CorrectAnswerCount++;
    }
    else
        jQuery("#LabelForRadio8").addClass("IncorrectAnswer");

    if (jQuery("input[name='Retain']:checked").val() == "28%") {
        jQuery("#LabelForRadio11").addClass("CorrectAnswer");
        CorrectAnswerCount++;
    }
    else
        jQuery("#LabelForRadio11").addClass("IncorrectAnswer");

    switch(CorrectAnswerCount)
    {
        case 0:
            ResultMessage = "Bad luck! 0 out of 4.";
            break;
        case 1:
            ResultMessage = "Sorry! 1 out of 4.";
            break;
        case 2:
            ResultMessage = "Nice Try! 2 out of 4.";
            break;
        case 3: 
            ResultMessage = "Nice work! 3 out of 4.";
            break;
        case 4:
            ResultMessage = "Congratulations! 4 out of 4.";
            break;
        default:
            break;
    }
    
    // Show the contact form
    jQuery("#Contact").show();
    // Hide the button
    jQuery("#Button_CheckAnswers").hide();

    jQuery("#Results").html(ResultMessage);
    jQuery("#Results").show();
}