// GroupServer module for displaying URLs
jQuery.noConflict();
GSDisplayURL = function () {
    /* GroupServer Display URL
    
    As the user types in a subdomain name, reflect the resulting URL
    back to them.
    
    FUNCTIONS
      "init":   Add the code to display the URL.
    
    */

    // Private variables
    var subdomain = null;
    var displayedURL = null;
    var displayedSubdomain = null;
    
    // Private methods
      var update_url = function() {
        var subd = jQuery(subdomain).val().toLowerCase();
        var m = '';
        var urlShown = ( jQuery(displayedURL).css('display') != 'none' );
        var urlOrigShown = urlShown;
        
        if ( subd ) {
            if ( !urlShown ) {
                urlShown = true;
                jQuery(displayedURL).fadeIn("slow");
            }
            jQuery(displayedSubdomain).text(subd)
        } else {
            jQuery(displayedURL).fadeOut("slow");
            urlShown = false;
        }
        if (!urlShown && urlOrigShown ) {
            jQuery(displayedURL).fadeOut("slow");
        }
    }
      
    // Public methods and properties
    return {
        init: function (s, u, d) {
            /* Add the address-checking code to the correct widgets
            
            ARGUMENTS
              s:  String containing the ID of the subdomain-entry widget
              u:  String containing the ID of the displayed url for the entry.
              d:  String containing the ID of the displayed subdomain for the entry.
            */
            subdomain = s;
            displayedURL = u;
            displayedSubdomain = d;
            
            subdomainEntry = jQuery(s);
            
            subdomainEntry.keyup(function(event) {
                update_url();
            });
        }
    };
}(); // GSDisplayURL


