Index: /branches/devel-api/plugins/markasjunk/markasjunk.js
===================================================================
--- /branches/devel-api/plugins/markasjunk/markasjunk.js	(revision 2284)
+++ /branches/devel-api/plugins/markasjunk/markasjunk.js	(revision 2285)
@@ -14,5 +14,5 @@
 // callback for app-onload event
 if (window.rcmail) {
-  rcmail.add_onload(function(){
+  rcmail.addEventListener('init', function(evt) {
     
     // create button
Index: /branches/devel-api/plugins/userinfo/userinfo.js
===================================================================
--- /branches/devel-api/plugins/userinfo/userinfo.js	(revision 2284)
+++ /branches/devel-api/plugins/userinfo/userinfo.js	(revision 2285)
@@ -2,5 +2,5 @@
 
 if (window.rcmail) {
-  rcmail.add_onload(function(){
+  rcmail.addEventListener('init', function(evt) {
     // <span id="settingstabdefault" class="tablink"><roundcube:button command="preferences" type="link" label="preferences" title="editpreferences" /></span>
     var tab = $('<span>').attr('id', 'settingstabpluginuserinfo').addClass('tablink');
Index: /branches/devel-api/program/include/rcube_plugin.php
===================================================================
--- /branches/devel-api/program/include/rcube_plugin.php	(revision 2284)
+++ /branches/devel-api/program/include/rcube_plugin.php	(revision 2285)
@@ -131,10 +131,26 @@
   public function include_script($fn)
   {
-    // relative file name
-    if ($fn[0] != '/' && !eregi('^https?://', $fn)) {
-      $fn = $this->ID.'/'.$fn;
-    }
-    
-    $this->api->include_script($fn);
+    $this->api->include_script($this->ressource_url($fn));
+  }
+
+  /**
+   * Make this stylesheet available on the client
+   *
+   * @param string File path; absolute or relative to the plugin directory
+   */
+  public function include_stylesheet($fn)
+  {
+    $this->api->include_stylesheet($this->ressource_url($fn));
+  }
+
+  /**
+   * Make the given file name link into the plugin directory
+   */
+  private function ressource_url($fn)
+  {
+    if ($fn[0] != '/' && !eregi('^https?://', $fn))
+      return $this->ID . '/' . $fn;
+    else
+      return $fn;
   }
 
Index: /branches/devel-api/program/include/rcube_plugin_api.php
===================================================================
--- /branches/devel-api/program/include/rcube_plugin_api.php	(revision 2284)
+++ /branches/devel-api/program/include/rcube_plugin_api.php	(revision 2285)
@@ -39,4 +39,5 @@
   private $objectsmap = array();
   private $scripts = array();
+  private $stylesheets = array();
   private $output;
   
@@ -110,4 +111,7 @@
       $output->add_handlers($this->objectsmap);
       
+      foreach ($this->stylesheets as $css)
+        $output->add_header(html::tag('link', array('rel' => "stylesheet", 'type' => "text/css", 'href' => $css)));
+      
       foreach ($this->scripts as $script)
         $output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $script)));
@@ -229,11 +233,40 @@
   
   /**
-   *
+   * Include a plugin script file in the current HTML page
    */
   public function include_script($fn)
   {
-    $this->scripts[] = $this->url . $fn;
-  }
-
+    $src = $this->ressource_url($fn);
+    
+    if ($this->output)
+      $this->output->add_header(html::tag('script', array('type' => "text/javascript", 'src' => $src)));
+    else
+      $this->scripts[] = $src;
+  }
+
+  /**
+    * Include a plugin stylesheet in the current HTML page
+   */
+  public function include_stylesheet($fn)
+  {
+    $src = $this->ressource_url($fn);
+    
+    if ($this->output)
+      $this->output->add_header(html::tag('link', array('rel' => "stylesheet", 'type' => "text/css", 'href' => $src)));
+    else
+      $this->stylesheets[] = $src;
+  }
+  
+  
+  /**
+   * Make the given file name link into the plugins directory
+   */
+  private function ressource_url($fn)
+  {
+    if ($fn[0] != '/' && !eregi('^https?://', $fn))
+      return $this->url . $fn;
+    else
+      return $fn;
+  }
 
 }
Index: /branches/devel-api/program/include/rcube_template.php
===================================================================
--- /branches/devel-api/program/include/rcube_template.php	(revision 2284)
+++ /branches/devel-api/program/include/rcube_template.php	(revision 2285)
@@ -580,9 +580,5 @@
                 
             case 'container':
-                $this->add_script(sprintf(
-                  "%s.gui_container('%s', '%s');",
-                  JS_OBJECT_NAME,
-                  $attrib['name'],
-                  $attrib['id']));
+                $this->command('gui_container', $attrib['name'], $attrib['id']);
                 break;
 
Index: /branches/devel-api/program/js/app.js
===================================================================
--- /branches/devel-api/program/js/app.js	(revision 2284)
+++ /branches/devel-api/program/js/app.js	(revision 2285)
@@ -296,4 +296,6 @@
           else
             this.contact_list.focus();
+            
+          this.gui_objects.folderlist = this.gui_objects.contactslist;
           }
 
@@ -376,9 +378,14 @@
     if (this.pending_message)
       this.display_message(this.pending_message[0], this.pending_message[1]);
-
-    // start keep-alive interval
-    this.start_keepalive();
+      
+    // map implicit containers
+    if (this.gui_objects.folderlist)
+      this.gui_containers.foldertray = $(this.gui_objects.folderlist);
+
+    // trigger init event hook
+    this.triggerEvent('init', { task:this.task, action:this.env.action });
     
     // execute all foreign onload scripts
+    // @deprecated
     for (var i=0; i<this.onloads.length; i++)
       {
@@ -388,5 +395,8 @@
         this.onloads[i]();
       }
-    };
+
+    // start keep-alive interval
+    this.start_keepalive();
+  };
 
   // start interval for keep-alive/recent_check signal
@@ -1229,5 +1239,5 @@
       {
       var li, pos, list, height;
-      list = $((this.task == 'mail' ? '#mailboxlist' : '#directorylist'));
+      list = $(this.gui_objects.folderlist);
       pos = list.offset();
       this.env.folderlist_coords = { x1:pos.left, y1:pos.top, x2:pos.left + list.width(), y2:pos.top + list.height() };
Index: /branches/devel-api/skins/default/templates/mail.html
===================================================================
--- /branches/devel-api/skins/default/templates/mail.html	(revision 2284)
+++ /branches/devel-api/skins/default/templates/mail.html	(revision 2285)
@@ -34,5 +34,4 @@
 <h3 id="mailboxlist-header"><roundcube:label name="mailboxlist" /></h3>
 <roundcube:object name="mailboxlist" id="mailboxlist" maxlength="16" />
-<roundcube:container name="folders" id="mailboxlist" />
 </div>
 
