// JavaScript Document -- REQUIRES jQuery
jQuery(function(){
	var effectSpeed= 200;
	$('.divisions h3').each(function(){
		$(this).hover(function(){
			//mouseover
			$(this).addClass('hover');
		}, function(){
			//mouseout
			$(this).removeClass('hover');
		}).click(function(){
			var thisParent = $(this).parent('li');
			if($(thisParent).hasClass('expanded')){
				//contract
				$(thisParent).removeClass('expanded').children('.team_list:first').slideUp(effectSpeed);
			}else{
				//expand
				$('.team_list:visible').slideUp(effectSpeed);
				$('.divisions .expanded').removeClass('expanded');
				$(thisParent).addClass('expanded').children('.team_list:first').slideDown(effectSpeed);
			}
		});
	});
	
	//highlight popups
	$('.highlight').each(function(){
		$(this).hover(function(){
			//mouseover
			var thisOffset = getRealPos(this, $('#main'));
			//change position of popup
			var popup = {
				x: thisOffset.x+$(this).width()+5+'px',
				y: thisOffset.y-44+'px'
			};
			//clone in content
			$('#popup #content').html($(this).children('.content').html());
			//show popup
			$('#popup').css({left:popup.x, top:popup.y}).addClass('active');
		}, function(){
			//mouseout
			//hide popup
			$('#popup').removeClass('active');
		});
	});
});
