﻿// jQuery Intellisense
/// <reference path="jquery-1.4.2.min.js" />

function validateAllQuestionsAnswered(selectorOfDivContainingQuestions) {
	if ($(selectorOfDivContainingQuestions + " input:radio:checked").length == $(selectorOfDivContainingQuestions + " li").length) {
		return true;
	}
	else {
		var haveNotScrolled = true;
		var allRadioButtons = $(selectorOfDivContainingQuestions + " li");
		var numbersNotAnswered = [];
		allRadioButtons.each(function (index) {
			$(this).removeClass('notAnswered');
			if ($(this).find(":radio:checked").length == 0) {
				numbersNotAnswered.push(index + 1);
				$(this).effect('pulsate', { times: 2 });
				$(this).addClass('notAnswered');
				if (haveNotScrolled) {
					this.scrollIntoView()
					haveNotScrolled = false;
				}
			}
		});
		$(".errorMessage").text("Following questions unanswered: " + numbersNotAnswered.join(",")).show(300);
		return false;
	}
}

$(function () {
	$('.schoolCarouselInfoLink').live("click", function (e) {
		e.preventDefault();
		$('#modal').load($(this).attr('href'), function () {
			$('#modal').modal({
				onOpen: function (dialog) {
					dialog.overlay.fadeIn('slow', function () {
						dialog.data.hide();
						dialog.container.fadeIn('slow', function () {
							dialog.data.slideDown('slow');
						});
					});
				}
			});
		});
	});
})

if ($(".home").length > 0) {
    var homeImage = Math.floor(Math.random() * 3) + 1;
    $('#content').css('backgroundImage', 'url(/content/images/img_home' + homeImage + '.jpg)');
}

if ($("#currentStudyAreas").length > 0) {
    var studyHeight = $('#currentStudyAreas').height();
    studyHeight = studyHeight + 370;
    $('#filterForm').css('height', studyHeight + 'px');
}


