/*******************************
* Rypple Quiz JS
* (c) 2010, 2Catalyze, Inc. All rights reserved
********************************/

$(document).ready(function() {



    /***************************************************************************
    * Answers
    ***************************************************************************/
    $('.answer_labels li:nth-child(1)').prepend('<span class="step_label">Strongly Disagree</span> ');
    $('.answer_labels li:nth-child(2)').prepend('<span class="step_label">Disagree</span> ');
    $('.answer_labels li:nth-child(3)').prepend('<span class="step_label">Neutral</span> ');
    $('.answer_labels li:nth-child(4)').prepend('<span class="step_label">Agree</span> ');
    $('.answer_labels li:nth-child(5)').prepend('<span class="step_label">Strongly Agree</span> ');

    $('.answer_labels li').click(function(){
        $(this).parent().parent().children('.answer').slider('option', 'value', $(this).index()+1);
    });

    /***************************************************************************
    * Setup the carousel
    ***************************************************************************/
    $('#quiz_inside').carousel({btnsPosition:'outside'});

    /***************************************************************************
    * Intro slide covers up the quiz if we're showing someone's results
    ***************************************************************************/
    if($("#intro_start").length != 0) {
		$('#intro_start').click(function(){
	        $('#intro').fadeOut();
	    });
	}
    
    /***************************************************************************
    * Setup the slider
    ***************************************************************************/
    $('.answer').slider({animate: true, min: 1, max: 5, step: 1, value: 3});

});

/***************************************************************************
* calcScore
* Calculates and returns the score
***************************************************************************/
function calcScore(){
    var score = 0;
    $("#questions").children().each(function() {
        score += $(this).children('.answer').slider('option', 'value');
    });
    return score;
}
