/*****
	PLUGINS
*****/
/* Mouse Wheel - http://brandonaaron.net/code/mousewheel/demos */
(function($){var types=['DOMMouseScroll','mousewheel'];$.event.special.mousewheel={setup:function(){if(this.addEventListener)
for(var i=types.length;i;)
this.addEventListener(types[--i],handler,false);else
this.onmousewheel=handler;},teardown:function(){if(this.removeEventListener)
for(var i=types.length;i;)
this.removeEventListener(types[--i],handler,false);else
this.onmousewheel=null;}};$.fn.extend({mousewheel:function(fn){return fn?this.bind("mousewheel",fn):this.trigger("mousewheel");},unmousewheel:function(fn){return this.unbind("mousewheel",fn);}});function handler(event){var args=[].slice.call(arguments,1),delta=0,returnValue=true;event=$.event.fix(event||window.event);event.type="mousewheel";if(event.wheelDelta)delta=event.wheelDelta/120;if(event.detail)delta=-event.detail/3;args.unshift(event,delta);return $.event.handle.apply(this,args);}})(jQuery);


$(window).bind("load",function(){

	/*****
		Meet the team
	*****/
	$("#meetTheTeamSwitcher > div").hide();
	$("#meetTheTeamSwitcher > div:first").show();
	$("#meetTheTeam ul li a").click(function(){
		$("#meetTheTeam ul li a").removeClass("hover");
		$(this).addClass("hover");
		var meetTheTeam = $(this).attr("rel");
		$("#meetTheTeamSwitcher div:visible").fadeOut(300, function(){
			$("#meetTheTeamSwitcher ." + meetTheTeam).delay(300).fadeIn(300);
		});
		return false;
	});
	
	/*****
		Gallery
	*****/
	// Make galleryScroller the right width
	var theNumberOfItems = $("#galleryScroller ul li").size();
	var theNewWidth = (160 * theNumberOfItems)
	$("#galleryScroller ul").css("width",theNewWidth);
	$("#galleryScroller").mousewheel(function(event, delta) {
		this.scrollLeft -= (delta * 10);
		event.preventDefault();
	});
	
	// Change main image when thumb is clicked
	$("#galleryScroller ul li a").click(function(){
		$("#galleryScroller ul span a").removeClass("openFancybox");
		$(this).parent('li').next('span').find('a').addClass("openFancybox");
		var theNewImage = $(this).attr("href");
		$("#galleryMainImage").attr("src",theNewImage);
		$("#galleryMainImage").parent('a').attr("href",theNewImage);
		return false;
	});
	$("#galleryScroller ul span:first a").addClass("openFancybox");
	$("#startFancyBox").bind('click', function(){
		$(".openFancybox").click();
		return false;
	});
	
	$("a.fancybox").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'centerOnScroll'	: true,
		'overlayOpacity'	: 0.9,
		'overlayColor'		: '#000',
		'changeFade'		: 'fast'
	});

	
	/*****
		GROM OF THE MONTH
	*****/
	$("#gromOfTheMonth").hover(function(){
		$(this).find("img").css({opacity: 0.7});
	}, function(){
		$(this).find("img").css({opacity: 1});
	});

});
