function AEfilelist(pAEid, pAE_HTML_Node, pAE_ParamList, pAE_Parent)
{
/*
This is the Filelist Active Element, which is responsible for generating an XHTML list of files
pertaining to the parameters supplied (e.g. directory, filetype)

*/
    
    D.debugStartFunction("AEfilelist", arguments);
    
    this.superclass = activeElement;
    this.superclass(pAEid, "AEfilelist", "", pAE_HTML_Node, pAE_ParamList, pAE_Parent);
    
    
    this.aeInitialise = function() // Overloads master aeInitialise function
    {
        /*
        Overrides aeInitialise from master activeElement class.
        
        Called after new AE has been created.  Populates HTML nodes with startup text and
        performs any other initialisation for this AE.

        Request list of images from server, based on parameters supplied.
        (Response will be processed in aeProcessResponseData method)
        */
        
        D.debugStartFunction("AEfilelist:aeInitialise", arguments);

        var Header = new Array;
        var Parameters = new Array;
        var DataRequest;
        var RequestXML;
        var RequestDetails;

        Parameters = this.aeParseParameters(this.AE_paramList);
        
        if (Parameters['filetype'])
        {
            this.filetype = Parameters['filetype'];
            D.debug("Restrict list to files of type " + this.filetype );
        }
        else
        {
            this.filetype = "*"; // i.e. all filetypes
            D.debug("Defaulting to listing files of type *." + this.filetype);
        }
        
        this.aeSetStatus("RequestingData");
        D.debug("Sending Request");
        
        Header['msgseqnum']   = "01" // this.aeGetMsgSeqNum();
        Header['requesttype'] = 'datarequest';
        Header['loggingflag'] = 'true';
        Header['aetype']      = this.aeGetAEtype();
        Header['aeid']        = this.aeGetAEid();

        RequestXML = this.aeCreateRequestHeaderXML(Header);

        // The payload for the Imagelist request will consist of the request type (i.e. Imagelist) and
        // the (sub)directory for which a list of files will be returned.
        RequestDetails = this.aeXMLnodeCreate('datarequesttype', 'Filelist');
        RequestDetails += this.aeXMLnodeCreate('directory', Parameters['directory']);
        RequestDetails += this.aeXMLnodeCreate('filetype', Parameters['filetype']);
        RequestXML += this.aeCreateDataRequestXML(RequestDetails);
        
        DataRequest = this.aeXMLnodeCreate('activeelementrequest', RequestXML);
        
        this.aeSendRequest(DataRequest);
    
        // Propogate to any controlled AEs under this one
        
        for (var i=0; i<this.AE_controlledAE_Count; i++)
        {
            this.AE_controlledAE_List[i].aeInitialise();
        }
        
        D.debugEndFunction("aeInitialise");
    }
    
    this.aeScreenChange = function(pScreen)
    {
        D.debugStartFunction("AEfilelist.aeScreenChange", arguments);
        
        this.aeUpdateContent();
        // Cascade to all child AEs
        
        for (var i=0; i<this.AE_controlledAE_Count; i++)
        {
            D.debug("Cascading to AEid " + this.AE_controlledAE_List[i].AE_AEid);
            this.AE_controlledAE_List[i].aeScreenChange(pScreen);
        }
        D.debugEndFunction();
    }

    this.aeUpdateContent = function()
    {
        // This function starts the slideshow, which then runs automatically
        
        D.debugStartFunction("AEfilelist:aeUpdateContent", arguments);
        
        // Content will be updated when the response message is received, so there is nothing to do here
        
        D.debugEndFunction();
    }
    
    this.aeParseParameters = function(pParamString)
    {
    /* 
    This function parses the parameter list passed in to the constructor for the Slideshow.
    
    It is of the form name=value pairs separated by &
    where
        name = dir | filetype
    and
        value = [dir] directory (relative or absolute)
                [filetype] text (e.g. jpg, pdf, doc, *)
        
    */
        var paramArray = pParamString.split("&"); // now we can work on paramArray
        var paramData = new Array;

        D.debugStartFunction("aeParseParameters", arguments);

        for (var i=0; i<paramArray.length; i++)
        {
            var singleParamArray = paramArray[i].split("="); // now we can work on singleParamArray
            
            switch ( singleParamArray[0] )
            {
                case "dir":
                    paramData['directory'] = singleParamArray[1];
                    D.debug("Parameter [" + singleParamArray[0] + "] is [" + singleParamArray[1] + "]");
                break;
            
                case "filetype":
                    paramData['filetype'] = singleParamArray[1];
                    D.debug("Parameter [" + singleParamArray[0] + "] is [" + singleParamArray[1] + "]");
                break;
            
                default:
                    D.debug("Parameter [" + singleParamArray[0] + "] not known");
                break;
            }
        }

        D.debugEndFunction();
        return paramData;
    }
        
    this.aeCreateDataRequestXML = function(pRequestDetails)
    {
        var XML;
        
        XML = this.aeXMLnodeCreate('datarequest', pRequestDetails);
        
        return XML;
    }
    
    this.aeProcessResponseData = function(pXML)
    {
        /*
        This function overrides that of the parent class.
         
        From the file list returned, generate the XHTML to reside in the Slideshow, and start
        a timer to trigger the transition from one image to another.
        
        Note that associated CSS will style the slideshow (inc. showing/hiding images)
        */
        
        D.debugStartFunction("aeProcessResponseData", arguments);
        
        relative_pathname = pXML.getElementsByTagName('dir');
        // relative_pathname[0].firstChild.nodeValue contains what we want
        
        // Build up a list from the data received
        list = "<ul>";
    	filesInList = pXML.getElementsByTagName('file');
        for (var i=0; i<filesInList.length; i++)
        {
            list += "<li><a href=" + '"' + relative_pathname[0].firstChild.nodeValue + "/" + filesInList[i].getElementsByTagName('filename')[0].firstChild.nodeValue
                 + '" target="_blank">' + filesInList[i].getElementsByTagName('caption')[0].firstChild.nodeValue + "</a></li>";
        }
        list += "</ul>";

        this.aeUpdateHTML_Nodes(list);

        D.debugEndFunction();        
    }

    this.aeInitialise();
    this.aeUpdateContent();
    
    D.debugEndFunction("AEfilelist");
}
