$(document).ready(function(){
	$('span.email').each(function(){
		var email = $(this).html().replace(' [at] ', '@');
		$(this).html('<a href="mailto:' + email + '">' + email + '</a>');
	});

	$('a.user-action').click(function(){
		TINY.box.show({ iframe: $(this).attr('href'), width: 500, height: 350 });
		return false;
	});

	$(window).resize(function(){
		setAppSettings();
	}).trigger('resize');

	$('div.mask').click(function(){
		$('#content, div.mask').hide();
	})
});

function setAppSettings() {
	var w = $(window);
	var height = w.height();
	var bgTop = Math.ceil((height / 2 + 400) - 957);
	var sbTop = Math.ceil(height / 2) + 110;
	var contentBody = height - 250;

	$('body').css('background-position', '0 '+bgTop+'px');
	$('#sidebar').css('top', sbTop);
	$('#content .scroller').height(contentBody);
	$('.scroller').scrollbar();
}
