$(document).ready(function() {
	$('ul#filter a').click(function() {
		$(this).css('outline','none');
		$('ul#filter .current').removeClass('current');
		$(this).parent().addClass('current');

		var filterVal = $(this).text().toLowerCase().replace(' ','-');

		if(filterVal == 'all') {
			$('ul#portfolio li.hidden').fadeIn('slow').removeClass('hidden');
		} else {
			$('ul#portfolio li').each(function() {
				if(!$(this).hasClass(filterVal)) {
					$(this).fadeOut('normal').addClass('hidden');
				} else {
					$(this).fadeIn('slow').removeClass('hidden');
				}
			});
		}

		return false;
	});
});

$(".five_sixth:last-child").addClass("last");
$("#page-content .one_third:last-child").addClass("last");

$("ul#portfolio:last-child").addClass("last");

$(function(){
   var path = location.pathname.substring(1);
   if ( path )
 $('#menu-navigation li a[href$="' + path + '"]').attr('class', 'selected');
});




$(function () {
	$('.mimage img').css('display','none')
      $('.mimage img').fadeIn(500);
});

// Cufon Nice headings and legends

Cufon.replace('h1');
Cufon.replace('h2', {
		//color: '-linear-gradient(#BE3C14, #862a0e)',
		color: '-linear-gradient(#1e1e1e, #444)',
		textShadow: '-1px 1px #ddd',
	hover: {
		color: '-linear-gradient(#333, #000)',
		textShadow: '-1px 1px #ddd'
	}
});
Cufon.replace('h3', {
		color: '-linear-gradient(#1e1e1e, #444)',
		textShadow: '-1px 1px #ddd'
});
Cufon.replace('#footer h3', {
		color: '-linear-gradient(#f1f1f1, #7BD9F7)',
		textShadow: '-1px 1px #2B4D57'
});
Cufon.replace('legend', {
		color: '-linear-gradient(#1e1e1e, #444)',
		textShadow: '-1px 1px #ddd'
});
Cufon.replace('#portfolio .portfolio-title', {
		color: '-linear-gradient(#1e1e1e, #444)',
		textShadow: '-1px 1px #ccc'
});

Cufon.replace('#menu-nav li a', {
		textShadow: '-1px 1px #1e1e1e',
	hover: {
		color: '#1B7889'
	}
});

// Portfolio hover and Nav styles
$(function(){ 
  $('#portfolio li').hover(function(){
    $('.visit-portfolio', this).fadeIn(500)
  }, function() {
    $('.visit-portfolio', this).fadeOut(500)
  })
});

$(function(){ 
  $('#portfolio li img').hover(function(){
    $(this).stop().animate({
      'opacity' : 0.5
      }, 200)
  }, function() {
    $(this).stop().animate({
      'opacity' : 1
      }, 200)
  })
});



$(function(){ 
  $('#filter li a').hover(function(){
    $(this).stop().animate({
      'opacity' : 0.5
      }, 200)
  }, function() {
    $(this).stop().animate({
      'opacity' : 0.7
      }, 200)
  })
});

// Homepage Slideshow

$(function(){
    $('.fadein img:gt(0)').hide();
    setInterval(function(){
      $('.fadein :first-child').fadeOut(3000)
         .next('img').fadeIn(3000)
         .end().appendTo('.fadein');}, 
      8000);
});

$(function(){
    $('.fadeout img:gt(0)').hide();
    setInterval(function(){
      $('.fadeout :first-child').fadeOut(3000)
         .next('img').fadeIn(3000)
         .end().appendTo('.fadeout');}, 
      8000);
});

// Scroll all link targets

$(function(){ 
	$.localScroll();
 });
