// JavaScript Document

// Current Copyright Year
function Copyright() { document.write("&copy;" + new Date().getFullYear()) }

// Rollover State
function imgOver(imgName){ 
	document[imgName].src = eval(imgName + "_over.src"); 
}

function imgOff(imgName){ 
	document[imgName].src = eval(imgName + "_off.src"); 
}

myaccount_off = new Image();
myaccount_off.src = "/images/nav_myaccount.png";

myaccount_over = new Image();
myaccount_over.src = "/images/nav_myaccount_f2.png";

about_off = new Image();
about_off.src = "/images/nav_about.png";

about_over = new Image();
about_over.src = "/images/nav_about_f2.png";

education_off = new Image();
education_off.src = "/images/nav_education.png";

education_over = new Image();
education_over.src = "/images/nav_education_f2.png";

services_off = new Image();
services_off.src = "/images/nav_services.png";

services_over = new Image();
services_over.src = "/images/nav_services_f2.png";

events_off = new Image();
events_off.src = "/images/nav_events.png";

events_over = new Image();
events_over.src = "/images/nav_events_f2.png";

news_off = new Image();
news_off.src = "/images/nav_news.png";

news_over = new Image();
news_over.src = "/images/nav_news_f2.png";

join_off = new Image();
join_off.src = "/images/nav_join.png";

join_over = new Image();
join_over.src = "/images/nav_join_f2.png";

contact_off = new Image();
contact_off.src = "/images/nav_contact.png";

contact_over = new Image();
contact_over.src = "/images/nav_contact_f2.png";


$(function () {
	$('.bubbleInfo').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 50;

		var hideDelayTimer = null;

		var beingShown = false;
		var shown = false;
		var trigger = $('.trigger', this);
		var info = $('.popup-calendar', this).css('opacity', 0);


		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (beingShown || shown) {
				// don't trigger the animation again
				return;
			} else {
				// reset position of info box
				beingShown = true;

				info.css({
					top: 0,
					left: 10,
					display: 'block'
				}).animate({
					top: '-=' + distance + 'px',
					opacity: 1
				}, time, 'swing', function() {
					beingShown = false;
					shown = true;
				});
			}

			return false;
		}).mouseout(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			hideDelayTimer = setTimeout(function () {
				hideDelayTimer = null;
				info.animate({
					top: '-=' + distance + 'px',
					opacity: 0
				}, time, 'swing', function () {
					shown = false;
					info.css('display', 'none');
				});

			}, hideDelay);

			return false;
		});
	});
});
