Adroit = {
	root : null,
	
	lastXHR : null,
	
	initialize : function() {
        Adroit.attachXHRLoading('.ajax-link');
		Adroit.setupRollovers();
	},
	
	attachXHRLoading : function(query) {
	   $(query).click(function(e) {
			Adroit.stopEvent(e);
			var link = $(this).attr('href');
			if(Adroit.lastXHR === null || Adroit.lastXHR !== link) {
				Adroit.lastXHR = link;
				var height = $('#content-container')[0].scrollHeight-10;
				$('#content-container').css('height', height);
				$('#content').fadeOut('slow', function() {
				        $('#content-container').addClass('content-loading');
				        $('#content .ajax-link').unbind('click');
						$('#content').load(link, function() {
						$('#content').fadeIn('slow', function() {
						  $('#content-container').removeClass('content-loading');
						  Adroit.attachXHRLoading('#content .ajax-link');
						});
						$('#content-container').animate({height: $('#content')[0].scrollHeight});
						tb_init('a.thickbox, area.thickbox, input.thickbox');
					});
				});
			}
		});
	},
	
	setupRollovers : function() {
		$('.rollover').hover(function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		},
		function() {
			var currentImg = $(this).attr('src');
			$(this).attr('src', $(this).attr('hover'));
			$(this).attr('hover', currentImg);
		});
	},
	
	stopEvent : function(e) {
	    if(e.preventDefault !== undefined) {
	        e.preventDefault();
	    }
	    if(e.stopPropagation !== undefined) {
	        e.stopPropagation();
	    }
	    e.returnValue = false;
	}
	
}
$(Adroit.initialize);