$(document).ready(function() {
//quiz radio buttons
    $('#quiz_questions form fieldset input[type="radio"]').hide();
    
    $('.quiz form fieldset label').click(
        function(){
        $(this).parent('fieldset').children('label').removeClass('radio_checked');
        $(this).addClass('radio_checked');
        if($(this).hasClass('radio_checked')) {
            $(this).prev().attr('checked', 'checked');
        }
    });
    
    $('#quiz_questions form fieldset input[type="radio"][checked="checked"]').next().addClass('radio_checked');
    
    
    $('h6#age_1_notification, #start_the_quiz').hide();
    $('#restart_the_quiz').attr('disabled', 'disabled');

    
    $("#month").bind("change", function(){
       
       var val = parseInt( $(this).val() );
       
       if (val == 1) {
           
           $('#start_the_quiz').hide();
           $('#restart_the_quiz').hide();
           $('h6#age_1_notification').show();
           
       } else if (val > 1) {
       
            $('#start_the_quiz').show();
            $('#restart_the_quiz').show();
            $('#restart_the_quiz').attr('disabled', '');
            $('h6#age_1_notification').hide();
       
       } else if (val == 0) {
        
            $('#start_the_quiz').hide();
            $('#restart_the_quiz').show();
            $('#restart_the_quiz').attr('disabled', 'disabled');
            $('h6#age_1_notification').hide();
       
       }
        
    });

    // quiz text shortening (spanish is too long);

    $('#left_col_md li.one,#left_col_md li.two,#left_col_md li.three,#restart_the_quiz').each(function() {

        var initialWidth = $(this).width();
        $(this).css('width', 'auto');
        while ($(this).width() > (initialWidth - 15)) {
            var $font_size = parseInt($(this).css('font-size'));

           $(this).css('font-size', ($font_size - 1) + "px");
        }
        $(this).css('width', initialWidth);

    });

    $('body#quiz div#main div#page_content div#right_col_lg ul').addClass('list');
    $('body#quiz div#main div#page_content div#right_col_lg ul li').not(':first').removeClass('list_title');

    $('#header_outer #header_language_selection select').change(function() {
        $(this).siblings('.reloading').show();
        window.location = $(this).val();
        reloadingPhase();
    });

    function reloadingPhase() {
        $('.reloading').animate({color: '#FFF'}, 1000, function() {
            $('.reloading').animate({color: '#999'}, 1000, reloadingPhase);
        });
    }

});

