jQuery(document).ready(function() { 

	//Tooltips
	
	jQuery('#footer #social li.skype a').hover(function(){
		var socialcontent = jQuery(this).attr('title');
		jQuery(this).append('<span class="tooltip">'+ socialcontent +'</span>');	
	}, function(){
		jQuery('.tooltip').remove();
	});

	//Pictures
   	jQuery("a[rel='colorbox'], .underimg a").colorbox({transition:"fade"});
    
   	//Clients rotater
   	jQuery(".homeclientsouter").carousel({ direction: "vertical", loop: true, autoSlide: true, effect: "fade", });

	//Home Featured Work
	jQuery('#strapline').prepend('<div class="hometakeover">blah blah blah</div>'); //First add the slider bar

	//Then populate and slide
	jQuery('#featuredwork .tags ').hide();
	jQuery('#featuredwork li').hover(function(){
		var imghref = jQuery(this).find('a').attr('href');
		jQuery('#featuredwork li').removeClass('hometakeoveractive');
		jQuery(this).addClass('hometakeoveractive');
		jQuery(this).stop().animate({"left": "0","width": "100%"}, "slow");
		jQuery(this).siblings().stop().animate({"opacity": "0"}, "slow");
		jQuery(this).append('<a href='+imghref+' class="viewportfolio">View Project</a>').fadeIn('slow');
		jQuery(this).parent().next('a').hide();
		jQuery(this).find('.tags').show('slow');
		//jQuery(this).bind('mouseleave');
		//jQuery('.viewportfolio').animate({"bottom": "10px"}, "slow").css('z-index','3');

	},function(){
		jQuery(this).find('.viewportfolio').fadeOut();
		jQuery(this).parent().next('.viewportfolio').fadeIn();
		jQuery('#featuredwork li.last').animate({"left": "632px", "width": "308px","opacity": "1"}, "slow");
		jQuery('#featuredwork li.second').animate({"left": "316px", "width": "308px","opacity": "1"}, "slow");
		jQuery('#featuredwork li.first').animate({"left": "0","width": "308px","opacity": "1"}, "slow");
		jQuery('#featuredwork li').removeClass('hometakeoveractive');
		jQuery(this).find('.tags').hide('slow');
		//jQuery(this).unbind(' mouseleave');
		//jQuery('.viewportfolio').animate({"bottom": "-33px"}, "slow");

	});
	
	//Sidebar Filter
	jQuery('#sbblogfilter h2').replaceWith('<a href="#" class="filter">Filter by Category</a>');
	jQuery('#sbblogfilter ol').hide();
	jQuery('#sbblogfilter a.filter').click(function(){
		jQuery('#sbblogfilter ol').slideToggle('slow');
		return false
	});
	
	//Portfolio Organiser
	jQuery('ul#mainportfolio').before('<ul class="organiser"><li id="orgall" class="active"><a href="#">All</a></li><li id="orgweb"><a href="#">Website</a></li><li id="orgillustration"><a href="#">Illustration</a></li></ul>')

	jQuery('ul.organiser li a').click(function(){

	var whatselect = jQuery(this).parent().attr('id');

	if (whatselect == 'orgweb') {
		jQuery(this).parent().parent().find('li').removeClass('active');
		jQuery(this).parent().addClass('active');
		jQuery('.portfolio li:not(.website)').slideUp('slow');
		jQuery('.portfolio li.website').slideDown('slow');
	}

	if (whatselect == 'orgillustration') {
		jQuery(this).parent().parent().find('li').removeClass('active');
		jQuery(this).parent().addClass('active');
		jQuery('.portfolio li:not(.illustration)').slideUp('slow');
		jQuery('.portfolio li.illustration').slideDown('slow');
	}		
	
	if (whatselect == 'orgall') {
		jQuery(this).parent().parent().find('li').removeClass('active');
		jQuery(this).parent().addClass('active');
		jQuery('.portfolio li').slideDown('slow');
	}

	return false;
	});
	
	//About Hobbies
	jQuery('.aboutme dl').addClass('js');
	jQuery('.aboutme dl.js dt').click(function(){
		jQuery(this).toggleClass('expanded');
		jQuery(this).next('dd').toggle('slow');
	});
	
});
