$(document).ready(function () {

	$('#banner').flash({
		swf: '/assets/flash/jsjanimation.swf',
		height:'256',
		width:'740',
		wmode: "transparent"
	});
	
	$('#officers li a').toggle(function(e){
		e.preventDefault();
		$(this).parent().children("p").animate({height: 'show'}, 'normal');
		$(this).text("Hide Bio");
		$(this).css({backgroundPosition: "-100px 0"});
			$(this).mouseover(function(){
				$(this).css({backgroundPosition: "-100px -19px"});
			});
			$(this).mouseout(function(){
				$(this).css({backgroundPosition: "-100px 0"});
			});
		}, function(){
		$(this).parent().children("p").animate({height: 'hide'}, 'normal');
		$(this).text("Show Bio");
		$(this).css({backgroundPosition: "0 0"});
			$(this).mouseover(function(){
				$(this).css({backgroundPosition: "0 -19px"});
			});
			$(this).mouseout(function(){
				$(this).css({backgroundPosition: "0 0"});
			});
	});
	
	$('#map-filter a').click(function(e){
		e.preventDefault();
	
		var currentClass = this.className;
	
		if(currentClass != 'active')
		$(this).toggleClass('active');
		$(this).parent().siblings().children().removeClass('active');
	});
	
	$('#map-filter a:not(#all-btn)').click(function(){
		var name = $(this).html();
		var company = name.toLowerCase();
		
		$('#map a').each(function(){
			$(this).css({'display' : 'block'});
		});
		
		$('#map a:not(.' + company + ')').each(function(){
			$(this).css({'display' : 'none'});
		});
		$('#map a.multi').css({'display' : 'none'});
	});

	$('#izzy-btn + span').click(function(){
		$('#map a.izzy').css({'display' : 'block'})
		
		$('#map a:not(.izzy)').each(function(){
			$(this).css({'display' : 'none'});
		});
	});
	
	$('#all-btn').click(function(){
		$('#map a').each(function(){
			$(this).css({'display' : 'block'});
		});
		$('#map a.mi, #map a.jsj').each(function(){
			$(this).css({'display' : 'none'});
		});
	});
	
	$('#map a').click(function(e){e.preventDefault();});
	
	$('#map a:not(.multi)').colorbox({
		height: 340,
		width: 660,
		scrolling: false,
		iframe: true
	});

	$('#image-popup').live("mouseover", function(){
		$(this).colorbox({
			scrolling: false,
			iframe: true
		});
		return false;
	});
	
	$('#location-details').live("mouseover", function(){
		$(this).colorbox({
			height: 340,
			width: 660,
			scrolling: false,
			iframe: true
		});
		return false;
	});

	$('#map > a:not(.jsj, .multi)').tipsy({gravity: 'n', fade: false});
	$('#map > a:not(.jsj, .multi)').hover(function(){$('#multi-list').fadeOut();});
	$('#map > a.jsj').tipsy({gravity: 's', fade: false});
	
	$('.multi').mouseover(function(){
		var t;
		var currentClass = this.className;
		
		if(currentClass == 'multi') {
			$(this).addClass('expanded');
			$('#multi-list').css({'display' : 'inline-block' , opacity : 0}).animate({opacity: 1}, 'fast');		
		}
		
		else {
			$('#multi-list').fadeOut();
			$(this).removeClass('expanded');
		}
	
		$('#multi-list').css({'display' : 'inline-block', opacity : 0}).animate({opacity: 1}, 'fast');
	});
	
	$('#multi-list').mouseleave(function(){
		$(this).fadeOut();
		$('.multi').removeClass('expanded');
	});
	
	$('.multi').mouseout(function(){
		t = setTimeout(function(){$('#multi-list').fadeOut();}, 500);
	});
	
	$('#multi-list').hover(function(){clearTimeout(t);});
	
	$('#multi-list a').click(function(){
		$('#multi-list').fadeOut();
		$('.multi').removeClass('expanded');	
	});
	
});
