$(document).ready(function(){
	jQuery.easing.def = "easeOutQuad";

    $.fn.delay = function(time, callback) {
        // Empty function:
        jQuery.fx.step.delay = function() { };
        // Return meaningless animation, (will be added to queue)
        return this.animate({ delay: 1 }, time, callback);
    }
    
	var bIphone = navigator.userAgent.toLowerCase().indexOf('iphone')!=-1;
    
    if(!$.fontAvailable('Museo')) {
    	Cufon.replace('h1, h2, h3, p.intro, a.follow', { fontFamily: 'Museo 700', hover: true });
    }
    
    var sPageTitle = document.title;

	$('body').addClass('js');

	//$('body').append('<a class="toggle" title="Show grid">Show grid</a>');
	$('a.toggle').click(function(){
	 	$('#grid').toggle();
	 })
	
	$('ul.nav li a').click(function(){
		document.title = sPageTitle +' - '+ $(this).text();
	 })
	
	function setSelected()
	{
		$('ul.nav li a').each(function (){
			if($(this).attr('href') == location.hash)
			{
				$('ul.nav li.selected').removeClass('selected');
				$(this).parent().addClass('selected');
				document.title = sPageTitle +' - '+ $(this).text();
			}
		});
	}
	
	if(location.hash){
		$('div#content .columnset').height($(location.hash).height());	
	} else {
		$('div#content .columnset').height($('#home').height());	
	}
		
	$.localScroll({
		target: 'div#content .columnset', // could be a selector or a jQuery object too.
		axis:'x',
		queue:true,
		duration:750,
		easing:"easeOutQuad",
		hash:true,
		onBefore:function( e, anchor, $target, $items, pos ){
			var nHeight = $(anchor).height();			
		},
		onAfter:function( anchor, settings ){
			var nHeight = $(anchor).height();
			$(this).animate({height: nHeight,}, 750 );
			setSelected();
			// The 'this' contains the scrolled element (#content)
		}
	});
	
	setSelected();

});
