(function () {
    var A = Allthat, //shortcut to window.Allthat
        G = Allthat.namespace('Allthat.GUI'); // get link to the Allthat.Widget package (or create empty package if not yet exist)
    
    G.selectUsername = function () {
        $('login_username').focus();
    };
    
    G.selectSignup = function() {
	    $('signup_email').focus();
	};
	
	G.selectWishlist = function() {
	    $('wishlistName').focus();
	    $('wishlistName').select();
	};
	
	G.selectSignup = function() {
	    $('signup_email').focus();
	};
	
	G.fillEditForm = function () {
	    // find out current opened popup
	    var editLink = Allthat.Widget.Popup.POPUPS['edit_wishlist'].clicked;
	    // get id from link dom element id property
	    var id = parseInt(editLink.getProperty('id').match(/([\d]+)$/)[1], 0);
	    var name = $('wishlist_' + id + '_link').get('html').replace(/&nbsp;/g, '');
	    $('wishlist_id').value = id;
	    $('wishlistName').value = name;
	};

        G.fillShareForm = function (wishlist_id, wishlist_name, user) {
            var domain_name = document.location.hostname;
            if( document.location.port != "" ) {
	        domain_name += ":" + document.location.port;
            }
            $('shareUrl').value = "http://" + domain_name + "/follow/"+user+"/"+wishlist_name+"/"+wishlist_id;	  
	};	 


	G.initialize = function () {
        var authorizationStatus = {
            authorized : Allthat.authorized,
            logged_in : Allthat.logged_in
        };
        
        // effects first:
        this.mouseDonwn = new this.MouseDown();
        
        this.splash = new this.Splash();
        this.login = new this.Login(authorizationStatus);
    };
})();
