$(document).ready(function () {
	$('#glossary-open').click( function () {
		if($('#glossary-content-wrap').css("display") != "block") {

			$('#glossary-content-wrap').show();

			$('#glossary').animate( { 	height: $('#glossary-content-wrap').height() + 22 + "px",
										marginTop: "-87" - $('#glossary-content-wrap').height() + "px"
			} );

			$('footer').css("marginTop", "-90px");
		}

			else

		{
			$('#glossary').animate( { 	height: "25px",
										marginTop: "-90px"
			}, function () {
				$('#glossary-content-wrap').hide();
				$('footer').css("marginTop", "0");
			} );
		}

		return false;
	} );

	$('.more').hide();

	$('.more-link').click(function () {
		if(! $(this).hasClass('active')) {

			$(this).parents("li").addClass('with-details');
			$(this).addClass('active');

			$(this).parents("li").children(".more").slideDown();
		}
			else
		{
			$(this).parents("li").removeClass('with-details');
			$(this).removeClass('active');

			$(this).parents("li").children(".more").slideUp();
		}

		return false;
	});

	if ($('.question-group').length > 0) {
		$('.question-group-title a').click(function() {
			$(this).parents('.question-group').find('.question-group-list').toggle();
			return false;
		});
		$('.question-group-list a').click(function() {
			$(this).parents('li').find('.question-answer').toggle();
			return false;
		});
	}

    $('.poll_form').validate({
        errorContainer: '#poll_error_message',
        errorPlacement: function () {},
        submitHandler: function (form) {
            $(form).ajaxSubmit({
                success: function (responseText, statusText, xhr, $form) {
                    $p = $form.parents('.poll');
                    $form.remove();
                    $p.find('.results').html(responseText);
                }
            });
        }
    });
});



