var profilesPage = (function(){
	var vis = false;
	var activeLink = false;
	
	function showProfile(e){
		var el = $(e.target);
		var section = $('a[name="'+el.attr('hash').replace(/#/,'')+'"]');
		var container = false;
		if(section){
			container = section.parent('.profile');
			if(container){
				if(vis){
					vis.addClass('hidden');
					activeLink.removeClass('active');
				}
				el.addClass('active');
				container.removeClass('hidden');
				vis = container;
				activeLink = el;
				return false;
			}
		}
	}
	
	return {
		init: function(){
			var toClick = false;
			var offset = 20;
			$('#profiles-list li a').each(function(i,el){
				el = $(el);
				/*
				el.mouseover(highlightSiblings);
				el.mouseout(unhighlightSiblings);
				*/
				el.css({
					'position' : 'relative',
					'top' : '-'+(offset*i)+'px'
					
				});
				el.click(showProfile);
				if(i == 0){
					toClick = el;
				}
			});
			
			if(toClick){
				$('#loading').remove();
				toClick.click();
			}
		}
	};
	
})();

$(document).ready(function(){
	profilesPage.init();
});
