function resize()
{
	$('#login_box').css('top','34px');
	$('#login_box').css('left',(($('body').width()/2)-100)+'px');
	$('#welcome_box').css('top','130px');
	$('#welcome_box').css('left',(($('body').width()/2)-410)+'px');
	$('#reg_box').css('top','130px');
	$('#reg_box').css('left',(($('body').width()/2)-90)+'px');
	$('.layer').each( function(index) {
		$(this).css('top',(($(window).height()/2)-($(this).height()/2)+$(document).scrollTop())+'px');
		$(this).css('left',(($('body').width()/2)-$(this).width()/2)+'px');
	});
}
$(document).ready(function() {
	resize();
	$(window).resize(function() {
		resize();
	});
});

function toggleLayer(id)
{
	var iCurrentOpen = 0;
	$('.layer').each( function(index) {
		iCurrentOpen += $(this).is(':visible') ? 1 : 0;
		if ( ($(this).attr('id') != id && $(this).is(':visible')) || id == '' )
		{
			$(this).hide();
		}
	});
	
	if ( $('#'+id).is(':visible') || id == '' )
	{
		$('#dark_layer').css('width',$(document).width());
		$('#dark_layer').css('height',$(document).height());
		$('#dark_layer').css('z-index','-1');
		$('#dark_layer').fadeTo(200,0.0);
		$('#'+id).hide();
	}
	else
	{
		$('#dark_layer').css('width',$(document).width());
		$('#dark_layer').css('height',$(document).height());
		$('#dark_layer').fadeTo(200,0.75);
		$('#dark_layer').css('z-index','990');
		$('#'+id).show();
	}
}

AIM = {
	frame : function(c) {

		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('DIV');
		d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+n+'" name="'+n+'" onload="AIM.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);

		var i = document.getElementById(n);
		if (c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}

		return n;
	},

	form : function(f, name) {
		f.setAttribute('target', name);
	},

	submit : function(f, c) {
		AIM.form(f, AIM.frame(c));
		if (c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	},

	loaded : function(id) {
		var i = document.getElementById(id);
		if (i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow.document;
		} else {
			var d = window.frames[id].document;
		}
		if (d.location.href == "about:blank") {
			return;
		}

		if (typeof(i.onComplete) == 'function') {
			i.onComplete(d.body.innerHTML);
		}
	}
}
