jQuery(function($){
	
	// Frontpage carousel
	$('#slider').cycle({
		pager: '#slider-nav',
		timeout: 5000,
		pause: true
	});
	// Disable slider
	$('#slider a').click(function(e){
		e.preventDefault();
	});
	
	// Sorting people
	var $filterType = $('#filterOptions li.active a').attr('class');
	var $holder = $('ul.ourHolder');
	var $data = $holder.clone();
	$('#filterOptions li a').click(function(e) {
		$('#filterOptions li').removeClass('active');
		var $filterType = $(this).attr('class');
		$(this).parent().addClass('active');
		if ($filterType == 'all') {
			window.location.hash = '';
			var $filteredData = $data.find('li');
		} else {
			window.location.hash = $filterType;
			var $filteredData = $data.find('li[data-type=' + $filterType + ']');
		}
		$holder.quicksand($filteredData, {
			duration: 400,
			easing: 'easeInOutQuad'
		});
		return false;
	});
	
	// Filter if hash is available
	if ($('body').hasClass('page-mennesker')) {
		if (window.location.hash) $('#filter-' + window.location.hash.replace('#', '')).trigger('click');
	}
	
	// Products menu
	/*
	$('.catlist a').click(function(e){
		e.preventDefault();
		var $parent = $(this).parent('li');
		if ($parent.children('ul').length == 1) {
			$('.catlist ul').slideUp();
			$parent.children('ul').slideToggle();
		} else {
			window.location.href = $(this).attr('href');
		}
	});
	$('.catlist li li').each(function(i){
		var $anchor = $(this).children('a');
		if ($anchor.text() == $('#full_column h1:first-child').text()) {
			// $('.catlist a').parent('li').slideToggle();
			$anchor.parent('li').addClass('.here').parent('ul').slideToggle();
		}
	});
	*/
	
	// Fix category listing
	$('.category').each(function(){
		$(this).children('.list').each(function(i){
			$(this).addClass(i % 2 == 0 ? 'first' : 'last');
		});
	});
	
});
