﻿function fnCalculateQualifyTime(strHours,strDays)
{
	$("#result-weeks").text(Math.floor(parseInt($("#CourseLengthForm input[id$='HdnCourseLength']").val()) / (parseInt(strHours) * parseInt(strDays))));
}

$(document).ready(
	function ()
	{
		$.ajaxSetup({
			cache: false
		});

		if($('#testimonial').length)
		{
			var intQuoteCounter = 0;
			var arrQuotes = [
				"Since I enjoyed the coursework so much I have gone on to studying my degree which is Business Administration specialising in Law. This is a correspondence degree too. — A.F.",
				"The results I have gained are more than the money I paid for. As soon as I got my level 4 in Caring for People with Learning Disability. I was immediately promoted and now I am getting much more than what I paid for.",
				"Doing this course not only helped my career a great deal, but it also gave me insights into my own child's psyche and today I am a better parent for it.",
				"I have just completed my Beauty Therapist course and thoroughly enjoyed the experience, to the point that I am missing it. I am in my early 50's and it took me a long time and guts to start learning something new at my age. But I am so glad I took the plunge. All my assignments were clear and it took exactly 2-3 days for my work to be graded. Once I have set myself up soon, I am very tempted to follow another course to add to the current one. — K.O.",
				"The college give you when you ask for it. The course material is excellent and the learning method easy to follow. I have suggested it to many of my friends who also have given very good feedback.",
				"As a Certified Life Coach, certified Business and Family Mediator and Master Certified Counsellor while running my own private practice this course has helped me to continue to develop my stress management skills. I completed my Advanced Stress Management Course with a distinction.",
				"I found the course to be very interesting and filled with rich information that I would have never thought of if I had to open up a day care centre of my own without doing the course. The entire course was well laid out in every aspect and best of all, very easy to understand. I hardly needed help from the tutor and when I needed to find anything out, the relevant department/tutor responded very promptly giving me accurate information. — F.K.",
				"Studying the course was the best thing I could do to improve my studying. The tutor was great and helped a lot. Surely I would recommend this college excellent with studies and communication. It is worth all the money I paid for my course whuich was Child Care home study course.",
				"This course did not disappoint. It is one of the best distance learning courses I have ever taken. Best of all is how thorough and instructive the lessons are. For anyone who wants to learn about Clinical Nutrition or even eventually practice as a Nutritionist, they cannot do better than taking this Clinical Nutrition Diploma Course. — L.E.N.",
				"I have just finished the Basic Counselling Skills Diploma course and I can honestly say the whole of my course has been spot on; my first enquiry was responded to quickly and efficiently. A truly well worked out course, with excellent back up and as I said positive response, this is always a good thing when learning. 10/10 from me. — T.K.",
				"In addition to enjoying the return to study at an adult level it started me on a personal development plan, gaining other qualifications leading me from a security officer to becoming a competency based industrial trainer, teaching security officers, door supervisors, cctv, first aid and fire awareness wardens amongst other subjects. — S.M."
			];

			setInterval(function ()
			{
				$('#testimonial').fadeOut('slow', function ()
				{
					if(arrQuotes.length == intQuoteCounter)
					{
						intQuoteCounter = 0;
					}

					$('#quote').text(arrQuotes[intQuoteCounter]);

					$('#testimonial').fadeIn('slow', function ()
					{
						intQuoteCounter++;
					});
				});
			}, 15000);
		}

		if($('#CourseLengthForm').length)
		{
			var intCourseHours = $("#CourseLengthForm input[id$='HdnCourseLength']").val();

			$("#slider-hours").slider(
			{
				step: 1,
				min: 1,
				max: 10,
				value: 4,
				slide: function (event, ui)
				{
					$("#result-hours").text(ui.value);
					fnCalculateQualifyTime(ui.value, $("#slider-days").slider("value"));
				}
			});

			$("#slider-days").slider({

				step: 1,
				min: 1,
				max: 7,
				value: 2,
				slide: function (event, ui)
				{
					$("#result-days").text(ui.value);
					fnCalculateQualifyTime($("#slider-hours").slider("value"), ui.value);
				}
			});

			$("#result-hours").text($("#slider-hours").slider("value"));
			$("#result-days").text($("#slider-days").slider("value"));
			fnCalculateQualifyTime($("#slider-hours").slider("value"), $("#slider-days").slider("value"));
		};

		if($('div.associations').length)
		{
			// create new container for images
			$("<div>").attr("id", "scroller-container").css({ position: "absolute" }).width(1975).height(61).appendTo("#scroller-images");

			// add images to container
			$("#scroller-images img").each(function ()
			{
				$(this).appendTo("#scroller-container");
			});

			// work out duration of anim based on number of images (1 second for each image)
			var duration = $("#scroller-images img").length * 1000;

			// store speed for later (distance / time)
			var speed = (parseInt($("#scroller-container").width()) + parseInt($("#scroller-images").width())) / duration;

			// animator function
			var animator = function (el, time)
			{
				// animate the el
				el.animate({ left: "-" + el.width() + "px" }, time, "linear", function ()
				{
					// reset container position
					$(this).css({ left: $("#scroller-inner-container").width(), right: "" });

					// restart animation
					animator($(this), duration);
				});
			}

			// start anim
			animator($("#scroller-container"), duration);
		};

		$('ul.sf-menu').superfish(
		{
			hoverClass: 'active',
			delay: 1000,
			animation: { opacity: 'show', height: 'show' },
			speed: 'fast',
			autoArrows: false,
			dropShadows: false
		});
	}
);
