var $j = jQuery.noConflict();

$j(document).ready(function(){

	$j("#projects-home .post").fadeIn();
	
	$j(".hide-edit").click(function(){
		$j(".post-edit-link").fadeOut();
		$j(".hide-edit").fadeOut();
	});
		
	if ($j.url.segment(0)) {
		$j(".filter-all").removeClass('active');
		$j(".filter-"+$j.url.segment(0)).addClass('active');
	}

	if ($j.url.segment(1)) {
		$j(".filter-all").removeClass('active');
		$j(".filter-"+$j.url.segment(1)).addClass('active');
	}

    $j("#toggle-about").click(function(){
		$j("#header-fold #about").slideToggle('1000');
		$j("#header-fold #clients").slideUp('1000');
		$j("#header-fold #press").slideUp('1000');
	});

    $j("#toggle-clients").click(function(){
		$j("#header-fold #clients").slideToggle('1000');
		$j("#header-fold #about").slideUp('1000');
		$j("#header-fold #press").slideUp('1000');
	});
	
	$j("#toggle-press").click(function(){
		$j("#header-fold #press").slideToggle('1000');
		$j("#header-fold #about").slideUp('1000');
		$j("#header-fold #clients").slideUp('1000');
	});
	
	$j(".thumb").hover(
		function(){
			$j(this).next(".postmetadata").children("h2").children("a").addClass('active');
		},
		function(){
			$j(this).next(".postmetadata").children("h2").children("a").removeClass('active');
		}
	);
		
	$j('.backlink').click(function(){
	
		// SET THE CURRENT DOMAIN
		var currentDomain = "workingformat.com";
		
		// If it was linked from the site, go back in history
		if(document.referrer.indexOf(currentDomain) != -1) {
			history.go(-1);
		}
		
		// otherwise go to homepage
		else {
			window.location=currentDomain;
		}
	
	});
	
	$j('img').removeAttr("title");

});
