//When the DOM tree is loaded
$(document).ready(function() {

	 $(function(){
		var mWorking = $('span.mailwork');
		var mHello = $('span.mailhello');
		$(mWorking).html('<a href="mailto:working@designagency.co.uk" onclick="javascript:_gaq.push([\'_trackPageview\',\'/mailto/working\']);">working@designagency.co.uk</a>');
		$(mHello).html('<a href="mailto:hello@designagency.co.uk" onclick="javascript:_gaq.push([\'_trackPageview\',\'/mailto/hello\']);">hello@designagency.co.uk</a>');
	});

    //Add pointer class to .photo .item
    $(".photo .item").addClass("pointer");

    //Hover over photo fade in hidden span
    $(".photo .item").hover(
        function() {
            $(this).find("span").fadeIn();
        },
        function() {
            $(this).find("span").fadeOut();
        }
    );
  
    // This section if for the home page
    $("#readmorehome").hide();
  
     $(".showread").click(function() {
      $("#readmorehome").show(500);
      return false;
    });
    
    $(".hideread").click(function() {
      $("#readmorehome").hide(500);
      return false;
    });
	
	//Show and hide the top contact
	$(".topclose").click(function() {
      $("#topcontact").animate({height: "0px"}, {queue:false, duration:300,easing:'easeInBack'});
      return false;
    });
	
	//Show and hide the top contact
	$("a#acblue").click(function() {
      $("#topcontact").animate({height: "160px"}, {queue:false, duration:300, easing:'easeOutBack'});
      return false;
    });
	
	//Side dude disappear
	$(".sidelurker").hover(function() {
      $(this).animate({width: "0px"}, {queue:false, duration:200, easing:'easeInBack'});
      return false;
    });
	
	// Slide navigation
	$(function(){
	/**
	*	Jquery Horizontal Slide Navigation
	*	webmaster@chazzuka.com
	*	http://www.chazzuka.com
	*	Nov 13th 2008 @ Denpasar, Bali Paradise Island
	**/
	//@ active scroll
    var _active = null;
	//@ max expand in pixel
    var _hmax = 20;
	//@ min height in pixel
    var _hmin = 0;	
	//@ loop through matches selector
    $("#mainnav li a").each(function(){
		//@ in/out handler
		$(this).hover(
			//@ hover
			function(){
				//@ child span expand
				$(this).find('span').animate({height: _hmax+"px"}, {queue:false, duration:300, easing:'easeOutBack'});
				//@ set active to current hovered
				_active = $(this);
			},
			//@ out
			function() {
				//@ slide back
				$(_active).find('span').animate({height: _hmin+"px"}, {queue:false, duration:300,easing:'easeInBack'});
			}
		);	
	});
	});
 
});
