$(function() {
	$('input.SleepDisordersQuizRadio').change(function() {

		counter = 0;
		$('input.SleepDisordersQuizRadio').each(function(index) {
			var SleepDisordersQuizRadio = $(this).attr('name');
			if($('input:radio[name='+SleepDisordersQuizRadio+']:checked').val() == 'Yes') { counter++; }
		});
  				
		if (counter >= 6) {
			if($('#SleepDisordersQuizAction').css('display') == 'none') {
				$('#SleepDisordersQuizAction').fadeIn('slow', function() {
					$('#SleepDisordersQuizAction').css('display','block');
				});
				$('#SleepDisordersQuizAction').scrollTo(1000);
			}}
		else {
			if($('#SleepDisordersQuizAction').css('display') == 'block') {
				$('#SleepDisordersQuizAction').fadeOut('slow', function() {
					$('#SleepDisordersQuizAction').css('display','none');
				});
			}
		}
		return true;
	});

	/*
	 * ScrollToElement 1.0
	 * Copyright (c) 2009 Lauri Huovila, Neovica Oy
	 *  lauri.huovila@neovica.fi
	 *  http://www.neovica.fi
	 *  
	 * Dual licensed under the MIT and GPL licenses.
	 */

	(function($) {
		$.scrollToElement = function( $element, speed ) {

			speed = speed || 750;

			$("html, body").animate({
				scrollTop: $element.offset().top,
				scrollLeft: $element.offset().left
			}, speed);
			return $element;
		};

		$.fn.scrollTo = function( speed ) {
			speed = speed || "normal";
			return $.scrollToElement( this, speed );
		};
	})(jQuery);
});
