$(document).ready(function(){

	//HOME PAGE
	$('#board-member-ad').hover(function(){
		$('#board-profile-image #profile-image-silo').hide();
		$('#board-profile-image #profile-image').show();
		$(this).find('a').addClass('active');
	}, function(){
		$('#board-profile-image #profile-image-silo').show();
		$('#board-profile-image #profile-image').hide();	
		$(this).find('a').removeClass('active');
	});
	
	$('#hero').cycle({ 
	    timeout:  5000, 
	    speed:  1000
	});

	//BOARD MEMBER PAGE
	$('#map-base-image').css('opacity','0'); //hide the image used for the image map so the div container background image can be seen
		
	var region = $('#region').val();
	
	$('body, #map').addClass(region);	
	$('#region-label strong').html(region);
		
	//swap div background image on area hover
	$('area').hover(function(){
		hoverRegion = $(this).attr('class');
		$('#map').removeClass();
		$('#map').addClass(hoverRegion);
		$('#region-label strong').html(hoverRegion);
	}, function(){
		$('#map').removeClass();
		$('#map').addClass(region);
		$('#region-label strong').html(region);
	});

	//add loading image on region click
	/*
	$('area, #map-faces a, #board-nav a').click(function(){
		var height = $('#board-detail').height();
		$('#board-member-image, #board-member-description').height(height);
		$('#board-detail').addClass('loading');
		$('#board-detail.loading #board-member-image img').hide();
		$('#board-detail.loading #board-member-description').children().hide();
	});
	*/
	
	//swap face images on hover	
	$('#map-faces li').not('li.' + region).children('a').hover(function(){
		var hoverRegion = $(this).parent().attr('class');
		$(this).children('.default-face').hide();
		$(this).children('.active-face').show();
	}, function(){
		$(this).children('.default-face').show();
		$(this).children('.active-face').hide();
	});
	
	// zone switcher for projects map
	$('#zone-switcher').click(function(){
		$(this).children('a').toggleClass('active');
		$(this).children('span').toggleClass('active');
		$('#zone-menu').fadeIn('normal', function(){
			$(document).bind('click', function(){
				$('#zone-menu').fadeOut('normal');
				$('#zone-switcher a').removeClass('active');
				$('#zone-switcher span').removeClass('active');	
				$(this).unbind('click');
			});
		});
	});
	
	// issue switcher for projects map
	$('#issue-switcher').click(function(){
		$(this).children('a').toggleClass('active');
		$(this).children('span').toggleClass('active');
		$('#issue-menu').fadeIn('normal', function(){
			$(document).bind('click', function(){
				$('#issue-menu').fadeOut('normal');
				$('#issue-switcher a').removeClass('active');
				$('#issue-switcher span').removeClass('active');	
				$(this).unbind('click');
			});
		});
	});
	
	// project page tabs
	$('.tab-box .tab-content').hide();
	$('.tab-box .tab-content:first').show();
	$('.tab-box .tabs ul li:first').addClass('active');
	
	$('.tab-box .tabs ul li a').click(function(){
		$('.tab-box .tabs ul li').removeClass('active');
		$(this).parent().addClass('active');
		
		var currentTab = $(this).attr('href');
		$('.tab-box .tab-content').hide();
		$(currentTab).show();
		return false;
	});
});
