$(function() {
		
	$(".latest-projects article, .articles li, .projects li, #departments article").live('click', function(e){
		 window.location=$(this).find("a").attr("href");
	});	

	//Overlays

	$("#departments section").hover(
		function () {
			$(this).children('article').stop().animate({"top": "0"}, "normal");
		},
		function () {
			$(this).children('article').stop().animate({"top": "142px"}, "normal");
		}
	);	
	
		
	$('#departments section').find('article').delay(400).animate({"top": "142px"}, "normal");	
		
	//$('#departments section:nth-child(1)').find('article').delay(100).animate({"top": "142px"}, "normal");
	//$('#departments section:nth-child(2)').find('article').delay(200).animate({"top": "142px"}, "normal");	
	//$('#departments section:nth-child(3)').find('article').delay(300).animate({"top": "142px"}, "normal");
	//$('#departments section:nth-child(4)').find('article').delay(400).animate({"top": "142px"}, "normal");
	//$('#departments section:nth-child(5)').find('article').delay(500).animate({"top": "142px"}, "normal");	


	//Sec-nav
	
	$.fn.slideFadeToggle  = function(speed, easing, callback) {
		return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
	};

	$('.sec-nav dt').hover(function(){
		$(this).toggleClass('hover')
	}).click(function(){ 	
		$('.sec-nav dd').hide(); 
		$(this).toggleClass('active').next().stop(true,true);
		$(this).toggleClass('active').next().slideFadeToggle('normal');
		$('.sec-nav dt').removeClass('active').stop(true,true);
		$(this).addClass('active').stop(true,true);
	}); 

	$('#logo').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence'
	});


	//Dropdowns	
	
	$('#main-nav li ul').hide();
	
	//$('#main-nav li').mouseenter(function() {
	//	$(this).addClass('hover');	
	//	$(this).children('ul').stop(true,true).show('normal');
	//});
	//$('#main-nav li').mouseleave(function() {
	//	$(this).removeClass('hover');
	//	$(this).children('ul').stop(true,true).hide('fast');
	//});
	
	$("#main-nav li").hoverIntent({
		over: showSub, 
		timeout: 0, 
		out: hideSub
	});
	function showSub(){  
			$(this).addClass('hover').children('ul').stop(true,true).css('display','block');
	}
	function hideSub(){ 
			$(this).removeClass('hover').children('ul').stop(true,true).css('display','none');
	}

	
	$('.thumbs ul li a').click(function() {
		var liId =  $(this).attr('id').replace("t_", "");
		
		$('.frame .s').hide();
		$('#m_'+liId).fadeIn('slow');
		$('#m_'+liId).removeClass('hide');
		$('.thumbs ul li a.active').removeClass('active');
		$('#t_'+liId).addClass('active');
		
	    return false;
	});
	
	$('.tab-nav ul li a').click(function() {
		var liId =  $(this).attr('id').replace("a_", "");
		$('.service-lead').hide();	
		$('#a_'+liId).fadeIn();
		$('#a_'+liId).removeClass('hide');
		$('.tab-nav li').removeClass('active');
		$('#l_'+liId).addClass('active');	
	    return false;
	});
	
	
	//Equal heights
	
	var maxHeight = 0;
	
	$(".complex .latest-projects .left .entry").each(function(){
	   if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
	});
	$(".complex .latest-projects .left .entry").height(maxHeight);	
	
});








