$(document).ready(function(){
    // text is the quiz is present
    if ( $('#scored_quiz').length ) {
        $("#scored_quiz").submit(function(){
            // check the quiz chekcboxes


           $.ajax({
                url: scored_quiz_callback_url,
                global: false,
                type: "POST",
                data: $("#scored_quiz").serialize(),
                dataType: "html",
                success: function(msg){
                    //$('#scored_quiz_container').html("<pre>"+msg+"</pre>");
                    result_message = "<div class=\"quiz_results\"><h2>The results of your quiz are:</h2><p>";
                    result_message = result_message + results(msg) + "</p><p>Effectively getting what you need to thrive starts with understanding whether you would benefit from being managed, coached or mentored.  If you lead, coach or manage others, Way to Grow! will provide you with accurate insight into who needs your time and why.  Way to Grow! will help you maximize your confidence, self-empowerment and overall success as a leader, manager or employee.<br />" + '<iframe src="http://rcm.amazon.com/e/cm?t=lindgali-20&o=1&p=8&l=as1&asins=1885228643&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>' + "</p></div>";
                    $('#scored_quiz_container').html(result_message);
                    return false;
                }
            });

            return false;
        });

    }
});

function results(score) {
    score = parseFloat(score);
    if ((score > 0) && (score <= 12)) {
        return "You are likely an ORCHID that needs day-to-day contact with a manager to tend you.  A little spritz of water in the face on a regular basis may wake you up to the fact that you are high maintenance and likely to be draining others around you.  Orchids have a shallow root system and need to be managed for just the right amount of nutrients as over feeding or over maintaining cal lead to certain and swift demise, as can even the slightest lack of attention.  Best kept indoors.";
    }

    
    if ((score > 12) && (score <= 22)) {
        return "You are likely a DAISY, and with some coaching in the right areas can thrive even in less than ideal environments.  You require occasional managerial maintenance and adequate sunshine, but with that will prosper and grow.  With experience and growing confidence you may eventually join the ranks of the weeds, while new environments and uncertain circumstances can relegate you to orchid status, albeit temporarily."
    }


    if ((score > 22) && (score <= 25)) {
        return "You are likely a WEED.  You need only hear what the goal is to take root and prosper, and, absent even that, you will fashion your own goal and drive toward it.  You appreciate nutrients but do not require them, and in fact you relish the challenge of occasional poor soil, excessive heat, and scattered weed killers. Your confidence and competence attracts other weeds, inspires daisies, and frustrates orchids.  You can handle yourself in even the most hostile of environments, but are accountable enough to either change your mindset and circumstances to suit you or look for and go to the environment you know will further your ability to thrive and positively impact others."
    }
}
