(function($) {
	$(document).ready( function() {
	
		$(".mainMenu li").hover(
		  function () {
			$(this).addClass("active");
		  }, 
		  function () {
			$(this).removeClass("active");
		  }
		);

		    $(".slidePanel").hide();
				$(".show_hide").show();
				
				$('.show_hide').click(function(){
				$(".slidePanel").slideToggle();
				$(this).text($(this).text() == 'read more' ? 'read less' : 'read more');
			});
			
			
		$(".mod-studioTeamMembers").hover(
		  function () {
			$(this).addClass("mod-studioTeamMembers-active");
		  }, 
		  function () {
			$(this).removeClass("mod-studioTeamMembers-active");
		  }
		);		
	
		$('.member-information').each(function(i,el){
			el.id = ("member-information-")+i;
		});
		$('.mod-studioTeamMembers').each(function(i,el){
			el.id = ("mod-studioTeamMembers-")+i;
		});
		$('.mod-studioClients img').each(function(i,el){
			el.id = ("img-")+i;
		});
		$('.member-information').each(function(i,el) {
			$(this).each(function() {   
			   $(this).addClass('mod-studioTeamMembers-' +i);
			});
		});
		
		//Clones all content and inserts under menu
		$('.member-information').clone().appendTo("#secondary .infoDesc");
		
		 $('.mod-studioTeamMembers img').click(function(e) {
	        $('.secondary .member-information').css({display: "block"});
	    });
 
		$(".mod-studioTeamMembers").live("click", function(){
			var a = $(this);
				$(".member-information").css("display","none");
				$("."+a.attr("id")).css("display","block");
		});
		
		$(".page-id-30 .entry-title").wrapInner('<a name="profile" />');
		$(".page-id-30 .mod-studioTeam h2").wrapInner('<a name="team" />');
		$(".page-id-30 .mod-studioClients h2").wrapInner('<a name="clients" />');
		$(".page-id-30 .mod-studioAwards h2").wrapInner('<a name="awards" />');
		
		$('.anchorNav .itemFour').click(function(){
			$.scrollTo( $('.mod-studioAwards h2'), 800);
		});
		
		$(".scrollTop").click(function(){
				  $('html, body').animate({ scrollTop: 0 }, 'slow');
		});
	

	  $(".category-item h3 a").mouseenter(function () {
		$(this).animate({ 'padding-right' : '30px' }, "slow");
	  });
	  $(".category-item h3 a").mouseleave(function () {
		$(this).animate({ 'padding-right' : '3px' }, "slow");
	  });


	
		$('.page-id-30 .anchorNav a').each(function(i,el){
			el.id = ("item-")+i;
		});
		
		$('.category .widget .category-item').each(function(i,el){
			el.id = ("item-")+i;
		});
		
		$('.anchorNav-projects a').each(function(i,el){
			el.id = ("item-projects-")+i;
		});
	
	
	    $('.feature-slider a').click(function(e) {
	        $('.featured-posts section.featured-post').css({
	            opacity: 0,
	            visibility: 'hidden'
	        });
	        $(this.hash).css({
	            opacity: 1,
	            visibility: 'visible'
	        });
	        $('.feature-slider a').removeClass('active');
	        $(this).addClass('active');
	        e.preventDefault();
	    });
	});
	
	
	
	function filterPath(string) {
  return string
    .replace(/^\//,'')
    .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
    .replace(/\/$/,'');
  }
  var locationPath = filterPath(location.pathname);
  var scrollElem = scrollableElement('html', 'body');

  $('a[href*=#]').each(function() {
    var thisPath = filterPath(this.pathname) || locationPath;
    if (  locationPath == thisPath
    && (location.hostname == this.hostname || !this.hostname)
    && this.hash.replace(/#/,'') ) {
      var $target = $(this.hash), target = this.hash;
      if (target) {
        var targetOffset = $target.offset().top;
        $(this).click(function(event) {
          event.preventDefault();
          $(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
            location.hash = target;
          });
        });
      }
    }
  });

  // use the first element that is "scrollable"
  function scrollableElement(els) {
    for (var i = 0, argLength = arguments.length; i <argLength; i++) {
      var el = arguments[i],
          $scrollElement = $(el);
      if ($scrollElement.scrollTop()> 0) {
        return el;
      } else {
        $scrollElement.scrollTop(1);
        var isScrollable = $scrollElement.scrollTop()> 0;
        $scrollElement.scrollTop(0);
        if (isScrollable) {
          return el;
        }
      }
    }
    return [];
  }

	
	
	
	
})(jQuery);
