$(function() {
	var $hash = window.location.hash;
	
	$('.author-home-profile').hide();
	$('a.author-switcher').live('click', function() {
		var $this = $(this);
		$('.author-home-profile').hide();
		$('.author-switcher').removeClass('active');
		$($this.attr('href')).show();
		$this.addClass('active');
		return false;
	});
	$('a.author-switcher:first').click();
	
	$('#home-tabs .home-tabs .tab').hide();
	$('#home-tabs > ul li a').live('click', function() {
		var $this = $(this);
		$('#home-tabs > ul li a').removeClass('active');
		$this.addClass('active');
		$('#home-tabs .home-tabs .tab').hide();
		$($this.attr('href')).show();
		window.location.hash = $this.attr('href').replace('#', '#_');
		return false;
	});
	$('#home-tabs > ul li a.selected').click();
	
	$('#home-feature .cat-post').hide();
	$('#home-feature > ul li a').live('click', function() {
		var $this = $(this);
		$('#home-feature > ul li a').removeClass('active');
		$this.addClass('active');
		$('#home-feature .cat-post').hide();
		$($this.attr('href')).show();
		return false;
	});
	$('#home-feature > ul li a:first').click();
	
	$('#author-main a.more-link').live('click', function() {
		var $this = $(this);
		var $sib = $this.parents('p:eq(0)').prev('.post-content');
		if(!$sib.hasClass('expanded')) {
			$sib.addClass('expanded');
			$('span', $this).text('Læs mindre');
		} else {
			$sib.removeClass('expanded');
			$('span', $this).text('Læs mere');
		}
	});
	$('#home-feature > ul li a:first').click();
	
	$('.auto-clear:input').focus(function() {
		var $this = $(this);
		if($this.val() == $this.attr('title')) {
			$this.addClass('activated');
			$this.val('');
		}
	}).blur(function() {
		var $this = $(this);
		if($this.val() == '') {
			$this.val($this.attr('title'));
			$this.removeClass('activated');
		}
	});
	
	if($hash != '') {
		$($hash+'-div.hashactive').each(function() {
			var $this = $(this);
			$this.addClass('active');
		});
		$('a[href="'+$hash.replace('#_', '#')+'"]').click();
	}
});
