$().ready(function() {
	$('#boxes .box').hover(
		function() {
			$(this).addClass('hover');
		},
		function() {
			$(this).removeClass('hover');
		}
	)

	$('#boxes .box').hover(
		function() {
			$button = $(this);
			$image = $button.find('img.hover');
			$image.stop(true);

			if ($image.length > 0)
			{
				if ($image.data('loaded'))
				{
					$image.fadeTo(750, 1);
					return;
				}
			}
			else
			{
				$image = $button.find('img');
				$position = $image.offset();
				$image.before("<img src=\"" + $image.attr('rel') + "\" class=\"hover\" />");
				$image = $button.find('img.hover');
				$image.css('top', $position.top);
				$image.css('left', $position.left);
			}

			$image.fadeTo(0, 0);
			$image.load(function() {
				$(this).data('loaded', true);
				$(this).fadeTo(750, 1);
			});
		},
		function() {
			$image = $button.find('img.hover');
			$image.fadeTo(750, 0, function() {
				$(this).remove();									  
			});
		}
	);

	$buttons = $('a[href*=miamiadschool.com]');
	$buttons.click(function() {
		$url = $(this).attr('href');
		$url = $url.split('http://www.miamiadschool.com').join('');
		$url = $url.split('http://miamiadschool.com').join('');
		$url = $url.split('http:/').join('');
		pageTracker._trackPageview('click:/' + $url);
		if ($(this).attr('target') != '_blank') document.location = $(this).attr('href');
	});
});