
new function()
{
	//var _this = this;
	var account_control_class = "account_control";
	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) {
				// Disable links inside the toggler
				toggler.select("a").each(function(elem) {
					elem.observe("click", function(e) {
						// Prevent the default behavior of the link, but don't stop the event bubbling
						e.preventDefault();
					});
				});
				
				// Set up on-click behavior
				toggler.observe("click", function(e) {
					// By way of the awesomeness of closures... toggle the popup
					if (popup.style.display != "block") {
						popup.style.display = "block";
						
						// Auto-select an input
						var autofocus_target = popup.select(".autofocus").first();
						if (autofocus_target) {
							autofocus_target.focus();
						}
					} else {
						popup.hide();
					}
										
					// Stop the link's default on-click behavior
					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();
					});
				}
			}
		});
	}
	
	if (typeof Prototype != "undefined") {
		document.observe("dom:loaded", init);
	}
};

