
new function()
{
	//var _this = this;
	var account_control_class = "account_control_logged_in";
	var popup_class = "popup";
	var toggler_class = "toggler";
	
	function init()
	{
		// For each account_control
		$$("." + account_control_class).each(function(account_control) {
			// Find account control's popup
			var popup = account_control.select("." + popup_class).first();
			
			// Find the account control's toggler
			var toggler = account_control.select("." + toggler_class).first();
			
			// If both are available
			if (toggler && popup) {
				// Make clicking the toggler toggle the visibility of the popup
				toggler.observe("click", function(e) {
					// By way of the awesomeness of closures... toggle the popup
					if (popup.style.display != "block") {
						popup.style.display = "block";
					} else {
						popup.hide();
					}
					
					$(e).stop();
				});
				
				// Set up another way to close the popup
				popup.observe("click", function(e) {
					e.stopPropagation();
				});
				var first_html = $$("html").first();
				if (first_html) {
					first_html.observe("click", function(e) {
						popup.hide();
					});
				}
				
				/*
				setTimeout(function() {
					var firstTogglerImage = toggler.select("img").first();
					if (firstTogglerImage) {
						if ($("ac_username")) {
							$("ac_username").style.zIndex = 9000;
							alert("username zIndex = " + $("ac_username").style.zIndex);
						}
						firstTogglerImage.style.zIndex = 9999;
						alert("first toggler image zIndex = " + firstTogglerImage.style.zIndex);
					}
				}, 5000);
				*/
			}
		});
	}
	
	if (typeof Prototype != "undefined") {
		document.observe("dom:loaded", init);
	}
};

