var $j = jQuery.noConflict();

// filter: everything on to start, hide reset filter links
$j('#archives').isotope({ filter: '' });
$j('#isotope-filters span.reset').hide();

$j('#isotope-filters a').click(function(){
	// get href attribute, minus the '#'
	var sortName = $j(this).attr('href').slice(1);
	if ( sortName != 'reset' ) {
		// This happens when we click a regular filter link
		$j('#archives').isotope({ filter: '.'+sortName });
	} else {
		// This happens when we click a reset link
		$j('#archives').isotope({ filter: '' });	
		$j('#isotope-filters').find('.selected').removeClass('selected');
		$j('#isotope-filters span.reset').hide('fast');
	}
	return false;
});

// switches selected class on buttons, and shows the reset links 
$j('#isotope-filters').find('a:not(.reset-link)').click(function(){
	var $this = $j(this);
	$j('#isotope-filters span.reset').show('fast');
	// don't proceed if already selected
	if ( !$this.hasClass('selected') ) {
		$this.parents('#isotope-filters').find('.selected').removeClass('selected');
		$this.addClass('selected');
	}
});

// Prepopulate any search boxes, and clear on click
$j(document).ready(function(){
	$j('.search input').autofill({
		value: 'Search & discover',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
	$j('input#name').autofill({
		value: 'Your name',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
	$j('input#uyiily-uyiily').autofill({
		value: 'Your email address',
		defaultTextColor: '#666',
		activeTextColor: '#333'
	});
});

// Get recent tweets for the front page
$j('#bocca-twitter-feed').jTweetsAnywhere({
    username: 'boccalatte',
    count: 5,
    showTweetFeed: {
/*     	showTimestamp: { refreshInterval: 30 }, //refreshes timestamp on tweets every 30 seconds */
    	showTimestamp: false // but this setting turns off timestamps all together
/*     	paging: { mode: "prev-next" } */
    }
});

// BigTarget for projects etc

$j("div.project-medium h3 a").bigTarget({
	hoverClass: 'hover', // CSS class applied to the click zone onHover
	clickZone : 'div:eq(0)' // jQuery parent selector
});

$j("div.project-small h3 a").bigTarget({
	hoverClass: 'hover', // CSS class applied to the click zone onHover
	clickZone : 'div:eq(0)' // jQuery parent selector
});

$j("div.blog-post h3 a").bigTarget({
	hoverClass: 'hover', // CSS class applied to the click zone onHover
	clickZone : 'div:eq(0)' // jQuery parent selector
});

$j("div.project-old-loved h3 a").bigTarget({
	hoverClass: 'hover', // CSS class applied to the click zone onHover
	clickZone : 'div:eq(0)' // jQuery parent selector
});

$j("ul.bloglist li h3 a").bigTarget({
	hoverClass: 'hover', // CSS class applied to the click zone onHover
	clickZone : 'li:eq(0)' // jQuery parent selector
});

// All links with href "#top", scroll to page top
$j('a[href=#top]').click(function(e){
    $j('html, body').animate({scrollTop:0}, 'slow');
    e.preventDefault();
});


