$(document).ready(function() {
	$.localScroll.hash();
	
	$('#membersContent').localScroll();
	
	$('.openMemberDetails').click(function(){
		getMemberDetailsHTML($(this).attr("id"));	
	});
	
	if ($.url.param("id"))
		getMemberDetailsHTML('MemberId_' + $.url.param("id"));
		
	$('.letterFilter span').click(function() {
		//Set all the letters to their normal state
		$('.letterFilter span').attr('class', 'itemNormal');
		//Select the clicked letter
		$(this).attr('class', 'itemSelected');
		//Change the value of the hidden filter
		$('#FilterLetter').attr('value', $(this).text());
	});
});
	
function getMemberDetailsHTML(memberBoxId) {
	$('<div title=""><img src="images/wait.gif" /></div>').dialog({
		bgiframe: true,
		//height: 600,
		width: 600,
		modal: true,
		autoOpen: true,
		draggable: false,
		resizable: false,
		overlay: {
			backgroundColor: '#FF0000',
			opacity: 0.5
		},
		buttons: {
			'Fermer': function() {
				$(this).dialog('close');
			}
		},
		open: function(event, ui) 
		{
			var box = $(this);
			
			$.ajax({
				type: "GET",
				url: "includes/ajax/ajax_factory.php?className=MemberDetails",
				data: "id=" + memberBoxId,
				async: false,
				dataType: "text",
				success: function(msg)
					{
						$(box).html(msg);
					}
				});
		},
        close : function()
        {
            $(this).dialog('destroy');
            $(this).remove();
        }
	});
}
