Index: /branches/OaaS/HeuristicLab.Services.Hive.WebRole/WebRole.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Hive.WebRole/WebRole.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Hive.WebRole/WebRole.cs	(revision 9215)
@@ -24,4 +24,5 @@
 using Microsoft.WindowsAzure.Diagnostics;
 using Microsoft.WindowsAzure.ServiceRuntime;
+using System.Diagnostics;
 
 namespace HeuristicLab.Services.Hive.WebRole {
@@ -31,18 +32,38 @@
 
     public override bool OnStart() {
+      Trace.WriteLine("Starting Janitor Service...");
+      try {
+        DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
+        /*diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
+        diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());*/
+        diagnosticConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
+        diagnosticConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
+        diagnosticConfig.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
+        diagnosticConfig.WindowsEventLog.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
+        DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfig);
+      }
+      catch (Exception e) {
+        Trace.WriteLine("Error during diagnostic configuration: " + e.Message);
+      }
+
       // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config  
-      DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
-      diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
-      diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());
-
+      
+      Trace.WriteLine("Loading diagnostic configuration...");
+      
       // For information on handling configuration changes
       // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
 
       // Start Janitorn Service:
-      janitor = new HiveJanitor();
-      janitorThread = new Thread(janitor.Run);
-      janitorThread.IsBackground = true; //dont keep app alive
-      janitorThread.Start();
-
+      Trace.WriteLine("Starting HiveJanitor...");
+      try {
+        janitor = new HiveJanitor();
+        janitorThread = new Thread(janitor.Run);
+        janitorThread.IsBackground = true; //dont keep app alive
+        janitorThread.Start();
+      }
+      catch (Exception e) {
+        Trace.WriteLine("Error during janitor startup: " + e.Message);
+      }
+      Trace.WriteLine("Startup completed...");
       return base.OnStart();
     }
@@ -51,5 +72,4 @@
       janitor.StopJanitor();
       janitorThread.Join();
-
       base.OnStop();
     }
Index: /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveDao.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveDao.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveDao.cs	(revision 9215)
@@ -28,4 +28,5 @@
 using HeuristicLab.Services.Hive.Interfaces;
 using System.Data.Common;
+using System.Configuration;
 
 namespace HeuristicLab.Services.Hive.DataAccess {
@@ -34,5 +35,11 @@
     public HiveDataContext CreateContext(bool longRunning = false) {
       //var context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
-      var context = new HiveDataContext(provider.GetOpenConnection(Settings.Default.HiveConnectionStringName));      
+      HiveDataContext context;
+      if (ConfigurationManager.ConnectionStrings[Settings.Default.HiveConnectionStringName] == null) {
+        context = new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
+      }
+      else {
+        context = new HiveDataContext(provider.GetOpenConnection(Settings.Default.HiveConnectionStringName));
+      }
       if (longRunning) context.CommandTimeout = (int)Settings.Default.LongRunningDatabaseCommandTimeout.TotalSeconds;
       return context;
Index: /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Hive/3.3/HiveJanitor.cs	(revision 9215)
@@ -23,4 +23,5 @@
 using System.Threading;
 using HeuristicLab.Services.Hive.DataAccess;
+using System.Diagnostics;
 
 namespace HeuristicLab.Services.Hive {
@@ -55,4 +56,5 @@
         try {
           LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: starting cleanup");
+          Trace.WriteLine("HiveJanitor: starting cleanup");
           bool cleanup = false;
           DateTime lastCleanup = DateTime.MinValue;
@@ -70,7 +72,9 @@
           }
           LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log("HiveJanitor: cleanup finished");
+          Trace.WriteLine("HiveJanitor: cleanup finished");
         }
         catch (Exception e) {
           LogFactory.GetLogger(typeof(HiveJanitor).Namespace).Log(string.Format("HiveJanitor: The following exception occured: {0}", e.ToString()));
+          Trace.WriteLine(string.Format("HiveJanitor: The following exception occured: {0}", e.ToString()));
         }
         waitHandle.WaitOne(HeuristicLab.Services.Hive.Properties.Settings.Default.CleanupInterval);
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs	(revision 9215)
@@ -8,4 +8,5 @@
 using Microsoft.WindowsAzure.ServiceRuntime;
 using System.Diagnostics;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
 
 namespace HeuristicLab.Services.Optimization.ControllerService.Azure {
@@ -13,4 +14,5 @@
     public static readonly string SCENARIO_TABLE = "Scenario";
     public static readonly string SCENARIO_BLOB_CONTAINER = "scenario";
+    public static readonly string EXPERIMENT_TABLE = "Experiment";
     public static readonly string CLOUD_SETTINGS_KEY = "Cloudia.WindowsAzure.Storage";
   }
@@ -91,7 +93,96 @@
   }
 
+  internal sealed class ExperimentEntity : TableServiceEntity {
+    public ExperimentEntity() {
+    }
+
+    public ExperimentEntity(string user, Experiment experiment) {
+      PartitionKey = "ScenarioPartition";
+      RowKey = user + "_" + experiment.Name;
+      var scenarios = "";
+      foreach (var scen in experiment.Scenarios) {
+        scenarios += scen.Id + ",";
+      }
+      Scenarios = scenarios.Remove(scenarios.Length - 1);
+      User = user;
+    }
+
+    public string User { get; set; }
+
+    public string Scenarios { get; set; }
+
+  }
+
+  public class ExperimentDao : IExperimentDao {
+    public CloudBlobClient BlobClient { get; set; }
+    public CloudTableClient TableClient { get; set; }
+
+    public bool Add(string username, Model.Experiment experiment) {
+      if (FindByName(username, experiment.Name) != null)
+        return false;
+
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
+      var entity = new ExperimentEntity(username, experiment);
+      serviceContext.AddObject(AzureConstants.EXPERIMENT_TABLE, entity);
+      serviceContext.SaveChangesWithRetries();
+      return true;
+    }
+
+    public bool DeleteByName(string username, string experiment) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
+      var entity = (from e in serviceContext.CreateQuery<ExperimentEntity>(AzureConstants.EXPERIMENT_TABLE)
+                    where e.RowKey == (username + "_" + experiment)
+                    select e).FirstOrDefault();
+      
+      if (entity == null)
+        return false;
+
+      serviceContext.DeleteObject(entity);
+      serviceContext.SaveChangesWithRetries();
+      return true;
+    }
+
+    public Model.Experiment FindByName(string username, string experiment) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
+      var entity = (from e in serviceContext.CreateQuery<ExperimentEntity>(AzureConstants.EXPERIMENT_TABLE)
+                    where e.RowKey == (username + "_" + experiment)
+                    select e).FirstOrDefault();
+      
+      if (entity == null) {
+        return null;
+      }
+
+      var exp = Convert(entity);
+      return exp;
+    }
+
+    private Experiment Convert(ExperimentEntity entity) {
+      var exp = new Experiment() { Name = entity.RowKey.Split('_')[1] };
+      foreach (var scenarioName in entity.Scenarios.Split(','))
+        exp.Scenarios.Add(new OptimizationScenario() { Id = scenarioName });
+      return exp;
+    }
+
+    public IEnumerable<Model.Experiment> GetExperiments(string user) {
+      TableServiceContext serviceContext = TableClient.GetDataServiceContext();
+      TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE);
+      var entites = (from e in serviceContext.CreateQuery<ExperimentEntity>(AzureConstants.EXPERIMENT_TABLE)
+                    where e.User == user
+                    select e).ToList();
+      var experiments = new List<Experiment>();
+      foreach (var entity in entites) {
+        experiments.Add(Convert(entity));
+      }
+      return experiments;
+    }
+  }
+
   public class AzureDataAccessLayer : IDataAccessLayer {
     private IScenarioDao scenarioDao;
     private IBlobDao blobDao;
+    private IExperimentDao expDao;
 
     private CloudStorageAccount storageAccount;
@@ -115,5 +206,5 @@
       get {
         if (scenarioDao == null) {
-          scenarioDao = new ScenarioDao();
+          scenarioDao = new ScenarioDao() { TableClient = StorageAccount.CreateCloudTableClient() };
         }
         return scenarioDao;
@@ -124,5 +215,5 @@
       get {
         if (blobDao == null) {
-          blobDao = new BlobDao();
+          blobDao = new BlobDao() { BlobClient = StorageAccount.CreateCloudBlobClient() };
         }
         return blobDao;
@@ -130,10 +221,11 @@
     }
 
-    public IScenarioDao CreateScenarioDao() {
-      return new ScenarioDao() { TableClient = StorageAccount.CreateCloudTableClient() };
-    }
-
-    public IBlobDao CreateBlobDao() {
-      return new BlobDao() { BlobClient = StorageAccount.CreateCloudBlobClient() };
+    public IExperimentDao ExperimentDao {
+      get {
+        if (expDao == null) {
+          expDao = new ExperimentDao() { TableClient = StorageAccount.CreateCloudTableClient() };
+        }
+        return expDao;
+      }
     }
   }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/HiveScenarioManager.cs	(revision 9215)
@@ -52,5 +52,5 @@
     }
 
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+    public string DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
       // Experiment experiment = new Experiment();
       // var problem = new TravelingSalesmanProblem();
@@ -66,8 +66,8 @@
         br.Optimizer = algo;        
         br.Repetitions = details.Repititions;
-        SendExperimentToHive(user, br, details);
+        return SendExperimentToHive(user, br, details);
       }
       else {       
-        SendExperimentToHive(user, algo, details);
+        return SendExperimentToHive(user, algo, details);
       }
     }
@@ -141,5 +141,5 @@
     }
 
-    private void SendExperimentToHive(Model.User user, IOptimizer exp, JobExecutionDetails details) {      
+    private string SendExperimentToHive(Model.User user, IOptimizer exp, JobExecutionDetails details) {      
       var job = new RefreshableJob();
       job.IsAllowedPrivileged = true;      
@@ -156,6 +156,7 @@
         Console.WriteLine(ex.StackTrace); 
       }, job, new CancellationToken());
-
+      
       job.StopResultPolling();
+      return job.Id != null ? job.Id.ToString() : null;
     }
 
@@ -168,5 +169,5 @@
       foreach (var job in jobsLoaded) {
         jobs.Add(ConvertJob(user, job));
-      }
+      }      
       return jobs;
     }
@@ -182,4 +183,5 @@
       else
         state = JobState.Waiting;
+
       return new Model.Job() { Id = job.Id.ToString(), Name = job.Name, Resource = job.ResourceNames, State = state.Value, DateCreated = job.DateCreated };
     }
@@ -193,8 +195,9 @@
 
 
-    public void DeleteJob(User user, string id) {
+    public bool DeleteJob(User user, string id) {
       ConfigureHive(user);
-      var guid = Guid.Parse(id);
-      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));      
+      var guid = Guid.Parse(id);      
+      HiveServiceLocator.Instance.CallHiveService(s => s.DeleteJob(guid));
+      return true;
     }
 
@@ -344,6 +347,6 @@
       
       // insert into table & blob store
-      var scenDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
+      var scenDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
       
       Guid scenarioXmlGuid = Guid.NewGuid();
@@ -369,6 +372,6 @@
 
     private string GetMapperFromBlobStore(string scenarioName) {
-      var scenarioDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
+      var scenarioDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
       var entity = scenarioDao.FindByName(scenarioName);
       if (entity == null)
@@ -383,6 +386,6 @@
     public bool DeleteScenario(User user, string scenarioName) {
       // delete from table & blob store
-      var scenarioDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
+      var scenarioDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
 
       var entity = scenarioDao.FindByName(scenarioName);
@@ -395,4 +398,89 @@
       return true;
     }
+
+    public bool SaveExperiment(User user, Model.Experiment experiment) {
+      return dal.ExperimentDao.Add(user.Username, experiment);
+    }
+
+    public IEnumerable<string> GetExperiments(User user) {
+      return (from exp in dal.ExperimentDao.GetExperiments(user.Username)
+              select exp.Name);
+    }
+
+
+    public bool DeleteExperiment(User user, string experiment) {
+      return dal.ExperimentDao.DeleteByName(user.Username, experiment);
+    }
+
+
+    public Model.Task GetTaskData(User u, string jobId, string taskId) {
+      ConfigureHive(u);
+      TaskDownloader downloader = new TaskDownloader(new List<Guid>(){Guid.Parse(taskId)});
+      downloader.StartAsync();
+      while (!downloader.IsFinished) {
+        Thread.Sleep(250);
+        if (downloader.IsFaulted) {
+          throw downloader.Exception;
+        }
+      }
+      
+      IDictionary<Guid, HiveTask> hiveTasks = downloader.Results;
+      var task = hiveTasks[Guid.Parse(taskId)];
+      if (task == null) 
+        return null;
+      
+      return new Model.Task() {
+        State = new Model.TaskState() {
+          DateCreated = task.Task.DateCreated.ToString(),
+          DateFinished = task.Task.DateFinished.ToString(),
+          ExecutionTime = task.Task.ExecutionTime.ToString(),
+          State = task.Task.State.ToString()
+        },
+        General = new Model.General() {
+          Id = task.Task.Id.ToString(),
+          LastChanged = task.Task.Modified.ToString(),
+          Name = task.ItemTask.Name
+        }
+      };
+    }
+
+    public Model.Job GetTasks(User u, string jobId) {
+      ConfigureHive(u);
+      var jobTasks = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightJobTasks(Guid.Parse(jobId)));
+      
+      var job = new Model.Job();
+      job.Id = jobId;
+      var tasks = new Dictionary<Guid, Model.Task>();
+      // push all elements to dictionary
+      foreach (var task in jobTasks) {
+        // TODO: Crawl children + parent and create hierarchy!
+        var children = HiveServiceLocator.Instance.CallHiveService<IEnumerable<HeuristicLab.Clients.Hive.LightweightTask>>(s => s.GetLightweightChildTasks(Guid.Parse(jobId), true, true));
+        foreach (var child in children) {
+          tasks[child.Id] = new Model.Task() {
+            State = new Model.TaskState() {
+              DateCreated = child.DateCreated.ToString(),
+              DateFinished = child.DateFinished.ToString(),
+              ExecutionTime = child.ExecutionTime.ToString(),
+              State = child.State.ToString()
+            },
+            General = new Model.General() {
+              Id = child.Id.ToString(),
+              LastChanged = child.Modified.ToString(),
+              Name = child.ItemName
+            }
+          };
+        }
+      }
+
+      // traverse all tasks again and create tree of tasks
+      foreach (var task in jobTasks) {
+        if (task.ParentTaskId.HasValue)
+          tasks[task.Id].Children.Add(tasks[task.ParentTaskId.Value]);
+        else // its a root task
+          job.Tasks.Add(tasks[task.Id]);
+      }
+
+      return job;
+    }
   }
 }
Index: anches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HL/ScenarioParser.cs	(revision 9214)
+++ 	(revision )
@@ -1,316 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using System.Xml;
-using System.Globalization;
-using System.Xml.Linq;
-using HeuristicLab.Services.Optimization.ControllerService.Azure;
-using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
-using System.Diagnostics;
-
-namespace HeuristicLab.Services.Optimization.ControllerService {
-  public class ScenarioParser {
-    private static IList<Model.OptimizationScenario> scenarios;
-    private static object lockable = new object();
-
-    private IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
-
-    public IList<Model.OptimizationScenario> Scenarios {
-      get {
-        if (scenarios == null) {
-          lock (lockable) {
-            if (scenarios == null) {
-              ParseScenarios();
-            }
-          }
-        }
-        return scenarios;
-      }
-    }
-    
-    public Model.OptimizationScenario GetByName(string name) {
-      foreach (var scen in Scenarios) {
-        if (scen.Id == name) {
-          return scen;
-        }
-      }
-      return null;
-    }
-
-    /*// http://www.sascha-dittmann.de/post/Webseitenpfade-einer-Windows-Azure-Web-Rolle-bestimmen.aspx
-    private static IEnumerable<string> WebSiteDirectories {
-      get {
-        var roleRootDir = Environment.GetEnvironmentVariable("RdRoleRoot");
-        if (roleRootDir == null)
-          return Enumerable.Empty<string>();
-        XNamespace roleModelNs =
-          "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition";
-        var roleModelDoc = XDocument.Load(Path.Combine(roleRootDir, "RoleModel.xml"));
-        if (roleModelDoc.Root == null)
-          return Enumerable.Empty<string>();
-
-        var sites = roleModelDoc.Root.Element(roleModelNs + "Sites");
-        if (sites == null)
-          return Enumerable.Empty<string>();
-
-        var siteElements = sites.Elements(roleModelNs + "Site");
-
-        return
-          from siteElement in siteElements
-          where siteElement.Attribute("name") != null
-                && siteElement.Attribute("name").Value == "Web"
-                && siteElement.Attribute("physicalDirectory") != null
-          select Path.Combine(roleRootDir,
-                 siteElement.Attribute("physicalDirectory").Value);
-      }
-    }
-     */
-
-    private void ParseScenarios() {
-      var scens = new List<Model.OptimizationScenario>();
-      /*string path;
-      if (WebSiteDirectories.Count() != 0) {
-        path = WebSiteDirectories.FirstOrDefault() + @"\Mappings";
-      } else {
-        path = AppDomain.CurrentDomain.BaseDirectory + @"\Mappings";
-      }
-        
-      foreach (var file in Directory.EnumerateFiles(path, "*.xml")) {
-        var scenario = ParseScenarioFromFile(file);
-        if (scenario != null)
-          scens.Add(scenario);
-      }*/
-
-      var scenarioDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
-      foreach (var entity in scenarioDao.GetAllEntities()) {
-        var scenarioXml = blobDao.FindByKey(entity.Scenario).Text;
-        var scenario = ParseScenarioFromXml(scenarioXml);
-        if (scenario != null)
-          scens.Add(scenario);
-      }
-
-      scenarios = scens;
-    }
-
-    private XmlReaderSettings GetSettings() {
-      // Set the validation settings.
-      XmlReaderSettings settings = new XmlReaderSettings();
-      settings.ValidationType = ValidationType.Schema;
-      settings.Schemas.Add("urn:scenario-schema", AppDomain.CurrentDomain.BaseDirectory + @"\Mappings\scenario.xsd");      
-      return settings;
-    }
-
-    public Model.OptimizationScenario ParseScenarioFromXml(string xml) {
-      //using (var reader = XmlReader.Create(new StringReader(xml), GetSettings())) {
-        return ParseScenario(new StringReader(xml));
-      //}            
-    }
-
-   /* private Model.OptimizationScenario ParseScenarioFromFile(string filename) {
-      using (var reader = XmlReader.Create(new FileStream(filename, FileMode.Open), GetSettings())) {
-        return ParseScenario(reader);
-      }      
-    } */
-
-    private Model.Problem ParseProblem(XmlReader reader) {
-      var problem = new Model.Problem();
-      while (reader.Read()) {
-        if (reader.NodeType == XmlNodeType.EndElement)
-          break;
-        if (reader.Name == "parameters")
-          problem.Parameters.Items = ParseParameters(reader);
-      }
-      return problem;
-    }
-
-    private void ParseAlgorithms(out IList<Model.Algorithm> algos, XmlReader reader) {
-      algos = new List<Model.Algorithm>();
-      var depth = reader.Depth;
-      do {
-        if (reader.Name == "algorithm" && reader.Depth == depth) {
-          var innerAlg = new Model.Algorithm();
-          algos.Add(innerAlg);
-          
-          innerAlg.Mapper = reader.GetAttribute("mapper");
-          reader.Read();
-          for (;;) {
-            if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.EndElement)
-              break;
-
-            if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.Element) {
-              innerAlg.Parameters.Items = ParseParameters(reader);
-              continue;
-            }
-            else if (reader.Name == "problem" && reader.NodeType == XmlNodeType.Element) {
-              innerAlg.Problem = ParseProblem(reader);
-              continue;
-            }
-            else if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.Element) {
-              IList<Model.Algorithm> childAlgos;
-              ParseAlgorithms(out childAlgos, reader);
-              innerAlg.ChildAlgorithms = childAlgos;
-              //TODO: Test with child algorithms
-              continue;
-            }
-            reader.Read();
-          }
-        }
-      } while (reader.Read() && reader.Depth >= depth);
-    }
-
-    private Model.OptimizationScenario ParseScenarioElement(XmlReader reader) {
-      var scenario = new Model.OptimizationScenario();
-      var depth = reader.Depth;
-      while (reader.Depth >= depth) {
-        if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.EndElement)
-          break;
-
-        if (reader.Name == "name") {
-          scenario.Id = reader.ReadElementContentAsString();
-          continue;
-        }
-        else if (reader.Name == "algorithm") {
-          IList<Model.Algorithm> algos;
-          ParseAlgorithms(out algos, reader);
-          scenario.Algorithm = algos;
-          continue;
-        }
-        reader.Read();
-      }
-      return scenario;
-    }
-
-    private Model.OptimizationScenario ParseScenario(StringReader str) {
-      // Set the validation settings.      
-      bool isErrorPresent = false;
-      var settings = GetSettings();
-      settings.ValidationEventHandler += (sender, args) => {
-        Trace.WriteLine(args.Message);
-        isErrorPresent = true;
-      };
-      Model.OptimizationScenario scenario = null;      
-      using (var reader = XmlReader.Create(str, settings)) {        
-        while (!reader.EOF) {
-          if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.Element) {
-            scenario = ParseScenarioElement(reader);            
-          }
-          reader.Read();
-        }
-      }
-      
-      if (isErrorPresent)
-        return null;
-      return scenario;
-    }
-
-    struct ValueEntry {
-      public double v1;
-      public double v2;
-    };
-
-    private void ParseDecimalMatrix(Model.DecimalMatrix matrix, XmlReader reader) {      
-      IList<ValueEntry> ventries = new List<ValueEntry>();
-      while (reader.Read()) {        
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "value") {
-          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
-          var val2 = Convert.ToDouble(reader.GetAttribute("v2"), CultureInfo.InvariantCulture.NumberFormat);
-          ventries.Add(new ValueEntry() { v1 = val1, v2 = val2 });          
-        }
-      }
-      double[][] mat = new double[ventries.Count][];
-      int i=0;
-      foreach (var entry in ventries) {
-        mat[i] = new double[2];
-        mat[i][0] = entry.v1;
-        mat[i][1] = entry.v2;
-        i++;
-      }
-      matrix.Value = mat;
-    }
-
-    private IList<Model.Parameter> ParseParameters(XmlReader reader) {
-      IList<Model.Parameter> parameters = new List<Model.Parameter>();
-      while (reader.Read()) {
-        if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.EndElement)
-          break;
-        // parse parameter
-        if (reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
-          var param = new Model.Parameter();
-          var typeAtt = reader.GetAttribute("type");
-          param.Type = (Model.ParameterType)Enum.Parse(typeof(Model.ParameterType), typeAtt);
-          switch (param.Type) {
-            case Model.ParameterType.Boolean:
-              param.Value = new Model.BoolValue() { Name = reader.GetAttribute("name"), Value = Convert.ToBoolean(reader.GetAttribute("value")) };
-              break;
-            case Model.ParameterType.Integer:
-            case Model.ParameterType.Percent:
-            case Model.ParameterType.Decimal:
-              //TODO: Check which comma char is being used; enhance to use any
-              param.Value = new Model.DecimalValue() { Name = reader.GetAttribute("name"), Value = Convert.ToDouble(reader.GetAttribute("value"), CultureInfo.InvariantCulture.NumberFormat) };
-              break;            
-            case Model.ParameterType.DecimalMatrix:
-              var decMatrix = new Model.DecimalMatrix() { Name = reader.GetAttribute("name") };
-              ParseDecimalMatrix(decMatrix, reader);
-              param.Value = decMatrix;
-              break;
-            case Model.ParameterType.DecimalVector:
-              var decVec = new Model.DecimalVector() { Name = reader.GetAttribute("name") };
-              ParseDecimalVector(decVec, reader);
-              param.Value = decVec;
-              break;
-            case Model.ParameterType.Type:
-              var type = new Model.TypeValue() { Name = reader.GetAttribute("name") };
-              ParseType(type, reader);
-              param.Value = type;
-              break;
-            case Model.ParameterType.String:
-              param.Value = new Model.StringValue() { Name = reader.GetAttribute("name"), Value = reader.GetAttribute("value") };
-              break;
-            default:
-              Console.WriteLine("Unhandled model type: " + param.Type);
-              break;
-          }
-          parameters.Add(param);
-        }
-      }
-      return parameters;
-    }
-
-    private void ParseType(Model.TypeValue type, XmlReader reader) {
-      var choices = new List<string>();
-      string selected = null;
-      while (reader.Read()) {
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "choice") {
-          var choice = reader.GetAttribute("name");
-          if (reader.HasAttributes && Convert.ToBoolean(reader.GetAttribute("selected"))) {            
-            selected = choice;
-          }
-          choices.Add(choice);
-        }
-      }
-      type.Options = choices.ToArray();
-      type.Value = selected;
-    }
-
-    private void ParseDecimalVector(Model.DecimalVector decVec, XmlReader reader) {
-      var entries = new List<double>();
-      //IList<ValueEntry> ventries = new List<ValueEntry>();
-      while (reader.Read()) {
-        if (reader.Name == "param")
-          break;
-        if (reader.Name == "value") {
-          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
-          entries.Add(val1);
-        }
-      }
-      decVec.Value = entries.ToArray();      
-    }
-  }
-}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/HeuristicLab.Services.Optimization.ControllerService.csproj	(revision 9215)
@@ -151,4 +151,7 @@
     <Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
     <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
+    <Reference Include="Newtonsoft.Json">
+      <HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.configuration" />
@@ -175,7 +178,8 @@
     <Compile Include="Mockup\MockupDAL.cs" />
     <Compile Include="Mockup\MockupScenarioManager.cs" />
+    <Compile Include="Parsers\AlgorithmConverter.cs" />
     <Compile Include="PlaceholderControllerService.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="HL\ScenarioParser.cs" />
+    <Compile Include="Parsers\ScenarioParser.cs" />
     <Compile Include="Utility.cs" />
   </ItemGroup>
@@ -186,5 +190,4 @@
     <None Include="packages.config" />
   </ItemGroup>
-  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <PropertyGroup>
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/DAL.cs	(revision 9215)
@@ -3,4 +3,5 @@
 using System.Linq;
 using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
 
 namespace HeuristicLab.Services.Optimization.ControllerService.Interfaces {
@@ -17,4 +18,11 @@
   }
 
+  public interface IExperimentDao {
+    bool Add(string username, Experiment experiment);
+    bool DeleteByName(string username, string experiment);
+    Experiment FindByName(string username, string experiment);
+    IEnumerable<Experiment> GetExperiments(string user);
+  }
+
   public interface IBlobDao {
     bool Add(StringEntry entry);
@@ -24,6 +32,7 @@
 
   public interface IDataAccessLayer {
-    IScenarioDao CreateScenarioDao();
-    IBlobDao CreateBlobDao();
+    IScenarioDao ScenarioDao { get; }
+    IBlobDao BlobDao { get; }
+    IExperimentDao ExperimentDao { get; }    
   }
 
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IControllerService.cs	(revision 9215)
@@ -20,5 +20,5 @@
 
     [OperationContract]
-    void ScheduleOptimizationScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
+    bool ScheduleOptimizationScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
 
     [OperationContract]
@@ -29,5 +29,5 @@
 
     [OperationContract]
-    void DeleteJob(User user, string id);
+    bool DeleteJob(User user, string id);
 
     [OperationContract]
@@ -39,4 +39,19 @@
     [OperationContract]
     bool DeleteHiveScenario(User user, string scenarioName);
+
+    [OperationContract]
+    bool SaveExperiment(User user, Experiment experiment);
+
+    [OperationContract]
+    IEnumerable<string> GetExperiments(User user);
+
+    [OperationContract]
+    bool DeleteExperiment(User user, string experiment);
+
+    [OperationContract]
+    Job GetTasks(User u, string jobId);
+
+    [OperationContract]
+    Task GetTaskData(User u, string jobId, string taskId);
   }
 }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/IScenarioManager.cs	(revision 9215)
@@ -7,11 +7,18 @@
 namespace HeuristicLab.Services.Optimization.ControllerService.Interfaces {
   public interface IScenarioManager {
-    void DispatchScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
+    string DispatchScenario(User user, OptimizationScenario scenario, JobExecutionDetails details);
     IList<Job> GetJobs(User user);
     Job GetJob(User user, string id);
-    void DeleteJob(User user, string id);
+    bool DeleteJob(User user, string id);
     IList<Model.Run> GetJobResults(User user, string id);
     bool AddScenario(User user, string scenarioName, string scenarioXml, string scenarioMapper);
     bool DeleteScenario(User user, string scenarioName);
+
+    bool SaveExperiment(User user, Experiment experiment);
+    IEnumerable<string> GetExperiments(User user);
+    bool DeleteExperiment(User user, string experiment);
+
+    Task GetTaskData(User u, string jobId, string taskId);
+    Job GetTasks(User u, string jobId);
   }
 }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Interfaces/Model/ControllerModel.cs	(revision 9215)
@@ -306,4 +306,7 @@
   public class Experiment {
     [DataMember]
+    public string Name { get; set; }
+
+    [DataMember]
     public IList<OptimizationScenario> Scenarios { get; set; }
 
@@ -340,4 +343,88 @@
 
   [DataContract]
+  public class Property {
+    [DataMember]
+    public string Key { get; set; }
+    [DataMember]
+    public string Value { get; set; }
+  }
+  
+  [DataContract]
+  public class General {
+    [DataMember]
+    public string Name { get { return GetValue("Name"); } set { SetValue("Name", value); } }
+    [DataMember]
+    public string Id { get { return GetValue("Id"); } set { SetValue("Id", value); } }
+    [DataMember]
+    public string Priority { get { return GetValue("Priority"); } set { SetValue("Priority", value); } }
+    [DataMember]
+    public string LastChanged { get { return GetValue("LastChanged"); } set { SetValue("LastChanged", value); } }
+
+    
+    private IList<Property> properties = new List<Property>();
+    [DataMember]
+	  public IList<Property> Properties
+	  {
+		  get { 
+        if (properties == null) 
+          properties = new List<Property>();
+        return properties;
+      }
+		  set { properties = value;}
+	  }
+
+    private string GetValue(string key) {      
+      return (from p in Properties where p.Key == key select p.Value).FirstOrDefault();
+    }
+
+    private void SetValue(string key, string value) {
+      var prop = (from p in Properties where p.Key == key select p).FirstOrDefault();
+      if (prop == null) {
+        prop = new Property();
+        Properties.Add(prop);
+      }
+      prop.Key = key;
+      prop.Value = value;
+    }
+  }
+
+  [DataContract]
+  public class TaskState {
+    [DataMember]
+    public string State { get; set; }
+    [DataMember]
+    public string ExecutionTime { get; set; }
+    [DataMember]
+    public string DateCreated { get; set; }
+    [DataMember]
+    public string DateFinished { get; set; }
+  }
+
+  [DataContract]
+  public class Task {
+    private General general = new General();
+    [DataMember]
+    public General General {
+      get { return general; }
+      set { general = value; }
+    }
+
+    private IList<Task> tasks = new List<Task>();
+    [DataMember]
+    public IList<Task> Children {
+      get { return tasks; }
+      set { tasks = value; }
+    }
+    
+    private TaskState state = new TaskState();
+
+    [DataMember]
+    public TaskState State {
+      get { return state; }
+      set { state = value; }
+    }
+  }
+
+  [DataContract]
   public class Job {
     [DataMember]
@@ -355,4 +442,13 @@
     [DataMember]
     public DateTime DateCreated { get; set; }
+
+    private IList<Task> tasks = new List<Task>();
+
+    [DataMember]
+    public IList<Task> Tasks {
+      get { return tasks; }
+      set { tasks = value; }
+    }
+
   }
 
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupDAL.cs	(revision 9215)
@@ -246,11 +246,12 @@
     }
 
-    public IScenarioDao CreateScenarioDao() {
-      return new ScenarioDao();
-    }
-
-    public IBlobDao CreateBlobDao() {
-      return new BlobDao();
-    }
+    private IExperimentDao experimentDao;
+
+    public IExperimentDao ExperimentDao {
+      get {         
+        return null; 
+      }      
+    }
+
   }
 }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Mockup/MockupScenarioManager.cs	(revision 9215)
@@ -131,6 +131,7 @@
     }
 
-    public void DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
-      // does nothign
+    public string DispatchScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+      // does nothing
+      return "guid";
     }
 
@@ -144,6 +145,7 @@
 
 
-    public void DeleteJob(User user, string id) {
+    public bool DeleteJob(User user, string id) {
       jobs.RemoveAll(j => j.Id == id);
+      return true;
     }
 
@@ -199,6 +201,6 @@
       
       // insert into table & blob store
-      var scenDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
+      var scenDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
       
       Guid scenarioXmlGuid = Guid.NewGuid();
@@ -225,6 +227,6 @@
     public bool DeleteScenario(User user, string scenarioName) {
       // delete from table & blob store
-      var scenarioDao = dal.CreateScenarioDao();
-      var blobDao = dal.CreateBlobDao();
+      var scenarioDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
 
       var entity = scenarioDao.FindByName(scenarioName);
@@ -237,4 +239,28 @@
       return true;
     }
+
+
+    public bool SaveExperiment(User user, Model.Experiment experiment) {
+      throw new NotImplementedException();
+    }
+
+
+    public IEnumerable<string> GetExperiments(User user) {
+      throw new NotImplementedException();
+    }
+
+
+    public bool DeleteExperiment(User user, string experiment) {
+      throw new NotImplementedException();
+    }
+
+
+    public Model.Task GetTaskData(User u, string jobId, string taskId) {
+      throw new NotImplementedException();
+    }
+
+    public Model.Job GetTasks(User u, string jobId) {
+      throw new NotImplementedException();
+    }
   }
 }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/AlgorithmConverter.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/AlgorithmConverter.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/AlgorithmConverter.cs	(revision 9215)
@@ -0,0 +1,76 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using Newtonsoft.Json.Linq;
+
+namespace HeuristicLab.Services.Optimization.ControllerService.Parsers {
+  public static class AlgorithmConverter {
+
+    public static Algorithm Convert(string json) {
+      var algorithm = new Algorithm();
+      var o = JObject.Parse(json);
+      foreach (JProperty param in o["Algorithm Parameters"]) {
+        Parameter parameter = CreateParameter(param);
+        algorithm.Parameters.Items.Add(parameter);
+      }
+
+      var problemParams = o["Problem Parameters"];
+      // TODO: Store problem parameters
+      if (problemParams != null) {
+        algorithm.Problem = new Problem();
+        foreach (JProperty param in problemParams) {
+          Parameter parameter = CreateParameter(param);
+          algorithm.Problem.Parameters.Items.Add(parameter);
+        }
+      }
+      return algorithm;
+    }
+
+    public static Algorithm ConvertAppend(string json, Algorithm algorithm) {
+      var o = JObject.Parse(json);
+      foreach (JProperty param in o["Algorithm Parameters"]) {
+        Parameter parameter = CreateParameter(param);
+        var oldParameter = (from p in algorithm.Parameters.Items where p.Value.Name == parameter.Value.Name select p).FirstOrDefault();
+        if (oldParameter != null) {
+          oldParameter.Value = parameter.Value;
+        }
+        else {
+          algorithm.Parameters.Items.Add(parameter);
+        }
+      }
+
+      var problemParams = o["Problem Parameters"];
+      if (problemParams != null) {
+        algorithm.Problem = new Problem();
+        foreach (JProperty param in problemParams) {
+          Parameter parameter = CreateParameter(param);          
+          var oldParameter = (from p in algorithm.Problem.Parameters.Items where p.Value.Name == parameter.Value.Name select p).FirstOrDefault();
+          if (oldParameter != null) {
+            oldParameter.Value = parameter.Value;
+          }
+          else {
+            algorithm.Problem.Parameters.Items.Add(parameter);
+          }
+        }
+      }
+      return algorithm;
+    }
+
+    private static Parameter CreateParameter(JProperty property) {
+      JToken token = property.Value;
+      switch (token.Type) {
+        case JTokenType.Integer:
+        case JTokenType.Float:
+          return new Parameter() { Type = ParameterType.Decimal, Value = new DecimalValue() { Name = property.Name, Value = (double)property.Value } };
+        case JTokenType.Boolean:
+          return new Parameter() { Type = ParameterType.Boolean, Value = new BoolValue() { Name = property.Name, Value = (bool)property.Value } };
+        case JTokenType.String:
+          return new Parameter() { Type = ParameterType.Type, Value = new TypeValue() { Name = property.Name, Value = (string)property.Value } };                  
+        default:
+          throw new Exception("Unhandled datatype: " + property.Type);
+      }
+    }
+  }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/ScenarioParser.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/ScenarioParser.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/Parsers/ScenarioParser.cs	(revision 9215)
@@ -0,0 +1,316 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Xml;
+using System.Globalization;
+using System.Xml.Linq;
+using HeuristicLab.Services.Optimization.ControllerService.Azure;
+using HeuristicLab.Services.Optimization.ControllerService.Interfaces;
+using System.Diagnostics;
+
+namespace HeuristicLab.Services.Optimization.ControllerService {
+  public class ScenarioParser {
+    private static IList<Model.OptimizationScenario> scenarios;
+    private static object lockable = new object();
+
+    private IDataAccessLayer dal = DataAccessLayerProvider.GetLayer();
+
+    public IList<Model.OptimizationScenario> Scenarios {
+      get {
+        if (scenarios == null) {
+          lock (lockable) {
+            if (scenarios == null) {
+              ParseScenarios();
+            }
+          }
+        }
+        return scenarios;
+      }
+    }
+    
+    public Model.OptimizationScenario GetByName(string name) {
+      foreach (var scen in Scenarios) {
+        if (scen.Id == name) {
+          return scen;
+        }
+      }
+      return null;
+    }
+
+    /*// http://www.sascha-dittmann.de/post/Webseitenpfade-einer-Windows-Azure-Web-Rolle-bestimmen.aspx
+    private static IEnumerable<string> WebSiteDirectories {
+      get {
+        var roleRootDir = Environment.GetEnvironmentVariable("RdRoleRoot");
+        if (roleRootDir == null)
+          return Enumerable.Empty<string>();
+        XNamespace roleModelNs =
+          "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition";
+        var roleModelDoc = XDocument.Load(Path.Combine(roleRootDir, "RoleModel.xml"));
+        if (roleModelDoc.Root == null)
+          return Enumerable.Empty<string>();
+
+        var sites = roleModelDoc.Root.Element(roleModelNs + "Sites");
+        if (sites == null)
+          return Enumerable.Empty<string>();
+
+        var siteElements = sites.Elements(roleModelNs + "Site");
+
+        return
+          from siteElement in siteElements
+          where siteElement.Attribute("name") != null
+                && siteElement.Attribute("name").Value == "Web"
+                && siteElement.Attribute("physicalDirectory") != null
+          select Path.Combine(roleRootDir,
+                 siteElement.Attribute("physicalDirectory").Value);
+      }
+    }
+     */
+
+    private void ParseScenarios() {
+      var scens = new List<Model.OptimizationScenario>();
+      /*string path;
+      if (WebSiteDirectories.Count() != 0) {
+        path = WebSiteDirectories.FirstOrDefault() + @"\Mappings";
+      } else {
+        path = AppDomain.CurrentDomain.BaseDirectory + @"\Mappings";
+      }
+        
+      foreach (var file in Directory.EnumerateFiles(path, "*.xml")) {
+        var scenario = ParseScenarioFromFile(file);
+        if (scenario != null)
+          scens.Add(scenario);
+      }*/
+
+      var scenarioDao = dal.ScenarioDao;
+      var blobDao = dal.BlobDao;
+      foreach (var entity in scenarioDao.GetAllEntities()) {
+        var scenarioXml = blobDao.FindByKey(entity.Scenario).Text;
+        var scenario = ParseScenarioFromXml(scenarioXml);
+        if (scenario != null)
+          scens.Add(scenario);
+      }
+
+      scenarios = scens;
+    }
+
+    private XmlReaderSettings GetSettings() {
+      // Set the validation settings.
+      XmlReaderSettings settings = new XmlReaderSettings();
+      settings.ValidationType = ValidationType.Schema;
+      settings.Schemas.Add("urn:scenario-schema", AppDomain.CurrentDomain.BaseDirectory + @"\Mappings\scenario.xsd");      
+      return settings;
+    }
+
+    public Model.OptimizationScenario ParseScenarioFromXml(string xml) {
+      //using (var reader = XmlReader.Create(new StringReader(xml), GetSettings())) {
+        return ParseScenario(new StringReader(xml));
+      //}            
+    }
+
+   /* private Model.OptimizationScenario ParseScenarioFromFile(string filename) {
+      using (var reader = XmlReader.Create(new FileStream(filename, FileMode.Open), GetSettings())) {
+        return ParseScenario(reader);
+      }      
+    } */
+
+    private Model.Problem ParseProblem(XmlReader reader) {
+      var problem = new Model.Problem();
+      while (reader.Read()) {
+        if (reader.NodeType == XmlNodeType.EndElement)
+          break;
+        if (reader.Name == "parameters")
+          problem.Parameters.Items = ParseParameters(reader);
+      }
+      return problem;
+    }
+
+    private void ParseAlgorithms(out IList<Model.Algorithm> algos, XmlReader reader) {
+      algos = new List<Model.Algorithm>();
+      var depth = reader.Depth;
+      do {
+        if (reader.Name == "algorithm" && reader.Depth == depth) {
+          var innerAlg = new Model.Algorithm();
+          algos.Add(innerAlg);
+          
+          innerAlg.Mapper = reader.GetAttribute("mapper");
+          reader.Read();
+          for (;;) {
+            if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.EndElement)
+              break;
+
+            if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.Element) {
+              innerAlg.Parameters.Items = ParseParameters(reader);
+              continue;
+            }
+            else if (reader.Name == "problem" && reader.NodeType == XmlNodeType.Element) {
+              innerAlg.Problem = ParseProblem(reader);
+              continue;
+            }
+            else if (reader.Name == "algorithm" && reader.NodeType == XmlNodeType.Element) {
+              IList<Model.Algorithm> childAlgos;
+              ParseAlgorithms(out childAlgos, reader);
+              innerAlg.ChildAlgorithms = childAlgos;
+              //TODO: Test with child algorithms
+              continue;
+            }
+            reader.Read();
+          }
+        }
+      } while (reader.Read() && reader.Depth >= depth);
+    }
+
+    private Model.OptimizationScenario ParseScenarioElement(XmlReader reader) {
+      var scenario = new Model.OptimizationScenario();
+      var depth = reader.Depth;
+      while (reader.Depth >= depth) {
+        if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.EndElement)
+          break;
+
+        if (reader.Name == "name") {
+          scenario.Id = reader.ReadElementContentAsString();
+          continue;
+        }
+        else if (reader.Name == "algorithm") {
+          IList<Model.Algorithm> algos;
+          ParseAlgorithms(out algos, reader);
+          scenario.Algorithm = algos;
+          continue;
+        }
+        reader.Read();
+      }
+      return scenario;
+    }
+
+    private Model.OptimizationScenario ParseScenario(StringReader str) {
+      // Set the validation settings.      
+      bool isErrorPresent = false;
+      var settings = GetSettings();
+      settings.ValidationEventHandler += (sender, args) => {
+        Trace.WriteLine(args.Message);
+        isErrorPresent = true;
+      };
+      Model.OptimizationScenario scenario = null;      
+      using (var reader = XmlReader.Create(str, settings)) {        
+        while (!reader.EOF) {
+          if (reader.Name == "scenario" && reader.NodeType == XmlNodeType.Element) {
+            scenario = ParseScenarioElement(reader);            
+          }
+          reader.Read();
+        }
+      }
+      
+      if (isErrorPresent)
+        return null;
+      return scenario;
+    }
+
+    struct ValueEntry {
+      public double v1;
+      public double v2;
+    };
+
+    private void ParseDecimalMatrix(Model.DecimalMatrix matrix, XmlReader reader) {      
+      IList<ValueEntry> ventries = new List<ValueEntry>();
+      while (reader.Read()) {        
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "value") {
+          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
+          var val2 = Convert.ToDouble(reader.GetAttribute("v2"), CultureInfo.InvariantCulture.NumberFormat);
+          ventries.Add(new ValueEntry() { v1 = val1, v2 = val2 });          
+        }
+      }
+      double[][] mat = new double[ventries.Count][];
+      int i=0;
+      foreach (var entry in ventries) {
+        mat[i] = new double[2];
+        mat[i][0] = entry.v1;
+        mat[i][1] = entry.v2;
+        i++;
+      }
+      matrix.Value = mat;
+    }
+
+    private IList<Model.Parameter> ParseParameters(XmlReader reader) {
+      IList<Model.Parameter> parameters = new List<Model.Parameter>();
+      while (reader.Read()) {
+        if (reader.Name == "parameters" && reader.NodeType == XmlNodeType.EndElement)
+          break;
+        // parse parameter
+        if (reader.Name == "param" && reader.NodeType == XmlNodeType.Element) {
+          var param = new Model.Parameter();
+          var typeAtt = reader.GetAttribute("type");
+          param.Type = (Model.ParameterType)Enum.Parse(typeof(Model.ParameterType), typeAtt);
+          switch (param.Type) {
+            case Model.ParameterType.Boolean:
+              param.Value = new Model.BoolValue() { Name = reader.GetAttribute("name"), Value = Convert.ToBoolean(reader.GetAttribute("value")) };
+              break;
+            case Model.ParameterType.Integer:
+            case Model.ParameterType.Percent:
+            case Model.ParameterType.Decimal:
+              //TODO: Check which comma char is being used; enhance to use any
+              param.Value = new Model.DecimalValue() { Name = reader.GetAttribute("name"), Value = Convert.ToDouble(reader.GetAttribute("value"), CultureInfo.InvariantCulture.NumberFormat) };
+              break;            
+            case Model.ParameterType.DecimalMatrix:
+              var decMatrix = new Model.DecimalMatrix() { Name = reader.GetAttribute("name") };
+              ParseDecimalMatrix(decMatrix, reader);
+              param.Value = decMatrix;
+              break;
+            case Model.ParameterType.DecimalVector:
+              var decVec = new Model.DecimalVector() { Name = reader.GetAttribute("name") };
+              ParseDecimalVector(decVec, reader);
+              param.Value = decVec;
+              break;
+            case Model.ParameterType.Type:
+              var type = new Model.TypeValue() { Name = reader.GetAttribute("name") };
+              ParseType(type, reader);
+              param.Value = type;
+              break;
+            case Model.ParameterType.String:
+              param.Value = new Model.StringValue() { Name = reader.GetAttribute("name"), Value = reader.GetAttribute("value") };
+              break;
+            default:
+              Console.WriteLine("Unhandled model type: " + param.Type);
+              break;
+          }
+          parameters.Add(param);
+        }
+      }
+      return parameters;
+    }
+
+    private void ParseType(Model.TypeValue type, XmlReader reader) {
+      var choices = new List<string>();
+      string selected = null;
+      while (reader.Read()) {
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "choice") {
+          var choice = reader.GetAttribute("name");
+          if (reader.HasAttributes && Convert.ToBoolean(reader.GetAttribute("selected"))) {            
+            selected = choice;
+          }
+          choices.Add(choice);
+        }
+      }
+      type.Options = choices.ToArray();
+      type.Value = selected;
+    }
+
+    private void ParseDecimalVector(Model.DecimalVector decVec, XmlReader reader) {
+      var entries = new List<double>();
+      //IList<ValueEntry> ventries = new List<ValueEntry>();
+      while (reader.Read()) {
+        if (reader.Name == "param")
+          break;
+        if (reader.Name == "value") {
+          var val1 = Convert.ToDouble(reader.GetAttribute("v1"), CultureInfo.InvariantCulture.NumberFormat);
+          entries.Add(val1);
+        }
+      }
+      decVec.Value = entries.ToArray();      
+    }
+  }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Controller/PlaceholderControllerService.cs	(revision 9215)
@@ -69,6 +69,7 @@
     }
 
-    public void ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
+    public bool ScheduleOptimizationScenario(Model.User user, Model.OptimizationScenario scenario, JobExecutionDetails details) {
       hiveManager.DispatchScenario(user, scenario, details);
+      return true;
     }
 
@@ -83,6 +84,6 @@
 
 
-    public void DeleteJob(Model.User user, string id) {
-      hiveManager.DeleteJob(user, id);
+    public bool DeleteJob(Model.User user, string id) {
+      return hiveManager.DeleteJob(user, id);
     }
 
@@ -117,4 +118,28 @@
               select e.Id).AsEnumerable();      
     }
+
+
+    public bool SaveExperiment(User user, Experiment experiment) {
+      return hiveManager.SaveExperiment(user, experiment);
+    }
+
+
+    public IEnumerable<string> GetExperiments(User user) {
+      return hiveManager.GetExperiments(user);
+    }
+
+
+    public bool DeleteExperiment(User user, string experiment) {
+      return hiveManager.DeleteExperiment(user, experiment);
+    }
+
+
+    public Job GetTasks(User u, string jobId) {
+      return hiveManager.GetTasks(u, jobId);
+    }
+
+    public Task GetTaskData(User u, string jobId, string taskId) {
+      return hiveManager.GetTaskData(u, jobId, taskId);
+    }
   }
 }
Index: anches/OaaS/HeuristicLab.Services.Optimization.ControllerService.Tests/mappings/mapping.tsp.xml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.ControllerService.Tests/mappings/mapping.tsp.xml	(revision 9214)
+++ 	(revision )
@@ -1,16 +1,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!-- for testing resource reading-->
-<otis-mapping xmlns="urn:otis-mapping-1.0">
-	<!--corlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089-->
-	<!--DoubleValue, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec-->
-    <class name="HeuristicLab.Data.DoubleValue, HeuristicLab.Data-3.3" source="System.Double, mscorlib">
-		<member name="Value" expression="source"/>
-	</class>
-    <!--, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec-->
-	<!--, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null-->
-	<class name="HeuristicLab.Problems.TravelingSalesman.TravelingSalesmanProblem, HeuristicLab.Problems.TravelingSalesman-3.3" source="HeuristicLab.Services.Optimization.ControllerService.Model.OptimizationScenario, HeuristicLab.Services.Optimization.ControllerService" >
-		<!--member name="BestKnownQuality" expression="[$InputParameters.FindDoubleValue('BestKnownQuality')]"/-->
-		<member name="BestKnownQuality" expression="[HeuristicLab.Services.Optimization.ControllerService.Model.HiveMapper.FindDoubleValue($InputParameters, 'BestKnownQuality')]"/>
-	</class>
-	
-</otis-mapping>
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/ExperimentSupport.js
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/ExperimentSupport.js	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/ExperimentSupport.js	(revision 9215)
@@ -0,0 +1,140 @@
+﻿function workInProgress(isWorking) {
+    var loader = $(".loader");
+    var submitButton = $(".submitter");
+    if (isWorking) {
+        loader.removeClass("unseen");
+        submitButton.attr("disabled", "disabled");
+    } else {
+        loader.addClass("unseen");
+        submitButton.removeAttr("disabled");
+    }
+}
+
+function log(arguments) {
+    if (window.console && console && console.log) {
+        if ($.isArray(arguments)) {
+            if ((Array.prototype.slice.call(arguments)).length == 1 && typeof Array.prototype.slice.call(arguments)[0] == 'string') {
+                var txt = (Array.prototype.slice.call(arguments)).toString();
+                console.log(txt);
+                return txt;
+            }
+            else {
+                var txt = Array.prototype.slice.call(arguments);
+                console.log(txt);
+                return txt;
+            }
+        } else {
+            console.log(arguments);
+            return arguments;
+        }
+    }
+}
+
+$(document).ready(function () {
+    var tree = $('#container').dynatree({
+        onActivate: function (node) {
+            if (node && node.data.title !== "Experiment") {
+                $('input[name="RemoveNode"]').removeAttr("disabled");
+            } else if (node) {
+                $('input[name="RemoveNode"]').attr("disabled", "disabled");
+            }
+        },
+        onDeactivate: function (node) {
+        },
+        dnd: {
+            autoExpandMS: 750,
+
+            onDragStart: function (node) {
+                return node.data.title !== "Experiment";
+            },
+            onDragEnter: function (node, sourceNode) {
+                return true;
+            },
+            onDragOver: function (node, sourceNode, hitMode) {
+                return node.data.title !== "Experiment" || hitMode === "over";
+            },
+            onDrop: function (node, sourceNode, hitMode, ui, draggable) {
+                if (sourceNode) {
+                    sourceNode.move(node, hitMode);
+                }
+                else {
+                    newNode = { title: draggable.element[0].id };
+                    if (hitMode == "over") {
+                        node.addChild(newNode);
+                        node.expand(true);
+                    }
+                    else if (hitMode == "before") {
+                        node.parent.addChild(newNode, node);
+                    }
+                    else {
+                        node.parent.addChild(newNode, node.getNextSibling());
+                    }
+                }
+            },
+            onDragLeave: function (node, sourceNode) {
+            }
+        }
+    });
+
+    $('.dragables').each(function () {
+        $(this).draggable({
+            revert: true,
+            connectToDynatree: true,
+            cursorAt: { top: -5, left: -5 },
+            helper: "clone"
+        });
+    });
+
+    $(".submitter").each(function () {
+        var btn = $(this);
+        $(this).click(function () {
+            workInProgress(true);
+            var name = $('input[name="Name"]').val();
+            var root = {
+                Experiment: $("#container").dynatree("getTree").toDict(),
+                Name: name
+            };
+            $.ajax({
+                type: "POST",
+                url: '/Experiment/Save',
+                contentType: "application/json; charset=utf-8",
+                dataType: "json",
+                data: JSON.stringify(root),
+                success: function (result) {
+                    log(result);
+                    if (result.success) {
+                        var clearers = $("#experiments .clearer");
+                        if (clearers && clearers.length > 0) {
+                            var experimentDiv = $('<div class="dragables" id="' + name + '"><p>' + name + '</p></div>').draggable({
+                                revert: true,
+                                connectToDynatree: true,
+                                cursorAt: { top: -5, left: -5 },
+                                helper: "clone"
+                            });
+                            experimentDiv.insertBefore("#experiments .clearer");
+                            //$(clearers[clearers.length - 1]).parent().before().append('<div class="dragables" id="' + name + '"><p>' + name + '</p></div>');
+                            log("Added new div to experiments");
+                            $("#jsonMessage").text("Saved experiment '" + result.data + "'!");
+                        }
+                    } else {
+                        $("#jsonMessage").text(result.error);
+                    }
+                    workInProgress(false);
+                },
+                error: function (errMsg) {
+                    var txt = log(errMsg);
+                    $("#jsonMessage").text(txt);
+                    workInProgress(false);
+                }
+            });
+            return false;
+        });
+    });
+
+    $('input[name="RemoveNode"]').click(function () {
+        var node = $("#container").dynatree("getActiveNode");
+        if (node && node.data.title !== "Experiment")
+            node.remove();
+        $(this).attr("disabled", "disabled");
+    });
+});
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/Site.css
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/Site.css	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/Site.css	(revision 9215)
@@ -335,2 +335,23 @@
     overflow: auto;
 }
+
+.dragables 
+{
+  height :100px;
+  width:100px;
+  border:1px solid #000000;  
+  background: #EEEEEE;  
+  padding: 5px 5px 5px 5px;
+  margin: 5px 5px 5px 5px;
+  float: left;
+}
+
+.clearer 
+{  
+  clear:both;
+}
+
+.treeStyle 
+{
+  border: 1px solid black;
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree-1.2.2.js
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree-1.2.2.js	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree-1.2.2.js	(revision 9215)
@@ -0,0 +1,3336 @@
+/*! jQuery Dynatree Plugin - v1.2.2 - 2012-10-07
+* http://dynatree.googlecode.com/
+* Copyright (c) 2012 Martin Wendt; Licensed MIT, GPL */
+
+/* jsHint options*/
+// Note: We currently allow eval() to parse the 'data' attribtes, when initializing from HTML.
+// TODO: pass jsHint with the options given in grunt.js only.
+//       The following should not be required:
+/*global alert */
+/*jshint nomen:false, smarttabs:true, eqeqeq:false, evil:true, regexp:false */
+
+/*************************************************************************
+ *	Debug functions
+ */
+
+var _canLog = true;
+
+function _log(mode, msg) {
+	/**
+	 * Usage: logMsg("%o was toggled", this);
+	 */
+	if( !_canLog ){
+		return;
+	}
+	// Remove first argument
+	var args = Array.prototype.slice.apply(arguments, [1]);
+	// Prepend timestamp
+	var dt = new Date();
+	var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
+	args[0] = tag + " - " + args[0];
+
+	try {
+		switch( mode ) {
+		case "info":
+			window.console.info.apply(window.console, args);
+			break;
+		case "warn":
+			window.console.warn.apply(window.console, args);
+			break;
+		default:
+			window.console.log.apply(window.console, args);
+			break;
+		}
+	} catch(e) {
+		if( !window.console ){
+			_canLog = false; // Permanently disable, when logging is not supported by the browser
+		}
+	}
+}
+
+function logMsg(msg) {
+	Array.prototype.unshift.apply(arguments, ["debug"]);
+	_log.apply(this, arguments);
+}
+
+
+// Forward declaration
+var getDynaTreePersistData = null;
+
+
+
+/*************************************************************************
+ *	Constants
+ */
+var DTNodeStatus_Error   = -1;
+var DTNodeStatus_Loading = 1;
+var DTNodeStatus_Ok      = 0;
+
+
+// Start of local namespace
+(function($) {
+
+/*************************************************************************
+ *	Common tool functions.
+ */
+
+var Class = {
+	create: function() {
+		return function() {
+			this.initialize.apply(this, arguments);
+		};
+	}
+};
+
+// Tool function to get dtnode from the event target:
+function getDtNodeFromElement(el) {
+	alert("getDtNodeFromElement is deprecated");
+	return $.ui.dynatree.getNode(el);
+/*
+	var iMax = 5;
+	while( el && iMax-- ) {
+		if(el.dtnode) { return el.dtnode; }
+		el = el.parentNode;
+	}
+	return null;
+*/
+}
+
+function noop() {
+}
+
+/*************************************************************************
+ *	Class DynaTreeNode
+ */
+var DynaTreeNode = Class.create();
+
+DynaTreeNode.prototype = {
+	initialize: function(parent, tree, data) {
+		/**
+		 * @constructor
+		 */
+		this.parent = parent;
+		this.tree = tree;
+		if ( typeof data === "string" ){
+			data = { title: data };
+		}
+		if( data.key === undefined ){
+			data.key = "_" + tree._nodeCount++;
+		}
+		this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
+		this.li = null; // not yet created
+		this.span = null; // not yet created
+		this.ul = null; // not yet created
+		this.childList = null; // no subnodes yet
+		this._isLoading = false; // Lazy content is being loaded
+		this.hasSubSel = false;
+		this.bExpanded = false;
+		this.bSelected = false;
+
+	},
+
+	toString: function() {
+		return "DynaTreeNode<" + this.data.key + ">: '" + this.data.title + "'";
+	},
+
+	toDict: function(recursive, callback) {
+		var dict = $.extend({}, this.data);
+		dict.activate = ( this.tree.activeNode === this );
+		dict.focus = ( this.tree.focusNode === this );
+		dict.expand = this.bExpanded;
+		dict.select = this.bSelected;
+		if( callback ){
+			callback(dict);
+		}
+		if( recursive && this.childList ) {
+			dict.children = [];
+			for(var i=0, l=this.childList.length; i<l; i++ ){
+				dict.children.push(this.childList[i].toDict(true, callback));
+			}
+		} else {
+			delete dict.children;
+		}
+		return dict;
+	},
+
+	fromDict: function(dict) {
+		/**
+		 * Update node data. If dict contains 'children', then also replace
+		 * the hole sub tree.
+		 */
+		var children = dict.children;
+		if(children === undefined){
+			this.data = $.extend(this.data, dict);
+			this.render();
+			return;
+		}
+		dict = $.extend({}, dict);
+		dict.children = undefined;
+		this.data = $.extend(this.data, dict);
+		this.removeChildren();
+		this.addChild(children);
+	},
+
+	_getInnerHtml: function() {
+		var tree = this.tree,
+			opts = tree.options,
+			cache = tree.cache,
+			level = this.getLevel(),
+			data = this.data,
+			res = "",
+			imageSrc;
+		// connector (expanded, expandable or simple)
+		if( level < opts.minExpandLevel ) {
+			if(level > 1){
+				res += cache.tagConnector;
+			}
+			// .. else (i.e. for root level) skip expander/connector altogether
+		} else if( this.hasChildren() !== false ) {
+			res += cache.tagExpander;
+		} else {
+			res += cache.tagConnector;
+		}
+		// Checkbox mode
+		if( opts.checkbox && data.hideCheckbox !== true && !data.isStatusNode ) {
+			res += cache.tagCheckbox;
+		}
+		// folder or doctype icon
+		if ( data.icon ) {
+			if (data.icon.charAt(0) === "/"){
+				imageSrc = data.icon;
+			}else{
+				imageSrc = opts.imagePath + data.icon;
+			}
+			res += "<img src='" + imageSrc + "' alt='' />";
+		} else if ( data.icon === false ) {
+			// icon == false means 'no icon'
+//			noop(); // keep JSLint happy
+		} else {
+			// icon == null means 'default icon'
+			res += cache.tagNodeIcon;
+		}
+		// node title
+		var nodeTitle = "";
+		if ( opts.onCustomRender ){
+			nodeTitle = opts.onCustomRender.call(tree, this) || "";
+		}
+		if(!nodeTitle){
+			var tooltip = data.tooltip ? ' title="' + data.tooltip.replace(/\"/g, '&quot;') + '"' : '',
+				href = data.href || "#";
+			if( opts.noLink || data.noLink ) {
+				nodeTitle = '<span style="display:inline-block;" class="' + opts.classNames.title + '"' + tooltip + '>' + data.title + '</span>';
+//				this.tree.logDebug("nodeTitle: " + nodeTitle);
+			} else {
+				nodeTitle = '<a href="' + href + '" class="' + opts.classNames.title + '"' + tooltip + '>' + data.title + '</a>';
+			}
+		}
+		res += nodeTitle;
+		return res;
+	},
+
+
+	_fixOrder: function() {
+		/**
+		 * Make sure, that <li> order matches childList order.
+		 */
+		var cl = this.childList;
+		if( !cl || !this.ul ){
+			return;
+		}
+		var childLI = this.ul.firstChild;
+		for(var i=0, l=cl.length-1; i<l; i++) {
+			var childNode1 = cl[i];
+			var childNode2 = childLI.dtnode;
+			if( childNode1 !== childNode2 ) {
+				this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
+				this.ul.insertBefore(childNode1.li, childNode2.li);
+			} else {
+				childLI = childLI.nextSibling;
+			}
+		}
+	},
+
+
+	render: function(useEffects, includeInvisible) {
+		/**
+		 * Create <li><span>..</span> .. </li> tags for this node.
+		 *
+		 * <li id='KEY' dtnode=NODE> // This div contains the node's span and list of child div's.
+		 *   <span class='title'>S S S A</span> // Span contains graphic spans and title <a> tag
+		 *   <ul> // only present, when node has children
+		 *       <li id='KEY' dtnode=NODE>child1</li>
+		 *       <li id='KEY' dtnode=NODE>child2</li>
+		 *   </ul>
+		 * </li>
+		 */
+//		this.tree.logDebug("%s.render(%s)", this, useEffects);
+		// ---
+		var tree = this.tree,
+			parent = this.parent,
+			data = this.data,
+			opts = tree.options,
+			cn = opts.classNames,
+			isLastSib = this.isLastSibling(),
+			firstTime = false;
+
+		if( !parent && !this.ul ) {
+			// Root node has only a <ul>
+			this.li = this.span = null;
+			this.ul = document.createElement("ul");
+			if( opts.minExpandLevel > 1 ){
+				this.ul.className = cn.container + " " + cn.noConnector;
+			}else{
+				this.ul.className = cn.container;
+			}
+		} else if( parent ) {
+			// Create <li><span /> </li>
+			if( ! this.li ) {
+				firstTime = true;
+				this.li = document.createElement("li");
+				this.li.dtnode = this;
+				if( data.key && opts.generateIds ){
+					this.li.id = opts.idPrefix + data.key;
+				}
+				this.span = document.createElement("span");
+				this.span.className = cn.title;
+				this.li.appendChild(this.span);
+
+				if( !parent.ul ) {
+					// This is the parent's first child: create UL tag
+					// (Hidden, because it will be
+					parent.ul = document.createElement("ul");
+					parent.ul.style.display = "none";
+					parent.li.appendChild(parent.ul);
+//					if( opts.minExpandLevel > this.getLevel() ){
+//						parent.ul.className = cn.noConnector;
+//					}
+				}
+				// set node connector images, links and text
+//				this.span.innerHTML = this._getInnerHtml();
+
+				parent.ul.appendChild(this.li);
+			}
+			// set node connector images, links and text
+			this.span.innerHTML = this._getInnerHtml();
+			// Set classes for current status
+			var cnList = [];
+			cnList.push(cn.node);
+			if( data.isFolder ){
+				cnList.push(cn.folder);
+			}
+			if( this.bExpanded ){
+				cnList.push(cn.expanded);
+			}
+			if( this.hasChildren() !== false ){
+				cnList.push(cn.hasChildren);
+			}
+			if( data.isLazy && this.childList === null ){
+				cnList.push(cn.lazy);
+			}
+			if( isLastSib ){
+				cnList.push(cn.lastsib);
+			}
+			if( this.bSelected ){
+				cnList.push(cn.selected);
+			}
+			if( this.hasSubSel ){
+				cnList.push(cn.partsel);
+			}
+			if( tree.activeNode === this ){
+				cnList.push(cn.active);
+			}
+			if( data.addClass ){
+				cnList.push(data.addClass);
+			}
+			// IE6 doesn't correctly evaluate multiple class names,
+			// so we create combined class names that can be used in the CSS
+			cnList.push(cn.combinedExpanderPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isLazy && this.childList === null ? "d" : "")
+					+ (isLastSib ? "l" : "")
+					);
+			cnList.push(cn.combinedIconPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isFolder ? "f" : "")
+					);
+			this.span.className = cnList.join(" ");
+
+			// TODO: we should not set this in the <span> tag also, if we set it here:
+			this.li.className = isLastSib ? cn.lastsib : "";
+
+			// Allow tweaking, binding, after node was created for the first time
+			if(firstTime && opts.onCreate){
+				opts.onCreate.call(tree, this, this.span);
+			}
+			// Hide children, if node is collapsed
+//			this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			// Allow tweaking after node state was rendered
+			if(opts.onRender){
+				opts.onRender.call(tree, this, this.span);
+			}
+		}
+		// Visit child nodes
+		if( (this.bExpanded || includeInvisible === true) && this.childList ) {
+			for(var i=0, l=this.childList.length; i<l; i++) {
+				this.childList[i].render(false, includeInvisible);
+			}
+			// Make sure the tag order matches the child array
+			this._fixOrder();
+		}
+		// Hide children, if node is collapsed
+		if( this.ul ) {
+			var isHidden = (this.ul.style.display === "none");
+			var isExpanded = !!this.bExpanded;
+//			logMsg("isHidden:%s", isHidden);
+			if( useEffects && opts.fx && (isHidden === isExpanded) ) {
+				var duration = opts.fx.duration || 200;
+				$(this.ul).animate(opts.fx, duration);
+			} else {
+				this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			}
+		}
+	},
+	/** Return '/id1/id2/id3'. */
+	getKeyPath: function(excludeSelf) {
+		var path = [];
+		this.visitParents(function(node){
+			if(node.parent){
+				path.unshift(node.data.key);
+			}
+		}, !excludeSelf);
+		return "/" + path.join(this.tree.options.keyPathSeparator);
+	},
+
+	getParent: function() {
+		return this.parent;
+	},
+
+	getChildren: function() {
+		if(this.hasChildren() === undefined){
+			return undefined; // Lazy node: unloaded, currently loading, or load error
+		}
+		return this.childList;
+	},
+
+	/** Check if node has children (returns undefined, if not sure). */
+	hasChildren: function() {
+		if(this.data.isLazy){
+			if(this.childList === null || this.childList === undefined){
+				// Not yet loaded
+				return undefined;
+			}else if(this.childList.length === 0){
+				// Loaded, but response was empty
+				return false;
+			}else if(this.childList.length === 1 && this.childList[0].isStatusNode()){
+				// Currently loading or load error
+				return undefined;
+			}
+			return true;
+		}
+		return !!this.childList;
+	},
+
+	isFirstSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[0] === this;
+	},
+
+	isLastSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[p.childList.length-1] === this;
+	},
+
+	isLoading: function() {
+		return !!this._isLoading;
+	},
+
+	getPrevSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=1, l=ac.length; i<l; i++){ // start with 1, so prev(first) = null
+			if( ac[i] === this ){
+				return ac[i-1];
+			}
+		}
+		return null;
+	},
+
+	getNextSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=0, l=ac.length-1; i<l; i++){ // up to length-2, so next(last) = null
+			if( ac[i] === this ){
+				return ac[i+1];
+			}
+		}
+		return null;
+	},
+
+	isStatusNode: function() {
+		return (this.data.isStatusNode === true);
+	},
+
+	isChildOf: function(otherNode) {
+		return (this.parent && this.parent === otherNode);
+	},
+
+	isDescendantOf: function(otherNode) {
+		if(!otherNode){
+			return false;
+		}
+		var p = this.parent;
+		while( p ) {
+			if( p === otherNode ){
+				return true;
+			}
+			p = p.parent;
+		}
+		return false;
+	},
+
+	countChildren: function() {
+		var cl = this.childList;
+		if( !cl ){
+			return 0;
+		}
+		var n = cl.length;
+		for(var i=0, l=n; i<l; i++){
+			var child = cl[i];
+			n += child.countChildren();
+		}
+		return n;
+	},
+
+	/**Sort child list by title.
+	 * cmd: optional compare function.
+	 * deep: optional: pass true to sort all descendant nodes.
+	 */
+	sortChildren: function(cmp, deep) {
+		var cl = this.childList;
+		if( !cl ){
+			return;
+		}
+		cmp = cmp || function(a, b) {
+//			return a.data.title === b.data.title ? 0 : a.data.title > b.data.title ? 1 : -1;
+			var x = a.data.title.toLowerCase(),
+				y = b.data.title.toLowerCase();
+			return x === y ? 0 : x > y ? 1 : -1;
+			};
+		cl.sort(cmp);
+		if( deep ){
+			for(var i=0, l=cl.length; i<l; i++){
+				if( cl[i].childList ){
+					cl[i].sortChildren(cmp, "$norender$");
+				}
+			}
+		}
+		if( deep !== "$norender$" ){
+			this.render();
+		}
+	},
+
+	_setStatusNode: function(data) {
+		// Create, modify or remove the status child node (pass 'null', to remove it).
+		var firstChild = ( this.childList ? this.childList[0] : null );
+		if( !data ) {
+			if ( firstChild && firstChild.isStatusNode()) {
+				try{
+					// I've seen exceptions here with loadKeyPath...
+					if(this.ul){
+						this.ul.removeChild(firstChild.li);
+						firstChild.li = null; // avoid leaks (issue 215)
+					}
+				}catch(e){}
+				if( this.childList.length === 1 ){
+					this.childList = [];
+				}else{
+					this.childList.shift();
+				}
+			}
+		} else if ( firstChild ) {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild.data = data;
+			firstChild.render();
+		} else {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild = this.addChild(data);
+		}
+	},
+
+	setLazyNodeStatus: function(lts, opts) {
+		var tooltip = (opts && opts.tooltip) ? opts.tooltip : null,
+			info = (opts && opts.info) ? " (" + opts.info + ")" : "";
+		switch( lts ) {
+			case DTNodeStatus_Ok:
+				this._setStatusNode(null);
+				$(this.span).removeClass(this.tree.options.classNames.nodeLoading);
+				this._isLoading = false;
+//				this.render();
+				if( this.tree.options.autoFocus ) {
+					if( this === this.tree.tnRoot && this.childList && this.childList.length > 0) {
+						// special case: using ajaxInit
+						this.childList[0].focus();
+					} else {
+						this.focus();
+					}
+				}
+				break;
+			case DTNodeStatus_Loading:
+				this._isLoading = true;
+				$(this.span).addClass(this.tree.options.classNames.nodeLoading);
+				// The root is hidden, so we set a temporary status child
+				if(!this.parent){
+					this._setStatusNode({
+						title: this.tree.options.strings.loading + info,
+						tooltip: tooltip,
+						addClass: this.tree.options.classNames.nodeWait
+					});
+				}
+				break;
+			case DTNodeStatus_Error:
+				this._isLoading = false;
+//				$(this.span).addClass(this.tree.options.classNames.nodeError);
+				this._setStatusNode({
+					title: this.tree.options.strings.loadError + info,
+					tooltip: tooltip,
+					addClass: this.tree.options.classNames.nodeError
+				});
+				break;
+			default:
+				throw "Bad LazyNodeStatus: '" + lts + "'.";
+		}
+	},
+
+	_parentList: function(includeRoot, includeSelf) {
+		var l = [];
+		var dtn = includeSelf ? this : this.parent;
+		while( dtn ) {
+			if( includeRoot || dtn.parent ){
+				l.unshift(dtn);
+			}
+			dtn = dtn.parent;
+		}
+		return l;
+	},
+	getLevel: function() {
+		/**
+		 * Return node depth. 0: System root node, 1: visible top-level node.
+		 */
+		var level = 0;
+		var dtn = this.parent;
+		while( dtn ) {
+			level++;
+			dtn = dtn.parent;
+		}
+		return level;
+	},
+
+	_getTypeForOuterNodeEvent: function(event) {
+		/** Return the inner node span (title, checkbox or expander) if
+		 *  event.target points to the outer span.
+		 *  This function should fix issue #93:
+		 *  FF2 ignores empty spans, when generating events (returning the parent instead).
+		 */
+		var cns = this.tree.options.classNames;
+		var target = event.target;
+		// Only process clicks on an outer node span (probably due to a FF2 event handling bug)
+		if( target.className.indexOf(cns.node) < 0 ) {
+			return null;
+		}
+		// Event coordinates, relative to outer node span:
+		var eventX = event.pageX - target.offsetLeft;
+		var eventY = event.pageY - target.offsetTop;
+
+		for(var i=0, l=target.childNodes.length; i<l; i++) {
+			var cn = target.childNodes[i];
+			var x = cn.offsetLeft - target.offsetLeft;
+			var y = cn.offsetTop - target.offsetTop;
+			var nx = cn.clientWidth, ny = cn.clientHeight;
+//	        alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
+			if( eventX >= x && eventX <= (x+nx) && eventY >= y && eventY <= (y+ny) ) {
+//	            alert("HIT "+ cn.className);
+				if( cn.className==cns.title ){
+					return "title";
+				}else if( cn.className==cns.expander ){
+					return "expander";
+				}else if( cn.className==cns.checkbox ){
+					return "checkbox";
+				}else if( cn.className==cns.nodeIcon ){
+					return "icon";
+				}
+			}
+		}
+		return "prefix";
+	},
+
+	getEventTargetType: function(event) {
+		// Return the part of a node, that a click event occured on.
+		// Note: there is no check, if the event was fired on THIS node.
+		var tcn = event && event.target ? event.target.className : "",
+			cns = this.tree.options.classNames;
+
+		if( tcn === cns.title ){
+			return "title";
+		}else if( tcn === cns.expander ){
+			return "expander";
+		}else if( tcn === cns.checkbox ){
+			return "checkbox";
+		}else if( tcn === cns.nodeIcon ){
+			return "icon";
+		}else if( tcn === cns.empty || tcn === cns.vline || tcn === cns.connector ){
+			return "prefix";
+		}else if( tcn.indexOf(cns.node) >= 0 ){
+			// FIX issue #93
+			return this._getTypeForOuterNodeEvent(event);
+		}
+		return null;
+	},
+
+	isVisible: function() {
+		// Return true, if all parents are expanded.
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			if( ! parents[i].bExpanded ){ return false; }
+		}
+		return true;
+	},
+
+	makeVisible: function() {
+		// Make sure, all parents are expanded
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			parents[i]._expand(true);
+		}
+	},
+
+	focus: function() {
+		// TODO: check, if we already have focus
+//		this.tree.logDebug("dtnode.focus(): %o", this);
+		this.makeVisible();
+		try {
+			$(this.span).find(">a").focus();
+		} catch(e) { }
+	},
+
+	isFocused: function() {
+		return (this.tree.tnFocused === this);
+	},
+
+	_activate: function(flag, fireEvents) {
+		// (De)Activate - but not focus - this node.
+		this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.tree, flag, this) === false ){
+			return; // Callback returned false
+		}
+		if( flag ) {
+			// Activate
+			if( this.tree.activeNode ) {
+				if( this.tree.activeNode === this ){
+					return;
+				}
+				this.tree.activeNode.deactivate();
+			}
+			if( opts.activeVisible ){
+				this.makeVisible();
+			}
+			this.tree.activeNode = this;
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
+			}
+			this.tree.persistence.activeKey = this.data.key;
+			$(this.span).addClass(opts.classNames.active);
+			if ( fireEvents && opts.onActivate ){
+				opts.onActivate.call(this.tree, this);
+			}
+		} else {
+			// Deactivate
+			if( this.tree.activeNode === this ) {
+				if ( opts.onQueryActivate && opts.onQueryActivate.call(this.tree, false, this) === false ){
+					return; // Callback returned false
+				}
+				$(this.span).removeClass(opts.classNames.active);
+				if( opts.persist ) {
+					// Note: we don't pass null, but ''. So the cookie is not deleted.
+					// If we pass null, we also have to pass a COPY of opts, because $cookie will override opts.expires (issue 84)
+					$.cookie(opts.cookieId+"-active", "", opts.cookie);
+				}
+				this.tree.persistence.activeKey = null;
+				this.tree.activeNode = null;
+				if ( fireEvents && opts.onDeactivate ){
+					opts.onDeactivate.call(this.tree, this);
+				}
+			}
+		}
+	},
+
+	activate: function() {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.activate(): %o", this);
+		this._activate(true, true);
+	},
+
+	activateSilently: function() {
+		this._activate(true, false);
+	},
+
+	deactivate: function() {
+//		this.tree.logDebug("dtnode.deactivate(): %o", this);
+		this._activate(false, true);
+	},
+
+	isActive: function() {
+		return (this.tree.activeNode === this);
+	},
+
+	_userActivate: function() {
+		// Handle user click / [space] / [enter], according to clickFolderMode.
+		var activate = true;
+		var expand = false;
+		if ( this.data.isFolder ) {
+			switch( this.tree.options.clickFolderMode ) {
+			case 2:
+				activate = false;
+				expand = true;
+				break;
+			case 3:
+				activate = expand = true;
+				break;
+			}
+		}
+		if( this.parent === null ) {
+			expand = false;
+		}
+		if( expand ) {
+			this.toggleExpand();
+			this.focus();
+		}
+		if( activate ) {
+			this.activate();
+		}
+	},
+
+	_setSubSel: function(hasSubSel) {
+		if( hasSubSel ) {
+			this.hasSubSel = true;
+			$(this.span).addClass(this.tree.options.classNames.partsel);
+		} else {
+			this.hasSubSel = false;
+			$(this.span).removeClass(this.tree.options.classNames.partsel);
+		}
+	},
+	/**
+	 * Fix selection and partsel status, of parent nodes, according to current status of
+	 * end nodes.
+	 */
+	_updatePartSelectionState: function() {
+//		alert("_updatePartSelectionState " + this);
+//		this.tree.logDebug("_updatePartSelectionState() - %o", this);
+		var sel;
+		// Return `true` or `false` for end nodes and remove part-sel flag
+		if( ! this.hasChildren() ){
+			sel = (this.bSelected && !this.data.unselectable && !this.data.isStatusNode);
+			this._setSubSel(false);
+			return sel;
+		}
+		// Return `true`, `false`, or `undefined` for parent nodes
+		var i, l,
+			cl = this.childList,
+			allSelected = true,
+			allDeselected = true;
+		for(i=0, l=cl.length; i<l;  i++) {
+			var n = cl[i],
+				s = n._updatePartSelectionState();
+			if( s !== false){
+				allDeselected = false;
+			}
+			if( s !== true){
+				allSelected = false;
+			}
+		}
+		if( allSelected ){
+			sel = true;
+		} else if ( allDeselected ){
+			sel = false;
+		} else {
+			sel = undefined;
+		}
+		this._setSubSel(sel === undefined);
+		this.bSelected = (sel === true);
+		return sel;
+	},
+
+	/**
+	 * Fix selection status, after this node was (de)selected in multi-hier mode.
+	 * This includes (de)selecting all children.
+	 */
+	_fixSelectionState: function() {
+//		alert("_fixSelectionState " + this);
+//		this.tree.logDebug("_fixSelectionState(%s) - %o", this.bSelected, this);
+		var p, i, l;
+		if( this.bSelected ) {
+			// Select all children
+			this.visit(function(node){
+				node.parent._setSubSel(true);
+				if(!node.data.unselectable){
+					node._select(true, false, false);
+				}
+			});
+			// Select parents, if all children are selected
+			p = this.parent;
+			while( p ) {
+				p._setSubSel(true);
+				var allChildsSelected = true;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					var n = p.childList[i];
+					if( !n.bSelected && !n.data.isStatusNode && !n.data.unselectable) {
+					// issue 305 proposes this:
+//					if( !n.bSelected && !n.data.isStatusNode ) {
+						allChildsSelected = false;
+						break;
+					}
+				}
+				if( allChildsSelected ){
+					p._select(true, false, false);
+				}
+				p = p.parent;
+			}
+		} else {
+			// Deselect all children
+			this._setSubSel(false);
+			this.visit(function(node){
+				node._setSubSel(false);
+				node._select(false, false, false);
+			});
+			// Deselect parents, and recalc hasSubSel
+			p = this.parent;
+			while( p ) {
+				p._select(false, false, false);
+				var isPartSel = false;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					if( p.childList[i].bSelected || p.childList[i].hasSubSel ) {
+						isPartSel = true;
+						break;
+					}
+				}
+				p._setSubSel(isPartSel);
+				p = p.parent;
+			}
+		}
+	},
+
+	_select: function(sel, fireEvents, deep) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode._select(%o) - %o", sel, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		//
+		if( this.bSelected === sel ) {
+//			this.tree.logDebug("dtnode._select(%o) IGNORED - %o", sel, this);
+			return;
+		}
+		// Allow event listener to abort selection
+		if ( fireEvents && opts.onQuerySelect && opts.onQuerySelect.call(this.tree, sel, this) === false ){
+			return; // Callback returned false
+		}
+		// Force single-selection
+		if( opts.selectMode==1 && sel ) {
+			this.tree.visit(function(node){
+				if( node.bSelected ) {
+					// Deselect; assuming that in selectMode:1 there's max. one other selected node
+					node._select(false, false, false);
+					return false;
+				}
+			});
+		}
+
+		this.bSelected = sel;
+//        this.tree._changeNodeList("select", this, sel);
+
+		if( sel ) {
+			if( opts.persist ){
+				this.tree.persistence.addSelect(this.data.key);
+			}
+			$(this.span).addClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, true, this);
+			}
+		} else {
+			if( opts.persist ){
+				this.tree.persistence.clearSelect(this.data.key);
+			}
+			$(this.span).removeClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, false, this);
+			}
+		}
+	},
+
+	select: function(sel) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.select(%o) - %o", sel, this);
+		if( this.data.unselectable ){
+			return this.bSelected;
+		}
+		return this._select(sel!==false, true, true);
+	},
+
+	toggleSelect: function() {
+//		this.tree.logDebug("dtnode.toggleSelect() - %o", this);
+		return this.select(!this.bSelected);
+	},
+
+	isSelected: function() {
+		return this.bSelected;
+	},
+
+	isLazy: function() {
+		return !!this.data.isLazy;
+	},
+
+	_loadContent: function() {
+		try {
+			var opts = this.tree.options;
+			this.tree.logDebug("_loadContent: start - %o", this);
+			this.setLazyNodeStatus(DTNodeStatus_Loading);
+			if( true === opts.onLazyRead.call(this.tree, this) ) {
+				// If function returns 'true', we assume that the loading is done:
+				this.setLazyNodeStatus(DTNodeStatus_Ok);
+				// Otherwise (i.e. if the loading was started as an asynchronous process)
+				// the onLazyRead(dtnode) handler is expected to call dtnode.setLazyNodeStatus(DTNodeStatus_Ok/_Error) when done.
+				this.tree.logDebug("_loadContent: succeeded - %o", this);
+			}
+		} catch(e) {
+			this.tree.logWarning("_loadContent: failed - %o", e);
+			this.setLazyNodeStatus(DTNodeStatus_Error, {tooltip: ""+e});
+		}
+	},
+
+	_expand: function(bExpand, forceSync) {
+		if( this.bExpanded === bExpand ) {
+			this.tree.logDebug("dtnode._expand(%o) IGNORED - %o", bExpand, this);
+			return;
+		}
+		this.tree.logDebug("dtnode._expand(%o) - %o", bExpand, this);
+		var opts = this.tree.options;
+		if( !bExpand && this.getLevel() < opts.minExpandLevel ) {
+			this.tree.logDebug("dtnode._expand(%o) prevented collapse - %o", bExpand, this);
+			return;
+		}
+		if ( opts.onQueryExpand && opts.onQueryExpand.call(this.tree, bExpand, this) === false ){
+			return; // Callback returned false
+		}
+		this.bExpanded = bExpand;
+
+		// Persist expand state
+		if( opts.persist ) {
+			if( bExpand ){
+				this.tree.persistence.addExpand(this.data.key);
+			}else{
+				this.tree.persistence.clearExpand(this.data.key);
+			}
+		}
+		// Do not apply animations in init phase, or before lazy-loading
+		var allowEffects = !(this.data.isLazy && this.childList === null)
+			&& !this._isLoading
+			&& !forceSync;
+		this.render(allowEffects);
+
+		// Auto-collapse mode: collapse all siblings
+		if( this.bExpanded && this.parent && opts.autoCollapse ) {
+			var parents = this._parentList(false, true);
+			for(var i=0, l=parents.length; i<l; i++){
+				parents[i].collapseSiblings();
+			}
+		}
+		// If the currently active node is now hidden, deactivate it
+		if( opts.activeVisible && this.tree.activeNode && ! this.tree.activeNode.isVisible() ) {
+			this.tree.activeNode.deactivate();
+		}
+		// Expanding a lazy node: set 'loading...' and call callback
+		if( bExpand && this.data.isLazy && this.childList === null && !this._isLoading ) {
+			this._loadContent();
+			return;
+		}
+		if ( opts.onExpand ){
+			opts.onExpand.call(this.tree, bExpand, this);
+		}
+	},
+
+	isExpanded: function() {
+		return this.bExpanded;
+	},
+
+	expand: function(flag) {
+		flag = (flag !== false);
+		if( !this.childList && !this.data.isLazy && flag ){
+			return; // Prevent expanding empty nodes
+		} else if( this.parent === null && !flag ){
+			return; // Prevent collapsing the root
+		}
+		this._expand(flag);
+	},
+
+	scheduleAction: function(mode, ms) {
+		/** Schedule activity for delayed execution (cancel any pending request).
+		 *  scheduleAction('cancel') will cancel the request.
+		 */
+		if( this.tree.timer ) {
+			clearTimeout(this.tree.timer);
+			this.tree.logDebug("clearTimeout(%o)", this.tree.timer);
+		}
+		var self = this; // required for closures
+		switch (mode) {
+		case "cancel":
+			// Simply made sure that timer was cleared
+			break;
+		case "expand":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger expand");
+				self.expand(true);
+			}, ms);
+			break;
+		case "activate":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger activate");
+				self.activate();
+			}, ms);
+			break;
+		default:
+			throw "Invalid mode " + mode;
+		}
+		this.tree.logDebug("setTimeout(%s, %s): %s", mode, ms, this.tree.timer);
+	},
+
+	toggleExpand: function() {
+		this.expand(!this.bExpanded);
+	},
+
+	collapseSiblings: function() {
+		if( this.parent === null ){
+			return;
+		}
+		var ac = this.parent.childList;
+		for (var i=0, l=ac.length; i<l; i++) {
+			if ( ac[i] !== this && ac[i].bExpanded ){
+				ac[i]._expand(false);
+			}
+		}
+	},
+
+	_onClick: function(event) {
+//		this.tree.logDebug("dtnode.onClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+		var targetType = this.getEventTargetType(event);
+		if( targetType === "expander" ) {
+			// Clicking the expander icon always expands/collapses
+			this.toggleExpand();
+			this.focus(); // issue 95
+		} else if( targetType === "checkbox" ) {
+			// Clicking the checkbox always (de)selects
+			this.toggleSelect();
+			this.focus(); // issue 95
+		} else {
+			this._userActivate();
+			var aTag = this.span.getElementsByTagName("a");
+			if(aTag[0]){
+				// issue 154, 313
+				if(!($.browser.msie && parseInt($.browser.version, 10) < 9)){
+					aTag[0].focus();
+				}
+			}else{
+				// 'noLink' option was set
+				return true;
+			}
+		}
+		// Make sure that clicks stop, otherwise <a href='#'> jumps to the top
+		event.preventDefault();
+	},
+
+	_onDblClick: function(event) {
+//		this.tree.logDebug("dtnode.onDblClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+	},
+
+	_onKeydown: function(event) {
+//		this.tree.logDebug("dtnode.onKeydown(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+		var handled = true,
+			sib;
+//		alert("keyDown" + event.which);
+
+		switch( event.which ) {
+			// charCodes:
+//			case 43: // '+'
+			case 107: // '+'
+			case 187: // '+' @ Chrome, Safari
+				if( !this.bExpanded ){ this.toggleExpand(); }
+				break;
+//			case 45: // '-'
+			case 109: // '-'
+			case 189: // '+' @ Chrome, Safari
+				if( this.bExpanded ){ this.toggleExpand(); }
+				break;
+			//~ case 42: // '*'
+				//~ break;
+			//~ case 47: // '/'
+				//~ break;
+			// case 13: // <enter>
+				// <enter> on a focused <a> tag seems to generate a click-event.
+				// this._userActivate();
+				// break;
+			case 32: // <space>
+				this._userActivate();
+				break;
+			case 8: // <backspace>
+				if( this.parent ){
+					this.parent.focus();
+				}
+				break;
+			case 37: // <left>
+				if( this.bExpanded ) {
+					this.toggleExpand();
+					this.focus();
+//				} else if( this.parent && (this.tree.options.rootVisible || this.parent.parent) ) {
+				} else if( this.parent && this.parent.parent ) {
+					this.parent.focus();
+				}
+				break;
+			case 39: // <right>
+				if( !this.bExpanded && (this.childList || this.data.isLazy) ) {
+					this.toggleExpand();
+					this.focus();
+				} else if( this.childList ) {
+					this.childList[0].focus();
+				}
+				break;
+			case 38: // <up>
+				sib = this.getPrevSibling();
+				while( sib && sib.bExpanded && sib.childList ){
+					sib = sib.childList[sib.childList.length-1];
+				}
+//				if( !sib && this.parent && (this.tree.options.rootVisible || this.parent.parent) )
+				if( !sib && this.parent && this.parent.parent ){
+					sib = this.parent;
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			case 40: // <down>
+				if( this.bExpanded && this.childList ) {
+					sib = this.childList[0];
+				} else {
+					var parents = this._parentList(false, true);
+					for(var i=parents.length-1; i>=0; i--) {
+						sib = parents[i].getNextSibling();
+						if( sib ){ break; }
+					}
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			default:
+				handled = false;
+		}
+		// Return false, if handled, to prevent default processing
+//		return !handled;
+		if(handled){
+			event.preventDefault();
+		}
+	},
+
+	_onKeypress: function(event) {
+		// onKeypress is only hooked to allow user callbacks.
+		// We don't process it, because IE and Safari don't fire keypress for cursor keys.
+//		this.tree.logDebug("dtnode.onKeypress(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+	},
+
+	_onFocus: function(event) {
+		// Handles blur and focus events.
+//		this.tree.logDebug("dtnode._onFocus(%o): %o", event, this);
+		var opts = this.tree.options;
+		if ( event.type == "blur" || event.type == "focusout" ) {
+			if ( opts.onBlur ){
+				opts.onBlur.call(this.tree, this);
+			}
+			if( this.tree.tnFocused ){
+				$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
+			}
+			this.tree.tnFocused = null;
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-focus", "", opts.cookie);
+			}
+		} else if ( event.type=="focus" || event.type=="focusin") {
+			// Fix: sometimes the blur event is not generated
+			if( this.tree.tnFocused && this.tree.tnFocused !== this ) {
+				this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o", this.tree.tnFocused);
+				$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
+			}
+			this.tree.tnFocused = this;
+			if ( opts.onFocus ){
+				opts.onFocus.call(this.tree, this);
+			}
+			$(this.tree.tnFocused.span).addClass(opts.classNames.focused);
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-focus", this.data.key, opts.cookie);
+			}
+		}
+		// TODO: return anything?
+//		return false;
+	},
+
+	visit: function(fn, includeSelf) {
+		// Call fn(node) for all child nodes. Stop iteration, if fn() returns false.
+		var res = true;
+		if( includeSelf === true ) {
+			res = fn(this);
+			if( res === false || res == "skip" ){
+				return res;
+			}
+		}
+		if(this.childList){
+			for(var i=0, l=this.childList.length; i<l; i++){
+				res = this.childList[i].visit(fn, true);
+				if( res === false ){
+					break;
+				}
+			}
+		}
+		return res;
+	},
+
+	visitParents: function(fn, includeSelf) {
+		// Visit parent nodes (bottom up)
+		if(includeSelf && fn(this) === false){
+			return false;
+		}
+		var p = this.parent;
+		while( p ) {
+			if(fn(p) === false){
+				return false;
+			}
+			p = p.parent;
+		}
+		return true;
+	},
+
+	remove: function() {
+		// Remove this node
+//		this.tree.logDebug ("%s.remove()", this);
+		if ( this === this.tree.root ){
+			throw "Cannot remove system root";
+		}
+		return this.parent.removeChild(this);
+	},
+
+	removeChild: function(tn) {
+		// Remove tn from list of direct children.
+		var ac = this.childList;
+		if( ac.length == 1 ) {
+			if( tn !== ac[0] ){
+				throw "removeChild: invalid child";
+			}
+			return this.removeChildren();
+		}
+		if( tn === this.tree.activeNode ){
+			tn.deactivate();
+		}
+		if( this.tree.options.persist ) {
+			if( tn.bSelected ){
+				this.tree.persistence.clearSelect(tn.data.key);
+			}
+			if ( tn.bExpanded ){
+				this.tree.persistence.clearExpand(tn.data.key);
+			}
+		}
+		tn.removeChildren(true);
+//		this.div.removeChild(tn.div);
+		this.ul.removeChild(tn.li);
+		for(var i=0, l=ac.length; i<l; i++) {
+			if( ac[i] === tn ) {
+				this.childList.splice(i, 1);
+//				delete tn;  // JSLint complained
+				break;
+			}
+		}
+	},
+
+	removeChildren: function(isRecursiveCall, retainPersistence) {
+		// Remove all child nodes (more efficiently than recursive remove())
+		this.tree.logDebug("%s.removeChildren(%o)", this, isRecursiveCall);
+		var tree = this.tree;
+		var ac = this.childList;
+		if( ac ) {
+			for(var i=0, l=ac.length; i<l; i++) {
+				var tn = ac[i];
+				if ( tn === tree.activeNode && !retainPersistence ){
+					tn.deactivate();
+				}
+				if( this.tree.options.persist && !retainPersistence ) {
+					if( tn.bSelected ){
+						this.tree.persistence.clearSelect(tn.data.key);
+					}
+					if ( tn.bExpanded ){
+						this.tree.persistence.clearExpand(tn.data.key);
+					}
+				}
+				tn.removeChildren(true, retainPersistence);
+				if(this.ul){
+//					this.ul.removeChild(tn.li);
+					$("li", $(this.ul)).remove(); // issue 231
+				}
+//				delete tn;  JSLint complained
+			}
+			// Set to 'null' which is interpreted as 'not yet loaded' for lazy
+			// nodes
+			this.childList = null;
+		}
+		if( ! isRecursiveCall ) {
+//			this._expand(false);
+//			this.isRead = false;
+			this._isLoading = false;
+			this.render();
+		}
+	},
+
+	setTitle: function(title) {
+		this.fromDict({title: title});
+	},
+
+	reload: function(force) {
+		throw "Use reloadChildren() instead";
+	},
+
+	reloadChildren: function(callback) {
+		// Reload lazy content (expansion state is maintained).
+		if( this.parent === null ){
+			throw "Use tree.reload() instead";
+		}else if( ! this.data.isLazy ){
+			throw "node.reloadChildren() requires lazy nodes.";
+		}
+		// appendAjax triggers 'nodeLoaded' event.
+		// We listen to this, if a callback was passed to reloadChildren
+		if(callback){
+			var self = this;
+			var eventType = "nodeLoaded.dynatree." + this.tree.$tree.attr("id")
+				+ "." + this.data.key;
+			this.tree.$tree.bind(eventType, function(e, node, isOk){
+				self.tree.$tree.unbind(eventType);
+				self.tree.logDebug("loaded %o, %o, %o", e, node, isOk);
+				if(node !== self){
+					throw "got invalid load event";
+				}
+				callback.call(self.tree, node, isOk);
+			});
+		}
+		// The expansion state is maintained
+		this.removeChildren();
+		this._loadContent();
+//		if( this.bExpanded ) {
+//			// Remove children first, to prevent effects being applied
+//			this.removeChildren();
+//			// then force re-expand to trigger lazy loading
+////			this.expand(false);
+////			this.expand(true);
+//			this._loadContent();
+//		} else {
+//			this.removeChildren();
+//			this._loadContent();
+//		}
+	},
+
+	/**
+	 * Make sure the node with a given key path is available in the tree.
+	 */
+	_loadKeyPath: function(keyPath, callback) {
+		var tree = this.tree;
+		tree.logDebug("%s._loadKeyPath(%s)", this, keyPath);
+		if(keyPath === ""){
+			throw "Key path must not be empty";
+		}
+		var segList = keyPath.split(tree.options.keyPathSeparator);
+		if(segList[0] === ""){
+			throw "Key path must be relative (don't start with '/')";
+		}
+		var seg = segList.shift();
+		if(this.childList){
+			for(var i=0, l=this.childList.length; i < l; i++){
+				var child = this.childList[i];
+				if( child.data.key === seg ){
+					if(segList.length === 0) {
+						// Found the end node
+						callback.call(tree, child, "ok");
+
+					}else if(child.data.isLazy && (child.childList === null || child.childList === undefined)){
+						tree.logDebug("%s._loadKeyPath(%s) -> reloading %s...", this, keyPath, child);
+						var self = this;
+						// Note: this line gives a JSLint warning (Don't make functions within a loop)
+						/*jshint loopfunc:true */
+						child.reloadChildren(function(node, isOk){
+							// After loading, look for direct child with that key
+							if(isOk){
+								tree.logDebug("%s._loadKeyPath(%s) -> reloaded %s.", node, keyPath, node);
+								callback.call(tree, child, "loaded");
+								node._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
+							}else{
+								tree.logWarning("%s._loadKeyPath(%s) -> reloadChildren() failed.", self, keyPath);
+								callback.call(tree, child, "error");
+							}
+						});
+						// we can ignore it, since it will only be exectuted once, the the loop is ended
+						// See also http://stackoverflow.com/questions/3037598/how-to-get-around-the-jslint-error-dont-make-functions-within-a-loop
+					} else {
+						callback.call(tree, child, "loaded");
+						// Look for direct child with that key
+						child._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
+					}
+					return;
+				}
+			}
+		}
+		// Could not find key
+		// Callback params: child: undefined, the segment, isEndNode (segList.length === 0)
+		callback.call(tree, undefined, "notfound", seg, segList.length === 0);
+		tree.logWarning("Node not found: " + seg);
+		return;
+	},
+
+	resetLazy: function() {
+		// Discard lazy content.
+		if( this.parent === null ){
+			throw "Use tree.reload() instead";
+		}else if( ! this.data.isLazy ){
+			throw "node.resetLazy() requires lazy nodes.";
+		}
+		this.expand(false);
+		this.removeChildren();
+	},
+
+	_addChildNode: function(dtnode, beforeNode) {
+		/**
+		 * Internal function to add one single DynatreeNode as a child.
+		 *
+		 */
+		var tree = this.tree,
+			opts = tree.options,
+			pers = tree.persistence;
+
+//		tree.logDebug("%s._addChildNode(%o)", this, dtnode);
+
+		// --- Update and fix dtnode attributes if necessary
+		dtnode.parent = this;
+//		if( beforeNode && (beforeNode.parent !== this || beforeNode === dtnode ) )
+//			throw "<beforeNode> must be another child of <this>";
+
+		// --- Add dtnode as a child
+		if ( this.childList === null ) {
+			this.childList = [];
+		} else if( ! beforeNode ) {
+			// Fix 'lastsib'
+			if(this.childList.length > 0) {
+				$(this.childList[this.childList.length-1].span).removeClass(opts.classNames.lastsib);
+			}
+		}
+		if( beforeNode ) {
+			var iBefore = $.inArray(beforeNode, this.childList);
+			if( iBefore < 0 ){
+				throw "<beforeNode> must be a child of <this>";
+			}
+			this.childList.splice(iBefore, 0, dtnode);
+		} else {
+			// Append node
+			this.childList.push(dtnode);
+		}
+
+		// --- Handle persistence
+		// Initial status is read from cookies, if persistence is active and
+		// cookies are already present.
+		// Otherwise the status is read from the data attributes and then persisted.
+		var isInitializing = tree.isInitializing();
+		if( opts.persist && pers.cookiesFound && isInitializing ) {
+			// Init status from cookies
+//			tree.logDebug("init from cookie, pa=%o, dk=%o", pers.activeKey, dtnode.data.key);
+			if( pers.activeKey === dtnode.data.key ){
+				tree.activeNode = dtnode;
+			}
+			if( pers.focusedKey === dtnode.data.key ){
+				tree.focusNode = dtnode;
+			}
+			dtnode.bExpanded = ($.inArray(dtnode.data.key, pers.expandedKeyList) >= 0);
+			dtnode.bSelected = ($.inArray(dtnode.data.key, pers.selectedKeyList) >= 0);
+//			tree.logDebug("    key=%o, bSelected=%o", dtnode.data.key, dtnode.bSelected);
+		} else {
+			// Init status from data (Note: we write the cookies after the init phase)
+//			tree.logDebug("init from data");
+			if( dtnode.data.activate ) {
+				tree.activeNode = dtnode;
+				if( opts.persist ){
+					pers.activeKey = dtnode.data.key;
+				}
+			}
+			if( dtnode.data.focus ) {
+				tree.focusNode = dtnode;
+				if( opts.persist ){
+					pers.focusedKey = dtnode.data.key;
+				}
+			}
+			dtnode.bExpanded = ( dtnode.data.expand === true ); // Collapsed by default
+			if( dtnode.bExpanded && opts.persist ){
+				pers.addExpand(dtnode.data.key);
+			}
+			dtnode.bSelected = ( dtnode.data.select === true ); // Deselected by default
+/*
+			Doesn't work, cause pers.selectedKeyList may be null
+			if( dtnode.bSelected && opts.selectMode==1
+				&& pers.selectedKeyList && pers.selectedKeyList.length>0 ) {
+				tree.logWarning("Ignored multi-selection in single-mode for %o", dtnode);
+				dtnode.bSelected = false; // Fixing bad input data (multi selection for mode:1)
+			}
+*/
+			if( dtnode.bSelected && opts.persist ){
+				pers.addSelect(dtnode.data.key);
+			}
+		}
+
+		// Always expand, if it's below minExpandLevel
+//		tree.logDebug ("%s._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
+		if ( opts.minExpandLevel >= dtnode.getLevel() ) {
+//			tree.logDebug ("Force expand for %o", dtnode);
+			this.bExpanded = true;
+		}
+
+		// In multi-hier mode, update the parents selection state
+		// issue #82: only if not initializing, because the children may not exist yet
+//		if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
+//			dtnode._fixSelectionState();
+
+		// In multi-hier mode, update the parents selection state
+		if( dtnode.bSelected && opts.selectMode==3 ) {
+			var p = this;
+			while( p ) {
+				if( !p.hasSubSel ){
+					p._setSubSel(true);
+				}
+				p = p.parent;
+			}
+		}
+		// render this node and the new child
+		if ( tree.bEnableUpdate ){
+			this.render();
+		}
+		return dtnode;
+	},
+
+	addChild: function(obj, beforeNode) {
+		/**
+		 * Add a node object as child.
+		 *
+		 * This should be the only place, where a DynaTreeNode is constructed!
+		 * (Except for the root node creation in the tree constructor)
+		 *
+		 * @param obj A JS object (may be recursive) or an array of those.
+		 * @param {DynaTreeNode} beforeNode (optional) sibling node.
+		 *
+		 * Data format: array of node objects, with optional 'children' attributes.
+		 * [
+		 *	{ title: "t1", isFolder: true, ... }
+		 *	{ title: "t2", isFolder: true, ...,
+		 *		children: [
+		 *			{title: "t2.1", ..},
+		 *			{..}
+		 *			]
+		 *	}
+		 * ]
+		 * A simple object is also accepted instead of an array.
+		 *
+		 */
+//		this.tree.logDebug("%s.addChild(%o, %o)", this, obj, beforeNode);
+		if(typeof(obj) == "string"){
+			throw "Invalid data type for " + obj;
+		}else if( !obj || obj.length === 0 ){ // Passed null or undefined or empty array
+			return;
+		}else if( obj instanceof DynaTreeNode ){
+			return this._addChildNode(obj, beforeNode);
+		}
+
+		if( !obj.length ){ // Passed a single data object
+			obj = [ obj ];
+		}
+		var prevFlag = this.tree.enableUpdate(false);
+
+		var tnFirst = null;
+		for (var i=0, l=obj.length; i<l; i++) {
+			var data = obj[i];
+			var dtnode = this._addChildNode(new DynaTreeNode(this, this.tree, data), beforeNode);
+			if( !tnFirst ){
+				tnFirst = dtnode;
+			}
+			// Add child nodes recursively
+			if( data.children ){
+				dtnode.addChild(data.children, null);
+			}
+		}
+		this.tree.enableUpdate(prevFlag);
+		return tnFirst;
+	},
+
+	append: function(obj) {
+		this.tree.logWarning("node.append() is deprecated (use node.addChild() instead).");
+		return this.addChild(obj, null);
+	},
+
+	appendAjax: function(ajaxOptions) {
+		var self = this;
+		this.removeChildren(false, true);
+		this.setLazyNodeStatus(DTNodeStatus_Loading);
+		// Debug feature: force a delay, to simulate slow loading...
+		if(ajaxOptions.debugLazyDelay){
+			var ms = ajaxOptions.debugLazyDelay;
+			ajaxOptions.debugLazyDelay = 0;
+			this.tree.logInfo("appendAjax: waiting for debugLazyDelay " + ms);
+			setTimeout(function(){self.appendAjax(ajaxOptions);}, ms);
+			return;
+		}
+		// Ajax option inheritance: $.ajaxSetup < $.ui.dynatree.prototype.options.ajaxDefaults < tree.options.ajaxDefaults < ajaxOptions
+		var orgSuccess = ajaxOptions.success,
+			orgError = ajaxOptions.error,
+			eventType = "nodeLoaded.dynatree." + this.tree.$tree.attr("id") + "." + this.data.key;
+		var options = $.extend({}, this.tree.options.ajaxDefaults, ajaxOptions, {
+			success: function(data, textStatus, jqXHR){
+				// <this> is the request options
+//				self.tree.logDebug("appendAjax().success");
+				var prevPhase = self.tree.phase;
+				self.tree.phase = "init";
+				// postProcess is similar to the standard dataFilter hook,
+				// but it is also called for JSONP
+				if( options.postProcess ){
+					data = options.postProcess.call(this, data, this.dataType);
+				}
+				// Process ASPX WebMethod JSON object inside "d" property
+				// http://code.google.com/p/dynatree/issues/detail?id=202
+				else if (data && data.hasOwnProperty("d")) {
+				   data = (typeof data.d) == "string" ? $.parseJSON(data.d) : data.d;
+				}
+				if(!$.isArray(data) || data.length !== 0){
+					self.addChild(data, null);
+				}
+				self.tree.phase = "postInit";
+				if( orgSuccess ){
+					orgSuccess.call(options, self, data, textStatus);
+				}
+				self.tree.logDebug("trigger " + eventType);
+				self.tree.$tree.trigger(eventType, [self, true]);
+				self.tree.phase = prevPhase;
+				// This should be the last command, so node._isLoading is true
+				// while the callbacks run
+				self.setLazyNodeStatus(DTNodeStatus_Ok);
+				if($.isArray(data) && data.length === 0){
+					// Set to [] which is interpreted as 'no children' for lazy
+					// nodes
+					self.childList = [];
+					self.render();
+				}
+				},
+			error: function(jqXHR, textStatus, errorThrown){
+				// <this> is the request options
+				self.tree.logWarning("appendAjax failed:", textStatus, ":\n", jqXHR, "\n", errorThrown);
+				if( orgError ){
+					orgError.call(options, self, jqXHR, textStatus, errorThrown);
+				}
+				self.tree.$tree.trigger(eventType, [self, false]);
+				self.setLazyNodeStatus(DTNodeStatus_Error, {info: textStatus, tooltip: "" + errorThrown});
+				}
+		});
+		$.ajax(options);
+	},
+
+	move: function(targetNode, mode) {
+		/**Move this node to targetNode.
+		 *  mode 'child': append this node as last child of targetNode.
+		 *                This is the default. To be compatble with the D'n'd
+		 *                hitMode, we also accept 'over'.
+		 *  mode 'before': add this node as sibling before targetNode.
+		 *  mode 'after': add this node as sibling after targetNode.
+		 */
+		var pos;
+		if(this === targetNode){
+			return;
+		}
+		if( !this.parent  ){
+			throw "Cannot move system root";
+		}
+		if(mode === undefined || mode == "over"){
+			mode = "child";
+		}
+		var prevParent = this.parent;
+		var targetParent = (mode === "child") ? targetNode : targetNode.parent;
+		if( targetParent.isDescendantOf(this) ){
+			throw "Cannot move a node to it's own descendant";
+		}
+		// Unlink this node from current parent
+		if( this.parent.childList.length == 1 ) {
+			this.parent.childList = this.parent.data.isLazy ? [] : null;
+			this.parent.bExpanded = false;
+		} else {
+			pos = $.inArray(this, this.parent.childList);
+			if( pos < 0 ){
+				throw "Internal error";
+			}
+			this.parent.childList.splice(pos, 1);
+		}
+		// Remove from source DOM parent
+		if(this.parent.ul){
+			this.parent.ul.removeChild(this.li);
+		}
+
+		// Insert this node to target parent's child list
+		this.parent = targetParent;
+		if( targetParent.hasChildren() ) {
+			switch(mode) {
+			case "child":
+				// Append to existing target children
+				targetParent.childList.push(this);
+				break;
+			case "before":
+				// Insert this node before target node
+				pos = $.inArray(targetNode, targetParent.childList);
+				if( pos < 0 ){
+					throw "Internal error";
+				}
+				targetParent.childList.splice(pos, 0, this);
+				break;
+			case "after":
+				// Insert this node after target node
+				pos = $.inArray(targetNode, targetParent.childList);
+				if( pos < 0 ){
+					throw "Internal error";
+				}
+				targetParent.childList.splice(pos+1, 0, this);
+				break;
+			default:
+				throw "Invalid mode " + mode;
+			}
+		} else {
+			targetParent.childList = [ this ];
+		}
+		// Parent has no <ul> tag yet:
+		if( !targetParent.ul ) {
+			// This is the parent's first child: create UL tag
+			// (Hidden, because it will be
+			targetParent.ul = document.createElement("ul");
+			targetParent.ul.style.display = "none";
+			targetParent.li.appendChild(targetParent.ul);
+		}
+		// Issue 319: Add to target DOM parent (only if node was already rendered(expanded))
+		if(this.li){
+			targetParent.ul.appendChild(this.li);
+		}
+
+		if( this.tree !== targetNode.tree ) {
+			// Fix node.tree for all source nodes
+			this.visit(function(node){
+				node.tree = targetNode.tree;
+			}, null, true);
+			throw "Not yet implemented.";
+		}
+		// TODO: fix selection state
+		// TODO: fix active state
+		if( !prevParent.isDescendantOf(targetParent)) {
+			prevParent.render();
+		}
+		if( !targetParent.isDescendantOf(prevParent) ) {
+			targetParent.render();
+		}
+//		this.tree.redraw();
+/*
+		var tree = this.tree;
+		var opts = tree.options;
+		var pers = tree.persistence;
+
+
+		// Always expand, if it's below minExpandLevel
+//		tree.logDebug ("%s._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
+		if ( opts.minExpandLevel >= dtnode.getLevel() ) {
+//			tree.logDebug ("Force expand for %o", dtnode);
+			this.bExpanded = true;
+		}
+
+		// In multi-hier mode, update the parents selection state
+		// issue #82: only if not initializing, because the children may not exist yet
+//		if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
+//			dtnode._fixSelectionState();
+
+		// In multi-hier mode, update the parents selection state
+		if( dtnode.bSelected && opts.selectMode==3 ) {
+			var p = this;
+			while( p ) {
+				if( !p.hasSubSel )
+					p._setSubSel(true);
+				p = p.parent;
+			}
+		}
+		// render this node and the new child
+		if ( tree.bEnableUpdate )
+			this.render();
+
+		return dtnode;
+
+*/
+	},
+
+	// --- end of class
+	lastentry: undefined
+};
+
+/*************************************************************************
+ * class DynaTreeStatus
+ */
+
+var DynaTreeStatus = Class.create();
+
+
+DynaTreeStatus._getTreePersistData = function(cookieId, cookieOpts) {
+	// Static member: Return persistence information from cookies
+	var ts = new DynaTreeStatus(cookieId, cookieOpts);
+	ts.read();
+	return ts.toDict();
+};
+// Make available in global scope
+getDynaTreePersistData = DynaTreeStatus._getTreePersistData; // TODO: deprecated
+
+
+DynaTreeStatus.prototype = {
+	// Constructor
+	initialize: function(cookieId, cookieOpts) {
+//		this._log("DynaTreeStatus: initialize");
+		if( cookieId === undefined ){
+			cookieId = $.ui.dynatree.prototype.options.cookieId;
+		}
+		cookieOpts = $.extend({}, $.ui.dynatree.prototype.options.cookie, cookieOpts);
+
+		this.cookieId = cookieId;
+		this.cookieOpts = cookieOpts;
+		this.cookiesFound = undefined;
+		this.activeKey = null;
+		this.focusedKey = null;
+		this.expandedKeyList = null;
+		this.selectedKeyList = null;
+	},
+	// member functions
+	_log: function(msg) {
+		//	this.logDebug("_changeNodeList(%o): nodeList:%o, idx:%o", mode, nodeList, idx);
+		Array.prototype.unshift.apply(arguments, ["debug"]);
+		_log.apply(this, arguments);
+	},
+	read: function() {
+//		this._log("DynaTreeStatus: read");
+		// Read or init cookies.
+		this.cookiesFound = false;
+
+		var cookie = $.cookie(this.cookieId + "-active");
+		this.activeKey = ( cookie === null ) ? "" : cookie;
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-focus");
+		this.focusedKey = ( cookie === null ) ? "" : cookie;
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-expand");
+		this.expandedKeyList = ( cookie === null ) ? [] : cookie.split(",");
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-select");
+		this.selectedKeyList = ( cookie === null ) ? [] : cookie.split(",");
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+	},
+	write: function() {
+//		this._log("DynaTreeStatus: write");
+		$.cookie(this.cookieId + "-active", ( this.activeKey === null ) ? "" : this.activeKey, this.cookieOpts);
+		$.cookie(this.cookieId + "-focus", ( this.focusedKey === null ) ? "" : this.focusedKey, this.cookieOpts);
+		$.cookie(this.cookieId + "-expand", ( this.expandedKeyList === null ) ? "" : this.expandedKeyList.join(","), this.cookieOpts);
+		$.cookie(this.cookieId + "-select", ( this.selectedKeyList === null ) ? "" : this.selectedKeyList.join(","), this.cookieOpts);
+	},
+	addExpand: function(key) {
+//		this._log("addExpand(%o)", key);
+		if( $.inArray(key, this.expandedKeyList) < 0 ) {
+			this.expandedKeyList.push(key);
+			$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	clearExpand: function(key) {
+//		this._log("clearExpand(%o)", key);
+		var idx = $.inArray(key, this.expandedKeyList);
+		if( idx >= 0 ) {
+			this.expandedKeyList.splice(idx, 1);
+			$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	addSelect: function(key) {
+//		this._log("addSelect(%o)", key);
+		if( $.inArray(key, this.selectedKeyList) < 0 ) {
+			this.selectedKeyList.push(key);
+			$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	clearSelect: function(key) {
+//		this._log("clearSelect(%o)", key);
+		var idx = $.inArray(key, this.selectedKeyList);
+		if( idx >= 0 ) {
+			this.selectedKeyList.splice(idx, 1);
+			$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	isReloading: function() {
+		return this.cookiesFound === true;
+	},
+	toDict: function() {
+		return {
+			cookiesFound: this.cookiesFound,
+			activeKey: this.activeKey,
+			focusedKey: this.activeKey,
+			expandedKeyList: this.expandedKeyList,
+			selectedKeyList: this.selectedKeyList
+		};
+	},
+	// --- end of class
+	lastentry: undefined
+};
+
+
+/*************************************************************************
+ * class DynaTree
+ */
+
+var DynaTree = Class.create();
+
+// --- Static members ----------------------------------------------------------
+
+DynaTree.version = "$Version:$";
+
+/*
+DynaTree._initTree = function() {
+};
+
+DynaTree._bind = function() {
+};
+*/
+//--- Class members ------------------------------------------------------------
+
+DynaTree.prototype = {
+	// Constructor
+//	initialize: function(divContainer, options) {
+	initialize: function($widget) {
+		// instance members
+		this.phase = "init";
+		this.$widget = $widget;
+		this.options = $widget.options;
+		this.$tree = $widget.element;
+		this.timer = null;
+		// find container element
+		this.divTree = this.$tree.get(0);
+
+//		var parentPos = $(this.divTree).parent().offset();
+//		this.parentTop = parentPos.top;
+//		this.parentLeft = parentPos.left;
+
+		_initDragAndDrop(this);
+	},
+
+	// member functions
+
+	_load: function(callback) {
+		var $widget = this.$widget;
+		var opts = this.options,
+			self = this;
+		this.bEnableUpdate = true;
+		this._nodeCount = 1;
+		this.activeNode = null;
+		this.focusNode = null;
+
+		// Some deprecation warnings to help with migration
+		if( opts.rootVisible !== undefined ){
+			this.logWarning("Option 'rootVisible' is no longer supported.");
+		}
+		if( opts.minExpandLevel < 1 ) {
+			this.logWarning("Option 'minExpandLevel' must be >= 1.");
+			opts.minExpandLevel = 1;
+		}
+//		_log("warn", "jQuery.support.boxModel " + jQuery.support.boxModel);
+
+		// If a 'options.classNames' dictionary was passed, still use defaults
+		// for undefined classes:
+		if( opts.classNames !== $.ui.dynatree.prototype.options.classNames ) {
+			opts.classNames = $.extend({}, $.ui.dynatree.prototype.options.classNames, opts.classNames);
+		}
+		if( opts.ajaxDefaults !== $.ui.dynatree.prototype.options.ajaxDefaults ) {
+			opts.ajaxDefaults = $.extend({}, $.ui.dynatree.prototype.options.ajaxDefaults, opts.ajaxDefaults);
+		}
+		if( opts.dnd !== $.ui.dynatree.prototype.options.dnd ) {
+			opts.dnd = $.extend({}, $.ui.dynatree.prototype.options.dnd, opts.dnd);
+		}
+		// Guess skin path, if not specified
+		if(!opts.imagePath) {
+			$("script").each( function () {
+				var _rexDtLibName = /.*dynatree[^\/]*\.js$/i;
+				if( this.src.search(_rexDtLibName) >= 0 ) {
+					if( this.src.indexOf("/")>=0 ){ // issue #47
+						opts.imagePath = this.src.slice(0, this.src.lastIndexOf("/")) + "/skin/";
+					}else{
+						opts.imagePath = "skin/";
+					}
+					self.logDebug("Guessing imagePath from '%s': '%s'", this.src, opts.imagePath);
+					return false; // first match
+				}
+			});
+		}
+
+		this.persistence = new DynaTreeStatus(opts.cookieId, opts.cookie);
+		if( opts.persist ) {
+			if( !$.cookie ){
+				_log("warn", "Please include jquery.cookie.js to use persistence.");
+			}
+			this.persistence.read();
+		}
+		this.logDebug("DynaTree.persistence: %o", this.persistence.toDict());
+
+		// Cached tag strings
+		this.cache = {
+			tagEmpty: "<span class='" + opts.classNames.empty + "'></span>",
+			tagVline: "<span class='" + opts.classNames.vline + "'></span>",
+			tagExpander: "<span class='" + opts.classNames.expander + "'></span>",
+			tagConnector: "<span class='" + opts.classNames.connector + "'></span>",
+			tagNodeIcon: "<span class='" + opts.classNames.nodeIcon + "'></span>",
+			tagCheckbox: "<span class='" + opts.classNames.checkbox + "'></span>",
+			lastentry: undefined
+		};
+
+		// Clear container, in case it contained some 'waiting' or 'error' text
+		// for clients that don't support JS.
+		// We don't do this however, if we try to load from an embedded UL element.
+		if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId ){
+			$(this.divTree).empty();
+		}
+		var $ulInitialize = this.$tree.find(">ul:first").hide();
+
+		// Create the root element
+		this.tnRoot = new DynaTreeNode(null, this, {});
+		this.tnRoot.bExpanded = true;
+		this.tnRoot.render();
+		this.divTree.appendChild(this.tnRoot.ul);
+
+		var root = this.tnRoot,
+			isReloading = ( opts.persist && this.persistence.isReloading() ),
+			isLazy = false,
+			prevFlag = this.enableUpdate(false);
+
+		this.logDebug("Dynatree._load(): read tree structure...");
+
+		// Init tree structure
+		if( opts.children ) {
+			// Read structure from node array
+			root.addChild(opts.children);
+
+		} else if( opts.initAjax && opts.initAjax.url ) {
+			// Init tree from AJAX request
+			isLazy = true;
+			root.data.isLazy = true;
+			this._reloadAjax(callback);
+
+		} else if( opts.initId ) {
+			// Init tree from another UL element
+			this._createFromTag(root, $("#"+opts.initId));
+
+		} else {
+			// Init tree from the first UL element inside the container <div>
+//			var $ul = this.$tree.find(">ul:first").hide();
+			this._createFromTag(root, $ulInitialize);
+			$ulInitialize.remove();
+		}
+
+		this._checkConsistency();
+		// Fix part-sel flags
+		if(!isLazy && opts.selectMode == 3){
+			root._updatePartSelectionState();
+		}
+		// Render html markup
+		this.logDebug("Dynatree._load(): render nodes...");
+		this.enableUpdate(prevFlag);
+
+		// bind event handlers
+		this.logDebug("Dynatree._load(): bind events...");
+		this.$widget.bind();
+
+		// --- Post-load processing
+		this.logDebug("Dynatree._load(): postInit...");
+		this.phase = "postInit";
+
+		// In persist mode, make sure that cookies are written, even if they are empty
+		if( opts.persist ) {
+			this.persistence.write();
+		}
+		// Set focus, if possible (this will also fire an event and write a cookie)
+		if( this.focusNode && this.focusNode.isVisible() ) {
+			this.logDebug("Focus on init: %o", this.focusNode);
+			this.focusNode.focus();
+		}
+		if( !isLazy ) {
+			if( opts.onPostInit ) {
+				opts.onPostInit.call(this, isReloading, false);
+			}
+			if( callback ){
+				callback.call(this, "ok");
+			}
+		}
+		this.phase = "idle";
+	},
+
+	_reloadAjax: function(callback) {
+		// Reload
+		var opts = this.options;
+		if( ! opts.initAjax || ! opts.initAjax.url ){
+			throw "tree.reload() requires 'initAjax' mode.";
+		}
+		var pers = this.persistence;
+		var ajaxOpts = $.extend({}, opts.initAjax);
+		// Append cookie info to the request
+//		this.logDebug("reloadAjax: key=%o, an.key:%o", pers.activeKey, this.activeNode?this.activeNode.data.key:"?");
+		if( ajaxOpts.addActiveKey ){
+			ajaxOpts.data.activeKey = pers.activeKey;
+		}
+		if( ajaxOpts.addFocusedKey ){
+			ajaxOpts.data.focusedKey = pers.focusedKey;
+		}
+		if( ajaxOpts.addExpandedKeyList ){
+			ajaxOpts.data.expandedKeyList = pers.expandedKeyList.join(",");
+		}
+		if( ajaxOpts.addSelectedKeyList ){
+			ajaxOpts.data.selectedKeyList = pers.selectedKeyList.join(",");
+		}
+		// Set up onPostInit callback to be called when Ajax returns
+		if( ajaxOpts.success ){
+			this.logWarning("initAjax: success callback is ignored; use onPostInit instead.");
+		}
+		if( ajaxOpts.error ){
+			this.logWarning("initAjax: error callback is ignored; use onPostInit instead.");
+		}
+		var isReloading = pers.isReloading();
+		ajaxOpts.success = function(dtnode, data, textStatus) {
+			if(opts.selectMode == 3){
+				dtnode.tree.tnRoot._updatePartSelectionState();
+			}
+			if(opts.onPostInit){
+				opts.onPostInit.call(dtnode.tree, isReloading, false);
+			}
+			if(callback){
+				callback.call(dtnode.tree, "ok");
+			}
+		};
+		ajaxOpts.error = function(dtnode, XMLHttpRequest, textStatus, errorThrown) {
+			if(opts.onPostInit){
+				opts.onPostInit.call(dtnode.tree, isReloading, true, XMLHttpRequest, textStatus, errorThrown);
+			}
+			if(callback){
+				callback.call(dtnode.tree, "error", XMLHttpRequest, textStatus, errorThrown);
+			}
+		};
+//		}
+		this.logDebug("Dynatree._init(): send Ajax request...");
+		this.tnRoot.appendAjax(ajaxOpts);
+	},
+
+	toString: function() {
+//		return "DynaTree '" + this.options.title + "'";
+		return "Dynatree '" + this.$tree.attr("id") + "'";
+	},
+
+	toDict: function() {
+		return this.tnRoot.toDict(true);
+	},
+
+	serializeArray: function(stopOnParents) {
+		// Return a JavaScript array of objects, ready to be encoded as a JSON
+		// string for selected nodes
+		var nodeList = this.getSelectedNodes(stopOnParents),
+			name = this.$tree.attr("name") || this.$tree.attr("id"),
+			arr = [];
+		for(var i=0, l=nodeList.length; i<l; i++){
+			arr.push({name: name, value: nodeList[i].data.key});
+		}
+		return arr;
+	},
+
+	getPersistData: function() {
+		return this.persistence.toDict();
+	},
+
+	logDebug: function(msg) {
+		if( this.options.debugLevel >= 2 ) {
+			Array.prototype.unshift.apply(arguments, ["debug"]);
+			_log.apply(this, arguments);
+		}
+	},
+
+	logInfo: function(msg) {
+		if( this.options.debugLevel >= 1 ) {
+			Array.prototype.unshift.apply(arguments, ["info"]);
+			_log.apply(this, arguments);
+		}
+	},
+
+	logWarning: function(msg) {
+		Array.prototype.unshift.apply(arguments, ["warn"]);
+		_log.apply(this, arguments);
+	},
+
+	isInitializing: function() {
+		return ( this.phase=="init" || this.phase=="postInit" );
+	},
+	isReloading: function() {
+		return ( this.phase=="init" || this.phase=="postInit" ) && this.options.persist && this.persistence.cookiesFound;
+	},
+	isUserEvent: function() {
+		return ( this.phase=="userEvent" );
+	},
+
+	redraw: function() {
+//		this.logDebug("dynatree.redraw()...");
+		this.tnRoot.render(false, false);
+//		this.logDebug("dynatree.redraw() done.");
+	},
+	renderInvisibleNodes: function() {
+		this.tnRoot.render(false, true);
+	},
+	reload: function(callback) {
+		this._load(callback);
+	},
+
+	getRoot: function() {
+		return this.tnRoot;
+	},
+
+	enable: function() {
+		this.$widget.enable();
+	},
+
+	disable: function() {
+		this.$widget.disable();
+	},
+
+	getNodeByKey: function(key) {
+		// Search the DOM by element ID (assuming this is faster than traversing all nodes).
+		// $("#...") has problems, if the key contains '.', so we use getElementById()
+		var el = document.getElementById(this.options.idPrefix + key);
+		if( el ){
+			return el.dtnode ? el.dtnode : null;
+		}
+		// Not found in the DOM, but still may be in an unrendered part of tree
+		var match = null;
+		this.visit(function(node){
+//			window.console.log("%s", node);
+			if(node.data.key == key) {
+				match = node;
+				return false;
+			}
+		}, true);
+		return match;
+	},
+
+	getActiveNode: function() {
+		return this.activeNode;
+	},
+
+	reactivate: function(setFocus) {
+		// Re-fire onQueryActivate and onActivate events.
+		var node = this.activeNode;
+//		this.logDebug("reactivate %o", node);
+		if( node ) {
+			this.activeNode = null; // Force re-activating
+			node.activate();
+			if( setFocus ){
+				node.focus();
+			}
+		}
+	},
+
+	getSelectedNodes: function(stopOnParents) {
+		var nodeList = [];
+		this.tnRoot.visit(function(node){
+			if( node.bSelected ) {
+				nodeList.push(node);
+				if( stopOnParents === true ){
+					return "skip"; // stop processing this branch
+				}
+			}
+		});
+		return nodeList;
+	},
+
+	activateKey: function(key) {
+		var dtnode = (key === null) ? null : this.getNodeByKey(key);
+		if( !dtnode ) {
+			if( this.activeNode ){
+				this.activeNode.deactivate();
+			}
+			this.activeNode = null;
+			return null;
+		}
+		dtnode.focus();
+		dtnode.activate();
+		return dtnode;
+	},
+
+	loadKeyPath: function(keyPath, callback) {
+		var segList = keyPath.split(this.options.keyPathSeparator);
+		// Remove leading '/'
+		if(segList[0] === ""){
+			segList.shift();
+		}
+		// Remove leading system root key
+		if(segList[0] == this.tnRoot.data.key){
+			this.logDebug("Removed leading root key.");
+			segList.shift();
+		}
+		keyPath = segList.join(this.options.keyPathSeparator);
+		return this.tnRoot._loadKeyPath(keyPath, callback);
+	},
+
+	selectKey: function(key, select) {
+		var dtnode = this.getNodeByKey(key);
+		if( !dtnode ){
+			return null;
+		}
+		dtnode.select(select);
+		return dtnode;
+	},
+
+	enableUpdate: function(bEnable) {
+		if ( this.bEnableUpdate==bEnable ){
+			return bEnable;
+		}
+		this.bEnableUpdate = bEnable;
+		if ( bEnable ){
+			this.redraw();
+		}
+		return !bEnable; // return previous value
+	},
+
+	count: function() {
+		return this.tnRoot.countChildren();
+	},
+
+	visit: function(fn, includeRoot) {
+		return this.tnRoot.visit(fn, includeRoot);
+	},
+
+	_createFromTag: function(parentTreeNode, $ulParent) {
+		// Convert a <UL>...</UL> list into children of the parent tree node.
+		var self = this;
+/*
+TODO: better?
+		this.$lis = $("li:has(a[href])", this.element);
+		this.$tabs = this.$lis.map(function() { return $("a", this)[0]; });
+ */
+		$ulParent.find(">li").each(function() {
+			var $li = $(this),
+				$liSpan = $li.find(">span:first"),
+				$liA = $li.find(">a:first"),
+				title,
+				href = null,
+				target = null,
+				tooltip;
+			if( $liSpan.length ) {
+				// If a <li><span> tag is specified, use it literally.
+				title = $liSpan.html();
+			} else if( $liA.length ) {
+				title = $liA.html();
+				href = $liA.attr("href");
+				target = $liA.attr("target");
+				tooltip = $liA.attr("title");
+			} else {
+				// If only a <li> tag is specified, use the trimmed string up to
+				// the next child <ul> tag.
+				title = $li.html();
+				var iPos = title.search(/<ul/i);
+				if( iPos >= 0 ){
+					title = $.trim(title.substring(0, iPos));
+				}else{
+					title = $.trim(title);
+				}
+//				self.logDebug("%o", title);
+			}
+			// Parse node options from ID, title and class attributes
+			var data = {
+				title: title,
+				tooltip: tooltip,
+				isFolder: $li.hasClass("folder"),
+				isLazy: $li.hasClass("lazy"),
+				expand: $li.hasClass("expanded"),
+				select: $li.hasClass("selected"),
+				activate: $li.hasClass("active"),
+				focus: $li.hasClass("focused"),
+				noLink: $li.hasClass("noLink")
+			};
+			if( href ){
+				data.href = href;
+				data.target = target;
+			}
+			if( $li.attr("title") ){
+				data.tooltip = $li.attr("title"); // overrides <a title='...'>
+			}
+			if( $li.attr("id") ){
+				data.key = $li.attr("id");
+			}
+			// If a data attribute is present, evaluate as a JavaScript object
+			if( $li.attr("data") ) {
+				var dataAttr = $.trim($li.attr("data"));
+				if( dataAttr ) {
+					if( dataAttr.charAt(0) != "{" ){
+						dataAttr = "{" + dataAttr + "}";
+					}
+					try {
+						$.extend(data, eval("(" + dataAttr + ")"));
+					} catch(e) {
+						throw ("Error parsing node data: " + e + "\ndata:\n'" + dataAttr + "'");
+					}
+				}
+			}
+			var childNode = parentTreeNode.addChild(data);
+			// Recursive reading of child nodes, if LI tag contains an UL tag
+			var $ul = $li.find(">ul:first");
+			if( $ul.length ) {
+				self._createFromTag(childNode, $ul); // must use 'self', because 'this' is the each() context
+			}
+		});
+	},
+
+	_checkConsistency: function() {
+//		this.logDebug("tree._checkConsistency() NOT IMPLEMENTED - %o", this);
+	},
+
+	_setDndStatus: function(sourceNode, targetNode, helper, hitMode, accept) {
+		// hitMode: 'after', 'before', 'over', 'out', 'start', 'stop'
+		var $source = sourceNode ? $(sourceNode.span) : null,
+			$target = $(targetNode.span);
+		if( !this.$dndMarker ) {
+			this.$dndMarker = $("<div id='dynatree-drop-marker'></div>")
+				.hide()
+				.css({"z-index": 1000})
+				.prependTo($(this.divTree).parent());
+
+//			logMsg("Creating marker: %o", this.$dndMarker);
+		}
+/*
+		if(hitMode === "start"){
+		}
+		if(hitMode === "stop"){
+//			sourceNode.removeClass("dynatree-drop-target");
+		}
+*/
+		if(hitMode === "after" || hitMode === "before" || hitMode === "over"){
+//			$source && $source.addClass("dynatree-drag-source");
+//			$target.addClass("dynatree-drop-target");
+
+			var markerOffset = "0 0";
+
+			switch(hitMode){
+			case "before":
+				this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-over");
+				this.$dndMarker.addClass("dynatree-drop-before");
+				markerOffset = "0 -8";
+				break;
+			case "after":
+				this.$dndMarker.removeClass("dynatree-drop-before dynatree-drop-over");
+				this.$dndMarker.addClass("dynatree-drop-after");
+				markerOffset = "0 8";
+				break;
+			default:
+				this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-before");
+				this.$dndMarker.addClass("dynatree-drop-over");
+				$target.addClass("dynatree-drop-target");
+				markerOffset = "8 0";
+			}
+//			logMsg("Creating marker: %o", this.$dndMarker);
+//			logMsg("    $target.offset=%o", $target);
+//			logMsg("    pos/$target.offset=%o", pos);
+//			logMsg("    $target.position=%o", $target.position());
+//			logMsg("    $target.offsetParent=%o, ot:%o", $target.offsetParent(), $target.offsetParent().offset());
+//			logMsg("    $(this.divTree).offset=%o", $(this.divTree).offset());
+//			logMsg("    $(this.divTree).parent=%o", $(this.divTree).parent());
+//			var pos = $target.offset();
+//			var parentPos = $target.offsetParent().offset();
+//			var bodyPos = $target.offsetParent().offset();
+
+			this.$dndMarker
+				.show()
+				.position({
+					my: "left top",
+					at: "left top",
+					of: $target,
+					offset: markerOffset
+				});
+
+//			helper.addClass("dynatree-drop-hover");
+		} else {
+//			$source && $source.removeClass("dynatree-drag-source");
+			$target.removeClass("dynatree-drop-target");
+			this.$dndMarker.hide();
+//			helper.removeClass("dynatree-drop-hover");
+		}
+		if(hitMode === "after"){
+			$target.addClass("dynatree-drop-after");
+		} else {
+			$target.removeClass("dynatree-drop-after");
+		}
+		if(hitMode === "before"){
+			$target.addClass("dynatree-drop-before");
+		} else {
+			$target.removeClass("dynatree-drop-before");
+		}
+		if(accept === true){
+			if($source){
+				$source.addClass("dynatree-drop-accept");
+			}
+			$target.addClass("dynatree-drop-accept");
+			helper.addClass("dynatree-drop-accept");
+		}else{
+			if($source){
+				$source.removeClass("dynatree-drop-accept");
+			}
+			$target.removeClass("dynatree-drop-accept");
+			helper.removeClass("dynatree-drop-accept");
+		}
+		if(accept === false){
+			if($source){
+				$source.addClass("dynatree-drop-reject");
+			}
+			$target.addClass("dynatree-drop-reject");
+			helper.addClass("dynatree-drop-reject");
+		}else{
+			if($source){
+				$source.removeClass("dynatree-drop-reject");
+			}
+			$target.removeClass("dynatree-drop-reject");
+			helper.removeClass("dynatree-drop-reject");
+		}
+	},
+
+	_onDragEvent: function(eventName, node, otherNode, event, ui, draggable) {
+		/**
+		 * Handles drag'n'drop functionality.
+		 *
+		 * A standard jQuery drag-and-drop process may generate these calls:
+		 *
+		 * draggable helper():
+		 *     _onDragEvent("helper", sourceNode, null, event, null, null);
+		 * start:
+		 *     _onDragEvent("start", sourceNode, null, event, ui, draggable);
+		 * drag:
+		 *     _onDragEvent("leave", prevTargetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("over", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("enter", targetNode, sourceNode, event, ui, draggable);
+		 * stop:
+		 *     _onDragEvent("drop", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("leave", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("stop", sourceNode, null, event, ui, draggable);
+		 */
+//		if(eventName !== "over"){
+//			this.logDebug("tree._onDragEvent(%s, %o, %o) - %o", eventName, node, otherNode, this);
+//		}
+		var opts = this.options,
+			dnd = this.options.dnd,
+			res = null,
+			nodeTag = $(node.span),
+			hitMode,
+			enterResponse;
+
+		switch (eventName) {
+		case "helper":
+			// Only event and node argument is available
+			var $helper = $("<div class='dynatree-drag-helper'><span class='dynatree-drag-helper-img' /></div>")
+				.append($(event.target).closest('a').clone());
+			// issue 244: helper should be child of scrollParent
+			$("ul.dynatree-container", node.tree.divTree).append($helper);
+//			$(node.tree.divTree).append($helper);
+			// Attach node reference to helper object
+			$helper.data("dtSourceNode", node);
+//			this.logDebug("helper=%o", $helper);
+//			this.logDebug("helper.sourceNode=%o", $helper.data("dtSourceNode"));
+			res = $helper;
+			break;
+		case "start":
+			if(node.isStatusNode()) {
+				res = false;
+			} else if(dnd.onDragStart) {
+				res = dnd.onDragStart(node);
+			}
+			if(res === false) {
+				this.logDebug("tree.onDragStart() cancelled");
+				//draggable._clear();
+				// NOTE: the return value seems to be ignored (drag is not canceled, when false is returned)
+				ui.helper.trigger("mouseup");
+				ui.helper.hide();
+			} else {
+				nodeTag.addClass("dynatree-drag-source");
+			}
+			break;
+		case "enter":
+			res = dnd.onDragEnter ? dnd.onDragEnter(node, otherNode) : null;
+			if(!res){
+				// convert null, undefined, false to false
+				res = false;
+			}else{
+				res = {
+					over: ((res === true) || (res === "over") || $.inArray("over", res) >= 0),
+					before: ((res === true) || (res === "before") || $.inArray("before", res) >= 0),
+					after: ((res === true) || (res === "after") || $.inArray("after", res) >= 0)
+				};
+			}
+			ui.helper.data("enterResponse", res);
+//			this.logDebug("helper.enterResponse: %o", res);
+			break;
+		case "over":
+			enterResponse = ui.helper.data("enterResponse");
+			hitMode = null;
+			if(enterResponse === false){
+				// Don't call onDragOver if onEnter returned false.
+				// issue 332
+//				break;
+			} else if(typeof enterResponse === "string") {
+				// Use hitMode from onEnter if provided.
+				hitMode = enterResponse;
+			} else {
+				// Calculate hitMode from relative cursor position.
+				var nodeOfs = nodeTag.offset();
+//				var relPos = { x: event.clientX - nodeOfs.left,
+//							y: event.clientY - nodeOfs.top };
+//				nodeOfs.top += this.parentTop;
+//				nodeOfs.left += this.parentLeft;
+				var relPos = { x: event.pageX - nodeOfs.left,
+							   y: event.pageY - nodeOfs.top };
+				var relPos2 = { x: relPos.x / nodeTag.width(),
+								y: relPos.y / nodeTag.height() };
+//				this.logDebug("event.page: %s/%s", event.pageX, event.pageY);
+//				this.logDebug("event.client: %s/%s", event.clientX, event.clientY);
+//				this.logDebug("nodeOfs: %s/%s", nodeOfs.left, nodeOfs.top);
+////				this.logDebug("parent: %s/%s", this.parentLeft, this.parentTop);
+//				this.logDebug("relPos: %s/%s", relPos.x, relPos.y);
+//				this.logDebug("relPos2: %s/%s", relPos2.x, relPos2.y);
+				if( enterResponse.after && relPos2.y > 0.75 ){
+					hitMode = "after";
+				} else if(!enterResponse.over && enterResponse.after && relPos2.y > 0.5 ){
+					hitMode = "after";
+				} else if(enterResponse.before && relPos2.y <= 0.25) {
+					hitMode = "before";
+				} else if(!enterResponse.over && enterResponse.before && relPos2.y <= 0.5) {
+					hitMode = "before";
+				} else if(enterResponse.over) {
+					hitMode = "over";
+				}
+				// Prevent no-ops like 'before source node'
+				// TODO: these are no-ops when moving nodes, but not in copy mode
+				if( dnd.preventVoidMoves ){
+					if(node === otherNode){
+//						this.logDebug("    drop over source node prevented");
+						hitMode = null;
+					}else if(hitMode === "before" && otherNode && node === otherNode.getNextSibling()){
+//						this.logDebug("    drop after source node prevented");
+						hitMode = null;
+					}else if(hitMode === "after" && otherNode && node === otherNode.getPrevSibling()){
+//						this.logDebug("    drop before source node prevented");
+						hitMode = null;
+					}else if(hitMode === "over" && otherNode
+							&& otherNode.parent === node && otherNode.isLastSibling() ){
+//						this.logDebug("    drop last child over own parent prevented");
+						hitMode = null;
+					}
+				}
+//				this.logDebug("hitMode: %s - %s - %s", hitMode, (node.parent === otherNode), node.isLastSibling());
+				ui.helper.data("hitMode", hitMode);
+			}
+			// Auto-expand node (only when 'over' the node, not 'before', or 'after')
+			if(hitMode === "over"
+				&& dnd.autoExpandMS && node.hasChildren() !== false && !node.bExpanded) {
+				node.scheduleAction("expand", dnd.autoExpandMS);
+			}
+			if(hitMode && dnd.onDragOver){
+				res = dnd.onDragOver(node, otherNode, hitMode);
+				if(res === "over" || res === "before" || res === "after") {
+					hitMode = res;
+				}
+			}
+			// issue 332
+//			this._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false);
+			this._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false && hitMode !== null);
+			break;
+		case "drop":
+			// issue 286: don't trigger onDrop, if DnD status is 'reject'
+			var isForbidden = ui.helper.hasClass("dynatree-drop-reject");
+			hitMode = ui.helper.data("hitMode");
+			if(hitMode && dnd.onDrop && !isForbidden){
+				dnd.onDrop(node, otherNode, hitMode, ui, draggable);
+			}
+			break;
+		case "leave":
+			// Cancel pending expand request
+			node.scheduleAction("cancel");
+			ui.helper.data("enterResponse", null);
+			ui.helper.data("hitMode", null);
+			this._setDndStatus(otherNode, node, ui.helper, "out", undefined);
+			if(dnd.onDragLeave){
+				dnd.onDragLeave(node, otherNode);
+			}
+			break;
+		case "stop":
+			nodeTag.removeClass("dynatree-drag-source");
+			if(dnd.onDragStop){
+				dnd.onDragStop(node);
+			}
+			break;
+		default:
+			throw "Unsupported drag event: " + eventName;
+		}
+		return res;
+	},
+
+	cancelDrag: function() {
+		 var dd = $.ui.ddmanager.current;
+		 if(dd){
+			 dd.cancel();
+		 }
+	},
+
+	// --- end of class
+	lastentry: undefined
+};
+
+/*************************************************************************
+ * Widget $(..).dynatree
+ */
+
+$.widget("ui.dynatree", {
+/*
+	init: function() {
+		// ui.core 1.6 renamed init() to _init(): this stub assures backward compatibility
+		_log("warn", "ui.dynatree.init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher.");
+		return this._init();
+	},
+ */
+	_init: function() {
+		if( parseFloat($.ui.version) < 1.8 ) {
+			// jquery.ui.core 1.8 renamed _init() to _create(): this stub assures backward compatibility
+			if(this.options.debugLevel >= 0){
+				_log("warn", "ui.dynatree._init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher.");
+			}
+			return this._create();
+		}
+		// jquery.ui.core 1.8 still uses _init() to perform "default functionality"
+		if(this.options.debugLevel >= 2){
+			_log("debug", "ui.dynatree._init() was called; no current default functionality.");
+		}
+	},
+
+	_create: function() {
+		var opts = this.options;
+		if(opts.debugLevel >= 1){
+			logMsg("Dynatree._create(): version='%s', debugLevel=%o.", $.ui.dynatree.version, this.options.debugLevel);
+		}
+		// The widget framework supplies this.element and this.options.
+		this.options.event += ".dynatree"; // namespace event
+
+		var divTree = this.element.get(0);
+/*		// Clear container, in case it contained some 'waiting' or 'error' text
+		// for clients that don't support JS
+		if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
+			$(divTree).empty();
+*/
+		// Create the DynaTree object
+		this.tree = new DynaTree(this);
+		this.tree._load();
+		this.tree.logDebug("Dynatree._init(): done.");
+	},
+
+	bind: function() {
+		// Prevent duplicate binding
+		this.unbind();
+
+		var eventNames = "click.dynatree dblclick.dynatree";
+		if( this.options.keyboard ){
+			// Note: leading ' '!
+			eventNames += " keypress.dynatree keydown.dynatree";
+		}
+		this.element.bind(eventNames, function(event){
+			var dtnode = $.ui.dynatree.getNode(event.target);
+			if( !dtnode ){
+				return true;  // Allow bubbling of other events
+			}
+			var tree = dtnode.tree;
+			var o = tree.options;
+			tree.logDebug("event(%s): dtnode: %s", event.type, dtnode);
+			var prevPhase = tree.phase;
+			tree.phase = "userEvent";
+			try {
+				switch(event.type) {
+				case "click":
+					return ( o.onClick && o.onClick.call(tree, dtnode, event)===false ) ? false : dtnode._onClick(event);
+				case "dblclick":
+					return ( o.onDblClick && o.onDblClick.call(tree, dtnode, event)===false ) ? false : dtnode._onDblClick(event);
+				case "keydown":
+					return ( o.onKeydown && o.onKeydown.call(tree, dtnode, event)===false ) ? false : dtnode._onKeydown(event);
+				case "keypress":
+					return ( o.onKeypress && o.onKeypress.call(tree, dtnode, event)===false ) ? false : dtnode._onKeypress(event);
+				}
+			} catch(e) {
+				var _ = null; // issue 117
+				tree.logWarning("bind(%o): dtnode: %o, error: %o", event, dtnode, e);
+			} finally {
+				tree.phase = prevPhase;
+			}
+		});
+
+		// focus/blur don't bubble, i.e. are not delegated to parent <div> tags,
+		// so we use the addEventListener capturing phase.
+		// See http://www.howtocreate.co.uk/tutorials/javascript/domevents
+		function __focusHandler(event) {
+			// Handles blur and focus.
+			// Fix event for IE:
+			// doesn't pass JSLint:
+//			event = arguments[0] = $.event.fix( event || window.event );
+			// what jQuery does:
+//			var args = jQuery.makeArray( arguments );
+//			event = args[0] = jQuery.event.fix( event || window.event );
+			event = $.event.fix( event || window.event );
+			var dtnode = $.ui.dynatree.getNode(event.target);
+			return dtnode ? dtnode._onFocus(event) : false;
+		}
+		var div = this.tree.divTree;
+
+		if( div.addEventListener ) {
+			div.addEventListener("focus", __focusHandler, true);
+			div.addEventListener("blur", __focusHandler, true);
+		} else {
+			div.onfocusin = div.onfocusout = __focusHandler;
+		}
+		// EVENTS
+		// disable click if event is configured to something else
+//		if (!(/^click/).test(o.event))
+//			this.$tabs.bind("click.tabs", function() { return false; });
+
+	},
+
+	unbind: function() {
+		this.element.unbind(".dynatree");
+	},
+
+/* TODO: we could handle option changes during runtime here (maybe to re-render, ...)
+	setData: function(key, value) {
+		this.tree.logDebug("dynatree.setData('" + key + "', '" + value + "')");
+	},
+*/
+	enable: function() {
+		this.bind();
+		// Call default disable(): remove -disabled from css:
+		$.Widget.prototype.enable.apply(this, arguments);
+	},
+
+	disable: function() {
+		this.unbind();
+		// Call default disable(): add -disabled to css:
+		$.Widget.prototype.disable.apply(this, arguments);
+	},
+
+	// --- getter methods (i.e. NOT returning a reference to $)
+	getTree: function() {
+		return this.tree;
+	},
+
+	getRoot: function() {
+		return this.tree.getRoot();
+	},
+
+	getActiveNode: function() {
+		return this.tree.getActiveNode();
+	},
+
+	getSelectedNodes: function() {
+		return this.tree.getSelectedNodes();
+	},
+
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+});
+
+
+// The following methods return a value (thus breaking the jQuery call chain):
+if( parseFloat($.ui.version) < 1.8 ) {
+	$.ui.dynatree.getter = "getTree getRoot getActiveNode getSelectedNodes";
+}
+
+/*******************************************************************************
+ * Tools in ui.dynatree namespace
+ */
+$.ui.dynatree.version = "$Version:$";
+
+/**
+ * Return a DynaTreeNode object for a given DOM element
+ */
+$.ui.dynatree.getNode = function(el) {
+	if(el instanceof DynaTreeNode){
+		return el; // el already was a DynaTreeNode
+	}
+	if(el.selector !== undefined){
+		el = el[0]; // el was a jQuery object: use the DOM element
+	}
+	// TODO: for some reason $el.parents("[dtnode]") does not work (jQuery 1.6.1)
+	// maybe, because dtnode is a property, not an attribute
+	while( el ) {
+		if(el.dtnode) {
+			return el.dtnode;
+		}
+		el = el.parentNode;
+	}
+	return null;
+/*
+	var $el = el.selector === undefined ? $(el) : el,
+//		parent = $el.closest("[dtnode]"),
+//		parent = $el.parents("[dtnode]").first(),
+		useProp = (typeof $el.prop == "function"),
+		node;
+	$el.parents().each(function(){
+		node = useProp ? $(this).prop("dtnode") : $(this).attr("dtnode");
+		if(node){
+			return false;
+		}
+	});
+	return node;
+*/
+};
+
+/**Return persistence information from cookies.*/
+$.ui.dynatree.getPersistData = DynaTreeStatus._getTreePersistData;
+
+/*******************************************************************************
+ * Plugin default options:
+ */
+$.ui.dynatree.prototype.options = {
+	title: "Dynatree", // Tree's name (only used for debug output)
+	minExpandLevel: 1, // 1: root node is not collapsible
+	imagePath: null, // Path to a folder containing icons. Defaults to 'skin/' subdirectory.
+	children: null, // Init tree structure from this object array.
+	initId: null, // Init tree structure from a <ul> element with this ID.
+	initAjax: null, // Ajax options used to initialize the tree strucuture.
+	autoFocus: true, // Set focus to first child, when expanding or lazy-loading.
+	keyboard: true, // Support keyboard navigation.
+	persist: false, // Persist expand-status to a cookie
+	autoCollapse: false, // Automatically collapse all siblings, when a node is expanded.
+	clickFolderMode: 3, // 1:activate, 2:expand, 3:activate and expand
+	activeVisible: true, // Make sure, active nodes are visible (expanded).
+	checkbox: false, // Show checkboxes.
+	selectMode: 2, // 1:single, 2:multi, 3:multi-hier
+	fx: null, // Animations, e.g. null or { height: "toggle", duration: 200 }
+	noLink: false, // Use <span> instead of <a> tags for all nodes
+	// Low level event handlers: onEvent(dtnode, event): return false, to stop default processing
+	onClick: null, // null: generate focus, expand, activate, select events.
+	onDblClick: null, // (No default actions.)
+	onKeydown: null, // null: generate keyboard navigation (focus, expand, activate).
+	onKeypress: null, // (No default actions.)
+	onFocus: null, // null: set focus to node.
+	onBlur: null, // null: remove focus from node.
+
+	// Pre-event handlers onQueryEvent(flag, dtnode): return false, to stop processing
+	onQueryActivate: null, // Callback(flag, dtnode) before a node is (de)activated.
+	onQuerySelect: null, // Callback(flag, dtnode) before a node is (de)selected.
+	onQueryExpand: null, // Callback(flag, dtnode) before a node is expanded/collpsed.
+
+	// High level event handlers
+	onPostInit: null, // Callback(isReloading, isError) when tree was (re)loaded.
+	onActivate: null, // Callback(dtnode) when a node is activated.
+	onDeactivate: null, // Callback(dtnode) when a node is deactivated.
+	onSelect: null, // Callback(flag, dtnode) when a node is (de)selected.
+	onExpand: null, // Callback(flag, dtnode) when a node is expanded/collapsed.
+	onLazyRead: null, // Callback(dtnode) when a lazy node is expanded for the first time.
+	onCustomRender: null, // Callback(dtnode) before a node is rendered. Return a HTML string to override.
+	onCreate: null, // Callback(dtnode, nodeSpan) after a node was rendered for the first time.
+	onRender: null, // Callback(dtnode, nodeSpan) after a node was rendered.
+				// postProcess is similar to the standard dataFilter hook,
+				// but it is also called for JSONP
+	postProcess: null, // Callback(data, dataType) before an Ajax result is passed to dynatree
+
+	// Drag'n'drop support
+	dnd: {
+		// Make tree nodes draggable:
+		onDragStart: null, // Callback(sourceNode), return true, to enable dnd
+		onDragStop: null, // Callback(sourceNode)
+//		helper: null,
+		// Make tree nodes accept draggables
+		autoExpandMS: 1000, // Expand nodes after n milliseconds of hovering.
+		preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
+		onDragEnter: null, // Callback(targetNode, sourceNode)
+		onDragOver: null, // Callback(targetNode, sourceNode, hitMode)
+		onDrop: null, // Callback(targetNode, sourceNode, hitMode)
+		onDragLeave: null // Callback(targetNode, sourceNode)
+	},
+	ajaxDefaults: { // Used by initAjax option
+		cache: false, // false: Append random '_' argument to the request url to prevent caching.
+		timeout: 0, // >0: Make sure we get an ajax error for invalid URLs
+		dataType: "json" // Expect json format and pass json object to callbacks.
+	},
+	strings: {
+		loading: "Loading&#8230;",
+		loadError: "Load error!"
+	},
+	generateIds: false, // Generate id attributes like <span id='dynatree-id-KEY'>
+	idPrefix: "dynatree-id-", // Used to generate node id's like <span id="dynatree-id-<key>">.
+	keyPathSeparator: "/", // Used by node.getKeyPath() and tree.loadKeyPath().
+//    cookieId: "dynatree-cookie", // Choose a more unique name, to allow multiple trees.
+	cookieId: "dynatree", // Choose a more unique name, to allow multiple trees.
+	cookie: {
+		expires: null //7, // Days or Date; null: session cookie
+//		path: "/", // Defaults to current page
+//		domain: "jquery.com",
+//		secure: true
+	},
+	// Class names used, when rendering the HTML markup.
+	// Note: if only single entries are passed for options.classNames, all other
+	// values are still set to default.
+	classNames: {
+		container: "dynatree-container",
+		node: "dynatree-node",
+		folder: "dynatree-folder",
+//		document: "dynatree-document",
+
+		empty: "dynatree-empty",
+		vline: "dynatree-vline",
+		expander: "dynatree-expander",
+		connector: "dynatree-connector",
+		checkbox: "dynatree-checkbox",
+		nodeIcon: "dynatree-icon",
+		title: "dynatree-title",
+		noConnector: "dynatree-no-connector",
+
+		nodeError: "dynatree-statusnode-error",
+		nodeWait: "dynatree-statusnode-wait",
+		hidden: "dynatree-hidden",
+		combinedExpanderPrefix: "dynatree-exp-",
+		combinedIconPrefix: "dynatree-ico-",
+		nodeLoading: "dynatree-loading",
+//		disabled: "dynatree-disabled",
+		hasChildren: "dynatree-has-children",
+		active: "dynatree-active",
+		selected: "dynatree-selected",
+		expanded: "dynatree-expanded",
+		lazy: "dynatree-lazy",
+		focused: "dynatree-focused",
+		partsel: "dynatree-partsel",
+		lastsib: "dynatree-lastsib"
+	},
+	debugLevel: 2, // 0:quiet, 1:normal, 2:debug $REPLACE:	debugLevel: 1,
+
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+};
+//
+if( parseFloat($.ui.version) < 1.8 ) {
+	$.ui.dynatree.defaults = $.ui.dynatree.prototype.options;
+}
+
+/*******************************************************************************
+ * Reserved data attributes for a tree node.
+ */
+$.ui.dynatree.nodedatadefaults = {
+	title: null, // (required) Displayed name of the node (html is allowed here)
+	key: null, // May be used with activate(), select(), find(), ...
+	isFolder: false, // Use a folder icon. Also the node is expandable but not selectable.
+	isLazy: false, // Call onLazyRead(), when the node is expanded for the first time to allow for delayed creation of children.
+	tooltip: null, // Show this popup text.
+	href: null, // Added to the generated <a> tag.
+	icon: null, // Use a custom image (filename relative to tree.options.imagePath). 'null' for default icon, 'false' for no icon.
+	addClass: null, // Class name added to the node's span tag.
+	noLink: false, // Use <span> instead of <a> tag for this node
+	activate: false, // Initial active status.
+	focus: false, // Initial focused status.
+	expand: false, // Initial expanded status.
+	select: false, // Initial selected status.
+	hideCheckbox: false, // Suppress checkbox display for this node.
+	unselectable: false, // Prevent selection.
+//  disabled: false,
+	// The following attributes are only valid if passed to some functions:
+	children: null, // Array of child nodes.
+	// NOTE: we can also add custom attributes here.
+	// This may then also be used in the onActivate(), onSelect() or onLazyTree() callbacks.
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+};
+
+/*******************************************************************************
+ * Drag and drop support
+ */
+function _initDragAndDrop(tree) {
+	var dnd = tree.options.dnd || null;
+	// Register 'connectToDynatree' option with ui.draggable
+	if(dnd && (dnd.onDragStart || dnd.onDrop)) {
+		_registerDnd();
+	}
+	// Attach ui.draggable to this Dynatree instance
+	if(dnd && dnd.onDragStart ) {
+		tree.$tree.draggable({
+			addClasses: false,
+			appendTo: "body",
+			containment: false,
+			delay: 0,
+			distance: 4,
+			revert: false,
+			scroll: true, // issue 244: enable scrolling (if ul.dynatree-container)
+			scrollSpeed: 7,
+			scrollSensitivity: 10,
+			// Delegate draggable.start, drag, and stop events to our handler
+			connectToDynatree: true,
+			// Let source tree create the helper element
+			helper: function(event) {
+				var sourceNode = $.ui.dynatree.getNode(event.target);
+				if(!sourceNode){ // issue 211
+					return "<div></div>";
+				}
+				return sourceNode.tree._onDragEvent("helper", sourceNode, null, event, null, null);
+			},
+			start: function(event, ui) {
+				// See issues 211, 268, 278
+//				var sourceNode = $.ui.dynatree.getNode(event.target);
+				var sourceNode = ui.helper.data("dtSourceNode");
+				return !!sourceNode; // Abort dragging if no Node could be found
+			},
+			_last: null
+		});
+	}
+	// Attach ui.droppable to this Dynatree instance
+	if(dnd && dnd.onDrop) {
+		tree.$tree.droppable({
+			addClasses: false,
+			tolerance: "intersect",
+			greedy: false,
+			_last: null
+		});
+	}
+}
+
+//--- Extend ui.draggable event handling --------------------------------------
+var didRegisterDnd = false;
+var _registerDnd = function() {
+	if(didRegisterDnd){
+		return;
+	}
+	// Register proxy-functions for draggable.start/drag/stop
+	$.ui.plugin.add("draggable", "connectToDynatree", {
+		start: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null;
+//			logMsg("draggable-connectToDynatree.start, %s", sourceNode);
+//			logMsg("    this: %o", this);
+//			logMsg("    event: %o", event);
+//			logMsg("    draggable: %o", draggable);
+//			logMsg("    ui: %o", ui);
+
+			if(sourceNode) {
+				// Adjust helper offset, so cursor is slightly outside top/left corner
+//				draggable.offset.click.top -= event.target.offsetTop;
+//				draggable.offset.click.left -= event.target.offsetLeft;
+				draggable.offset.click.top = -2;
+				draggable.offset.click.left = + 16;
+//				logMsg("    draggable2: %o", draggable);
+//				logMsg("    draggable.offset.click FIXED: %s/%s", draggable.offset.click.left, draggable.offset.click.top);
+				// Trigger onDragStart event
+				// TODO: when called as connectTo..., the return value is ignored(?)
+				return sourceNode.tree._onDragEvent("start", sourceNode, null, event, ui, draggable);
+			}
+		},
+		drag: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null,
+				prevTargetNode = ui.helper.data("dtTargetNode") || null,
+				targetNode = $.ui.dynatree.getNode(event.target);
+//			logMsg("$.ui.dynatree.getNode(%o): %s", event.target, targetNode);
+//			logMsg("connectToDynatree.drag: helper: %o", ui.helper[0]);
+			if(event.target && !targetNode){
+				// We got a drag event, but the targetNode could not be found
+				// at the event location. This may happen,
+				// 1. if the mouse jumped over the drag helper,
+				// 2. or if non-dynatree element is dragged
+				// We ignore it:
+				var isHelper = $(event.target).closest("div.dynatree-drag-helper,#dynatree-drop-marker").length > 0;
+				if(isHelper){
+//					logMsg("Drag event over helper: ignored.");
+					return;
+				}
+			}
+//			logMsg("draggable-connectToDynatree.drag: targetNode(from event): %s, dtTargetNode: %s", targetNode, ui.helper.data("dtTargetNode"));
+			ui.helper.data("dtTargetNode", targetNode);
+			// Leaving a tree node
+			if(prevTargetNode && prevTargetNode !== targetNode ) {
+				prevTargetNode.tree._onDragEvent("leave", prevTargetNode, sourceNode, event, ui, draggable);
+			}
+			if(targetNode){
+				if(!targetNode.tree.options.dnd.onDrop) {
+					// not enabled as drop target
+//					noop(); // Keep JSLint happy
+				} else if(targetNode === prevTargetNode) {
+					// Moving over same node
+					targetNode.tree._onDragEvent("over", targetNode, sourceNode, event, ui, draggable);
+				}else{
+					// Entering this node first time
+					targetNode.tree._onDragEvent("enter", targetNode, sourceNode, event, ui, draggable);
+				}
+			}
+			// else go ahead with standard event handling
+		},
+		stop: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null,
+				targetNode = ui.helper.data("dtTargetNode") || null,
+				mouseDownEvent = draggable._mouseDownEvent,
+				eventType = event.type,
+				dropped = (eventType == "mouseup" && event.which == 1);
+//			logMsg("draggable-connectToDynatree.stop: targetNode(from event): %s, dtTargetNode: %s", targetNode, ui.helper.data("dtTargetNode"));
+//			logMsg("draggable-connectToDynatree.stop, %s", sourceNode);
+//			logMsg("    type: %o, downEvent: %o, upEvent: %o", eventType, mouseDownEvent, event);
+//			logMsg("    targetNode: %o", targetNode);
+			if(!dropped){
+				logMsg("Drag was cancelled");
+			}
+			if(targetNode) {
+				if(dropped){
+					targetNode.tree._onDragEvent("drop", targetNode, sourceNode, event, ui, draggable);
+				}
+				targetNode.tree._onDragEvent("leave", targetNode, sourceNode, event, ui, draggable);
+			}
+			if(sourceNode){
+				sourceNode.tree._onDragEvent("stop", sourceNode, null, event, ui, draggable);
+			}
+		}
+	});
+	didRegisterDnd = true;
+};
+
+// ---------------------------------------------------------------------------
+}(jQuery));
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree.min.js
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree.min.js	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/dist/jquery.dynatree.min.js	(revision 9215)
@@ -0,0 +1,4 @@
+/*! jQuery Dynatree Plugin - v1.2.2 - 2012-10-07
+* http://dynatree.googlecode.com/
+* Copyright (c) 2012 Martin Wendt; Licensed MIT, GPL */
+function _log(a,b){if(!_canLog)return;var c=Array.prototype.slice.apply(arguments,[1]),d=new Date,e=d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+"."+d.getMilliseconds();c[0]=e+" - "+c[0];try{switch(a){case"info":window.console.info.apply(window.console,c);break;case"warn":window.console.warn.apply(window.console,c);break;default:window.console.log.apply(window.console,c)}}catch(f){window.console||(_canLog=!1)}}function logMsg(a){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)}var _canLog=!0,getDynaTreePersistData=null,DTNodeStatus_Error=-1,DTNodeStatus_Loading=1,DTNodeStatus_Ok=0;(function($){function getDtNodeFromElement(a){return alert("getDtNodeFromElement is deprecated"),$.ui.dynatree.getNode(a)}function noop(){}function _initDragAndDrop(a){var b=a.options.dnd||null;b&&(b.onDragStart||b.onDrop)&&_registerDnd(),b&&b.onDragStart&&a.$tree.draggable({addClasses:!1,appendTo:"body",containment:!1,delay:0,distance:4,revert:!1,scroll:!0,scrollSpeed:7,scrollSensitivity:10,connectToDynatree:!0,helper:function(a){var b=$.ui.dynatree.getNode(a.target);return b?b.tree._onDragEvent("helper",b,null,a,null,null):"<div></div>"},start:function(a,b){var c=b.helper.data("dtSourceNode");return!!c},_last:null}),b&&b.onDrop&&a.$tree.droppable({addClasses:!1,tolerance:"intersect",greedy:!1,_last:null})}var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}},DynaTreeNode=Class.create();DynaTreeNode.prototype={initialize:function(a,b,c){this.parent=a,this.tree=b,typeof c=="string"&&(c={title:c}),c.key===undefined&&(c.key="_"+b._nodeCount++),this.data=$.extend({},$.ui.dynatree.nodedatadefaults,c),this.li=null,this.span=null,this.ul=null,this.childList=null,this._isLoading=!1,this.hasSubSel=!1,this.bExpanded=!1,this.bSelected=!1},toString:function(){return"DynaTreeNode<"+this.data.key+">: '"+this.data.title+"'"},toDict:function(a,b){var c=$.extend({},this.data);c.activate=this.tree.activeNode===this,c.focus=this.tree.focusNode===this,c.expand=this.bExpanded,c.select=this.bSelected,b&&b(c);if(a&&this.childList){c.children=[];for(var d=0,e=this.childList.length;d<e;d++)c.children.push(this.childList[d].toDict(!0,b))}else delete c.children;return c},fromDict:function(a){var b=a.children;if(b===undefined){this.data=$.extend(this.data,a),this.render();return}a=$.extend({},a),a.children=undefined,this.data=$.extend(this.data,a),this.removeChildren(),this.addChild(b)},_getInnerHtml:function(){var a=this.tree,b=a.options,c=a.cache,d=this.getLevel(),e=this.data,f="",g;d<b.minExpandLevel?d>1&&(f+=c.tagConnector):this.hasChildren()!==!1?f+=c.tagExpander:f+=c.tagConnector,b.checkbox&&e.hideCheckbox!==!0&&!e.isStatusNode&&(f+=c.tagCheckbox),e.icon?(e.icon.charAt(0)==="/"?g=e.icon:g=b.imagePath+e.icon,f+="<img src='"+g+"' alt='' />"):e.icon!==!1&&(f+=c.tagNodeIcon);var h="";b.onCustomRender&&(h=b.onCustomRender.call(a,this)||"");if(!h){var i=e.tooltip?' title="'+e.tooltip.replace(/\"/g,"&quot;")+'"':"",j=e.href||"#";b.noLink||e.noLink?h='<span style="display:inline-block;" class="'+b.classNames.title+'"'+i+">"+e.title+"</span>":h='<a href="'+j+'" class="'+b.classNames.title+'"'+i+">"+e.title+"</a>"}return f+=h,f},_fixOrder:function(){var a=this.childList;if(!a||!this.ul)return;var b=this.ul.firstChild;for(var c=0,d=a.length-1;c<d;c++){var e=a[c],f=b.dtnode;e!==f?(this.tree.logDebug("_fixOrder: mismatch at index "+c+": "+e+" != "+f),this.ul.insertBefore(e.li,f.li)):b=b.nextSibling}},render:function(a,b){var c=this.tree,d=this.parent,e=this.data,f=c.options,g=f.classNames,h=this.isLastSibling(),i=!1;if(!d&&!this.ul)this.li=this.span=null,this.ul=document.createElement("ul"),f.minExpandLevel>1?this.ul.className=g.container+" "+g.noConnector:this.ul.className=g.container;else if(d){this.li||(i=!0,this.li=document.createElement("li"),this.li.dtnode=this,e.key&&f.generateIds&&(this.li.id=f.idPrefix+e.key),this.span=document.createElement("span"),this.span.className=g.title,this.li.appendChild(this.span),d.ul||(d.ul=document.createElement("ul"),d.ul.style.display="none",d.li.appendChild(d.ul)),d.ul.appendChild(this.li)),this.span.innerHTML=this._getInnerHtml();var j=[];j.push(g.node),e.isFolder&&j.push(g.folder),this.bExpanded&&j.push(g.expanded),this.hasChildren()!==!1&&j.push(g.hasChildren),e.isLazy&&this.childList===null&&j.push(g.lazy),h&&j.push(g.lastsib),this.bSelected&&j.push(g.selected),this.hasSubSel&&j.push(g.partsel),c.activeNode===this&&j.push(g.active),e.addClass&&j.push(e.addClass),j.push(g.combinedExpanderPrefix+(this.bExpanded?"e":"c")+(e.isLazy&&this.childList===null?"d":"")+(h?"l":"")),j.push(g.combinedIconPrefix+(this.bExpanded?"e":"c")+(e.isFolder?"f":"")),this.span.className=j.join(" "),this.li.className=h?g.lastsib:"",i&&f.onCreate&&f.onCreate.call(c,this,this.span),f.onRender&&f.onRender.call(c,this,this.span)}if((this.bExpanded||b===!0)&&this.childList){for(var k=0,l=this.childList.length;k<l;k++)this.childList[k].render(!1,b);this._fixOrder()}if(this.ul){var m=this.ul.style.display==="none",n=!!this.bExpanded;if(a&&f.fx&&m===n){var o=f.fx.duration||200;$(this.ul).animate(f.fx,o)}else this.ul.style.display=this.bExpanded||!d?"":"none"}},getKeyPath:function(a){var b=[];return this.visitParents(function(a){a.parent&&b.unshift(a.data.key)},!a),"/"+b.join(this.tree.options.keyPathSeparator)},getParent:function(){return this.parent},getChildren:function(){return this.hasChildren()===undefined?undefined:this.childList},hasChildren:function(){if(this.data.isLazy)return this.childList===null||this.childList===undefined?undefined:this.childList.length===0?!1:this.childList.length===1&&this.childList[0].isStatusNode()?undefined:!0;return!!this.childList},isFirstSibling:function(){var a=this.parent;return!a||a.childList[0]===this},isLastSibling:function(){var a=this.parent;return!a||a.childList[a.childList.length-1]===this},isLoading:function(){return!!this._isLoading},getPrevSibling:function(){if(!this.parent)return null;var a=this.parent.childList;for(var b=1,c=a.length;b<c;b++)if(a[b]===this)return a[b-1];return null},getNextSibling:function(){if(!this.parent)return null;var a=this.parent.childList;for(var b=0,c=a.length-1;b<c;b++)if(a[b]===this)return a[b+1];return null},isStatusNode:function(){return this.data.isStatusNode===!0},isChildOf:function(a){return this.parent&&this.parent===a},isDescendantOf:function(a){if(!a)return!1;var b=this.parent;while(b){if(b===a)return!0;b=b.parent}return!1},countChildren:function(){var a=this.childList;if(!a)return 0;var b=a.length;for(var c=0,d=b;c<d;c++){var e=a[c];b+=e.countChildren()}return b},sortChildren:function(a,b){var c=this.childList;if(!c)return;a=a||function(a,b){var c=a.data.title.toLowerCase(),d=b.data.title.toLowerCase();return c===d?0:c>d?1:-1},c.sort(a);if(b)for(var d=0,e=c.length;d<e;d++)c[d].childList&&c[d].sortChildren(a,"$norender$");b!=="$norender$"&&this.render()},_setStatusNode:function(a){var b=this.childList?this.childList[0]:null;if(!a){if(b&&b.isStatusNode()){try{this.ul&&(this.ul.removeChild(b.li),b.li=null)}catch(c){}this.childList.length===1?this.childList=[]:this.childList.shift()}}else b?(a.isStatusNode=!0,a.key="_statusNode",b.data=a,b.render()):(a.isStatusNode=!0,a.key="_statusNode",b=this.addChild(a))},setLazyNodeStatus:function(a,b){var c=b&&b.tooltip?b.tooltip:null,d=b&&b.info?" ("+b.info+")":"";switch(a){case DTNodeStatus_Ok:this._setStatusNode(null),$(this.span).removeClass(this.tree.options.classNames.nodeLoading),this._isLoading=!1,this.tree.options.autoFocus&&(this===this.tree.tnRoot&&this.childList&&this.childList.length>0?this.childList[0].focus():this.focus());break;case DTNodeStatus_Loading:this._isLoading=!0,$(this.span).addClass(this.tree.options.classNames.nodeLoading),this.parent||this._setStatusNode({title:this.tree.options.strings.loading+d,tooltip:c,addClass:this.tree.options.classNames.nodeWait});break;case DTNodeStatus_Error:this._isLoading=!1,this._setStatusNode({title:this.tree.options.strings.loadError+d,tooltip:c,addClass:this.tree.options.classNames.nodeError});break;default:throw"Bad LazyNodeStatus: '"+a+"'."}},_parentList:function(a,b){var c=[],d=b?this:this.parent;while(d)(a||d.parent)&&c.unshift(d),d=d.parent;return c},getLevel:function(){var a=0,b=this.parent;while(b)a++,b=b.parent;return a},_getTypeForOuterNodeEvent:function(a){var b=this.tree.options.classNames,c=a.target;if(c.className.indexOf(b.node)<0)return null;var d=a.pageX-c.offsetLeft,e=a.pageY-c.offsetTop;for(var f=0,g=c.childNodes.length;f<g;f++){var h=c.childNodes[f],i=h.offsetLeft-c.offsetLeft,j=h.offsetTop-c.offsetTop,k=h.clientWidth,l=h.clientHeight;if(d>=i&&d<=i+k&&e>=j&&e<=j+l){if(h.className==b.title)return"title";if(h.className==b.expander)return"expander";if(h.className==b.checkbox)return"checkbox";if(h.className==b.nodeIcon)return"icon"}}return"prefix"},getEventTargetType:function(a){var b=a&&a.target?a.target.className:"",c=this.tree.options.classNames;return b===c.title?"title":b===c.expander?"expander":b===c.checkbox?"checkbox":b===c.nodeIcon?"icon":b===c.empty||b===c.vline||b===c.connector?"prefix":b.indexOf(c.node)>=0?this._getTypeForOuterNodeEvent(a):null},isVisible:function(){var a=this._parentList(!0,!1);for(var b=0,c=a.length;b<c;b++)if(!a[b].bExpanded)return!1;return!0},makeVisible:function(){var a=this._parentList(!0,!1);for(var b=0,c=a.length;b<c;b++)a[b]._expand(!0)},focus:function(){this.makeVisible();try{$(this.span).find(">a").focus()}catch(a){}},isFocused:function(){return this.tree.tnFocused===this},_activate:function(a,b){this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o",a,b,this);var c=this.tree.options;if(this.data.isStatusNode)return;if(b&&c.onQueryActivate&&c.onQueryActivate.call(this.tree,a,this)===!1)return;if(a){if(this.tree.activeNode){if(this.tree.activeNode===this)return;this.tree.activeNode.deactivate()}c.activeVisible&&this.makeVisible(),this.tree.activeNode=this,c.persist&&$.cookie(c.cookieId+"-active",this.data.key,c.cookie),this.tree.persistence.activeKey=this.data.key,$(this.span).addClass(c.classNames.active),b&&c.onActivate&&c.onActivate.call(this.tree,this)}else if(this.tree.activeNode===this){if(c.onQueryActivate&&c.onQueryActivate.call(this.tree,!1,this)===!1)return;$(this.span).removeClass(c.classNames.active),c.persist&&$.cookie(c.cookieId+"-active","",c.cookie),this.tree.persistence.activeKey=null,this.tree.activeNode=null,b&&c.onDeactivate&&c.onDeactivate.call(this.tree,this)}},activate:function(){this._activate(!0,!0)},activateSilently:function(){this._activate(!0,!1)},deactivate:function(){this._activate(!1,!0)},isActive:function(){return this.tree.activeNode===this},_userActivate:function(){var a=!0,b=!1;if(this.data.isFolder)switch(this.tree.options.clickFolderMode){case 2:a=!1,b=!0;break;case 3:a=b=!0}this.parent===null&&(b=!1),b&&(this.toggleExpand(),this.focus()),a&&this.activate()},_setSubSel:function(a){a?(this.hasSubSel=!0,$(this.span).addClass(this.tree.options.classNames.partsel)):(this.hasSubSel=!1,$(this.span).removeClass(this.tree.options.classNames.partsel))},_updatePartSelectionState:function(){var a;if(!this.hasChildren())return a=this.bSelected&&!this.data.unselectable&&!this.data.isStatusNode,this._setSubSel(!1),a;var b,c,d=this.childList,e=!0,f=!0;for(b=0,c=d.length;b<c;b++){var g=d[b],h=g._updatePartSelectionState();h!==!1&&(f=!1),h!==!0&&(e=!1)}return e?a=!0:f?a=!1:a=undefined,this._setSubSel(a===undefined),this.bSelected=a===!0,a},_fixSelectionState:function(){var a,b,c;if(this.bSelected){this.visit(function(a){a.parent._setSubSel(!0),a.data.unselectable||a._select(!0,!1,!1)}),a=this.parent;while(a){a._setSubSel(!0);var d=!0;for(b=0,c=a.childList.length;b<c;b++){var e=a.childList[b];if(!e.bSelected&&!e.data.isStatusNode&&!e.data.unselectable){d=!1;break}}d&&a._select(!0,!1,!1),a=a.parent}}else{this._setSubSel(!1),this.visit(function(a){a._setSubSel(!1),a._select(!1,!1,!1)}),a=this.parent;while(a){a._select(!1,!1,!1);var f=!1;for(b=0,c=a.childList.length;b<c;b++)if(a.childList[b].bSelected||a.childList[b].hasSubSel){f=!0;break}a._setSubSel(f),a=a.parent}}},_select:function(a,b,c){var d=this.tree.options;if(this.data.isStatusNode)return;if(this.bSelected===a)return;if(b&&d.onQuerySelect&&d.onQuerySelect.call(this.tree,a,this)===!1)return;d.selectMode==1&&a&&this.tree.visit(function(a){if(a.bSelected)return a._select(!1,!1,!1),!1}),this.bSelected=a,a?(d.persist&&this.tree.persistence.addSelect(this.data.key),$(this.span).addClass(d.classNames.selected),c&&d.selectMode===3&&this._fixSelectionState(),b&&d.onSelect&&d.onSelect.call(this.tree,!0,this)):(d.persist&&this.tree.persistence.clearSelect(this.data.key),$(this.span).removeClass(d.classNames.selected),c&&d.selectMode===3&&this._fixSelectionState(),b&&d.onSelect&&d.onSelect.call(this.tree,!1,this))},select:function(a){return this.data.unselectable?this.bSelected:this._select(a!==!1,!0,!0)},toggleSelect:function(){return this.select(!this.bSelected)},isSelected:function(){return this.bSelected},isLazy:function(){return!!this.data.isLazy},_loadContent:function(){try{var a=this.tree.options;this.tree.logDebug("_loadContent: start - %o",this),this.setLazyNodeStatus(DTNodeStatus_Loading),!0===a.onLazyRead.call(this.tree,this)&&(this.setLazyNodeStatus(DTNodeStatus_Ok),this.tree.logDebug("_loadContent: succeeded - %o",this))}catch(b){this.tree.logWarning("_loadContent: failed - %o",b),this.setLazyNodeStatus(DTNodeStatus_Error,{tooltip:""+b})}},_expand:function(a,b){if(this.bExpanded===a){this.tree.logDebug("dtnode._expand(%o) IGNORED - %o",a,this);return}this.tree.logDebug("dtnode._expand(%o) - %o",a,this);var c=this.tree.options;if(!a&&this.getLevel()<c.minExpandLevel){this.tree.logDebug("dtnode._expand(%o) prevented collapse - %o",a,this);return}if(c.onQueryExpand&&c.onQueryExpand.call(this.tree,a,this)===!1)return;this.bExpanded=a,c.persist&&(a?this.tree.persistence.addExpand(this.data.key):this.tree.persistence.clearExpand(this.data.key));var d=(!this.data.isLazy||this.childList!==null)&&!this._isLoading&&!b;this.render(d);if(this.bExpanded&&this.parent&&c.autoCollapse){var e=this._parentList(!1,!0);for(var f=0,g=e.length;f<g;f++)e[f].collapseSiblings()}c.activeVisible&&this.tree.activeNode&&!this.tree.activeNode.isVisible()&&this.tree.activeNode.deactivate();if(a&&this.data.isLazy&&this.childList===null&&!this._isLoading){this._loadContent();return}c.onExpand&&c.onExpand.call(this.tree,a,this)},isExpanded:function(){return this.bExpanded},expand:function(a){a=a!==!1;if(!this.childList&&!this.data.isLazy&&a)return;if(this.parent===null&&!a)return;this._expand(a)},scheduleAction:function(a,b){this.tree.timer&&(clearTimeout(this.tree.timer),this.tree.logDebug("clearTimeout(%o)",this.tree.timer));var c=this;switch(a){case"cancel":break;case"expand":this.tree.timer=setTimeout(function(){c.tree.logDebug("setTimeout: trigger expand"),c.expand(!0)},b);break;case"activate":this.tree.timer=setTimeout(function(){c.tree.logDebug("setTimeout: trigger activate"),c.activate()},b);break;default:throw"Invalid mode "+a}this.tree.logDebug("setTimeout(%s, %s): %s",a,b,this.tree.timer)},toggleExpand:function(){this.expand(!this.bExpanded)},collapseSiblings:function(){if(this.parent===null)return;var a=this.parent.childList;for(var b=0,c=a.length;b<c;b++)a[b]!==this&&a[b].bExpanded&&a[b]._expand(!1)},_onClick:function(a){var b=this.getEventTargetType(a);if(b==="expander")this.toggleExpand(),this.focus();else if(b==="checkbox")this.toggleSelect(),this.focus();else{this._userActivate();var c=this.span.getElementsByTagName("a");if(c[0])$.browser.msie&&parseInt($.browser.version,10)<9||c[0].focus();else return!0}a.preventDefault()},_onDblClick:function(a){},_onKeydown:function(a){var b=!0,c;switch(a.which){case 107:case 187:this.bExpanded||this.toggleExpand();break;case 109:case 189:this.bExpanded&&this.toggleExpand();break;case 32:this._userActivate();break;case 8:this.parent&&this.parent.focus();break;case 37:this.bExpanded?(this.toggleExpand(),this.focus()):this.parent&&this.parent.parent&&this.parent.focus();break;case 39:!this.bExpanded&&(this.childList||this.data.isLazy)?(this.toggleExpand(),this.focus()):this.childList&&this.childList[0].focus();break;case 38:c=this.getPrevSibling();while(c&&c.bExpanded&&c.childList)c=c.childList[c.childList.length-1];!c&&this.parent&&this.parent.parent&&(c=this.parent),c&&c.focus();break;case 40:if(this.bExpanded&&this.childList)c=this.childList[0];else{var d=this._parentList(!1,!0);for(var e=d.length-1;e>=0;e--){c=d[e].getNextSibling();if(c)break}}c&&c.focus();break;default:b=!1}b&&a.preventDefault()},_onKeypress:function(a){},_onFocus:function(a){var b=this.tree.options;if(a.type=="blur"||a.type=="focusout")b.onBlur&&b.onBlur.call(this.tree,this),this.tree.tnFocused&&$(this.tree.tnFocused.span).removeClass(b.classNames.focused),this.tree.tnFocused=null,b.persist&&$.cookie(b.cookieId+"-focus","",b.cookie);else if(a.type=="focus"||a.type=="focusin")this.tree.tnFocused&&this.tree.tnFocused!==this&&(this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o",this.tree.tnFocused),$(this.tree.tnFocused.span).removeClass(b.classNames.focused)),this.tree.tnFocused=this,b.onFocus&&b.onFocus.call(this.tree,this),$(this.tree.tnFocused.span).addClass(b.classNames.focused),b.persist&&$.cookie(b.cookieId+"-focus",this.data.key,b.cookie)},visit:function(a,b){var c=!0;if(b===!0){c=a(this);if(c===!1||c=="skip")return c}if(this.childList)for(var d=0,e=this.childList.length;d<e;d++){c=this.childList[d].visit(a,!0);if(c===!1)break}return c},visitParents:function(a,b){if(b&&a(this)===!1)return!1;var c=this.parent;while(c){if(a(c)===!1)return!1;c=c.parent}return!0},remove:function(){if(this===this.tree.root)throw"Cannot remove system root";return this.parent.removeChild(this)},removeChild:function(a){var b=this.childList;if(b.length==1){if(a!==b[0])throw"removeChild: invalid child";return this.removeChildren()}a===this.tree.activeNode&&a.deactivate(),this.tree.options.persist&&(a.bSelected&&this.tree.persistence.clearSelect(a.data.key),a.bExpanded&&this.tree.persistence.clearExpand(a.data.key)),a.removeChildren(!0),this.ul.removeChild(a.li);for(var c=0,d=b.length;c<d;c++)if(b[c]===a){this.childList.splice(c,1);break}},removeChildren:function(a,b){this.tree.logDebug("%s.removeChildren(%o)",this,a);var c=this.tree,d=this.childList;if(d){for(var e=0,f=d.length;e<f;e++){var g=d[e];g===c.activeNode&&!b&&g.deactivate(),this.tree.options.persist&&!b&&(g.bSelected&&this.tree.persistence.clearSelect(g.data.key),g.bExpanded&&this.tree.persistence.clearExpand(g.data.key)),g.removeChildren(!0,b),this.ul&&$("li",$(this.ul)).remove()}this.childList=null}a||(this._isLoading=!1,this.render())},setTitle:function(a){this.fromDict({title:a})},reload:function(a){throw"Use reloadChildren() instead"},reloadChildren:function(a){if(this.parent===null)throw"Use tree.reload() instead";if(!this.data.isLazy)throw"node.reloadChildren() requires lazy nodes.";if(a){var b=this,c="nodeLoaded.dynatree."+this.tree.$tree.attr("id")+"."+this.data.key;this.tree.$tree.bind(c,function(d,e,f){b.tree.$tree.unbind(c),b.tree.logDebug("loaded %o, %o, %o",d,e,f);if(e!==b)throw"got invalid load event";a.call(b.tree,e,f)})}this.removeChildren(),this._loadContent()},_loadKeyPath:function(a,b){var c=this.tree;c.logDebug("%s._loadKeyPath(%s)",this,a);if(a==="")throw"Key path must not be empty";var d=a.split(c.options.keyPathSeparator);if(d[0]==="")throw"Key path must be relative (don't start with '/')";var e=d.shift();if(this.childList)for(var f=0,g=this.childList.length;f<g;f++){var h=this.childList[f];if(h.data.key===e){if(d.length===0)b.call(c,h,"ok");else if(!h.data.isLazy||h.childList!==null&&h.childList!==undefined)b.call(c,h,"loaded"),h._loadKeyPath(d.join(c.options.keyPathSeparator),b);else{c.logDebug("%s._loadKeyPath(%s) -> reloading %s...",this,a,h);var i=this;h.reloadChildren(function(e,f){f?(c.logDebug("%s._loadKeyPath(%s) -> reloaded %s.",e,a,e),b.call(c,h,"loaded"),e._loadKeyPath(d.join(c.options.keyPathSeparator),b)):(c.logWarning("%s._loadKeyPath(%s) -> reloadChildren() failed.",i,a),b.call(c,h,"error"))})}return}}b.call(c,undefined,"notfound",e,d.length===0),c.logWarning("Node not found: "+e);return},resetLazy:function(){if(this.parent===null)throw"Use tree.reload() instead";if(!this.data.isLazy)throw"node.resetLazy() requires lazy nodes.";this.expand(!1),this.removeChildren()},_addChildNode:function(a,b){var c=this.tree,d=c.options,e=c.persistence;a.parent=this,this.childList===null?this.childList=[]:b||this.childList.length>0&&$(this.childList[this.childList.length-1].span).removeClass(d.classNames.lastsib);if(b){var f=$.inArray(b,this.childList);if(f<0)throw"<beforeNode> must be a child of <this>";this.childList.splice(f,0,a)}else this.childList.push(a);var g=c.isInitializing();d.persist&&e.cookiesFound&&g?(e.activeKey===a.data.key&&(c.activeNode=a),e.focusedKey===a.data.key&&(c.focusNode=a),a.bExpanded=$.inArray(a.data.key,e.expandedKeyList)>=0,a.bSelected=$.inArray(a.data.key,e.selectedKeyList)>=0):(a.data.activate&&(c.activeNode=a,d.persist&&(e.activeKey=a.data.key)),a.data.focus&&(c.focusNode=a,d.persist&&(e.focusedKey=a.data.key)),a.bExpanded=a.data.expand===!0,a.bExpanded&&d.persist&&e.addExpand(a.data.key),a.bSelected=a.data.select===!0,a.bSelected&&d.persist&&e.addSelect(a.data.key)),d.minExpandLevel>=a.getLevel()&&(this.bExpanded=!0);if(a.bSelected&&d.selectMode==3){var h=this;while(h)h.hasSubSel||h._setSubSel(!0),h=h.parent}return c.bEnableUpdate&&this.render(),a},addChild:function(a,b){if(typeof a=="string")throw"Invalid data type for "+a;if(!a||a.length===0)return;if(a instanceof DynaTreeNode)return this._addChildNode(a,b);a.length||(a=[a]);var c=this.tree.enableUpdate(!1),d=null;for(var e=0,f=a.length;e<f;e++){var g=a[e],h=this._addChildNode(new DynaTreeNode(this,this.tree,g),b);d||(d=h),g.children&&h.addChild(g.children,null)}return this.tree.enableUpdate(c),d},append:function(a){return this.tree.logWarning("node.append() is deprecated (use node.addChild() instead)."),this.addChild(a,null)},appendAjax:function(a){var b=this;this.removeChildren(!1,!0),this.setLazyNodeStatus(DTNodeStatus_Loading);if(a.debugLazyDelay){var c=a.debugLazyDelay;a.debugLazyDelay=0,this.tree.logInfo("appendAjax: waiting for debugLazyDelay "+c),setTimeout(function(){b.appendAjax(a)},c);return}var d=a.success,e=a.error,f="nodeLoaded.dynatree."+this.tree.$tree.attr("id")+"."+this.data.key,g=$.extend({},this.tree.options.ajaxDefaults,a,{success:function(a,c,e){var h=b.tree.phase;b.tree.phase="init",g.postProcess?a=g.postProcess.call(this,a,this.dataType):a&&a.hasOwnProperty("d")&&(a=typeof a.d=="string"?$.parseJSON(a.d):a.d),(!$.isArray(a)||a.length!==0)&&b.addChild(a,null),b.tree.phase="postInit",d&&d.call(g,b,a,c),b.tree.logDebug("trigger "+f),b.tree.$tree.trigger(f,[b,!0]),b.tree.phase=h,b.setLazyNodeStatus(DTNodeStatus_Ok),$.isArray(a)&&a.length===0&&(b.childList=[],b.render())},error:function(a,c,d){b.tree.logWarning("appendAjax failed:",c,":\n",a,"\n",d),e&&e.call(g,b,a,c,d),b.tree.$tree.trigger(f,[b,!1]),b.setLazyNodeStatus(DTNodeStatus_Error,{info:c,tooltip:""+d})}});$.ajax(g)},move:function(a,b){var c;if(this===a)return;if(!this.parent)throw"Cannot move system root";if(b===undefined||b=="over")b="child";var d=this.parent,e=b==="child"?a:a.parent;if(e.isDescendantOf(this))throw"Cannot move a node to it's own descendant";if(this.parent.childList.length==1)this.parent.childList=this.parent.data.isLazy?[]:null,this.parent.bExpanded=!1;else{c=$.inArray(this,this.parent.childList);if(c<0)throw"Internal error";this.parent.childList.splice(c,1)}this.parent.ul&&this.parent.ul.removeChild(this.li),this.parent=e;if(e.hasChildren())switch(b){case"child":e.childList.push(this);break;case"before":c=$.inArray(a,e.childList);if(c<0)throw"Internal error";e.childList.splice(c,0,this);break;case"after":c=$.inArray(a,e.childList);if(c<0)throw"Internal error";e.childList.splice(c+1,0,this);break;default:throw"Invalid mode "+b}else e.childList=[this];e.ul||(e.ul=document.createElement("ul"),e.ul.style.display="none",e.li.appendChild(e.ul)),this.li&&e.ul.appendChild(this.li);if(this.tree!==a.tree)throw this.visit(function(b){b.tree=a.tree},null,!0),"Not yet implemented.";d.isDescendantOf(e)||d.render(),e.isDescendantOf(d)||e.render()},lastentry:undefined};var DynaTreeStatus=Class.create();DynaTreeStatus._getTreePersistData=function(a,b){var c=new DynaTreeStatus(a,b);return c.read(),c.toDict()},getDynaTreePersistData=DynaTreeStatus._getTreePersistData,DynaTreeStatus.prototype={initialize:function(a,b){a===undefined&&(a=$.ui.dynatree.prototype.options.cookieId),b=$.extend({},$.ui.dynatree.prototype.options.cookie,b),this.cookieId=a,this.cookieOpts=b,this.cookiesFound=undefined,this.activeKey=null,this.focusedKey=null,this.expandedKeyList=null,this.selectedKeyList=null},_log:function(a){Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments)},read:function(){this.cookiesFound=!1;var a=$.cookie(this.cookieId+"-active");this.activeKey=a===null?"":a,a!==null&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-focus"),this.focusedKey=a===null?"":a,a!==null&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-expand"),this.expandedKeyList=a===null?[]:a.split(","),a!==null&&(this.cookiesFound=!0),a=$.cookie(this.cookieId+"-select"),this.selectedKeyList=a===null?[]:a.split(","),a!==null&&(this.cookiesFound=!0)},write:function(){$.cookie(this.cookieId+"-active",this.activeKey===null?"":this.activeKey,this.cookieOpts),$.cookie(this.cookieId+"-focus",this.focusedKey===null?"":this.focusedKey,this.cookieOpts),$.cookie(this.cookieId+"-expand",this.expandedKeyList===null?"":this.expandedKeyList.join(","),this.cookieOpts),$.cookie(this.cookieId+"-select",this.selectedKeyList===null?"":this.selectedKeyList.join(","),this.cookieOpts)},addExpand:function(a){$.inArray(a,this.expandedKeyList)<0&&(this.expandedKeyList.push(a),$.cookie(this.cookieId+"-expand",this.expandedKeyList.join(","),this.cookieOpts))},clearExpand:function(a){var b=$.inArray(a,this.expandedKeyList);b>=0&&(this.expandedKeyList.splice(b,1),$.cookie(this.cookieId+"-expand",this.expandedKeyList.join(","),this.cookieOpts))},addSelect:function(a){$.inArray(a,this.selectedKeyList)<0&&(this.selectedKeyList.push(a),$.cookie(this.cookieId+"-select",this.selectedKeyList.join(","),this.cookieOpts))},clearSelect:function(a){var b=$.inArray(a,this.selectedKeyList);b>=0&&(this.selectedKeyList.splice(b,1),$.cookie(this.cookieId+"-select",this.selectedKeyList.join(","),this.cookieOpts))},isReloading:function(){return this.cookiesFound===!0},toDict:function(){return{cookiesFound:this.cookiesFound,activeKey:this.activeKey,focusedKey:this.activeKey,expandedKeyList:this.expandedKeyList,selectedKeyList:this.selectedKeyList}},lastentry:undefined};var DynaTree=Class.create();DynaTree.version="$Version:$",DynaTree.prototype={initialize:function(a){this.phase="init",this.$widget=a,this.options=a.options,this.$tree=a.element,this.timer=null,this.divTree=this.$tree.get(0),_initDragAndDrop(this)},_load:function(a){var b=this.$widget,c=this.options,d=this;this.bEnableUpdate=!0,this._nodeCount=1,this.activeNode=null,this.focusNode=null,c.rootVisible!==undefined&&this.logWarning("Option 'rootVisible' is no longer supported."),c.minExpandLevel<1&&(this.logWarning("Option 'minExpandLevel' must be >= 1."),c.minExpandLevel=1),c.classNames!==$.ui.dynatree.prototype.options.classNames&&(c.classNames=$.extend({},$.ui.dynatree.prototype.options.classNames,c.classNames)),c.ajaxDefaults!==$.ui.dynatree.prototype.options.ajaxDefaults&&(c.ajaxDefaults=$.extend({},$.ui.dynatree.prototype.options.ajaxDefaults,c.ajaxDefaults)),c.dnd!==$.ui.dynatree.prototype.options.dnd&&(c.dnd=$.extend({},$.ui.dynatree.prototype.options.dnd,c.dnd)),c.imagePath||$("script").each(function(){var a=/.*dynatree[^\/]*\.js$/i;if(this.src.search(a)>=0)return this.src.indexOf("/")>=0?c.imagePath=this.src.slice(0,this.src.lastIndexOf("/"))+"/skin/":c.imagePath="skin/",d.logDebug("Guessing imagePath from '%s': '%s'",this.src,c.imagePath),!1}),this.persistence=new DynaTreeStatus(c.cookieId,c.cookie),c.persist&&($.cookie||_log("warn","Please include jquery.cookie.js to use persistence."),this.persistence.read()),this.logDebug("DynaTree.persistence: %o",this.persistence.toDict()),this.cache={tagEmpty:"<span class='"+c.classNames.empty+"'></span>",tagVline:"<span class='"+c.classNames.vline+"'></span>",tagExpander:"<span class='"+c.classNames.expander+"'></span>",tagConnector:"<span class='"+c.classNames.connector+"'></span>",tagNodeIcon:"<span class='"+c.classNames.nodeIcon+"'></span>",tagCheckbox:"<span class='"+c.classNames.checkbox+"'></span>",lastentry:undefined},(c.children||c.initAjax&&c.initAjax.url||c.initId)&&$(this.divTree).empty();var e=this.$tree.find(">ul:first").hide();this.tnRoot=new DynaTreeNode(null,this,{}),this.tnRoot.bExpanded=!0,this.tnRoot.render(),this.divTree.appendChild(this.tnRoot.ul);var f=this.tnRoot,g=c.persist&&this.persistence.isReloading(),h=!1,i=this.enableUpdate(!1);this.logDebug("Dynatree._load(): read tree structure..."),c.children?f.addChild(c.children):c.initAjax&&c.initAjax.url?(h=!0,f.data.isLazy=!0,this._reloadAjax(a)):c.initId?this._createFromTag(f,$("#"+c.initId)):(this._createFromTag(f,e),e.remove()),this._checkConsistency(),!h&&c.selectMode==3&&f._updatePartSelectionState(),this.logDebug("Dynatree._load(): render nodes..."),this.enableUpdate(i),this.logDebug("Dynatree._load(): bind events..."),this.$widget.bind(),this.logDebug("Dynatree._load(): postInit..."),this.phase="postInit",c.persist&&this.persistence.write(),this.focusNode&&this.focusNode.isVisible()&&(this.logDebug("Focus on init: %o",this.focusNode),this.focusNode.focus()),h||(c.onPostInit&&c.onPostInit.call(this,g,!1),a&&a.call(this,"ok")),this.phase="idle"},_reloadAjax:function(a){var b=this.options;if(!b.initAjax||!b.initAjax.url)throw"tree.reload() requires 'initAjax' mode.";var c=this.persistence,d=$.extend({},b.initAjax);d.addActiveKey&&(d.data.activeKey=c.activeKey),d.addFocusedKey&&(d.data.focusedKey=c.focusedKey),d.addExpandedKeyList&&(d.data.expandedKeyList=c.expandedKeyList.join(",")),d.addSelectedKeyList&&(d.data.selectedKeyList=c.selectedKeyList.join(",")),d.success&&this.logWarning("initAjax: success callback is ignored; use onPostInit instead."),d.error&&this.logWarning("initAjax: error callback is ignored; use onPostInit instead.");var e=c.isReloading();d.success=function(c,d,f){b.selectMode==3&&c.tree.tnRoot._updatePartSelectionState(),b.onPostInit&&b.onPostInit.call(c.tree,e,!1),a&&a.call(c.tree,"ok")},d.error=function(c,d,f,g){b.onPostInit&&b.onPostInit.call(c.tree,e,!0,d,f,g),a&&a.call(c.tree,"error",d,f,g)},this.logDebug("Dynatree._init(): send Ajax request..."),this.tnRoot.appendAjax(d)},toString:function(){return"Dynatree '"+this.$tree.attr("id")+"'"},toDict:function(){return this.tnRoot.toDict(!0)},serializeArray:function(a){var b=this.getSelectedNodes(a),c=this.$tree.attr("name")||this.$tree.attr("id"),d=[];for(var e=0,f=b.length;e<f;e++)d.push({name:c,value:b[e].data.key});return d},getPersistData:function(){return this.persistence.toDict()},logDebug:function(a){this.options.debugLevel>=2&&(Array.prototype.unshift.apply(arguments,["debug"]),_log.apply(this,arguments))},logInfo:function(a){this.options.debugLevel>=1&&(Array.prototype.unshift.apply(arguments,["info"]),_log.apply(this,arguments))},logWarning:function(a){Array.prototype.unshift.apply(arguments,["warn"]),_log.apply(this,arguments)},isInitializing:function(){return this.phase=="init"||this.phase=="postInit"},isReloading:function(){return(this.phase=="init"||this.phase=="postInit")&&this.options.persist&&this.persistence.cookiesFound},isUserEvent:function(){return this.phase=="userEvent"},redraw:function(){this.tnRoot.render(!1,!1)},renderInvisibleNodes:function(){this.tnRoot.render(!1,!0)},reload:function(a){this._load(a)},getRoot:function(){return this.tnRoot},enable:function(){this.$widget.enable()},disable:function(){this.$widget.disable()},getNodeByKey:function(a){var b=document.getElementById(this.options.idPrefix+a);if(b)return b.dtnode?b.dtnode:null;var c=null;return this.visit(function(b){if(b.data.key==a)return c=b,!1},!0),c},getActiveNode:function(){return this.activeNode},reactivate:function(a){var b=this.activeNode;b&&(this.activeNode=null,b.activate(),a&&b.focus())},getSelectedNodes:function(a){var b=[];return this.tnRoot.visit(function(c){if(c.bSelected){b.push(c);if(a===!0)return"skip"}}),b},activateKey:function(a){var b=a===null?null:this.getNodeByKey(a);return b?(b.focus(),b.activate(),b):(this.activeNode&&this.activeNode.deactivate(),this.activeNode=null,null)},loadKeyPath:function(a,b){var c=a.split(this.options.keyPathSeparator);return c[0]===""&&c.shift(),c[0]==this.tnRoot.data.key&&(this.logDebug("Removed leading root key."),c.shift()),a=c.join(this.options.keyPathSeparator),this.tnRoot._loadKeyPath(a,b)},selectKey:function(a,b){var c=this.getNodeByKey(a);return c?(c.select(b),c):null},enableUpdate:function(a){return this.bEnableUpdate==a?a:(this.bEnableUpdate=a,a&&this.redraw(),!a)},count:function(){return this.tnRoot.countChildren()},visit:function(a,b){return this.tnRoot.visit(a,b)},_createFromTag:function(parentTreeNode,$ulParent){var self=this;$ulParent.find(">li").each(function(){var $li=$(this),$liSpan=$li.find(">span:first"),$liA=$li.find(">a:first"),title,href=null,target=null,tooltip;if($liSpan.length)title=$liSpan.html();else if($liA.length)title=$liA.html(),href=$liA.attr("href"),target=$liA.attr("target"),tooltip=$liA.attr("title");else{title=$li.html();var iPos=title.search(/<ul/i);iPos>=0?title=$.trim(title.substring(0,iPos)):title=$.trim(title)}var data={title:title,tooltip:tooltip,isFolder:$li.hasClass("folder"),isLazy:$li.hasClass("lazy"),expand:$li.hasClass("expanded"),select:$li.hasClass("selected"),activate:$li.hasClass("active"),focus:$li.hasClass("focused"),noLink:$li.hasClass("noLink")};href&&(data.href=href,data.target=target),$li.attr("title")&&(data.tooltip=$li.attr("title")),$li.attr("id")&&(data.key=$li.attr("id"));if($li.attr("data")){var dataAttr=$.trim($li.attr("data"));if(dataAttr){dataAttr.charAt(0)!="{"&&(dataAttr="{"+dataAttr+"}");try{$.extend(data,eval("("+dataAttr+")"))}catch(e){throw"Error parsing node data: "+e+"\ndata:\n'"+dataAttr+"'"}}}var childNode=parentTreeNode.addChild(data),$ul=$li.find(">ul:first");$ul.length&&self._createFromTag(childNode,$ul)})},_checkConsistency:function(){},_setDndStatus:function(a,b,c,d,e){var f=a?$(a.span):null,g=$(b.span);this.$dndMarker||(this.$dndMarker=$("<div id='dynatree-drop-marker'></div>").hide().css({"z-index":1e3}).prependTo($(this.divTree).parent()));if(d==="after"||d==="before"||d==="over"){var h="0 0";switch(d){case"before":this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-over"),this.$dndMarker.addClass("dynatree-drop-before"),h="0 -8";break;case"after":this.$dndMarker.removeClass("dynatree-drop-before dynatree-drop-over"),this.$dndMarker.addClass("dynatree-drop-after"),h="0 8";break;default:this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-before"),this.$dndMarker.addClass("dynatree-drop-over"),g.addClass("dynatree-drop-target"),h="8 0"}this.$dndMarker.show().position({my:"left top",at:"left top",of:g,offset:h})}else g.removeClass("dynatree-drop-target"),this.$dndMarker.hide();d==="after"?g.addClass("dynatree-drop-after"):g.removeClass("dynatree-drop-after"),d==="before"?g.addClass("dynatree-drop-before"):g.removeClass("dynatree-drop-before"),e===!0?(f&&f.addClass("dynatree-drop-accept"),g.addClass("dynatree-drop-accept"),c.addClass("dynatree-drop-accept")):(f&&f.removeClass("dynatree-drop-accept"),g.removeClass("dynatree-drop-accept"),c.removeClass("dynatree-drop-accept")),e===!1?(f&&f.addClass("dynatree-drop-reject"),g.addClass("dynatree-drop-reject"),c.addClass("dynatree-drop-reject")):(f&&f.removeClass("dynatree-drop-reject"),g.removeClass("dynatree-drop-reject"),c.removeClass("dynatree-drop-reject"))},_onDragEvent:function(a,b,c,d,e,f){var g=this.options,h=this.options.dnd,i=null,j=$(b.span),k,l;switch(a){case"helper":var m=$("<div class='dynatree-drag-helper'><span class='dynatree-drag-helper-img' /></div>").append($(d.target).closest("a").clone());$("ul.dynatree-container",b.tree.divTree).append(m),m.data("dtSourceNode",b),i=m;break;case"start":b.isStatusNode()?i=!1:h.onDragStart&&(i=h.onDragStart(b)),i===!1?(this.logDebug("tree.onDragStart() cancelled"),e.helper.trigger("mouseup"),e.helper.hide()):j.addClass("dynatree-drag-source");break;case"enter":i=h.onDragEnter?h.onDragEnter(b,c):null,i?i={over:i===!0||i==="over"||$.inArray("over",i)>=0,before:i===!0||i==="before"||$.inArray("before",i)>=0,after:i===!0||i==="after"||$.inArray("after",i)>=0}:i=!1,e.helper.data("enterResponse",i);break;case"over":l=e.helper.data("enterResponse"),k=null;if(l!==!1)if(typeof l=="string")k=l;else{var n=j.offset(),o={x:d.pageX-n.left,y:d.pageY-n.top},p={x:o.x/j.width(),y:o.y/j.height()};l.after&&p.y>.75?k="after":!l.over&&l.after&&p.y>.5?k="after":l.before&&p.y<=.25?k="before":!l.over&&l.before&&p.y<=.5?k="before":l.over&&(k="over"),h.preventVoidMoves&&(b===c?k=null:k==="before"&&c&&b===c.getNextSibling()?k=null:k==="after"&&c&&b===c.getPrevSibling()?k=null:k==="over"&&c&&c.parent===b&&c.isLastSibling()&&(k=null)),e.helper.data("hitMode",k)}k==="over"&&h.autoExpandMS&&b.hasChildren()!==!1&&!b.bExpanded&&b.scheduleAction("expand",h.autoExpandMS);if(k&&h.onDragOver){i=h.onDragOver(b,c,k);if(i==="over"||i==="before"||i==="after")k=i}this._setDndStatus(c,b,e.helper,k,i!==!1&&k!==null);break;case"drop":var q=e.helper.hasClass("dynatree-drop-reject");k=e.helper.data("hitMode"),k&&h.onDrop&&!q&&h.onDrop(b,c,k,e,f);break;case"leave":b.scheduleAction("cancel"),e.helper.data("enterResponse",null),e.helper.data("hitMode",null),this._setDndStatus(c,b,e.helper,"out",undefined),h.onDragLeave&&h.onDragLeave(b,c);break;case"stop":j.removeClass("dynatree-drag-source"),h.onDragStop&&h.onDragStop(b);break;default:throw"Unsupported drag event: "+a}return i},cancelDrag:function(){var a=$.ui.ddmanager.current;a&&a.cancel()},lastentry:undefined},$.widget("ui.dynatree",{_init:function(){if(parseFloat($.ui.version)<1.8)return this.options.debugLevel>=0&&_log("warn","ui.dynatree._init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher."),this._create();this.options.debugLevel>=2&&_log("debug","ui.dynatree._init() was called; no current default functionality.")},_create:function(){var a=this.options;a.debugLevel>=1&&logMsg("Dynatree._create(): version='%s', debugLevel=%o.",$.ui.dynatree.version,this.options.debugLevel),this.options.event+=".dynatree";var b=this.element.get(0);this.tree=new DynaTree(this),this.tree._load(),this.tree.logDebug("Dynatree._init(): done.")},bind:function(){function b(a){a=$.event.fix(a||window.event);var b=$.ui.dynatree.getNode(a.target);return b?b._onFocus(a):!1}this.unbind();var a="click.dynatree dblclick.dynatree";this.options.keyboard&&(a+=" keypress.dynatree keydown.dynatree"),this.element.bind(a,function(a){var b=$.ui.dynatree.getNode(a.target);if(!b)return!0;var c=b.tree,d=c.options;c.logDebug("event(%s): dtnode: %s",a.type,b);var e=c.phase;c.phase="userEvent";try{switch(a.type){case"click":return d.onClick&&d.onClick.call(c,b,a)===!1?!1:b._onClick(a);case"dblclick":return d.onDblClick&&d.onDblClick.call(c,b,a)===!1?!1:b._onDblClick(a);case"keydown":return d.onKeydown&&d.onKeydown.call(c,b,a)===!1?!1:b._onKeydown(a);case"keypress":return d.onKeypress&&d.onKeypress.call(c,b,a)===!1?!1:b._onKeypress(a)}}catch(f){var g=null;c.logWarning("bind(%o): dtnode: %o, error: %o",a,b,f)}finally{c.phase=e}});var c=this.tree.divTree;c.addEventListener?(c.addEventListener("focus",b,!0),c.addEventListener("blur",b,!0)):c.onfocusin=c.onfocusout=b},unbind:function(){this.element.unbind(".dynatree")},enable:function(){this.bind(),$.Widget.prototype.enable.apply(this,arguments)},disable:function(){this.unbind(),$.Widget.prototype.disable.apply(this,arguments)},getTree:function(){return this.tree},getRoot:function(){return this.tree.getRoot()},getActiveNode:function(){return this.tree.getActiveNode()},getSelectedNodes:function(){return this.tree.getSelectedNodes()},lastentry:undefined}),parseFloat($.ui.version)<1.8&&($.ui.dynatree.getter="getTree getRoot getActiveNode getSelectedNodes"),$.ui.dynatree.version="$Version:$",$.ui.dynatree.getNode=function(a){if(a instanceof DynaTreeNode)return a;a.selector!==undefined&&(a=a[0]);while(a){if(a.dtnode)return a.dtnode;a=a.parentNode}return null},$.ui.dynatree.getPersistData=DynaTreeStatus._getTreePersistData,$.ui.dynatree.prototype.options={title:"Dynatree",minExpandLevel:1,imagePath:null,children:null,initId:null,initAjax:null,autoFocus:!0,keyboard:!0,persist:!1,autoCollapse:!1,clickFolderMode:3,activeVisible:!0,checkbox:!1,selectMode:2,fx:null,noLink:!1,onClick:null,onDblClick:null,onKeydown:null,onKeypress:null,onFocus:null,onBlur:null,onQueryActivate:null,onQuerySelect:null,onQueryExpand:null,onPostInit:null,onActivate:null,onDeactivate:null,onSelect:null,onExpand:null,onLazyRead:null,onCustomRender:null,onCreate:null,onRender:null,postProcess:null,dnd:{onDragStart:null,onDragStop:null,autoExpandMS:1e3,preventVoidMoves:!0,onDragEnter:null,onDragOver:null,onDrop:null,onDragLeave:null},ajaxDefaults:{cache:!1,timeout:0,dataType:"json"},strings:{loading:"Loading&#8230;",loadError:"Load error!"},generateIds:!1,idPrefix:"dynatree-id-",keyPathSeparator:"/",cookieId:"dynatree",cookie:{expires:null},classNames:{container:"dynatree-container",node:"dynatree-node",folder:"dynatree-folder",empty:"dynatree-empty",vline:"dynatree-vline",expander:"dynatree-expander",connector:"dynatree-connector",checkbox:"dynatree-checkbox",nodeIcon:"dynatree-icon",title:"dynatree-title",noConnector:"dynatree-no-connector",nodeError:"dynatree-statusnode-error",nodeWait:"dynatree-statusnode-wait",hidden:"dynatree-hidden",combinedExpanderPrefix:"dynatree-exp-",combinedIconPrefix:"dynatree-ico-",nodeLoading:"dynatree-loading",hasChildren:"dynatree-has-children",active:"dynatree-active",selected:"dynatree-selected",expanded:"dynatree-expanded",lazy:"dynatree-lazy",focused:"dynatree-focused",partsel:"dynatree-partsel",lastsib:"dynatree-lastsib"},debugLevel:2,lastentry:undefined},parseFloat($.ui.version)<1.8&&($.ui.dynatree.defaults=$.ui.dynatree.prototype.options),$.ui.dynatree.nodedatadefaults={title:null,key:null,isFolder:!1,isLazy:!1,tooltip:null,href:null,icon:null,addClass:null,noLink:!1,activate:!1,focus:!1,expand:!1,select:!1,hideCheckbox:!1,unselectable:!1,children:null,lastentry:undefined};var didRegisterDnd=!1,_registerDnd=function(){if(didRegisterDnd)return;$.ui.plugin.add("draggable","connectToDynatree",{start:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null;if(d)return c.offset.click.top=-2,c.offset.click.left=16,d.tree._onDragEvent("start",d,null,a,b,c)},drag:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null,e=b.helper.data("dtTargetNode")||null,f=$.ui.dynatree.getNode(a.target);if(a.target&&!f){var g=$(a.target).closest("div.dynatree-drag-helper,#dynatree-drop-marker").length>0;if(g)return}b.helper.data("dtTargetNode",f),e&&e!==f&&e.tree._onDragEvent("leave",e,d,a,b,c),f&&(!f.tree.options.dnd.onDrop||(f===e?f.tree._onDragEvent("over",f,d,a,b,c):f.tree._onDragEvent("enter",f,d,a,b,c)))},stop:function(a,b){var c=$(this).data("draggable"),d=b.helper.data("dtSourceNode")||null,e=b.helper.data("dtTargetNode")||null,f=c._mouseDownEvent,g=a.type,h=g=="mouseup"&&a.which==1;h||logMsg("Drag was cancelled"),e&&(h&&e.tree._onDragEvent("drop",e,d,a,b,c),e.tree._onDragEvent("leave",e,d,a,b,c)),d&&d.tree._onDragEvent("stop",d,null,a,b,c)}}),didRegisterDnd=!0}})(jQuery);
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/grunt.js
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/grunt.js	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/grunt.js	(revision 9215)
@@ -0,0 +1,80 @@
+/*jslint node:true */
+
+module.exports = function(grunt) {
+    // Project configuration.
+    grunt.initConfig({
+        pkg: "<json:package.json>",
+        // Project metadata, used by the <banner> directive.
+        meta: {
+            banner: "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
+                    "<%= grunt.template.today('yyyy-mm-dd') %>\n" +
+                    "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" +
+                    "* Copyright (c) <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
+                    " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */"
+        },
+        concat: {
+            dist: {
+                src: ["<banner:meta.banner>", "<file_strip_banner:src/<%= pkg.name %>.js>"],
+//                src: ["src/jquery.dynatree.js"],
+                dest: "dist/<%= pkg.name %>-<%= pkg.version %>.js"
+            }
+        },
+        min: {
+            dist: {
+                src: ["<banner:meta.banner>", "<config:concat.dist.dest>"],
+                dest: "dist/<%= pkg.name %>.min.js"
+            }
+        },
+//        qunit: {
+//            files: ["tests/unit/**/*.html"]
+//        },
+        lint: {
+//            beforeconcat: ["grunt.js", "src/**/*.js", "tests/**/*.js"],
+            beforeconcat: ["src/jquery.dynatree.js"],
+//            beforeconcat: ["grunt.js"],
+//            beforeconcat: ["grunt.js", "src/jquery.dynatree.js", "tests/**/*.js"],
+            afterconcat: ["<config:concat.dist.dest>"]
+        },
+        // watch: {
+        //   files: "<config:lint.files>",
+        //   tasks: "lint qunit"
+        // },        
+
+        jshint: {
+            options: {
+                // Enforcing Options:
+                bitwise: true,
+                curly: true,
+//              forin: true,
+                eqeqeq: true,
+                immed: true,
+                latedef: true,
+                newcap: true,
+                noarg: true,
+//              noempty: true,
+                nonew: true,
+//              plusplus: true,
+                regexp: true,
+//              strict: true,
+                sub: true,
+                undef: true,
+                // Relaxing Options:
+                eqnull: false,
+                laxbreak: true,
+//                laxcomma: true,
+                smarttabs: false,
+//                globalstrict: true,
+                // Environments:
+//              node: true,  // TODO: only for grunt.js and dynatree-server.json
+                browser: true
+            },
+            globals: {
+                jQuery: true
+            }
+        },
+        uglify: {
+        }
+    });
+    // Default task.
+    grunt.registerTask("default", "lint:beforeconcat concat lint:afterconcat min");
+};
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/package.json
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/package.json	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/package.json	(revision 9215)
@@ -0,0 +1,32 @@
+{
+  "name": "jquery.dynatree",
+  "title": "jQuery Dynatree Plugin",
+  "description": "Dynatree is a JavaScript dynamic tree view plugin for jQuery with support for persistence, keyboard, checkboxes, drag'n'drop, and lazy loading.",
+  "version": "1.2.2",
+  "homepage": "http://dynatree.googlecode.com/",
+  "author": {
+    "name": "Martin Wendt",
+    "url": "http://wwwendt.de/"
+  },
+  "repository": {
+    "type": "svn",
+    "url": "http://dynatree.googlecode.com/svn/trunk/"
+  },
+  "bugs": {
+    "url": "https://code.google.com/p/dynatree/issues/list"
+  },
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "https://code.google.com/p/dynatree/wiki/LicenseInfo"
+    },
+    {
+      "type": "GPL",
+      "url": "https://code.google.com/p/dynatree/wiki/LicenseInfo"
+    }
+  ],
+  "dependencies": {
+    "jquery": "~1.4.2"
+  },
+  "keywords": []
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/GPL-LICENSE.txt
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/GPL-LICENSE.txt	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/GPL-LICENSE.txt	(revision 9215)
@@ -0,0 +1,278 @@
+        GNU GENERAL PUBLIC LICENSE
+           Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+        GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+          NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/MIT-License.txt
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/MIT-License.txt	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/MIT-License.txt	(revision 9215)
@@ -0,0 +1,7 @@
+Copyright (c) 2006-2012  Martin Wendt (http://wwWendt.de)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/jquery.dynatree.js
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/jquery.dynatree.js	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/jquery.dynatree.js	(revision 9215)
@@ -0,0 +1,3351 @@
+/*************************************************************************
+	jquery.dynatree.js
+	Dynamic tree view control, with support for lazy loading of branches.
+
+	Copyright (c) 2006-2012, Martin Wendt (http://wwWendt.de)
+	Dual licensed under the MIT or GPL Version 2 licenses.
+	http://code.google.com/p/dynatree/wiki/LicenseInfo
+
+	A current version and some documentation is available at
+		http://dynatree.googlecode.com/
+
+	$Version: 1.2.2$
+	$Revision: 627, 2012-10-07 16:55:00$
+
+	@depends: jquery.js
+	@depends: jquery.ui.core.js
+	@depends: jquery.cookie.js
+*************************************************************************/
+
+/* jsHint options*/
+// Note: We currently allow eval() to parse the 'data' attribtes, when initializing from HTML.
+// TODO: pass jsHint with the options given in grunt.js only.
+//       The following should not be required:
+/*global alert */
+/*jshint nomen:false, smarttabs:true, eqeqeq:false, evil:true, regexp:false */
+
+/*************************************************************************
+ *	Debug functions
+ */
+
+var _canLog = true;
+
+function _log(mode, msg) {
+	/**
+	 * Usage: logMsg("%o was toggled", this);
+	 */
+	if( !_canLog ){
+		return;
+	}
+	// Remove first argument
+	var args = Array.prototype.slice.apply(arguments, [1]);
+	// Prepend timestamp
+	var dt = new Date();
+	var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
+	args[0] = tag + " - " + args[0];
+
+	try {
+		switch( mode ) {
+		case "info":
+			window.console.info.apply(window.console, args);
+			break;
+		case "warn":
+			window.console.warn.apply(window.console, args);
+			break;
+		default:
+			window.console.log.apply(window.console, args);
+			break;
+		}
+	} catch(e) {
+		if( !window.console ){
+			_canLog = false; // Permanently disable, when logging is not supported by the browser
+		}
+	}
+}
+
+function logMsg(msg) {
+	Array.prototype.unshift.apply(arguments, ["debug"]);
+	_log.apply(this, arguments);
+}
+
+
+// Forward declaration
+var getDynaTreePersistData = null;
+
+
+
+/*************************************************************************
+ *	Constants
+ */
+var DTNodeStatus_Error   = -1;
+var DTNodeStatus_Loading = 1;
+var DTNodeStatus_Ok      = 0;
+
+
+// Start of local namespace
+(function($) {
+
+/*************************************************************************
+ *	Common tool functions.
+ */
+
+var Class = {
+	create: function() {
+		return function() {
+			this.initialize.apply(this, arguments);
+		};
+	}
+};
+
+// Tool function to get dtnode from the event target:
+function getDtNodeFromElement(el) {
+	alert("getDtNodeFromElement is deprecated");
+	return $.ui.dynatree.getNode(el);
+/*
+	var iMax = 5;
+	while( el && iMax-- ) {
+		if(el.dtnode) { return el.dtnode; }
+		el = el.parentNode;
+	}
+	return null;
+*/
+}
+
+function noop() {
+}
+
+/*************************************************************************
+ *	Class DynaTreeNode
+ */
+var DynaTreeNode = Class.create();
+
+DynaTreeNode.prototype = {
+	initialize: function(parent, tree, data) {
+		/**
+		 * @constructor
+		 */
+		this.parent = parent;
+		this.tree = tree;
+		if ( typeof data === "string" ){
+			data = { title: data };
+		}
+		if( data.key === undefined ){
+			data.key = "_" + tree._nodeCount++;
+		}
+		this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
+		this.li = null; // not yet created
+		this.span = null; // not yet created
+		this.ul = null; // not yet created
+		this.childList = null; // no subnodes yet
+		this._isLoading = false; // Lazy content is being loaded
+		this.hasSubSel = false;
+		this.bExpanded = false;
+		this.bSelected = false;
+
+	},
+
+	toString: function() {
+		return "DynaTreeNode<" + this.data.key + ">: '" + this.data.title + "'";
+	},
+
+	toDict: function(recursive, callback) {
+		var dict = $.extend({}, this.data);
+		dict.activate = ( this.tree.activeNode === this );
+		dict.focus = ( this.tree.focusNode === this );
+		dict.expand = this.bExpanded;
+		dict.select = this.bSelected;
+		if( callback ){
+			callback(dict);
+		}
+		if( recursive && this.childList ) {
+			dict.children = [];
+			for(var i=0, l=this.childList.length; i<l; i++ ){
+				dict.children.push(this.childList[i].toDict(true, callback));
+			}
+		} else {
+			delete dict.children;
+		}
+		return dict;
+	},
+
+	fromDict: function(dict) {
+		/**
+		 * Update node data. If dict contains 'children', then also replace
+		 * the hole sub tree.
+		 */
+		var children = dict.children;
+		if(children === undefined){
+			this.data = $.extend(this.data, dict);
+			this.render();
+			return;
+		}
+		dict = $.extend({}, dict);
+		dict.children = undefined;
+		this.data = $.extend(this.data, dict);
+		this.removeChildren();
+		this.addChild(children);
+	},
+
+	_getInnerHtml: function() {
+		var tree = this.tree,
+			opts = tree.options,
+			cache = tree.cache,
+			level = this.getLevel(),
+			data = this.data,
+			res = "",
+			imageSrc;
+		// connector (expanded, expandable or simple)
+		if( level < opts.minExpandLevel ) {
+			if(level > 1){
+				res += cache.tagConnector;
+			}
+			// .. else (i.e. for root level) skip expander/connector altogether
+		} else if( this.hasChildren() !== false ) {
+			res += cache.tagExpander;
+		} else {
+			res += cache.tagConnector;
+		}
+		// Checkbox mode
+		if( opts.checkbox && data.hideCheckbox !== true && !data.isStatusNode ) {
+			res += cache.tagCheckbox;
+		}
+		// folder or doctype icon
+		if ( data.icon ) {
+			if (data.icon.charAt(0) === "/"){
+				imageSrc = data.icon;
+			}else{
+				imageSrc = opts.imagePath + data.icon;
+			}
+			res += "<img src='" + imageSrc + "' alt='' />";
+		} else if ( data.icon === false ) {
+			// icon == false means 'no icon'
+//			noop(); // keep JSLint happy
+		} else {
+			// icon == null means 'default icon'
+			res += cache.tagNodeIcon;
+		}
+		// node title
+		var nodeTitle = "";
+		if ( opts.onCustomRender ){
+			nodeTitle = opts.onCustomRender.call(tree, this) || "";
+		}
+		if(!nodeTitle){
+			var tooltip = data.tooltip ? ' title="' + data.tooltip.replace(/\"/g, '&quot;') + '"' : '',
+				href = data.href || "#";
+			if( opts.noLink || data.noLink ) {
+				nodeTitle = '<span style="display:inline-block;" class="' + opts.classNames.title + '"' + tooltip + '>' + data.title + '</span>';
+//				this.tree.logDebug("nodeTitle: " + nodeTitle);
+			} else {
+				nodeTitle = '<a href="' + href + '" class="' + opts.classNames.title + '"' + tooltip + '>' + data.title + '</a>';
+			}
+		}
+		res += nodeTitle;
+		return res;
+	},
+
+
+	_fixOrder: function() {
+		/**
+		 * Make sure, that <li> order matches childList order.
+		 */
+		var cl = this.childList;
+		if( !cl || !this.ul ){
+			return;
+		}
+		var childLI = this.ul.firstChild;
+		for(var i=0, l=cl.length-1; i<l; i++) {
+			var childNode1 = cl[i];
+			var childNode2 = childLI.dtnode;
+			if( childNode1 !== childNode2 ) {
+				this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
+				this.ul.insertBefore(childNode1.li, childNode2.li);
+			} else {
+				childLI = childLI.nextSibling;
+			}
+		}
+	},
+
+
+	render: function(useEffects, includeInvisible) {
+		/**
+		 * Create <li><span>..</span> .. </li> tags for this node.
+		 *
+		 * <li id='KEY' dtnode=NODE> // This div contains the node's span and list of child div's.
+		 *   <span class='title'>S S S A</span> // Span contains graphic spans and title <a> tag
+		 *   <ul> // only present, when node has children
+		 *       <li id='KEY' dtnode=NODE>child1</li>
+		 *       <li id='KEY' dtnode=NODE>child2</li>
+		 *   </ul>
+		 * </li>
+		 */
+//		this.tree.logDebug("%s.render(%s)", this, useEffects);
+		// ---
+		var tree = this.tree,
+			parent = this.parent,
+			data = this.data,
+			opts = tree.options,
+			cn = opts.classNames,
+			isLastSib = this.isLastSibling(),
+			firstTime = false;
+
+		if( !parent && !this.ul ) {
+			// Root node has only a <ul>
+			this.li = this.span = null;
+			this.ul = document.createElement("ul");
+			if( opts.minExpandLevel > 1 ){
+				this.ul.className = cn.container + " " + cn.noConnector;
+			}else{
+				this.ul.className = cn.container;
+			}
+		} else if( parent ) {
+			// Create <li><span /> </li>
+			if( ! this.li ) {
+				firstTime = true;
+				this.li = document.createElement("li");
+				this.li.dtnode = this;
+				if( data.key && opts.generateIds ){
+					this.li.id = opts.idPrefix + data.key;
+				}
+				this.span = document.createElement("span");
+				this.span.className = cn.title;
+				this.li.appendChild(this.span);
+
+				if( !parent.ul ) {
+					// This is the parent's first child: create UL tag
+					// (Hidden, because it will be
+					parent.ul = document.createElement("ul");
+					parent.ul.style.display = "none";
+					parent.li.appendChild(parent.ul);
+//					if( opts.minExpandLevel > this.getLevel() ){
+//						parent.ul.className = cn.noConnector;
+//					}
+				}
+				// set node connector images, links and text
+//				this.span.innerHTML = this._getInnerHtml();
+
+				parent.ul.appendChild(this.li);
+			}
+			// set node connector images, links and text
+			this.span.innerHTML = this._getInnerHtml();
+			// Set classes for current status
+			var cnList = [];
+			cnList.push(cn.node);
+			if( data.isFolder ){
+				cnList.push(cn.folder);
+			}
+			if( this.bExpanded ){
+				cnList.push(cn.expanded);
+			}
+			if( this.hasChildren() !== false ){
+				cnList.push(cn.hasChildren);
+			}
+			if( data.isLazy && this.childList === null ){
+				cnList.push(cn.lazy);
+			}
+			if( isLastSib ){
+				cnList.push(cn.lastsib);
+			}
+			if( this.bSelected ){
+				cnList.push(cn.selected);
+			}
+			if( this.hasSubSel ){
+				cnList.push(cn.partsel);
+			}
+			if( tree.activeNode === this ){
+				cnList.push(cn.active);
+			}
+			if( data.addClass ){
+				cnList.push(data.addClass);
+			}
+			// IE6 doesn't correctly evaluate multiple class names,
+			// so we create combined class names that can be used in the CSS
+			cnList.push(cn.combinedExpanderPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isLazy && this.childList === null ? "d" : "")
+					+ (isLastSib ? "l" : "")
+					);
+			cnList.push(cn.combinedIconPrefix
+					+ (this.bExpanded ? "e" : "c")
+					+ (data.isFolder ? "f" : "")
+					);
+			this.span.className = cnList.join(" ");
+
+			// TODO: we should not set this in the <span> tag also, if we set it here:
+			this.li.className = isLastSib ? cn.lastsib : "";
+
+			// Allow tweaking, binding, after node was created for the first time
+			if(firstTime && opts.onCreate){
+				opts.onCreate.call(tree, this, this.span);
+			}
+			// Hide children, if node is collapsed
+//			this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			// Allow tweaking after node state was rendered
+			if(opts.onRender){
+				opts.onRender.call(tree, this, this.span);
+			}
+		}
+		// Visit child nodes
+		if( (this.bExpanded || includeInvisible === true) && this.childList ) {
+			for(var i=0, l=this.childList.length; i<l; i++) {
+				this.childList[i].render(false, includeInvisible);
+			}
+			// Make sure the tag order matches the child array
+			this._fixOrder();
+		}
+		// Hide children, if node is collapsed
+		if( this.ul ) {
+			var isHidden = (this.ul.style.display === "none");
+			var isExpanded = !!this.bExpanded;
+//			logMsg("isHidden:%s", isHidden);
+			if( useEffects && opts.fx && (isHidden === isExpanded) ) {
+				var duration = opts.fx.duration || 200;
+				$(this.ul).animate(opts.fx, duration);
+			} else {
+				this.ul.style.display = ( this.bExpanded || !parent ) ? "" : "none";
+			}
+		}
+	},
+	/** Return '/id1/id2/id3'. */
+	getKeyPath: function(excludeSelf) {
+		var path = [];
+		this.visitParents(function(node){
+			if(node.parent){
+				path.unshift(node.data.key);
+			}
+		}, !excludeSelf);
+		return "/" + path.join(this.tree.options.keyPathSeparator);
+	},
+
+	getParent: function() {
+		return this.parent;
+	},
+
+	getChildren: function() {
+		if(this.hasChildren() === undefined){
+			return undefined; // Lazy node: unloaded, currently loading, or load error
+		}
+		return this.childList;
+	},
+
+	/** Check if node has children (returns undefined, if not sure). */
+	hasChildren: function() {
+		if(this.data.isLazy){
+			if(this.childList === null || this.childList === undefined){
+				// Not yet loaded
+				return undefined;
+			}else if(this.childList.length === 0){
+				// Loaded, but response was empty
+				return false;
+			}else if(this.childList.length === 1 && this.childList[0].isStatusNode()){
+				// Currently loading or load error
+				return undefined;
+			}
+			return true;
+		}
+		return !!this.childList;
+	},
+
+	isFirstSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[0] === this;
+	},
+
+	isLastSibling: function() {
+		var p = this.parent;
+		return !p || p.childList[p.childList.length-1] === this;
+	},
+
+	isLoading: function() {
+		return !!this._isLoading;
+	},
+
+	getPrevSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=1, l=ac.length; i<l; i++){ // start with 1, so prev(first) = null
+			if( ac[i] === this ){
+				return ac[i-1];
+			}
+		}
+		return null;
+	},
+
+	getNextSibling: function() {
+		if( !this.parent ){
+			return null;
+		}
+		var ac = this.parent.childList;
+		for(var i=0, l=ac.length-1; i<l; i++){ // up to length-2, so next(last) = null
+			if( ac[i] === this ){
+				return ac[i+1];
+			}
+		}
+		return null;
+	},
+
+	isStatusNode: function() {
+		return (this.data.isStatusNode === true);
+	},
+
+	isChildOf: function(otherNode) {
+		return (this.parent && this.parent === otherNode);
+	},
+
+	isDescendantOf: function(otherNode) {
+		if(!otherNode){
+			return false;
+		}
+		var p = this.parent;
+		while( p ) {
+			if( p === otherNode ){
+				return true;
+			}
+			p = p.parent;
+		}
+		return false;
+	},
+
+	countChildren: function() {
+		var cl = this.childList;
+		if( !cl ){
+			return 0;
+		}
+		var n = cl.length;
+		for(var i=0, l=n; i<l; i++){
+			var child = cl[i];
+			n += child.countChildren();
+		}
+		return n;
+	},
+
+	/**Sort child list by title.
+	 * cmd: optional compare function.
+	 * deep: optional: pass true to sort all descendant nodes.
+	 */
+	sortChildren: function(cmp, deep) {
+		var cl = this.childList;
+		if( !cl ){
+			return;
+		}
+		cmp = cmp || function(a, b) {
+//			return a.data.title === b.data.title ? 0 : a.data.title > b.data.title ? 1 : -1;
+			var x = a.data.title.toLowerCase(),
+				y = b.data.title.toLowerCase();
+			return x === y ? 0 : x > y ? 1 : -1;
+			};
+		cl.sort(cmp);
+		if( deep ){
+			for(var i=0, l=cl.length; i<l; i++){
+				if( cl[i].childList ){
+					cl[i].sortChildren(cmp, "$norender$");
+				}
+			}
+		}
+		if( deep !== "$norender$" ){
+			this.render();
+		}
+	},
+
+	_setStatusNode: function(data) {
+		// Create, modify or remove the status child node (pass 'null', to remove it).
+		var firstChild = ( this.childList ? this.childList[0] : null );
+		if( !data ) {
+			if ( firstChild && firstChild.isStatusNode()) {
+				try{
+					// I've seen exceptions here with loadKeyPath...
+					if(this.ul){
+						this.ul.removeChild(firstChild.li);
+						firstChild.li = null; // avoid leaks (issue 215)
+					}
+				}catch(e){}
+				if( this.childList.length === 1 ){
+					this.childList = [];
+				}else{
+					this.childList.shift();
+				}
+			}
+		} else if ( firstChild ) {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild.data = data;
+			firstChild.render();
+		} else {
+			data.isStatusNode = true;
+			data.key = "_statusNode";
+			firstChild = this.addChild(data);
+		}
+	},
+
+	setLazyNodeStatus: function(lts, opts) {
+		var tooltip = (opts && opts.tooltip) ? opts.tooltip : null,
+			info = (opts && opts.info) ? " (" + opts.info + ")" : "";
+		switch( lts ) {
+			case DTNodeStatus_Ok:
+				this._setStatusNode(null);
+				$(this.span).removeClass(this.tree.options.classNames.nodeLoading);
+				this._isLoading = false;
+//				this.render();
+				if( this.tree.options.autoFocus ) {
+					if( this === this.tree.tnRoot && this.childList && this.childList.length > 0) {
+						// special case: using ajaxInit
+						this.childList[0].focus();
+					} else {
+						this.focus();
+					}
+				}
+				break;
+			case DTNodeStatus_Loading:
+				this._isLoading = true;
+				$(this.span).addClass(this.tree.options.classNames.nodeLoading);
+				// The root is hidden, so we set a temporary status child
+				if(!this.parent){
+					this._setStatusNode({
+						title: this.tree.options.strings.loading + info,
+						tooltip: tooltip,
+						addClass: this.tree.options.classNames.nodeWait
+					});
+				}
+				break;
+			case DTNodeStatus_Error:
+				this._isLoading = false;
+//				$(this.span).addClass(this.tree.options.classNames.nodeError);
+				this._setStatusNode({
+					title: this.tree.options.strings.loadError + info,
+					tooltip: tooltip,
+					addClass: this.tree.options.classNames.nodeError
+				});
+				break;
+			default:
+				throw "Bad LazyNodeStatus: '" + lts + "'.";
+		}
+	},
+
+	_parentList: function(includeRoot, includeSelf) {
+		var l = [];
+		var dtn = includeSelf ? this : this.parent;
+		while( dtn ) {
+			if( includeRoot || dtn.parent ){
+				l.unshift(dtn);
+			}
+			dtn = dtn.parent;
+		}
+		return l;
+	},
+	getLevel: function() {
+		/**
+		 * Return node depth. 0: System root node, 1: visible top-level node.
+		 */
+		var level = 0;
+		var dtn = this.parent;
+		while( dtn ) {
+			level++;
+			dtn = dtn.parent;
+		}
+		return level;
+	},
+
+	_getTypeForOuterNodeEvent: function(event) {
+		/** Return the inner node span (title, checkbox or expander) if
+		 *  event.target points to the outer span.
+		 *  This function should fix issue #93:
+		 *  FF2 ignores empty spans, when generating events (returning the parent instead).
+		 */
+		var cns = this.tree.options.classNames;
+		var target = event.target;
+		// Only process clicks on an outer node span (probably due to a FF2 event handling bug)
+		if( target.className.indexOf(cns.node) < 0 ) {
+			return null;
+		}
+		// Event coordinates, relative to outer node span:
+		var eventX = event.pageX - target.offsetLeft;
+		var eventY = event.pageY - target.offsetTop;
+
+		for(var i=0, l=target.childNodes.length; i<l; i++) {
+			var cn = target.childNodes[i];
+			var x = cn.offsetLeft - target.offsetLeft;
+			var y = cn.offsetTop - target.offsetTop;
+			var nx = cn.clientWidth, ny = cn.clientHeight;
+//	        alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
+			if( eventX >= x && eventX <= (x+nx) && eventY >= y && eventY <= (y+ny) ) {
+//	            alert("HIT "+ cn.className);
+				if( cn.className==cns.title ){
+					return "title";
+				}else if( cn.className==cns.expander ){
+					return "expander";
+				}else if( cn.className==cns.checkbox ){
+					return "checkbox";
+				}else if( cn.className==cns.nodeIcon ){
+					return "icon";
+				}
+			}
+		}
+		return "prefix";
+	},
+
+	getEventTargetType: function(event) {
+		// Return the part of a node, that a click event occured on.
+		// Note: there is no check, if the event was fired on THIS node.
+		var tcn = event && event.target ? event.target.className : "",
+			cns = this.tree.options.classNames;
+
+		if( tcn === cns.title ){
+			return "title";
+		}else if( tcn === cns.expander ){
+			return "expander";
+		}else if( tcn === cns.checkbox ){
+			return "checkbox";
+		}else if( tcn === cns.nodeIcon ){
+			return "icon";
+		}else if( tcn === cns.empty || tcn === cns.vline || tcn === cns.connector ){
+			return "prefix";
+		}else if( tcn.indexOf(cns.node) >= 0 ){
+			// FIX issue #93
+			return this._getTypeForOuterNodeEvent(event);
+		}
+		return null;
+	},
+
+	isVisible: function() {
+		// Return true, if all parents are expanded.
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			if( ! parents[i].bExpanded ){ return false; }
+		}
+		return true;
+	},
+
+	makeVisible: function() {
+		// Make sure, all parents are expanded
+		var parents = this._parentList(true, false);
+		for(var i=0, l=parents.length; i<l; i++){
+			parents[i]._expand(true);
+		}
+	},
+
+	focus: function() {
+		// TODO: check, if we already have focus
+//		this.tree.logDebug("dtnode.focus(): %o", this);
+		this.makeVisible();
+		try {
+			$(this.span).find(">a").focus();
+		} catch(e) { }
+	},
+
+	isFocused: function() {
+		return (this.tree.tnFocused === this);
+	},
+
+	_activate: function(flag, fireEvents) {
+		// (De)Activate - but not focus - this node.
+		this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.tree, flag, this) === false ){
+			return; // Callback returned false
+		}
+		if( flag ) {
+			// Activate
+			if( this.tree.activeNode ) {
+				if( this.tree.activeNode === this ){
+					return;
+				}
+				this.tree.activeNode.deactivate();
+			}
+			if( opts.activeVisible ){
+				this.makeVisible();
+			}
+			this.tree.activeNode = this;
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
+			}
+			this.tree.persistence.activeKey = this.data.key;
+			$(this.span).addClass(opts.classNames.active);
+			if ( fireEvents && opts.onActivate ){
+				opts.onActivate.call(this.tree, this);
+			}
+		} else {
+			// Deactivate
+			if( this.tree.activeNode === this ) {
+				if ( opts.onQueryActivate && opts.onQueryActivate.call(this.tree, false, this) === false ){
+					return; // Callback returned false
+				}
+				$(this.span).removeClass(opts.classNames.active);
+				if( opts.persist ) {
+					// Note: we don't pass null, but ''. So the cookie is not deleted.
+					// If we pass null, we also have to pass a COPY of opts, because $cookie will override opts.expires (issue 84)
+					$.cookie(opts.cookieId+"-active", "", opts.cookie);
+				}
+				this.tree.persistence.activeKey = null;
+				this.tree.activeNode = null;
+				if ( fireEvents && opts.onDeactivate ){
+					opts.onDeactivate.call(this.tree, this);
+				}
+			}
+		}
+	},
+
+	activate: function() {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.activate(): %o", this);
+		this._activate(true, true);
+	},
+
+	activateSilently: function() {
+		this._activate(true, false);
+	},
+
+	deactivate: function() {
+//		this.tree.logDebug("dtnode.deactivate(): %o", this);
+		this._activate(false, true);
+	},
+
+	isActive: function() {
+		return (this.tree.activeNode === this);
+	},
+
+	_userActivate: function() {
+		// Handle user click / [space] / [enter], according to clickFolderMode.
+		var activate = true;
+		var expand = false;
+		if ( this.data.isFolder ) {
+			switch( this.tree.options.clickFolderMode ) {
+			case 2:
+				activate = false;
+				expand = true;
+				break;
+			case 3:
+				activate = expand = true;
+				break;
+			}
+		}
+		if( this.parent === null ) {
+			expand = false;
+		}
+		if( expand ) {
+			this.toggleExpand();
+			this.focus();
+		}
+		if( activate ) {
+			this.activate();
+		}
+	},
+
+	_setSubSel: function(hasSubSel) {
+		if( hasSubSel ) {
+			this.hasSubSel = true;
+			$(this.span).addClass(this.tree.options.classNames.partsel);
+		} else {
+			this.hasSubSel = false;
+			$(this.span).removeClass(this.tree.options.classNames.partsel);
+		}
+	},
+	/**
+	 * Fix selection and partsel status, of parent nodes, according to current status of
+	 * end nodes.
+	 */
+	_updatePartSelectionState: function() {
+//		alert("_updatePartSelectionState " + this);
+//		this.tree.logDebug("_updatePartSelectionState() - %o", this);
+		var sel;
+		// Return `true` or `false` for end nodes and remove part-sel flag
+		if( ! this.hasChildren() ){
+			sel = (this.bSelected && !this.data.unselectable && !this.data.isStatusNode);
+			this._setSubSel(false);
+			return sel;
+		}
+		// Return `true`, `false`, or `undefined` for parent nodes
+		var i, l,
+			cl = this.childList,
+			allSelected = true,
+			allDeselected = true;
+		for(i=0, l=cl.length; i<l;  i++) {
+			var n = cl[i],
+				s = n._updatePartSelectionState();
+			if( s !== false){
+				allDeselected = false;
+			}
+			if( s !== true){
+				allSelected = false;
+			}
+		}
+		if( allSelected ){
+			sel = true;
+		} else if ( allDeselected ){
+			sel = false;
+		} else {
+			sel = undefined;
+		}
+		this._setSubSel(sel === undefined);
+		this.bSelected = (sel === true);
+		return sel;
+	},
+
+	/**
+	 * Fix selection status, after this node was (de)selected in multi-hier mode.
+	 * This includes (de)selecting all children.
+	 */
+	_fixSelectionState: function() {
+//		alert("_fixSelectionState " + this);
+//		this.tree.logDebug("_fixSelectionState(%s) - %o", this.bSelected, this);
+		var p, i, l;
+		if( this.bSelected ) {
+			// Select all children
+			this.visit(function(node){
+				node.parent._setSubSel(true);
+				if(!node.data.unselectable){
+					node._select(true, false, false);
+				}
+			});
+			// Select parents, if all children are selected
+			p = this.parent;
+			while( p ) {
+				p._setSubSel(true);
+				var allChildsSelected = true;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					var n = p.childList[i];
+					if( !n.bSelected && !n.data.isStatusNode && !n.data.unselectable) {
+					// issue 305 proposes this:
+//					if( !n.bSelected && !n.data.isStatusNode ) {
+						allChildsSelected = false;
+						break;
+					}
+				}
+				if( allChildsSelected ){
+					p._select(true, false, false);
+				}
+				p = p.parent;
+			}
+		} else {
+			// Deselect all children
+			this._setSubSel(false);
+			this.visit(function(node){
+				node._setSubSel(false);
+				node._select(false, false, false);
+			});
+			// Deselect parents, and recalc hasSubSel
+			p = this.parent;
+			while( p ) {
+				p._select(false, false, false);
+				var isPartSel = false;
+				for(i=0, l=p.childList.length; i<l;  i++) {
+					if( p.childList[i].bSelected || p.childList[i].hasSubSel ) {
+						isPartSel = true;
+						break;
+					}
+				}
+				p._setSubSel(isPartSel);
+				p = p.parent;
+			}
+		}
+	},
+
+	_select: function(sel, fireEvents, deep) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode._select(%o) - %o", sel, this);
+		var opts = this.tree.options;
+		if( this.data.isStatusNode ){
+			return;
+		}
+		//
+		if( this.bSelected === sel ) {
+//			this.tree.logDebug("dtnode._select(%o) IGNORED - %o", sel, this);
+			return;
+		}
+		// Allow event listener to abort selection
+		if ( fireEvents && opts.onQuerySelect && opts.onQuerySelect.call(this.tree, sel, this) === false ){
+			return; // Callback returned false
+		}
+		// Force single-selection
+		if( opts.selectMode==1 && sel ) {
+			this.tree.visit(function(node){
+				if( node.bSelected ) {
+					// Deselect; assuming that in selectMode:1 there's max. one other selected node
+					node._select(false, false, false);
+					return false;
+				}
+			});
+		}
+
+		this.bSelected = sel;
+//        this.tree._changeNodeList("select", this, sel);
+
+		if( sel ) {
+			if( opts.persist ){
+				this.tree.persistence.addSelect(this.data.key);
+			}
+			$(this.span).addClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, true, this);
+			}
+		} else {
+			if( opts.persist ){
+				this.tree.persistence.clearSelect(this.data.key);
+			}
+			$(this.span).removeClass(opts.classNames.selected);
+
+			if( deep && opts.selectMode === 3 ){
+				this._fixSelectionState();
+			}
+			if ( fireEvents && opts.onSelect ){
+				opts.onSelect.call(this.tree, false, this);
+			}
+		}
+	},
+
+	select: function(sel) {
+		// Select - but not focus - this node.
+//		this.tree.logDebug("dtnode.select(%o) - %o", sel, this);
+		if( this.data.unselectable ){
+			return this.bSelected;
+		}
+		return this._select(sel!==false, true, true);
+	},
+
+	toggleSelect: function() {
+//		this.tree.logDebug("dtnode.toggleSelect() - %o", this);
+		return this.select(!this.bSelected);
+	},
+
+	isSelected: function() {
+		return this.bSelected;
+	},
+
+	isLazy: function() {
+		return !!this.data.isLazy;
+	},
+
+	_loadContent: function() {
+		try {
+			var opts = this.tree.options;
+			this.tree.logDebug("_loadContent: start - %o", this);
+			this.setLazyNodeStatus(DTNodeStatus_Loading);
+			if( true === opts.onLazyRead.call(this.tree, this) ) {
+				// If function returns 'true', we assume that the loading is done:
+				this.setLazyNodeStatus(DTNodeStatus_Ok);
+				// Otherwise (i.e. if the loading was started as an asynchronous process)
+				// the onLazyRead(dtnode) handler is expected to call dtnode.setLazyNodeStatus(DTNodeStatus_Ok/_Error) when done.
+				this.tree.logDebug("_loadContent: succeeded - %o", this);
+			}
+		} catch(e) {
+			this.tree.logWarning("_loadContent: failed - %o", e);
+			this.setLazyNodeStatus(DTNodeStatus_Error, {tooltip: ""+e});
+		}
+	},
+
+	_expand: function(bExpand, forceSync) {
+		if( this.bExpanded === bExpand ) {
+			this.tree.logDebug("dtnode._expand(%o) IGNORED - %o", bExpand, this);
+			return;
+		}
+		this.tree.logDebug("dtnode._expand(%o) - %o", bExpand, this);
+		var opts = this.tree.options;
+		if( !bExpand && this.getLevel() < opts.minExpandLevel ) {
+			this.tree.logDebug("dtnode._expand(%o) prevented collapse - %o", bExpand, this);
+			return;
+		}
+		if ( opts.onQueryExpand && opts.onQueryExpand.call(this.tree, bExpand, this) === false ){
+			return; // Callback returned false
+		}
+		this.bExpanded = bExpand;
+
+		// Persist expand state
+		if( opts.persist ) {
+			if( bExpand ){
+				this.tree.persistence.addExpand(this.data.key);
+			}else{
+				this.tree.persistence.clearExpand(this.data.key);
+			}
+		}
+		// Do not apply animations in init phase, or before lazy-loading
+		var allowEffects = !(this.data.isLazy && this.childList === null)
+			&& !this._isLoading
+			&& !forceSync;
+		this.render(allowEffects);
+
+		// Auto-collapse mode: collapse all siblings
+		if( this.bExpanded && this.parent && opts.autoCollapse ) {
+			var parents = this._parentList(false, true);
+			for(var i=0, l=parents.length; i<l; i++){
+				parents[i].collapseSiblings();
+			}
+		}
+		// If the currently active node is now hidden, deactivate it
+		if( opts.activeVisible && this.tree.activeNode && ! this.tree.activeNode.isVisible() ) {
+			this.tree.activeNode.deactivate();
+		}
+		// Expanding a lazy node: set 'loading...' and call callback
+		if( bExpand && this.data.isLazy && this.childList === null && !this._isLoading ) {
+			this._loadContent();
+			return;
+		}
+		if ( opts.onExpand ){
+			opts.onExpand.call(this.tree, bExpand, this);
+		}
+	},
+
+	isExpanded: function() {
+		return this.bExpanded;
+	},
+
+	expand: function(flag) {
+		flag = (flag !== false);
+		if( !this.childList && !this.data.isLazy && flag ){
+			return; // Prevent expanding empty nodes
+		} else if( this.parent === null && !flag ){
+			return; // Prevent collapsing the root
+		}
+		this._expand(flag);
+	},
+
+	scheduleAction: function(mode, ms) {
+		/** Schedule activity for delayed execution (cancel any pending request).
+		 *  scheduleAction('cancel') will cancel the request.
+		 */
+		if( this.tree.timer ) {
+			clearTimeout(this.tree.timer);
+			this.tree.logDebug("clearTimeout(%o)", this.tree.timer);
+		}
+		var self = this; // required for closures
+		switch (mode) {
+		case "cancel":
+			// Simply made sure that timer was cleared
+			break;
+		case "expand":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger expand");
+				self.expand(true);
+			}, ms);
+			break;
+		case "activate":
+			this.tree.timer = setTimeout(function(){
+				self.tree.logDebug("setTimeout: trigger activate");
+				self.activate();
+			}, ms);
+			break;
+		default:
+			throw "Invalid mode " + mode;
+		}
+		this.tree.logDebug("setTimeout(%s, %s): %s", mode, ms, this.tree.timer);
+	},
+
+	toggleExpand: function() {
+		this.expand(!this.bExpanded);
+	},
+
+	collapseSiblings: function() {
+		if( this.parent === null ){
+			return;
+		}
+		var ac = this.parent.childList;
+		for (var i=0, l=ac.length; i<l; i++) {
+			if ( ac[i] !== this && ac[i].bExpanded ){
+				ac[i]._expand(false);
+			}
+		}
+	},
+
+	_onClick: function(event) {
+//		this.tree.logDebug("dtnode.onClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+		var targetType = this.getEventTargetType(event);
+		if( targetType === "expander" ) {
+			// Clicking the expander icon always expands/collapses
+			this.toggleExpand();
+			this.focus(); // issue 95
+		} else if( targetType === "checkbox" ) {
+			// Clicking the checkbox always (de)selects
+			this.toggleSelect();
+			this.focus(); // issue 95
+		} else {
+			this._userActivate();
+			var aTag = this.span.getElementsByTagName("a");
+			if(aTag[0]){
+				// issue 154, 313
+				if(!($.browser.msie && parseInt($.browser.version, 10) < 9)){
+					aTag[0].focus();
+				}
+			}else{
+				// 'noLink' option was set
+				return true;
+			}
+		}
+		// Make sure that clicks stop, otherwise <a href='#'> jumps to the top
+		event.preventDefault();
+	},
+
+	_onDblClick: function(event) {
+//		this.tree.logDebug("dtnode.onDblClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
+	},
+
+	_onKeydown: function(event) {
+//		this.tree.logDebug("dtnode.onKeydown(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+		var handled = true,
+			sib;
+//		alert("keyDown" + event.which);
+
+		switch( event.which ) {
+			// charCodes:
+//			case 43: // '+'
+			case 107: // '+'
+			case 187: // '+' @ Chrome, Safari
+				if( !this.bExpanded ){ this.toggleExpand(); }
+				break;
+//			case 45: // '-'
+			case 109: // '-'
+			case 189: // '+' @ Chrome, Safari
+				if( this.bExpanded ){ this.toggleExpand(); }
+				break;
+			//~ case 42: // '*'
+				//~ break;
+			//~ case 47: // '/'
+				//~ break;
+			// case 13: // <enter>
+				// <enter> on a focused <a> tag seems to generate a click-event.
+				// this._userActivate();
+				// break;
+			case 32: // <space>
+				this._userActivate();
+				break;
+			case 8: // <backspace>
+				if( this.parent ){
+					this.parent.focus();
+				}
+				break;
+			case 37: // <left>
+				if( this.bExpanded ) {
+					this.toggleExpand();
+					this.focus();
+//				} else if( this.parent && (this.tree.options.rootVisible || this.parent.parent) ) {
+				} else if( this.parent && this.parent.parent ) {
+					this.parent.focus();
+				}
+				break;
+			case 39: // <right>
+				if( !this.bExpanded && (this.childList || this.data.isLazy) ) {
+					this.toggleExpand();
+					this.focus();
+				} else if( this.childList ) {
+					this.childList[0].focus();
+				}
+				break;
+			case 38: // <up>
+				sib = this.getPrevSibling();
+				while( sib && sib.bExpanded && sib.childList ){
+					sib = sib.childList[sib.childList.length-1];
+				}
+//				if( !sib && this.parent && (this.tree.options.rootVisible || this.parent.parent) )
+				if( !sib && this.parent && this.parent.parent ){
+					sib = this.parent;
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			case 40: // <down>
+				if( this.bExpanded && this.childList ) {
+					sib = this.childList[0];
+				} else {
+					var parents = this._parentList(false, true);
+					for(var i=parents.length-1; i>=0; i--) {
+						sib = parents[i].getNextSibling();
+						if( sib ){ break; }
+					}
+				}
+				if( sib ){
+					sib.focus();
+				}
+				break;
+			default:
+				handled = false;
+		}
+		// Return false, if handled, to prevent default processing
+//		return !handled;
+		if(handled){
+			event.preventDefault();
+		}
+	},
+
+	_onKeypress: function(event) {
+		// onKeypress is only hooked to allow user callbacks.
+		// We don't process it, because IE and Safari don't fire keypress for cursor keys.
+//		this.tree.logDebug("dtnode.onKeypress(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
+	},
+
+	_onFocus: function(event) {
+		// Handles blur and focus events.
+//		this.tree.logDebug("dtnode._onFocus(%o): %o", event, this);
+		var opts = this.tree.options;
+		if ( event.type == "blur" || event.type == "focusout" ) {
+			if ( opts.onBlur ){
+				opts.onBlur.call(this.tree, this);
+			}
+			if( this.tree.tnFocused ){
+				$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
+			}
+			this.tree.tnFocused = null;
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-focus", "", opts.cookie);
+			}
+		} else if ( event.type=="focus" || event.type=="focusin") {
+			// Fix: sometimes the blur event is not generated
+			if( this.tree.tnFocused && this.tree.tnFocused !== this ) {
+				this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o", this.tree.tnFocused);
+				$(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
+			}
+			this.tree.tnFocused = this;
+			if ( opts.onFocus ){
+				opts.onFocus.call(this.tree, this);
+			}
+			$(this.tree.tnFocused.span).addClass(opts.classNames.focused);
+			if( opts.persist ){
+				$.cookie(opts.cookieId+"-focus", this.data.key, opts.cookie);
+			}
+		}
+		// TODO: return anything?
+//		return false;
+	},
+
+	visit: function(fn, includeSelf) {
+		// Call fn(node) for all child nodes. Stop iteration, if fn() returns false.
+		var res = true;
+		if( includeSelf === true ) {
+			res = fn(this);
+			if( res === false || res == "skip" ){
+				return res;
+			}
+		}
+		if(this.childList){
+			for(var i=0, l=this.childList.length; i<l; i++){
+				res = this.childList[i].visit(fn, true);
+				if( res === false ){
+					break;
+				}
+			}
+		}
+		return res;
+	},
+
+	visitParents: function(fn, includeSelf) {
+		// Visit parent nodes (bottom up)
+		if(includeSelf && fn(this) === false){
+			return false;
+		}
+		var p = this.parent;
+		while( p ) {
+			if(fn(p) === false){
+				return false;
+			}
+			p = p.parent;
+		}
+		return true;
+	},
+
+	remove: function() {
+		// Remove this node
+//		this.tree.logDebug ("%s.remove()", this);
+		if ( this === this.tree.root ){
+			throw "Cannot remove system root";
+		}
+		return this.parent.removeChild(this);
+	},
+
+	removeChild: function(tn) {
+		// Remove tn from list of direct children.
+		var ac = this.childList;
+		if( ac.length == 1 ) {
+			if( tn !== ac[0] ){
+				throw "removeChild: invalid child";
+			}
+			return this.removeChildren();
+		}
+		if( tn === this.tree.activeNode ){
+			tn.deactivate();
+		}
+		if( this.tree.options.persist ) {
+			if( tn.bSelected ){
+				this.tree.persistence.clearSelect(tn.data.key);
+			}
+			if ( tn.bExpanded ){
+				this.tree.persistence.clearExpand(tn.data.key);
+			}
+		}
+		tn.removeChildren(true);
+//		this.div.removeChild(tn.div);
+		this.ul.removeChild(tn.li);
+		for(var i=0, l=ac.length; i<l; i++) {
+			if( ac[i] === tn ) {
+				this.childList.splice(i, 1);
+//				delete tn;  // JSLint complained
+				break;
+			}
+		}
+	},
+
+	removeChildren: function(isRecursiveCall, retainPersistence) {
+		// Remove all child nodes (more efficiently than recursive remove())
+		this.tree.logDebug("%s.removeChildren(%o)", this, isRecursiveCall);
+		var tree = this.tree;
+		var ac = this.childList;
+		if( ac ) {
+			for(var i=0, l=ac.length; i<l; i++) {
+				var tn = ac[i];
+				if ( tn === tree.activeNode && !retainPersistence ){
+					tn.deactivate();
+				}
+				if( this.tree.options.persist && !retainPersistence ) {
+					if( tn.bSelected ){
+						this.tree.persistence.clearSelect(tn.data.key);
+					}
+					if ( tn.bExpanded ){
+						this.tree.persistence.clearExpand(tn.data.key);
+					}
+				}
+				tn.removeChildren(true, retainPersistence);
+				if(this.ul){
+//					this.ul.removeChild(tn.li);
+					$("li", $(this.ul)).remove(); // issue 231
+				}
+//				delete tn;  JSLint complained
+			}
+			// Set to 'null' which is interpreted as 'not yet loaded' for lazy
+			// nodes
+			this.childList = null;
+		}
+		if( ! isRecursiveCall ) {
+//			this._expand(false);
+//			this.isRead = false;
+			this._isLoading = false;
+			this.render();
+		}
+	},
+
+	setTitle: function(title) {
+		this.fromDict({title: title});
+	},
+
+	reload: function(force) {
+		throw "Use reloadChildren() instead";
+	},
+
+	reloadChildren: function(callback) {
+		// Reload lazy content (expansion state is maintained).
+		if( this.parent === null ){
+			throw "Use tree.reload() instead";
+		}else if( ! this.data.isLazy ){
+			throw "node.reloadChildren() requires lazy nodes.";
+		}
+		// appendAjax triggers 'nodeLoaded' event.
+		// We listen to this, if a callback was passed to reloadChildren
+		if(callback){
+			var self = this;
+			var eventType = "nodeLoaded.dynatree." + this.tree.$tree.attr("id")
+				+ "." + this.data.key;
+			this.tree.$tree.bind(eventType, function(e, node, isOk){
+				self.tree.$tree.unbind(eventType);
+				self.tree.logDebug("loaded %o, %o, %o", e, node, isOk);
+				if(node !== self){
+					throw "got invalid load event";
+				}
+				callback.call(self.tree, node, isOk);
+			});
+		}
+		// The expansion state is maintained
+		this.removeChildren();
+		this._loadContent();
+//		if( this.bExpanded ) {
+//			// Remove children first, to prevent effects being applied
+//			this.removeChildren();
+//			// then force re-expand to trigger lazy loading
+////			this.expand(false);
+////			this.expand(true);
+//			this._loadContent();
+//		} else {
+//			this.removeChildren();
+//			this._loadContent();
+//		}
+	},
+
+	/**
+	 * Make sure the node with a given key path is available in the tree.
+	 */
+	_loadKeyPath: function(keyPath, callback) {
+		var tree = this.tree;
+		tree.logDebug("%s._loadKeyPath(%s)", this, keyPath);
+		if(keyPath === ""){
+			throw "Key path must not be empty";
+		}
+		var segList = keyPath.split(tree.options.keyPathSeparator);
+		if(segList[0] === ""){
+			throw "Key path must be relative (don't start with '/')";
+		}
+		var seg = segList.shift();
+		if(this.childList){
+			for(var i=0, l=this.childList.length; i < l; i++){
+				var child = this.childList[i];
+				if( child.data.key === seg ){
+					if(segList.length === 0) {
+						// Found the end node
+						callback.call(tree, child, "ok");
+
+					}else if(child.data.isLazy && (child.childList === null || child.childList === undefined)){
+						tree.logDebug("%s._loadKeyPath(%s) -> reloading %s...", this, keyPath, child);
+						var self = this;
+						// Note: this line gives a JSLint warning (Don't make functions within a loop)
+						/*jshint loopfunc:true */
+						child.reloadChildren(function(node, isOk){
+							// After loading, look for direct child with that key
+							if(isOk){
+								tree.logDebug("%s._loadKeyPath(%s) -> reloaded %s.", node, keyPath, node);
+								callback.call(tree, child, "loaded");
+								node._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
+							}else{
+								tree.logWarning("%s._loadKeyPath(%s) -> reloadChildren() failed.", self, keyPath);
+								callback.call(tree, child, "error");
+							}
+						});
+						// we can ignore it, since it will only be exectuted once, the the loop is ended
+						// See also http://stackoverflow.com/questions/3037598/how-to-get-around-the-jslint-error-dont-make-functions-within-a-loop
+					} else {
+						callback.call(tree, child, "loaded");
+						// Look for direct child with that key
+						child._loadKeyPath(segList.join(tree.options.keyPathSeparator), callback);
+					}
+					return;
+				}
+			}
+		}
+		// Could not find key
+		// Callback params: child: undefined, the segment, isEndNode (segList.length === 0)
+		callback.call(tree, undefined, "notfound", seg, segList.length === 0);
+		tree.logWarning("Node not found: " + seg);
+		return;
+	},
+
+	resetLazy: function() {
+		// Discard lazy content.
+		if( this.parent === null ){
+			throw "Use tree.reload() instead";
+		}else if( ! this.data.isLazy ){
+			throw "node.resetLazy() requires lazy nodes.";
+		}
+		this.expand(false);
+		this.removeChildren();
+	},
+
+	_addChildNode: function(dtnode, beforeNode) {
+		/**
+		 * Internal function to add one single DynatreeNode as a child.
+		 *
+		 */
+		var tree = this.tree,
+			opts = tree.options,
+			pers = tree.persistence;
+
+//		tree.logDebug("%s._addChildNode(%o)", this, dtnode);
+
+		// --- Update and fix dtnode attributes if necessary
+		dtnode.parent = this;
+//		if( beforeNode && (beforeNode.parent !== this || beforeNode === dtnode ) )
+//			throw "<beforeNode> must be another child of <this>";
+
+		// --- Add dtnode as a child
+		if ( this.childList === null ) {
+			this.childList = [];
+		} else if( ! beforeNode ) {
+			// Fix 'lastsib'
+			if(this.childList.length > 0) {
+				$(this.childList[this.childList.length-1].span).removeClass(opts.classNames.lastsib);
+			}
+		}
+		if( beforeNode ) {
+			var iBefore = $.inArray(beforeNode, this.childList);
+			if( iBefore < 0 ){
+				throw "<beforeNode> must be a child of <this>";
+			}
+			this.childList.splice(iBefore, 0, dtnode);
+		} else {
+			// Append node
+			this.childList.push(dtnode);
+		}
+
+		// --- Handle persistence
+		// Initial status is read from cookies, if persistence is active and
+		// cookies are already present.
+		// Otherwise the status is read from the data attributes and then persisted.
+		var isInitializing = tree.isInitializing();
+		if( opts.persist && pers.cookiesFound && isInitializing ) {
+			// Init status from cookies
+//			tree.logDebug("init from cookie, pa=%o, dk=%o", pers.activeKey, dtnode.data.key);
+			if( pers.activeKey === dtnode.data.key ){
+				tree.activeNode = dtnode;
+			}
+			if( pers.focusedKey === dtnode.data.key ){
+				tree.focusNode = dtnode;
+			}
+			dtnode.bExpanded = ($.inArray(dtnode.data.key, pers.expandedKeyList) >= 0);
+			dtnode.bSelected = ($.inArray(dtnode.data.key, pers.selectedKeyList) >= 0);
+//			tree.logDebug("    key=%o, bSelected=%o", dtnode.data.key, dtnode.bSelected);
+		} else {
+			// Init status from data (Note: we write the cookies after the init phase)
+//			tree.logDebug("init from data");
+			if( dtnode.data.activate ) {
+				tree.activeNode = dtnode;
+				if( opts.persist ){
+					pers.activeKey = dtnode.data.key;
+				}
+			}
+			if( dtnode.data.focus ) {
+				tree.focusNode = dtnode;
+				if( opts.persist ){
+					pers.focusedKey = dtnode.data.key;
+				}
+			}
+			dtnode.bExpanded = ( dtnode.data.expand === true ); // Collapsed by default
+			if( dtnode.bExpanded && opts.persist ){
+				pers.addExpand(dtnode.data.key);
+			}
+			dtnode.bSelected = ( dtnode.data.select === true ); // Deselected by default
+/*
+			Doesn't work, cause pers.selectedKeyList may be null
+			if( dtnode.bSelected && opts.selectMode==1
+				&& pers.selectedKeyList && pers.selectedKeyList.length>0 ) {
+				tree.logWarning("Ignored multi-selection in single-mode for %o", dtnode);
+				dtnode.bSelected = false; // Fixing bad input data (multi selection for mode:1)
+			}
+*/
+			if( dtnode.bSelected && opts.persist ){
+				pers.addSelect(dtnode.data.key);
+			}
+		}
+
+		// Always expand, if it's below minExpandLevel
+//		tree.logDebug ("%s._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
+		if ( opts.minExpandLevel >= dtnode.getLevel() ) {
+//			tree.logDebug ("Force expand for %o", dtnode);
+			this.bExpanded = true;
+		}
+
+		// In multi-hier mode, update the parents selection state
+		// issue #82: only if not initializing, because the children may not exist yet
+//		if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
+//			dtnode._fixSelectionState();
+
+		// In multi-hier mode, update the parents selection state
+		if( dtnode.bSelected && opts.selectMode==3 ) {
+			var p = this;
+			while( p ) {
+				if( !p.hasSubSel ){
+					p._setSubSel(true);
+				}
+				p = p.parent;
+			}
+		}
+		// render this node and the new child
+		if ( tree.bEnableUpdate ){
+			this.render();
+		}
+		return dtnode;
+	},
+
+	addChild: function(obj, beforeNode) {
+		/**
+		 * Add a node object as child.
+		 *
+		 * This should be the only place, where a DynaTreeNode is constructed!
+		 * (Except for the root node creation in the tree constructor)
+		 *
+		 * @param obj A JS object (may be recursive) or an array of those.
+		 * @param {DynaTreeNode} beforeNode (optional) sibling node.
+		 *
+		 * Data format: array of node objects, with optional 'children' attributes.
+		 * [
+		 *	{ title: "t1", isFolder: true, ... }
+		 *	{ title: "t2", isFolder: true, ...,
+		 *		children: [
+		 *			{title: "t2.1", ..},
+		 *			{..}
+		 *			]
+		 *	}
+		 * ]
+		 * A simple object is also accepted instead of an array.
+		 *
+		 */
+//		this.tree.logDebug("%s.addChild(%o, %o)", this, obj, beforeNode);
+		if(typeof(obj) == "string"){
+			throw "Invalid data type for " + obj;
+		}else if( !obj || obj.length === 0 ){ // Passed null or undefined or empty array
+			return;
+		}else if( obj instanceof DynaTreeNode ){
+			return this._addChildNode(obj, beforeNode);
+		}
+
+		if( !obj.length ){ // Passed a single data object
+			obj = [ obj ];
+		}
+		var prevFlag = this.tree.enableUpdate(false);
+
+		var tnFirst = null;
+		for (var i=0, l=obj.length; i<l; i++) {
+			var data = obj[i];
+			var dtnode = this._addChildNode(new DynaTreeNode(this, this.tree, data), beforeNode);
+			if( !tnFirst ){
+				tnFirst = dtnode;
+			}
+			// Add child nodes recursively
+			if( data.children ){
+				dtnode.addChild(data.children, null);
+			}
+		}
+		this.tree.enableUpdate(prevFlag);
+		return tnFirst;
+	},
+
+	append: function(obj) {
+		this.tree.logWarning("node.append() is deprecated (use node.addChild() instead).");
+		return this.addChild(obj, null);
+	},
+
+	appendAjax: function(ajaxOptions) {
+		var self = this;
+		this.removeChildren(false, true);
+		this.setLazyNodeStatus(DTNodeStatus_Loading);
+		// Debug feature: force a delay, to simulate slow loading...
+		if(ajaxOptions.debugLazyDelay){
+			var ms = ajaxOptions.debugLazyDelay;
+			ajaxOptions.debugLazyDelay = 0;
+			this.tree.logInfo("appendAjax: waiting for debugLazyDelay " + ms);
+			setTimeout(function(){self.appendAjax(ajaxOptions);}, ms);
+			return;
+		}
+		// Ajax option inheritance: $.ajaxSetup < $.ui.dynatree.prototype.options.ajaxDefaults < tree.options.ajaxDefaults < ajaxOptions
+		var orgSuccess = ajaxOptions.success,
+			orgError = ajaxOptions.error,
+			eventType = "nodeLoaded.dynatree." + this.tree.$tree.attr("id") + "." + this.data.key;
+		var options = $.extend({}, this.tree.options.ajaxDefaults, ajaxOptions, {
+			success: function(data, textStatus, jqXHR){
+				// <this> is the request options
+//				self.tree.logDebug("appendAjax().success");
+				var prevPhase = self.tree.phase;
+				self.tree.phase = "init";
+				// postProcess is similar to the standard dataFilter hook,
+				// but it is also called for JSONP
+				if( options.postProcess ){
+					data = options.postProcess.call(this, data, this.dataType);
+				}
+				// Process ASPX WebMethod JSON object inside "d" property
+				// http://code.google.com/p/dynatree/issues/detail?id=202
+				else if (data && data.hasOwnProperty("d")) {
+				   data = (typeof data.d) == "string" ? $.parseJSON(data.d) : data.d;
+				}
+				if(!$.isArray(data) || data.length !== 0){
+					self.addChild(data, null);
+				}
+				self.tree.phase = "postInit";
+				if( orgSuccess ){
+					orgSuccess.call(options, self, data, textStatus);
+				}
+				self.tree.logDebug("trigger " + eventType);
+				self.tree.$tree.trigger(eventType, [self, true]);
+				self.tree.phase = prevPhase;
+				// This should be the last command, so node._isLoading is true
+				// while the callbacks run
+				self.setLazyNodeStatus(DTNodeStatus_Ok);
+				if($.isArray(data) && data.length === 0){
+					// Set to [] which is interpreted as 'no children' for lazy
+					// nodes
+					self.childList = [];
+					self.render();
+				}
+				},
+			error: function(jqXHR, textStatus, errorThrown){
+				// <this> is the request options
+				self.tree.logWarning("appendAjax failed:", textStatus, ":\n", jqXHR, "\n", errorThrown);
+				if( orgError ){
+					orgError.call(options, self, jqXHR, textStatus, errorThrown);
+				}
+				self.tree.$tree.trigger(eventType, [self, false]);
+				self.setLazyNodeStatus(DTNodeStatus_Error, {info: textStatus, tooltip: "" + errorThrown});
+				}
+		});
+		$.ajax(options);
+	},
+
+	move: function(targetNode, mode) {
+		/**Move this node to targetNode.
+		 *  mode 'child': append this node as last child of targetNode.
+		 *                This is the default. To be compatble with the D'n'd
+		 *                hitMode, we also accept 'over'.
+		 *  mode 'before': add this node as sibling before targetNode.
+		 *  mode 'after': add this node as sibling after targetNode.
+		 */
+		var pos;
+		if(this === targetNode){
+			return;
+		}
+		if( !this.parent  ){
+			throw "Cannot move system root";
+		}
+		if(mode === undefined || mode == "over"){
+			mode = "child";
+		}
+		var prevParent = this.parent;
+		var targetParent = (mode === "child") ? targetNode : targetNode.parent;
+		if( targetParent.isDescendantOf(this) ){
+			throw "Cannot move a node to it's own descendant";
+		}
+		// Unlink this node from current parent
+		if( this.parent.childList.length == 1 ) {
+			this.parent.childList = this.parent.data.isLazy ? [] : null;
+			this.parent.bExpanded = false;
+		} else {
+			pos = $.inArray(this, this.parent.childList);
+			if( pos < 0 ){
+				throw "Internal error";
+			}
+			this.parent.childList.splice(pos, 1);
+		}
+		// Remove from source DOM parent
+		if(this.parent.ul){
+			this.parent.ul.removeChild(this.li);
+		}
+
+		// Insert this node to target parent's child list
+		this.parent = targetParent;
+		if( targetParent.hasChildren() ) {
+			switch(mode) {
+			case "child":
+				// Append to existing target children
+				targetParent.childList.push(this);
+				break;
+			case "before":
+				// Insert this node before target node
+				pos = $.inArray(targetNode, targetParent.childList);
+				if( pos < 0 ){
+					throw "Internal error";
+				}
+				targetParent.childList.splice(pos, 0, this);
+				break;
+			case "after":
+				// Insert this node after target node
+				pos = $.inArray(targetNode, targetParent.childList);
+				if( pos < 0 ){
+					throw "Internal error";
+				}
+				targetParent.childList.splice(pos+1, 0, this);
+				break;
+			default:
+				throw "Invalid mode " + mode;
+			}
+		} else {
+			targetParent.childList = [ this ];
+		}
+		// Parent has no <ul> tag yet:
+		if( !targetParent.ul ) {
+			// This is the parent's first child: create UL tag
+			// (Hidden, because it will be
+			targetParent.ul = document.createElement("ul");
+			targetParent.ul.style.display = "none";
+			targetParent.li.appendChild(targetParent.ul);
+		}
+		// Issue 319: Add to target DOM parent (only if node was already rendered(expanded))
+		if(this.li){
+			targetParent.ul.appendChild(this.li);
+		}
+
+		if( this.tree !== targetNode.tree ) {
+			// Fix node.tree for all source nodes
+			this.visit(function(node){
+				node.tree = targetNode.tree;
+			}, null, true);
+			throw "Not yet implemented.";
+		}
+		// TODO: fix selection state
+		// TODO: fix active state
+		if( !prevParent.isDescendantOf(targetParent)) {
+			prevParent.render();
+		}
+		if( !targetParent.isDescendantOf(prevParent) ) {
+			targetParent.render();
+		}
+//		this.tree.redraw();
+/*
+		var tree = this.tree;
+		var opts = tree.options;
+		var pers = tree.persistence;
+
+
+		// Always expand, if it's below minExpandLevel
+//		tree.logDebug ("%s._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
+		if ( opts.minExpandLevel >= dtnode.getLevel() ) {
+//			tree.logDebug ("Force expand for %o", dtnode);
+			this.bExpanded = true;
+		}
+
+		// In multi-hier mode, update the parents selection state
+		// issue #82: only if not initializing, because the children may not exist yet
+//		if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
+//			dtnode._fixSelectionState();
+
+		// In multi-hier mode, update the parents selection state
+		if( dtnode.bSelected && opts.selectMode==3 ) {
+			var p = this;
+			while( p ) {
+				if( !p.hasSubSel )
+					p._setSubSel(true);
+				p = p.parent;
+			}
+		}
+		// render this node and the new child
+		if ( tree.bEnableUpdate )
+			this.render();
+
+		return dtnode;
+
+*/
+	},
+
+	// --- end of class
+	lastentry: undefined
+};
+
+/*************************************************************************
+ * class DynaTreeStatus
+ */
+
+var DynaTreeStatus = Class.create();
+
+
+DynaTreeStatus._getTreePersistData = function(cookieId, cookieOpts) {
+	// Static member: Return persistence information from cookies
+	var ts = new DynaTreeStatus(cookieId, cookieOpts);
+	ts.read();
+	return ts.toDict();
+};
+// Make available in global scope
+getDynaTreePersistData = DynaTreeStatus._getTreePersistData; // TODO: deprecated
+
+
+DynaTreeStatus.prototype = {
+	// Constructor
+	initialize: function(cookieId, cookieOpts) {
+//		this._log("DynaTreeStatus: initialize");
+		if( cookieId === undefined ){
+			cookieId = $.ui.dynatree.prototype.options.cookieId;
+		}
+		cookieOpts = $.extend({}, $.ui.dynatree.prototype.options.cookie, cookieOpts);
+
+		this.cookieId = cookieId;
+		this.cookieOpts = cookieOpts;
+		this.cookiesFound = undefined;
+		this.activeKey = null;
+		this.focusedKey = null;
+		this.expandedKeyList = null;
+		this.selectedKeyList = null;
+	},
+	// member functions
+	_log: function(msg) {
+		//	this.logDebug("_changeNodeList(%o): nodeList:%o, idx:%o", mode, nodeList, idx);
+		Array.prototype.unshift.apply(arguments, ["debug"]);
+		_log.apply(this, arguments);
+	},
+	read: function() {
+//		this._log("DynaTreeStatus: read");
+		// Read or init cookies.
+		this.cookiesFound = false;
+
+		var cookie = $.cookie(this.cookieId + "-active");
+		this.activeKey = ( cookie === null ) ? "" : cookie;
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-focus");
+		this.focusedKey = ( cookie === null ) ? "" : cookie;
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-expand");
+		this.expandedKeyList = ( cookie === null ) ? [] : cookie.split(",");
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+		cookie = $.cookie(this.cookieId + "-select");
+		this.selectedKeyList = ( cookie === null ) ? [] : cookie.split(",");
+		if( cookie !== null ){
+			this.cookiesFound = true;
+		}
+	},
+	write: function() {
+//		this._log("DynaTreeStatus: write");
+		$.cookie(this.cookieId + "-active", ( this.activeKey === null ) ? "" : this.activeKey, this.cookieOpts);
+		$.cookie(this.cookieId + "-focus", ( this.focusedKey === null ) ? "" : this.focusedKey, this.cookieOpts);
+		$.cookie(this.cookieId + "-expand", ( this.expandedKeyList === null ) ? "" : this.expandedKeyList.join(","), this.cookieOpts);
+		$.cookie(this.cookieId + "-select", ( this.selectedKeyList === null ) ? "" : this.selectedKeyList.join(","), this.cookieOpts);
+	},
+	addExpand: function(key) {
+//		this._log("addExpand(%o)", key);
+		if( $.inArray(key, this.expandedKeyList) < 0 ) {
+			this.expandedKeyList.push(key);
+			$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	clearExpand: function(key) {
+//		this._log("clearExpand(%o)", key);
+		var idx = $.inArray(key, this.expandedKeyList);
+		if( idx >= 0 ) {
+			this.expandedKeyList.splice(idx, 1);
+			$.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	addSelect: function(key) {
+//		this._log("addSelect(%o)", key);
+		if( $.inArray(key, this.selectedKeyList) < 0 ) {
+			this.selectedKeyList.push(key);
+			$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	clearSelect: function(key) {
+//		this._log("clearSelect(%o)", key);
+		var idx = $.inArray(key, this.selectedKeyList);
+		if( idx >= 0 ) {
+			this.selectedKeyList.splice(idx, 1);
+			$.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
+		}
+	},
+	isReloading: function() {
+		return this.cookiesFound === true;
+	},
+	toDict: function() {
+		return {
+			cookiesFound: this.cookiesFound,
+			activeKey: this.activeKey,
+			focusedKey: this.activeKey,
+			expandedKeyList: this.expandedKeyList,
+			selectedKeyList: this.selectedKeyList
+		};
+	},
+	// --- end of class
+	lastentry: undefined
+};
+
+
+/*************************************************************************
+ * class DynaTree
+ */
+
+var DynaTree = Class.create();
+
+// --- Static members ----------------------------------------------------------
+
+DynaTree.version = "$Version: 1.2.2$";
+
+/*
+DynaTree._initTree = function() {
+};
+
+DynaTree._bind = function() {
+};
+*/
+//--- Class members ------------------------------------------------------------
+
+DynaTree.prototype = {
+	// Constructor
+//	initialize: function(divContainer, options) {
+	initialize: function($widget) {
+		// instance members
+		this.phase = "init";
+		this.$widget = $widget;
+		this.options = $widget.options;
+		this.$tree = $widget.element;
+		this.timer = null;
+		// find container element
+		this.divTree = this.$tree.get(0);
+
+//		var parentPos = $(this.divTree).parent().offset();
+//		this.parentTop = parentPos.top;
+//		this.parentLeft = parentPos.left;
+
+		_initDragAndDrop(this);
+	},
+
+	// member functions
+
+	_load: function(callback) {
+		var $widget = this.$widget;
+		var opts = this.options,
+			self = this;
+		this.bEnableUpdate = true;
+		this._nodeCount = 1;
+		this.activeNode = null;
+		this.focusNode = null;
+
+		// Some deprecation warnings to help with migration
+		if( opts.rootVisible !== undefined ){
+			this.logWarning("Option 'rootVisible' is no longer supported.");
+		}
+		if( opts.minExpandLevel < 1 ) {
+			this.logWarning("Option 'minExpandLevel' must be >= 1.");
+			opts.minExpandLevel = 1;
+		}
+//		_log("warn", "jQuery.support.boxModel " + jQuery.support.boxModel);
+
+		// If a 'options.classNames' dictionary was passed, still use defaults
+		// for undefined classes:
+		if( opts.classNames !== $.ui.dynatree.prototype.options.classNames ) {
+			opts.classNames = $.extend({}, $.ui.dynatree.prototype.options.classNames, opts.classNames);
+		}
+		if( opts.ajaxDefaults !== $.ui.dynatree.prototype.options.ajaxDefaults ) {
+			opts.ajaxDefaults = $.extend({}, $.ui.dynatree.prototype.options.ajaxDefaults, opts.ajaxDefaults);
+		}
+		if( opts.dnd !== $.ui.dynatree.prototype.options.dnd ) {
+			opts.dnd = $.extend({}, $.ui.dynatree.prototype.options.dnd, opts.dnd);
+		}
+		// Guess skin path, if not specified
+		if(!opts.imagePath) {
+			$("script").each( function () {
+				var _rexDtLibName = /.*dynatree[^\/]*\.js$/i;
+				if( this.src.search(_rexDtLibName) >= 0 ) {
+					if( this.src.indexOf("/")>=0 ){ // issue #47
+						opts.imagePath = this.src.slice(0, this.src.lastIndexOf("/")) + "/skin/";
+					}else{
+						opts.imagePath = "skin/";
+					}
+					self.logDebug("Guessing imagePath from '%s': '%s'", this.src, opts.imagePath);
+					return false; // first match
+				}
+			});
+		}
+
+		this.persistence = new DynaTreeStatus(opts.cookieId, opts.cookie);
+		if( opts.persist ) {
+			if( !$.cookie ){
+				_log("warn", "Please include jquery.cookie.js to use persistence.");
+			}
+			this.persistence.read();
+		}
+		this.logDebug("DynaTree.persistence: %o", this.persistence.toDict());
+
+		// Cached tag strings
+		this.cache = {
+			tagEmpty: "<span class='" + opts.classNames.empty + "'></span>",
+			tagVline: "<span class='" + opts.classNames.vline + "'></span>",
+			tagExpander: "<span class='" + opts.classNames.expander + "'></span>",
+			tagConnector: "<span class='" + opts.classNames.connector + "'></span>",
+			tagNodeIcon: "<span class='" + opts.classNames.nodeIcon + "'></span>",
+			tagCheckbox: "<span class='" + opts.classNames.checkbox + "'></span>",
+			lastentry: undefined
+		};
+
+		// Clear container, in case it contained some 'waiting' or 'error' text
+		// for clients that don't support JS.
+		// We don't do this however, if we try to load from an embedded UL element.
+		if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId ){
+			$(this.divTree).empty();
+		}
+		var $ulInitialize = this.$tree.find(">ul:first").hide();
+
+		// Create the root element
+		this.tnRoot = new DynaTreeNode(null, this, {});
+		this.tnRoot.bExpanded = true;
+		this.tnRoot.render();
+		this.divTree.appendChild(this.tnRoot.ul);
+
+		var root = this.tnRoot,
+			isReloading = ( opts.persist && this.persistence.isReloading() ),
+			isLazy = false,
+			prevFlag = this.enableUpdate(false);
+
+		this.logDebug("Dynatree._load(): read tree structure...");
+
+		// Init tree structure
+		if( opts.children ) {
+			// Read structure from node array
+			root.addChild(opts.children);
+
+		} else if( opts.initAjax && opts.initAjax.url ) {
+			// Init tree from AJAX request
+			isLazy = true;
+			root.data.isLazy = true;
+			this._reloadAjax(callback);
+
+		} else if( opts.initId ) {
+			// Init tree from another UL element
+			this._createFromTag(root, $("#"+opts.initId));
+
+		} else {
+			// Init tree from the first UL element inside the container <div>
+//			var $ul = this.$tree.find(">ul:first").hide();
+			this._createFromTag(root, $ulInitialize);
+			$ulInitialize.remove();
+		}
+
+		this._checkConsistency();
+		// Fix part-sel flags
+		if(!isLazy && opts.selectMode == 3){
+			root._updatePartSelectionState();
+		}
+		// Render html markup
+		this.logDebug("Dynatree._load(): render nodes...");
+		this.enableUpdate(prevFlag);
+
+		// bind event handlers
+		this.logDebug("Dynatree._load(): bind events...");
+		this.$widget.bind();
+
+		// --- Post-load processing
+		this.logDebug("Dynatree._load(): postInit...");
+		this.phase = "postInit";
+
+		// In persist mode, make sure that cookies are written, even if they are empty
+		if( opts.persist ) {
+			this.persistence.write();
+		}
+		// Set focus, if possible (this will also fire an event and write a cookie)
+		if( this.focusNode && this.focusNode.isVisible() ) {
+			this.logDebug("Focus on init: %o", this.focusNode);
+			this.focusNode.focus();
+		}
+		if( !isLazy ) {
+			if( opts.onPostInit ) {
+				opts.onPostInit.call(this, isReloading, false);
+			}
+			if( callback ){
+				callback.call(this, "ok");
+			}
+		}
+		this.phase = "idle";
+	},
+
+	_reloadAjax: function(callback) {
+		// Reload
+		var opts = this.options;
+		if( ! opts.initAjax || ! opts.initAjax.url ){
+			throw "tree.reload() requires 'initAjax' mode.";
+		}
+		var pers = this.persistence;
+		var ajaxOpts = $.extend({}, opts.initAjax);
+		// Append cookie info to the request
+//		this.logDebug("reloadAjax: key=%o, an.key:%o", pers.activeKey, this.activeNode?this.activeNode.data.key:"?");
+		if( ajaxOpts.addActiveKey ){
+			ajaxOpts.data.activeKey = pers.activeKey;
+		}
+		if( ajaxOpts.addFocusedKey ){
+			ajaxOpts.data.focusedKey = pers.focusedKey;
+		}
+		if( ajaxOpts.addExpandedKeyList ){
+			ajaxOpts.data.expandedKeyList = pers.expandedKeyList.join(",");
+		}
+		if( ajaxOpts.addSelectedKeyList ){
+			ajaxOpts.data.selectedKeyList = pers.selectedKeyList.join(",");
+		}
+		// Set up onPostInit callback to be called when Ajax returns
+		if( ajaxOpts.success ){
+			this.logWarning("initAjax: success callback is ignored; use onPostInit instead.");
+		}
+		if( ajaxOpts.error ){
+			this.logWarning("initAjax: error callback is ignored; use onPostInit instead.");
+		}
+		var isReloading = pers.isReloading();
+		ajaxOpts.success = function(dtnode, data, textStatus) {
+			if(opts.selectMode == 3){
+				dtnode.tree.tnRoot._updatePartSelectionState();
+			}
+			if(opts.onPostInit){
+				opts.onPostInit.call(dtnode.tree, isReloading, false);
+			}
+			if(callback){
+				callback.call(dtnode.tree, "ok");
+			}
+		};
+		ajaxOpts.error = function(dtnode, XMLHttpRequest, textStatus, errorThrown) {
+			if(opts.onPostInit){
+				opts.onPostInit.call(dtnode.tree, isReloading, true, XMLHttpRequest, textStatus, errorThrown);
+			}
+			if(callback){
+				callback.call(dtnode.tree, "error", XMLHttpRequest, textStatus, errorThrown);
+			}
+		};
+//		}
+		this.logDebug("Dynatree._init(): send Ajax request...");
+		this.tnRoot.appendAjax(ajaxOpts);
+	},
+
+	toString: function() {
+//		return "DynaTree '" + this.options.title + "'";
+		return "Dynatree '" + this.$tree.attr("id") + "'";
+	},
+
+	toDict: function() {
+		return this.tnRoot.toDict(true);
+	},
+
+	serializeArray: function(stopOnParents) {
+		// Return a JavaScript array of objects, ready to be encoded as a JSON
+		// string for selected nodes
+		var nodeList = this.getSelectedNodes(stopOnParents),
+			name = this.$tree.attr("name") || this.$tree.attr("id"),
+			arr = [];
+		for(var i=0, l=nodeList.length; i<l; i++){
+			arr.push({name: name, value: nodeList[i].data.key});
+		}
+		return arr;
+	},
+
+	getPersistData: function() {
+		return this.persistence.toDict();
+	},
+
+	logDebug: function(msg) {
+		if( this.options.debugLevel >= 2 ) {
+			Array.prototype.unshift.apply(arguments, ["debug"]);
+			_log.apply(this, arguments);
+		}
+	},
+
+	logInfo: function(msg) {
+		if( this.options.debugLevel >= 1 ) {
+			Array.prototype.unshift.apply(arguments, ["info"]);
+			_log.apply(this, arguments);
+		}
+	},
+
+	logWarning: function(msg) {
+		Array.prototype.unshift.apply(arguments, ["warn"]);
+		_log.apply(this, arguments);
+	},
+
+	isInitializing: function() {
+		return ( this.phase=="init" || this.phase=="postInit" );
+	},
+	isReloading: function() {
+		return ( this.phase=="init" || this.phase=="postInit" ) && this.options.persist && this.persistence.cookiesFound;
+	},
+	isUserEvent: function() {
+		return ( this.phase=="userEvent" );
+	},
+
+	redraw: function() {
+//		this.logDebug("dynatree.redraw()...");
+		this.tnRoot.render(false, false);
+//		this.logDebug("dynatree.redraw() done.");
+	},
+	renderInvisibleNodes: function() {
+		this.tnRoot.render(false, true);
+	},
+	reload: function(callback) {
+		this._load(callback);
+	},
+
+	getRoot: function() {
+		return this.tnRoot;
+	},
+
+	enable: function() {
+		this.$widget.enable();
+	},
+
+	disable: function() {
+		this.$widget.disable();
+	},
+
+	getNodeByKey: function(key) {
+		// Search the DOM by element ID (assuming this is faster than traversing all nodes).
+		// $("#...") has problems, if the key contains '.', so we use getElementById()
+		var el = document.getElementById(this.options.idPrefix + key);
+		if( el ){
+			return el.dtnode ? el.dtnode : null;
+		}
+		// Not found in the DOM, but still may be in an unrendered part of tree
+		var match = null;
+		this.visit(function(node){
+//			window.console.log("%s", node);
+			if(node.data.key == key) {
+				match = node;
+				return false;
+			}
+		}, true);
+		return match;
+	},
+
+	getActiveNode: function() {
+		return this.activeNode;
+	},
+
+	reactivate: function(setFocus) {
+		// Re-fire onQueryActivate and onActivate events.
+		var node = this.activeNode;
+//		this.logDebug("reactivate %o", node);
+		if( node ) {
+			this.activeNode = null; // Force re-activating
+			node.activate();
+			if( setFocus ){
+				node.focus();
+			}
+		}
+	},
+
+	getSelectedNodes: function(stopOnParents) {
+		var nodeList = [];
+		this.tnRoot.visit(function(node){
+			if( node.bSelected ) {
+				nodeList.push(node);
+				if( stopOnParents === true ){
+					return "skip"; // stop processing this branch
+				}
+			}
+		});
+		return nodeList;
+	},
+
+	activateKey: function(key) {
+		var dtnode = (key === null) ? null : this.getNodeByKey(key);
+		if( !dtnode ) {
+			if( this.activeNode ){
+				this.activeNode.deactivate();
+			}
+			this.activeNode = null;
+			return null;
+		}
+		dtnode.focus();
+		dtnode.activate();
+		return dtnode;
+	},
+
+	loadKeyPath: function(keyPath, callback) {
+		var segList = keyPath.split(this.options.keyPathSeparator);
+		// Remove leading '/'
+		if(segList[0] === ""){
+			segList.shift();
+		}
+		// Remove leading system root key
+		if(segList[0] == this.tnRoot.data.key){
+			this.logDebug("Removed leading root key.");
+			segList.shift();
+		}
+		keyPath = segList.join(this.options.keyPathSeparator);
+		return this.tnRoot._loadKeyPath(keyPath, callback);
+	},
+
+	selectKey: function(key, select) {
+		var dtnode = this.getNodeByKey(key);
+		if( !dtnode ){
+			return null;
+		}
+		dtnode.select(select);
+		return dtnode;
+	},
+
+	enableUpdate: function(bEnable) {
+		if ( this.bEnableUpdate==bEnable ){
+			return bEnable;
+		}
+		this.bEnableUpdate = bEnable;
+		if ( bEnable ){
+			this.redraw();
+		}
+		return !bEnable; // return previous value
+	},
+
+	count: function() {
+		return this.tnRoot.countChildren();
+	},
+
+	visit: function(fn, includeRoot) {
+		return this.tnRoot.visit(fn, includeRoot);
+	},
+
+	_createFromTag: function(parentTreeNode, $ulParent) {
+		// Convert a <UL>...</UL> list into children of the parent tree node.
+		var self = this;
+/*
+TODO: better?
+		this.$lis = $("li:has(a[href])", this.element);
+		this.$tabs = this.$lis.map(function() { return $("a", this)[0]; });
+ */
+		$ulParent.find(">li").each(function() {
+			var $li = $(this),
+				$liSpan = $li.find(">span:first"),
+				$liA = $li.find(">a:first"),
+				title,
+				href = null,
+				target = null,
+				tooltip;
+			if( $liSpan.length ) {
+				// If a <li><span> tag is specified, use it literally.
+				title = $liSpan.html();
+			} else if( $liA.length ) {
+				title = $liA.html();
+				href = $liA.attr("href");
+				target = $liA.attr("target");
+				tooltip = $liA.attr("title");
+			} else {
+				// If only a <li> tag is specified, use the trimmed string up to
+				// the next child <ul> tag.
+				title = $li.html();
+				var iPos = title.search(/<ul/i);
+				if( iPos >= 0 ){
+					title = $.trim(title.substring(0, iPos));
+				}else{
+					title = $.trim(title);
+				}
+//				self.logDebug("%o", title);
+			}
+			// Parse node options from ID, title and class attributes
+			var data = {
+				title: title,
+				tooltip: tooltip,
+				isFolder: $li.hasClass("folder"),
+				isLazy: $li.hasClass("lazy"),
+				expand: $li.hasClass("expanded"),
+				select: $li.hasClass("selected"),
+				activate: $li.hasClass("active"),
+				focus: $li.hasClass("focused"),
+				noLink: $li.hasClass("noLink")
+			};
+			if( href ){
+				data.href = href;
+				data.target = target;
+			}
+			if( $li.attr("title") ){
+				data.tooltip = $li.attr("title"); // overrides <a title='...'>
+			}
+			if( $li.attr("id") ){
+				data.key = $li.attr("id");
+			}
+			// If a data attribute is present, evaluate as a JavaScript object
+			if( $li.attr("data") ) {
+				var dataAttr = $.trim($li.attr("data"));
+				if( dataAttr ) {
+					if( dataAttr.charAt(0) != "{" ){
+						dataAttr = "{" + dataAttr + "}";
+					}
+					try {
+						$.extend(data, eval("(" + dataAttr + ")"));
+					} catch(e) {
+						throw ("Error parsing node data: " + e + "\ndata:\n'" + dataAttr + "'");
+					}
+				}
+			}
+			var childNode = parentTreeNode.addChild(data);
+			// Recursive reading of child nodes, if LI tag contains an UL tag
+			var $ul = $li.find(">ul:first");
+			if( $ul.length ) {
+				self._createFromTag(childNode, $ul); // must use 'self', because 'this' is the each() context
+			}
+		});
+	},
+
+	_checkConsistency: function() {
+//		this.logDebug("tree._checkConsistency() NOT IMPLEMENTED - %o", this);
+	},
+
+	_setDndStatus: function(sourceNode, targetNode, helper, hitMode, accept) {
+		// hitMode: 'after', 'before', 'over', 'out', 'start', 'stop'
+		var $source = sourceNode ? $(sourceNode.span) : null,
+			$target = $(targetNode.span);
+		if( !this.$dndMarker ) {
+			this.$dndMarker = $("<div id='dynatree-drop-marker'></div>")
+				.hide()
+				.css({"z-index": 1000})
+				.prependTo($(this.divTree).parent());
+
+//			logMsg("Creating marker: %o", this.$dndMarker);
+		}
+/*
+		if(hitMode === "start"){
+		}
+		if(hitMode === "stop"){
+//			sourceNode.removeClass("dynatree-drop-target");
+		}
+*/
+		if(hitMode === "after" || hitMode === "before" || hitMode === "over"){
+//			$source && $source.addClass("dynatree-drag-source");
+//			$target.addClass("dynatree-drop-target");
+
+			var markerOffset = "0 0";
+
+			switch(hitMode){
+			case "before":
+				this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-over");
+				this.$dndMarker.addClass("dynatree-drop-before");
+				markerOffset = "0 -8";
+				break;
+			case "after":
+				this.$dndMarker.removeClass("dynatree-drop-before dynatree-drop-over");
+				this.$dndMarker.addClass("dynatree-drop-after");
+				markerOffset = "0 8";
+				break;
+			default:
+				this.$dndMarker.removeClass("dynatree-drop-after dynatree-drop-before");
+				this.$dndMarker.addClass("dynatree-drop-over");
+				$target.addClass("dynatree-drop-target");
+				markerOffset = "8 0";
+			}
+//			logMsg("Creating marker: %o", this.$dndMarker);
+//			logMsg("    $target.offset=%o", $target);
+//			logMsg("    pos/$target.offset=%o", pos);
+//			logMsg("    $target.position=%o", $target.position());
+//			logMsg("    $target.offsetParent=%o, ot:%o", $target.offsetParent(), $target.offsetParent().offset());
+//			logMsg("    $(this.divTree).offset=%o", $(this.divTree).offset());
+//			logMsg("    $(this.divTree).parent=%o", $(this.divTree).parent());
+//			var pos = $target.offset();
+//			var parentPos = $target.offsetParent().offset();
+//			var bodyPos = $target.offsetParent().offset();
+
+			this.$dndMarker
+				.show()
+				.position({
+					my: "left top",
+					at: "left top",
+					of: $target,
+					offset: markerOffset
+				});
+
+//			helper.addClass("dynatree-drop-hover");
+		} else {
+//			$source && $source.removeClass("dynatree-drag-source");
+			$target.removeClass("dynatree-drop-target");
+			this.$dndMarker.hide();
+//			helper.removeClass("dynatree-drop-hover");
+		}
+		if(hitMode === "after"){
+			$target.addClass("dynatree-drop-after");
+		} else {
+			$target.removeClass("dynatree-drop-after");
+		}
+		if(hitMode === "before"){
+			$target.addClass("dynatree-drop-before");
+		} else {
+			$target.removeClass("dynatree-drop-before");
+		}
+		if(accept === true){
+			if($source){
+				$source.addClass("dynatree-drop-accept");
+			}
+			$target.addClass("dynatree-drop-accept");
+			helper.addClass("dynatree-drop-accept");
+		}else{
+			if($source){
+				$source.removeClass("dynatree-drop-accept");
+			}
+			$target.removeClass("dynatree-drop-accept");
+			helper.removeClass("dynatree-drop-accept");
+		}
+		if(accept === false){
+			if($source){
+				$source.addClass("dynatree-drop-reject");
+			}
+			$target.addClass("dynatree-drop-reject");
+			helper.addClass("dynatree-drop-reject");
+		}else{
+			if($source){
+				$source.removeClass("dynatree-drop-reject");
+			}
+			$target.removeClass("dynatree-drop-reject");
+			helper.removeClass("dynatree-drop-reject");
+		}
+	},
+
+	_onDragEvent: function(eventName, node, otherNode, event, ui, draggable) {
+		/**
+		 * Handles drag'n'drop functionality.
+		 *
+		 * A standard jQuery drag-and-drop process may generate these calls:
+		 *
+		 * draggable helper():
+		 *     _onDragEvent("helper", sourceNode, null, event, null, null);
+		 * start:
+		 *     _onDragEvent("start", sourceNode, null, event, ui, draggable);
+		 * drag:
+		 *     _onDragEvent("leave", prevTargetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("over", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("enter", targetNode, sourceNode, event, ui, draggable);
+		 * stop:
+		 *     _onDragEvent("drop", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("leave", targetNode, sourceNode, event, ui, draggable);
+		 *     _onDragEvent("stop", sourceNode, null, event, ui, draggable);
+		 */
+//		if(eventName !== "over"){
+//			this.logDebug("tree._onDragEvent(%s, %o, %o) - %o", eventName, node, otherNode, this);
+//		}
+		var opts = this.options,
+			dnd = this.options.dnd,
+			res = null,
+			nodeTag = $(node.span),
+			hitMode,
+			enterResponse;
+
+		switch (eventName) {
+		case "helper":
+			// Only event and node argument is available
+			var $helper = $("<div class='dynatree-drag-helper'><span class='dynatree-drag-helper-img' /></div>")
+				.append($(event.target).closest('a').clone());
+			// issue 244: helper should be child of scrollParent
+			$("ul.dynatree-container", node.tree.divTree).append($helper);
+//			$(node.tree.divTree).append($helper);
+			// Attach node reference to helper object
+			$helper.data("dtSourceNode", node);
+//			this.logDebug("helper=%o", $helper);
+//			this.logDebug("helper.sourceNode=%o", $helper.data("dtSourceNode"));
+			res = $helper;
+			break;
+		case "start":
+			if(node.isStatusNode()) {
+				res = false;
+			} else if(dnd.onDragStart) {
+				res = dnd.onDragStart(node);
+			}
+			if(res === false) {
+				this.logDebug("tree.onDragStart() cancelled");
+				//draggable._clear();
+				// NOTE: the return value seems to be ignored (drag is not canceled, when false is returned)
+				ui.helper.trigger("mouseup");
+				ui.helper.hide();
+			} else {
+				nodeTag.addClass("dynatree-drag-source");
+			}
+			break;
+		case "enter":
+			res = dnd.onDragEnter ? dnd.onDragEnter(node, otherNode) : null;
+			if(!res){
+				// convert null, undefined, false to false
+				res = false;
+			}else{
+				res = {
+					over: ((res === true) || (res === "over") || $.inArray("over", res) >= 0),
+					before: ((res === true) || (res === "before") || $.inArray("before", res) >= 0),
+					after: ((res === true) || (res === "after") || $.inArray("after", res) >= 0)
+				};
+			}
+			ui.helper.data("enterResponse", res);
+//			this.logDebug("helper.enterResponse: %o", res);
+			break;
+		case "over":
+			enterResponse = ui.helper.data("enterResponse");
+			hitMode = null;
+			if(enterResponse === false){
+				// Don't call onDragOver if onEnter returned false.
+				// issue 332
+//				break;
+			} else if(typeof enterResponse === "string") {
+				// Use hitMode from onEnter if provided.
+				hitMode = enterResponse;
+			} else {
+				// Calculate hitMode from relative cursor position.
+				var nodeOfs = nodeTag.offset();
+//				var relPos = { x: event.clientX - nodeOfs.left,
+//							y: event.clientY - nodeOfs.top };
+//				nodeOfs.top += this.parentTop;
+//				nodeOfs.left += this.parentLeft;
+				var relPos = { x: event.pageX - nodeOfs.left,
+							   y: event.pageY - nodeOfs.top };
+				var relPos2 = { x: relPos.x / nodeTag.width(),
+								y: relPos.y / nodeTag.height() };
+//				this.logDebug("event.page: %s/%s", event.pageX, event.pageY);
+//				this.logDebug("event.client: %s/%s", event.clientX, event.clientY);
+//				this.logDebug("nodeOfs: %s/%s", nodeOfs.left, nodeOfs.top);
+////				this.logDebug("parent: %s/%s", this.parentLeft, this.parentTop);
+//				this.logDebug("relPos: %s/%s", relPos.x, relPos.y);
+//				this.logDebug("relPos2: %s/%s", relPos2.x, relPos2.y);
+				if( enterResponse.after && relPos2.y > 0.75 ){
+					hitMode = "after";
+				} else if(!enterResponse.over && enterResponse.after && relPos2.y > 0.5 ){
+					hitMode = "after";
+				} else if(enterResponse.before && relPos2.y <= 0.25) {
+					hitMode = "before";
+				} else if(!enterResponse.over && enterResponse.before && relPos2.y <= 0.5) {
+					hitMode = "before";
+				} else if(enterResponse.over) {
+					hitMode = "over";
+				}
+				// Prevent no-ops like 'before source node'
+				// TODO: these are no-ops when moving nodes, but not in copy mode
+				if( dnd.preventVoidMoves ){
+					if(node === otherNode){
+//						this.logDebug("    drop over source node prevented");
+						hitMode = null;
+					}else if(hitMode === "before" && otherNode && node === otherNode.getNextSibling()){
+//						this.logDebug("    drop after source node prevented");
+						hitMode = null;
+					}else if(hitMode === "after" && otherNode && node === otherNode.getPrevSibling()){
+//						this.logDebug("    drop before source node prevented");
+						hitMode = null;
+					}else if(hitMode === "over" && otherNode
+							&& otherNode.parent === node && otherNode.isLastSibling() ){
+//						this.logDebug("    drop last child over own parent prevented");
+						hitMode = null;
+					}
+				}
+//				this.logDebug("hitMode: %s - %s - %s", hitMode, (node.parent === otherNode), node.isLastSibling());
+				ui.helper.data("hitMode", hitMode);
+			}
+			// Auto-expand node (only when 'over' the node, not 'before', or 'after')
+			if(hitMode === "over"
+				&& dnd.autoExpandMS && node.hasChildren() !== false && !node.bExpanded) {
+				node.scheduleAction("expand", dnd.autoExpandMS);
+			}
+			if(hitMode && dnd.onDragOver){
+				res = dnd.onDragOver(node, otherNode, hitMode);
+				if(res === "over" || res === "before" || res === "after") {
+					hitMode = res;
+				}
+			}
+			// issue 332
+//			this._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false);
+			this._setDndStatus(otherNode, node, ui.helper, hitMode, res!==false && hitMode !== null);
+			break;
+		case "drop":
+			// issue 286: don't trigger onDrop, if DnD status is 'reject'
+			var isForbidden = ui.helper.hasClass("dynatree-drop-reject");
+			hitMode = ui.helper.data("hitMode");
+			if(hitMode && dnd.onDrop && !isForbidden){
+				dnd.onDrop(node, otherNode, hitMode, ui, draggable);
+			}
+			break;
+		case "leave":
+			// Cancel pending expand request
+			node.scheduleAction("cancel");
+			ui.helper.data("enterResponse", null);
+			ui.helper.data("hitMode", null);
+			this._setDndStatus(otherNode, node, ui.helper, "out", undefined);
+			if(dnd.onDragLeave){
+				dnd.onDragLeave(node, otherNode);
+			}
+			break;
+		case "stop":
+			nodeTag.removeClass("dynatree-drag-source");
+			if(dnd.onDragStop){
+				dnd.onDragStop(node);
+			}
+			break;
+		default:
+			throw "Unsupported drag event: " + eventName;
+		}
+		return res;
+	},
+
+	cancelDrag: function() {
+		 var dd = $.ui.ddmanager.current;
+		 if(dd){
+			 dd.cancel();
+		 }
+	},
+
+	// --- end of class
+	lastentry: undefined
+};
+
+/*************************************************************************
+ * Widget $(..).dynatree
+ */
+
+$.widget("ui.dynatree", {
+/*
+	init: function() {
+		// ui.core 1.6 renamed init() to _init(): this stub assures backward compatibility
+		_log("warn", "ui.dynatree.init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher.");
+		return this._init();
+	},
+ */
+	_init: function() {
+		if( parseFloat($.ui.version) < 1.8 ) {
+			// jquery.ui.core 1.8 renamed _init() to _create(): this stub assures backward compatibility
+			if(this.options.debugLevel >= 0){
+				_log("warn", "ui.dynatree._init() was called; you should upgrade to jquery.ui.core.js v1.8 or higher.");
+			}
+			return this._create();
+		}
+		// jquery.ui.core 1.8 still uses _init() to perform "default functionality"
+		if(this.options.debugLevel >= 2){
+			_log("debug", "ui.dynatree._init() was called; no current default functionality.");
+		}
+	},
+
+	_create: function() {
+		var opts = this.options;
+		if(opts.debugLevel >= 1){
+			logMsg("Dynatree._create(): version='%s', debugLevel=%o.", $.ui.dynatree.version, this.options.debugLevel);
+		}
+		// The widget framework supplies this.element and this.options.
+		this.options.event += ".dynatree"; // namespace event
+
+		var divTree = this.element.get(0);
+/*		// Clear container, in case it contained some 'waiting' or 'error' text
+		// for clients that don't support JS
+		if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
+			$(divTree).empty();
+*/
+		// Create the DynaTree object
+		this.tree = new DynaTree(this);
+		this.tree._load();
+		this.tree.logDebug("Dynatree._init(): done.");
+	},
+
+	bind: function() {
+		// Prevent duplicate binding
+		this.unbind();
+
+		var eventNames = "click.dynatree dblclick.dynatree";
+		if( this.options.keyboard ){
+			// Note: leading ' '!
+			eventNames += " keypress.dynatree keydown.dynatree";
+		}
+		this.element.bind(eventNames, function(event){
+			var dtnode = $.ui.dynatree.getNode(event.target);
+			if( !dtnode ){
+				return true;  // Allow bubbling of other events
+			}
+			var tree = dtnode.tree;
+			var o = tree.options;
+			tree.logDebug("event(%s): dtnode: %s", event.type, dtnode);
+			var prevPhase = tree.phase;
+			tree.phase = "userEvent";
+			try {
+				switch(event.type) {
+				case "click":
+					return ( o.onClick && o.onClick.call(tree, dtnode, event)===false ) ? false : dtnode._onClick(event);
+				case "dblclick":
+					return ( o.onDblClick && o.onDblClick.call(tree, dtnode, event)===false ) ? false : dtnode._onDblClick(event);
+				case "keydown":
+					return ( o.onKeydown && o.onKeydown.call(tree, dtnode, event)===false ) ? false : dtnode._onKeydown(event);
+				case "keypress":
+					return ( o.onKeypress && o.onKeypress.call(tree, dtnode, event)===false ) ? false : dtnode._onKeypress(event);
+				}
+			} catch(e) {
+				var _ = null; // issue 117
+				tree.logWarning("bind(%o): dtnode: %o, error: %o", event, dtnode, e);
+			} finally {
+				tree.phase = prevPhase;
+			}
+		});
+
+		// focus/blur don't bubble, i.e. are not delegated to parent <div> tags,
+		// so we use the addEventListener capturing phase.
+		// See http://www.howtocreate.co.uk/tutorials/javascript/domevents
+		function __focusHandler(event) {
+			// Handles blur and focus.
+			// Fix event for IE:
+			// doesn't pass JSLint:
+//			event = arguments[0] = $.event.fix( event || window.event );
+			// what jQuery does:
+//			var args = jQuery.makeArray( arguments );
+//			event = args[0] = jQuery.event.fix( event || window.event );
+			event = $.event.fix( event || window.event );
+			var dtnode = $.ui.dynatree.getNode(event.target);
+			return dtnode ? dtnode._onFocus(event) : false;
+		}
+		var div = this.tree.divTree;
+
+		if( div.addEventListener ) {
+			div.addEventListener("focus", __focusHandler, true);
+			div.addEventListener("blur", __focusHandler, true);
+		} else {
+			div.onfocusin = div.onfocusout = __focusHandler;
+		}
+		// EVENTS
+		// disable click if event is configured to something else
+//		if (!(/^click/).test(o.event))
+//			this.$tabs.bind("click.tabs", function() { return false; });
+
+	},
+
+	unbind: function() {
+		this.element.unbind(".dynatree");
+	},
+
+/* TODO: we could handle option changes during runtime here (maybe to re-render, ...)
+	setData: function(key, value) {
+		this.tree.logDebug("dynatree.setData('" + key + "', '" + value + "')");
+	},
+*/
+	enable: function() {
+		this.bind();
+		// Call default disable(): remove -disabled from css:
+		$.Widget.prototype.enable.apply(this, arguments);
+	},
+
+	disable: function() {
+		this.unbind();
+		// Call default disable(): add -disabled to css:
+		$.Widget.prototype.disable.apply(this, arguments);
+	},
+
+	// --- getter methods (i.e. NOT returning a reference to $)
+	getTree: function() {
+		return this.tree;
+	},
+
+	getRoot: function() {
+		return this.tree.getRoot();
+	},
+
+	getActiveNode: function() {
+		return this.tree.getActiveNode();
+	},
+
+	getSelectedNodes: function() {
+		return this.tree.getSelectedNodes();
+	},
+
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+});
+
+
+// The following methods return a value (thus breaking the jQuery call chain):
+if( parseFloat($.ui.version) < 1.8 ) {
+	$.ui.dynatree.getter = "getTree getRoot getActiveNode getSelectedNodes";
+}
+
+/*******************************************************************************
+ * Tools in ui.dynatree namespace
+ */
+$.ui.dynatree.version = "$Version: 1.2.2$";
+
+/**
+ * Return a DynaTreeNode object for a given DOM element
+ */
+$.ui.dynatree.getNode = function(el) {
+	if(el instanceof DynaTreeNode){
+		return el; // el already was a DynaTreeNode
+	}
+	if(el.selector !== undefined){
+		el = el[0]; // el was a jQuery object: use the DOM element
+	}
+	// TODO: for some reason $el.parents("[dtnode]") does not work (jQuery 1.6.1)
+	// maybe, because dtnode is a property, not an attribute
+	while( el ) {
+		if(el.dtnode) {
+			return el.dtnode;
+		}
+		el = el.parentNode;
+	}
+	return null;
+/*
+	var $el = el.selector === undefined ? $(el) : el,
+//		parent = $el.closest("[dtnode]"),
+//		parent = $el.parents("[dtnode]").first(),
+		useProp = (typeof $el.prop == "function"),
+		node;
+	$el.parents().each(function(){
+		node = useProp ? $(this).prop("dtnode") : $(this).attr("dtnode");
+		if(node){
+			return false;
+		}
+	});
+	return node;
+*/
+};
+
+/**Return persistence information from cookies.*/
+$.ui.dynatree.getPersistData = DynaTreeStatus._getTreePersistData;
+
+/*******************************************************************************
+ * Plugin default options:
+ */
+$.ui.dynatree.prototype.options = {
+	title: "Dynatree", // Tree's name (only used for debug output)
+	minExpandLevel: 1, // 1: root node is not collapsible
+	imagePath: null, // Path to a folder containing icons. Defaults to 'skin/' subdirectory.
+	children: null, // Init tree structure from this object array.
+	initId: null, // Init tree structure from a <ul> element with this ID.
+	initAjax: null, // Ajax options used to initialize the tree strucuture.
+	autoFocus: true, // Set focus to first child, when expanding or lazy-loading.
+	keyboard: true, // Support keyboard navigation.
+	persist: false, // Persist expand-status to a cookie
+	autoCollapse: false, // Automatically collapse all siblings, when a node is expanded.
+	clickFolderMode: 3, // 1:activate, 2:expand, 3:activate and expand
+	activeVisible: true, // Make sure, active nodes are visible (expanded).
+	checkbox: false, // Show checkboxes.
+	selectMode: 2, // 1:single, 2:multi, 3:multi-hier
+	fx: null, // Animations, e.g. null or { height: "toggle", duration: 200 }
+	noLink: false, // Use <span> instead of <a> tags for all nodes
+	// Low level event handlers: onEvent(dtnode, event): return false, to stop default processing
+	onClick: null, // null: generate focus, expand, activate, select events.
+	onDblClick: null, // (No default actions.)
+	onKeydown: null, // null: generate keyboard navigation (focus, expand, activate).
+	onKeypress: null, // (No default actions.)
+	onFocus: null, // null: set focus to node.
+	onBlur: null, // null: remove focus from node.
+
+	// Pre-event handlers onQueryEvent(flag, dtnode): return false, to stop processing
+	onQueryActivate: null, // Callback(flag, dtnode) before a node is (de)activated.
+	onQuerySelect: null, // Callback(flag, dtnode) before a node is (de)selected.
+	onQueryExpand: null, // Callback(flag, dtnode) before a node is expanded/collpsed.
+
+	// High level event handlers
+	onPostInit: null, // Callback(isReloading, isError) when tree was (re)loaded.
+	onActivate: null, // Callback(dtnode) when a node is activated.
+	onDeactivate: null, // Callback(dtnode) when a node is deactivated.
+	onSelect: null, // Callback(flag, dtnode) when a node is (de)selected.
+	onExpand: null, // Callback(flag, dtnode) when a node is expanded/collapsed.
+	onLazyRead: null, // Callback(dtnode) when a lazy node is expanded for the first time.
+	onCustomRender: null, // Callback(dtnode) before a node is rendered. Return a HTML string to override.
+	onCreate: null, // Callback(dtnode, nodeSpan) after a node was rendered for the first time.
+	onRender: null, // Callback(dtnode, nodeSpan) after a node was rendered.
+				// postProcess is similar to the standard dataFilter hook,
+				// but it is also called for JSONP
+	postProcess: null, // Callback(data, dataType) before an Ajax result is passed to dynatree
+
+	// Drag'n'drop support
+	dnd: {
+		// Make tree nodes draggable:
+		onDragStart: null, // Callback(sourceNode), return true, to enable dnd
+		onDragStop: null, // Callback(sourceNode)
+//		helper: null,
+		// Make tree nodes accept draggables
+		autoExpandMS: 1000, // Expand nodes after n milliseconds of hovering.
+		preventVoidMoves: true, // Prevent dropping nodes 'before self', etc.
+		onDragEnter: null, // Callback(targetNode, sourceNode)
+		onDragOver: null, // Callback(targetNode, sourceNode, hitMode)
+		onDrop: null, // Callback(targetNode, sourceNode, hitMode)
+		onDragLeave: null // Callback(targetNode, sourceNode)
+	},
+	ajaxDefaults: { // Used by initAjax option
+		cache: false, // false: Append random '_' argument to the request url to prevent caching.
+		timeout: 0, // >0: Make sure we get an ajax error for invalid URLs
+		dataType: "json" // Expect json format and pass json object to callbacks.
+	},
+	strings: {
+		loading: "Loading&#8230;",
+		loadError: "Load error!"
+	},
+	generateIds: false, // Generate id attributes like <span id='dynatree-id-KEY'>
+	idPrefix: "dynatree-id-", // Used to generate node id's like <span id="dynatree-id-<key>">.
+	keyPathSeparator: "/", // Used by node.getKeyPath() and tree.loadKeyPath().
+//    cookieId: "dynatree-cookie", // Choose a more unique name, to allow multiple trees.
+	cookieId: "dynatree", // Choose a more unique name, to allow multiple trees.
+	cookie: {
+		expires: null //7, // Days or Date; null: session cookie
+//		path: "/", // Defaults to current page
+//		domain: "jquery.com",
+//		secure: true
+	},
+	// Class names used, when rendering the HTML markup.
+	// Note: if only single entries are passed for options.classNames, all other
+	// values are still set to default.
+	classNames: {
+		container: "dynatree-container",
+		node: "dynatree-node",
+		folder: "dynatree-folder",
+//		document: "dynatree-document",
+
+		empty: "dynatree-empty",
+		vline: "dynatree-vline",
+		expander: "dynatree-expander",
+		connector: "dynatree-connector",
+		checkbox: "dynatree-checkbox",
+		nodeIcon: "dynatree-icon",
+		title: "dynatree-title",
+		noConnector: "dynatree-no-connector",
+
+		nodeError: "dynatree-statusnode-error",
+		nodeWait: "dynatree-statusnode-wait",
+		hidden: "dynatree-hidden",
+		combinedExpanderPrefix: "dynatree-exp-",
+		combinedIconPrefix: "dynatree-ico-",
+		nodeLoading: "dynatree-loading",
+//		disabled: "dynatree-disabled",
+		hasChildren: "dynatree-has-children",
+		active: "dynatree-active",
+		selected: "dynatree-selected",
+		expanded: "dynatree-expanded",
+		lazy: "dynatree-lazy",
+		focused: "dynatree-focused",
+		partsel: "dynatree-partsel",
+		lastsib: "dynatree-lastsib"
+	},
+	debugLevel: 1,
+
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+};
+//
+if( parseFloat($.ui.version) < 1.8 ) {
+	$.ui.dynatree.defaults = $.ui.dynatree.prototype.options;
+}
+
+/*******************************************************************************
+ * Reserved data attributes for a tree node.
+ */
+$.ui.dynatree.nodedatadefaults = {
+	title: null, // (required) Displayed name of the node (html is allowed here)
+	key: null, // May be used with activate(), select(), find(), ...
+	isFolder: false, // Use a folder icon. Also the node is expandable but not selectable.
+	isLazy: false, // Call onLazyRead(), when the node is expanded for the first time to allow for delayed creation of children.
+	tooltip: null, // Show this popup text.
+	href: null, // Added to the generated <a> tag.
+	icon: null, // Use a custom image (filename relative to tree.options.imagePath). 'null' for default icon, 'false' for no icon.
+	addClass: null, // Class name added to the node's span tag.
+	noLink: false, // Use <span> instead of <a> tag for this node
+	activate: false, // Initial active status.
+	focus: false, // Initial focused status.
+	expand: false, // Initial expanded status.
+	select: false, // Initial selected status.
+	hideCheckbox: false, // Suppress checkbox display for this node.
+	unselectable: false, // Prevent selection.
+//  disabled: false,
+	// The following attributes are only valid if passed to some functions:
+	children: null, // Array of child nodes.
+	// NOTE: we can also add custom attributes here.
+	// This may then also be used in the onActivate(), onSelect() or onLazyTree() callbacks.
+	// ------------------------------------------------------------------------
+	lastentry: undefined
+};
+
+/*******************************************************************************
+ * Drag and drop support
+ */
+function _initDragAndDrop(tree) {
+	var dnd = tree.options.dnd || null;
+	// Register 'connectToDynatree' option with ui.draggable
+	if(dnd && (dnd.onDragStart || dnd.onDrop)) {
+		_registerDnd();
+	}
+	// Attach ui.draggable to this Dynatree instance
+	if(dnd && dnd.onDragStart ) {
+		tree.$tree.draggable({
+			addClasses: false,
+			appendTo: "body",
+			containment: false,
+			delay: 0,
+			distance: 4,
+			revert: false,
+			scroll: true, // issue 244: enable scrolling (if ul.dynatree-container)
+			scrollSpeed: 7,
+			scrollSensitivity: 10,
+			// Delegate draggable.start, drag, and stop events to our handler
+			connectToDynatree: true,
+			// Let source tree create the helper element
+			helper: function(event) {
+				var sourceNode = $.ui.dynatree.getNode(event.target);
+				if(!sourceNode){ // issue 211
+					return "<div></div>";
+				}
+				return sourceNode.tree._onDragEvent("helper", sourceNode, null, event, null, null);
+			},
+			start: function(event, ui) {
+				// See issues 211, 268, 278
+//				var sourceNode = $.ui.dynatree.getNode(event.target);
+				var sourceNode = ui.helper.data("dtSourceNode");
+				return !!sourceNode; // Abort dragging if no Node could be found
+			},
+			_last: null
+		});
+	}
+	// Attach ui.droppable to this Dynatree instance
+	if(dnd && dnd.onDrop) {
+		tree.$tree.droppable({
+			addClasses: false,
+			tolerance: "intersect",
+			greedy: false,
+			_last: null
+		});
+	}
+}
+
+//--- Extend ui.draggable event handling --------------------------------------
+var didRegisterDnd = false;
+var _registerDnd = function() {
+	if(didRegisterDnd){
+		return;
+	}
+	// Register proxy-functions for draggable.start/drag/stop
+	$.ui.plugin.add("draggable", "connectToDynatree", {
+		start: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null;
+//			logMsg("draggable-connectToDynatree.start, %s", sourceNode);
+//			logMsg("    this: %o", this);
+//			logMsg("    event: %o", event);
+//			logMsg("    draggable: %o", draggable);
+//			logMsg("    ui: %o", ui);
+
+			if(sourceNode) {
+				// Adjust helper offset, so cursor is slightly outside top/left corner
+//				draggable.offset.click.top -= event.target.offsetTop;
+//				draggable.offset.click.left -= event.target.offsetLeft;
+				draggable.offset.click.top = -2;
+				draggable.offset.click.left = + 16;
+//				logMsg("    draggable2: %o", draggable);
+//				logMsg("    draggable.offset.click FIXED: %s/%s", draggable.offset.click.left, draggable.offset.click.top);
+				// Trigger onDragStart event
+				// TODO: when called as connectTo..., the return value is ignored(?)
+				return sourceNode.tree._onDragEvent("start", sourceNode, null, event, ui, draggable);
+			}
+		},
+		drag: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null,
+				prevTargetNode = ui.helper.data("dtTargetNode") || null,
+				targetNode = $.ui.dynatree.getNode(event.target);
+//			logMsg("$.ui.dynatree.getNode(%o): %s", event.target, targetNode);
+//			logMsg("connectToDynatree.drag: helper: %o", ui.helper[0]);
+			if(event.target && !targetNode){
+				// We got a drag event, but the targetNode could not be found
+				// at the event location. This may happen,
+				// 1. if the mouse jumped over the drag helper,
+				// 2. or if non-dynatree element is dragged
+				// We ignore it:
+				var isHelper = $(event.target).closest("div.dynatree-drag-helper,#dynatree-drop-marker").length > 0;
+				if(isHelper){
+//					logMsg("Drag event over helper: ignored.");
+					return;
+				}
+			}
+//			logMsg("draggable-connectToDynatree.drag: targetNode(from event): %s, dtTargetNode: %s", targetNode, ui.helper.data("dtTargetNode"));
+			ui.helper.data("dtTargetNode", targetNode);
+			// Leaving a tree node
+			if(prevTargetNode && prevTargetNode !== targetNode ) {
+				prevTargetNode.tree._onDragEvent("leave", prevTargetNode, sourceNode, event, ui, draggable);
+			}
+			if(targetNode){
+				if(!targetNode.tree.options.dnd.onDrop) {
+					// not enabled as drop target
+//					noop(); // Keep JSLint happy
+				} else if(targetNode === prevTargetNode) {
+					// Moving over same node
+					targetNode.tree._onDragEvent("over", targetNode, sourceNode, event, ui, draggable);
+				}else{
+					// Entering this node first time
+					targetNode.tree._onDragEvent("enter", targetNode, sourceNode, event, ui, draggable);
+				}
+			}
+			// else go ahead with standard event handling
+		},
+		stop: function(event, ui) {
+			var draggable = $(this).data("draggable"),
+				sourceNode = ui.helper.data("dtSourceNode") || null,
+				targetNode = ui.helper.data("dtTargetNode") || null,
+				mouseDownEvent = draggable._mouseDownEvent,
+				eventType = event.type,
+				dropped = (eventType == "mouseup" && event.which == 1);
+//			logMsg("draggable-connectToDynatree.stop: targetNode(from event): %s, dtTargetNode: %s", targetNode, ui.helper.data("dtTargetNode"));
+//			logMsg("draggable-connectToDynatree.stop, %s", sourceNode);
+//			logMsg("    type: %o, downEvent: %o, upEvent: %o", eventType, mouseDownEvent, event);
+//			logMsg("    targetNode: %o", targetNode);
+			if(!dropped){
+				logMsg("Drag was cancelled");
+			}
+			if(targetNode) {
+				if(dropped){
+					targetNode.tree._onDragEvent("drop", targetNode, sourceNode, event, ui, draggable);
+				}
+				targetNode.tree._onDragEvent("leave", targetNode, sourceNode, event, ui, draggable);
+			}
+			if(sourceNode){
+				sourceNode.tree._onDragEvent("stop", sourceNode, null, event, ui, draggable);
+			}
+		}
+	});
+	didRegisterDnd = true;
+};
+
+// ---------------------------------------------------------------------------
+}(jQuery));
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin-vista/ui.dynatree.css
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin-vista/ui.dynatree.css	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin-vista/ui.dynatree.css	(revision 9215)
@@ -0,0 +1,452 @@
+/*******************************************************************************
+ * Tree container
+ */
+ul.dynatree-container
+{
+	font-family: tahoma, arial, helvetica;
+	font-size: 10pt; /* font size should not be too big */
+	white-space: nowrap;
+	padding: 3px;
+	margin: 0; /* issue 201 */
+	background-color: white;
+	border: 1px dotted gray;
+	overflow: auto;
+	height: 100%; /* issue 263 */
+}
+
+ul.dynatree-container ul
+{
+	padding: 0 0 0 16px;
+	margin: 0;
+}
+
+ul.dynatree-container li
+{
+	list-style-image: none;
+	list-style-position: outside;
+	list-style-type: none;
+	-moz-background-clip:border;
+	-moz-background-inline-policy: continuous;
+	-moz-background-origin: padding;
+	background-attachment: scroll;
+	background-color: transparent;
+	background-position: 0 0;
+	background-repeat: repeat-y;
+	background-image: none;  /* no v-lines */
+
+	margin:0;
+	padding:1px 0 0 0;
+}
+/* Suppress lines for last child node */
+ul.dynatree-container li.dynatree-lastsib
+{
+	background-image: none;
+}
+/* Suppress lines if level is fixed expanded (option minExpandLevel) */
+ul.dynatree-no-connector > li
+{
+	background-image: none;
+}
+
+/* Style, when control is disabled */
+.ui-dynatree-disabled ul.dynatree-container
+{
+	opacity: 0.5;
+/*	filter: alpha(opacity=50); /* Yields a css warning */
+	background-color: silver;
+}
+
+
+/*******************************************************************************
+ * Common icon definitions
+ */
+span.dynatree-empty,
+span.dynatree-vline,
+span.dynatree-connector,
+span.dynatree-expander,
+span.dynatree-icon,
+span.dynatree-checkbox,
+span.dynatree-radio,
+span.dynatree-drag-helper-img,
+#dynatree-drop-marker
+{
+	width: 16px;
+	height: 16px;
+/*	display: -moz-inline-box; /* @ FF 1+2 removed for issue 221*/
+/*	-moz-box-align: start; /* issue 221 */
+	display: inline-block; /* Required to make a span sizeable */
+	vertical-align: top;
+	background-repeat: no-repeat;
+	background-position: left;
+	background-image: url("icons.gif");
+	background-position: 0 0;
+}
+
+/** Used by 'icon' node option: */
+ul.dynatree-container img
+{
+	width: 16px;
+	height: 16px;
+	margin-left: 3px;
+	vertical-align: top;
+	border-style: none;
+}
+
+
+/*******************************************************************************
+ * Lines and connectors
+ */
+
+/*
+span.dynatree-empty
+{
+}
+span.dynatree-vline
+{
+}
+*/
+span.dynatree-connector
+{
+	background-image: none;
+}
+/*
+.dynatree-lastsib span.dynatree-connector
+{
+}
+*/
+/*******************************************************************************
+ * Expander icon
+ * Note: IE6 doesn't correctly evaluate multiples class names,
+ *		 so we create combined class names that can be used in the CSS.
+ *
+ * Prefix: dynatree-exp-
+ * 1st character: 'e': expanded, 'c': collapsed
+ * 2nd character (optional): 'd': lazy (Delayed)
+ * 3rd character (optional): 'l': Last sibling
+ */
+
+span.dynatree-expander
+{
+	background-position: 0px -80px;
+	cursor: pointer;
+}
+span.dynatree-expander:hover
+{
+	background-position: -16px -80px;
+}
+.dynatree-exp-cl span.dynatree-expander /* Collapsed, not delayed, last sibling */
+{
+}
+.dynatree-exp-cd span.dynatree-expander /* Collapsed, delayed, not last sibling */
+{
+}
+.dynatree-exp-cdl span.dynatree-expander /* Collapsed, delayed, last sibling */
+{
+}
+.dynatree-exp-e span.dynatree-expander,  /* Expanded, not delayed, not last sibling */
+.dynatree-exp-ed span.dynatree-expander,  /* Expanded, delayed, not last sibling */
+.dynatree-exp-el span.dynatree-expander,  /* Expanded, not delayed, last sibling */
+.dynatree-exp-edl span.dynatree-expander  /* Expanded, delayed, last sibling */
+{
+	background-position: -32px -80px;
+}
+.dynatree-exp-e span.dynatree-expander:hover,  /* Expanded, not delayed, not last sibling */
+.dynatree-exp-ed span.dynatree-expander:hover,  /* Expanded, delayed, not last sibling */
+.dynatree-exp-el span.dynatree-expander:hover,  /* Expanded, not delayed, last sibling */
+.dynatree-exp-edl span.dynatree-expander:hover  /* Expanded, delayed, last sibling */
+{
+	background-position: -48px -80px;
+}
+.dynatree-loading span.dynatree-expander  /* 'Loading' status overrides all others */
+{
+	background-position: 0 0;
+	background-image: url("loading.gif");
+}
+
+
+/*******************************************************************************
+ * Checkbox icon
+ */
+span.dynatree-checkbox
+{
+	margin-left: 3px;
+	background-position: 0px -32px;
+}
+span.dynatree-checkbox:hover
+{
+	background-position: -16px -32px;
+}
+
+.dynatree-partsel span.dynatree-checkbox
+{
+	background-position: -64px -32px;
+}
+.dynatree-partsel span.dynatree-checkbox:hover
+{
+	background-position: -80px -32px;
+}
+
+.dynatree-selected span.dynatree-checkbox
+{
+	background-position: -32px -32px;
+}
+.dynatree-selected span.dynatree-checkbox:hover
+{
+	background-position: -48px -32px;
+}
+
+/*******************************************************************************
+ * Radiobutton icon
+ * This is a customization, that may be activated by overriding the 'checkbox'
+ * class name as 'dynatree-radio' in the tree options.
+ */
+span.dynatree-radio
+{
+	margin-left: 3px;
+	background-position: 0px -48px;
+}
+span.dynatree-radio:hover
+{
+	background-position: -16px -48px;
+}
+
+.dynatree-partsel span.dynatree-radio
+{
+	background-position: -64px -48px;
+}
+.dynatree-partsel span.dynatree-radio:hover
+{
+	background-position: -80px -48px;
+}
+
+.dynatree-selected span.dynatree-radio
+{
+	background-position: -32px -48px;
+}
+.dynatree-selected span.dynatree-radio:hover
+{
+	background-position: -48px -48px;
+}
+
+/*******************************************************************************
+ * Node type icon
+ * Note: IE6 doesn't correctly evaluate multiples class names,
+ *		 so we create combined class names that can be used in the CSS.
+ *
+ * Prefix: dynatree-ico-
+ * 1st character: 'e': expanded, 'c': collapsed
+ * 2nd character (optional): 'f': folder
+ */
+
+span.dynatree-icon /* Default icon */
+{
+	margin-left: 3px;
+	background-position: 0px 0px;
+}
+
+.dynatree-has-children span.dynatree-icon /* Default icon */
+{
+/*    background-position: 0px -16px; */
+}
+
+.dynatree-ico-cf span.dynatree-icon  /* Collapsed Folder */
+{
+	background-position: 0px -16px;
+}
+
+.dynatree-ico-ef span.dynatree-icon  /* Expanded Folder */
+{
+	background-position: -64px -16px;
+}
+
+/* Status node icons */
+
+.dynatree-statusnode-wait span.dynatree-icon
+{
+	background-image: url("loading.gif");
+}
+
+.dynatree-statusnode-error span.dynatree-icon
+{
+	background-position: 0px -112px;
+/*	background-image: url("ltError.gif");*/
+}
+
+/*******************************************************************************
+ * Node titles
+ */
+
+/* @Chrome: otherwise hit area of node titles is broken (issue 133)
+   Removed again for issue 165; (133 couldn't be reproduced) */
+span.dynatree-node
+{
+/*	display: -moz-inline-box; /* issue 133, 165, 172, 192. removed for issue 221 */
+/*	-moz-box-align: start; /* issue 221 */
+/*  display: inline-block; /* Required to make a span sizeable */
+}
+
+
+/* Remove blue color and underline from title links */
+ul.dynatree-container a
+/*, ul.dynatree-container a:visited*/
+{
+	color: black; /* inherit doesn't work on IE */
+	text-decoration: none;
+	vertical-align: top;
+	margin: 0px;
+	margin-left: 3px;
+/*	outline: 0; /* @ Firefox, prevent dotted border after click */
+	/* Set transparent border to prevent jumping when active node gets a border
+	   (we can do this, because this theme doesn't use vertical lines)
+	   */
+	border: 1px solid white; /* Note: 'transparent' would not work in IE6 */
+
+}
+
+ul.dynatree-container a:hover
+{
+/*	text-decoration: underline; */
+	background: #F2F7FD; /* light blue */
+	border-color: #B8D6FB; /* darker light blue */
+}
+
+span.dynatree-node a
+{
+	display: inline-block; /* Better alignment, when title contains <br> */
+/*	vertical-align: top;*/
+	padding-left: 3px;
+	padding-right: 3px; /* Otherwise italic font will be outside bounds */
+	/*	line-height: 16px; /* should be the same as img height, in case 16 px */
+}
+span.dynatree-folder a
+{
+/*	font-weight: bold; */ /* custom */
+}
+
+ul.dynatree-container a:focus,
+span.dynatree-focused a:link  /* @IE */
+{
+	background-color: #EFEBDE; /* gray */
+}
+
+span.dynatree-has-children a
+{
+/*	font-style: oblique; /* custom: */
+}
+
+span.dynatree-expanded a
+{
+}
+
+span.dynatree-selected a
+{
+/*	color: green; */
+	font-style: italic;
+}
+
+span.dynatree-active a
+{
+	border: 1px solid #99DEFD;
+	background-color: #D8F0FA;
+}
+
+/*******************************************************************************
+ * Drag'n'drop support
+ */
+
+/*** Helper object ************************************************************/
+div.dynatree-drag-helper
+{
+}
+div.dynatree-drag-helper a
+{
+	border: 1px solid gray;
+	background-color: white;
+	padding-left: 5px;
+	padding-right: 5px;
+	opacity: 0.8;
+}
+span.dynatree-drag-helper-img
+{
+	/*
+	position: relative;
+	left: -16px;
+	*/
+}
+div.dynatree-drag-helper /*.dynatree-drop-accept*/
+{
+/*    border-color: green;
+	background-color: red;*/
+}
+div.dynatree-drop-accept span.dynatree-drag-helper-img
+{
+	background-position: -32px -112px;
+}
+div.dynatree-drag-helper.dynatree-drop-reject
+{
+	border-color: red;
+}
+div.dynatree-drop-reject span.dynatree-drag-helper-img
+{
+	background-position: -16px -112px;
+}
+
+/*** Drop marker icon *********************************************************/
+
+#dynatree-drop-marker
+{
+	width: 24px;
+	position: absolute;
+	background-position: 0 -128px;
+	margin: 0;
+}
+#dynatree-drop-marker.dynatree-drop-after,
+#dynatree-drop-marker.dynatree-drop-before
+{
+	width:64px;
+	background-position: 0 -144px;
+}
+#dynatree-drop-marker.dynatree-drop-copy
+{
+	background-position: -64px -128px;
+}
+#dynatree-drop-marker.dynatree-drop-move
+{
+	background-position: -64px -128px;
+}
+
+/*** Source node while dragging ***********************************************/
+
+span.dynatree-drag-source
+{
+	/* border: 1px dotted gray; */
+	background-color: #e0e0e0;
+}
+span.dynatree-drag-source a
+{
+	color: gray;
+}
+
+/*** Target node while dragging cursor is over it *****************************/
+
+span.dynatree-drop-target
+{
+	/*border: 1px solid gray;*/
+}
+span.dynatree-drop-target a
+{
+}
+span.dynatree-drop-target.dynatree-drop-accept a
+{
+	/*border: 1px solid green;*/
+	background-color: #3169C6 !important;
+	color: white !important; /* @ IE6 */
+	text-decoration: none;
+}
+span.dynatree-drop-target.dynatree-drop-reject
+{
+	/*border: 1px solid red;*/
+}
+span.dynatree-drop-target.dynatree-drop-after a
+{
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin/ui.dynatree.css
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin/ui.dynatree.css	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/dynatree/src/skin/ui.dynatree.css	(revision 9215)
@@ -0,0 +1,440 @@
+/*******************************************************************************
+ * Tree container
+ */
+ul.dynatree-container
+{
+	font-family: tahoma, arial, helvetica;
+	font-size: 10pt; /* font size should not be too big */
+	white-space: nowrap;
+	padding: 3px;
+	margin: 0; /* issue 201 */
+	background-color: white;
+	border: 1px dotted gray;
+	overflow: auto;
+	height: 100%; /* issue 263 */
+}
+
+ul.dynatree-container ul
+{
+	padding: 0 0 0 16px;
+	margin: 0;
+}
+
+ul.dynatree-container li
+{
+	list-style-image: none;
+	list-style-position: outside;
+	list-style-type: none;
+	-moz-background-clip:border;
+	-moz-background-inline-policy: continuous;
+	-moz-background-origin: padding;
+	background-attachment: scroll;
+	background-color: transparent;
+	background-repeat: repeat-y;
+	background-image: url("vline.gif");
+	background-position: 0 0;
+	/*
+	background-image: url("icons_96x256.gif");
+	background-position: -80px -64px;
+	*/
+	margin: 0;
+	padding: 1px 0 0 0;
+}
+/* Suppress lines for last child node */
+ul.dynatree-container li.dynatree-lastsib
+{
+	background-image: none;
+}
+/* Suppress lines if level is fixed expanded (option minExpandLevel) */
+ul.dynatree-no-connector > li
+{
+	background-image: none;
+}
+
+/* Style, when control is disabled */
+.ui-dynatree-disabled ul.dynatree-container
+{
+	opacity: 0.5;
+/*	filter: alpha(opacity=50); /* Yields a css warning */
+	background-color: silver;
+}
+
+/*******************************************************************************
+ * Common icon definitions
+ */
+span.dynatree-empty,
+span.dynatree-vline,
+span.dynatree-connector,
+span.dynatree-expander,
+span.dynatree-icon,
+span.dynatree-checkbox,
+span.dynatree-radio,
+span.dynatree-drag-helper-img,
+#dynatree-drop-marker
+{
+	width: 16px;
+	height: 16px;
+/*	display: -moz-inline-box; /* @ FF 1+2 removed for issue 221 */
+/*	-moz-box-align: start; /* issue 221 */
+	display: inline-block; /* Required to make a span sizeable */
+	vertical-align: top;
+	background-repeat: no-repeat;
+	background-position: left;
+	background-image: url("icons.gif");
+	background-position: 0 0;
+}
+
+/** Used by 'icon' node option: */
+ul.dynatree-container img
+{
+	width: 16px;
+	height: 16px;
+	margin-left: 3px;
+	vertical-align: top;
+	border-style: none;
+}
+
+
+/*******************************************************************************
+ * Lines and connectors
+ */
+
+span.dynatree-connector
+{
+	background-position: -16px -64px;
+}
+
+/*******************************************************************************
+ * Expander icon
+ * Note: IE6 doesn't correctly evaluate multiples class names,
+ *		 so we create combined class names that can be used in the CSS.
+ *
+ * Prefix: dynatree-exp-
+ * 1st character: 'e': expanded, 'c': collapsed
+ * 2nd character (optional): 'd': lazy (Delayed)
+ * 3rd character (optional): 'l': Last sibling
+ */
+
+span.dynatree-expander
+{
+	background-position: 0px -80px;
+	cursor: pointer;
+}
+.dynatree-exp-cl span.dynatree-expander /* Collapsed, not delayed, last sibling */
+{
+	background-position: 0px -96px;
+}
+.dynatree-exp-cd span.dynatree-expander /* Collapsed, delayed, not last sibling */
+{
+	background-position: -64px -80px;
+}
+.dynatree-exp-cdl span.dynatree-expander /* Collapsed, delayed, last sibling */
+{
+	background-position: -64px -96px;
+}
+.dynatree-exp-e span.dynatree-expander,  /* Expanded, not delayed, not last sibling */
+.dynatree-exp-ed span.dynatree-expander  /* Expanded, delayed, not last sibling */
+{
+	background-position: -32px -80px;
+}
+.dynatree-exp-el span.dynatree-expander,  /* Expanded, not delayed, last sibling */
+.dynatree-exp-edl span.dynatree-expander  /* Expanded, delayed, last sibling */
+{
+	background-position: -32px -96px;
+}
+.dynatree-loading span.dynatree-expander  /* 'Loading' status overrides all others */
+{
+	background-position: 0 0;
+	background-image: url("loading.gif");
+}
+
+
+/*******************************************************************************
+ * Checkbox icon
+ */
+span.dynatree-checkbox
+{
+	margin-left: 3px;
+	background-position: 0px -32px;
+}
+span.dynatree-checkbox:hover
+{
+	background-position: -16px -32px;
+}
+
+.dynatree-partsel span.dynatree-checkbox
+{
+	background-position: -64px -32px;
+}
+.dynatree-partsel span.dynatree-checkbox:hover
+{
+	background-position: -80px -32px;
+}
+
+.dynatree-selected span.dynatree-checkbox
+{
+	background-position: -32px -32px;
+}
+.dynatree-selected span.dynatree-checkbox:hover
+{
+	background-position: -48px -32px;
+}
+
+/*******************************************************************************
+ * Radiobutton icon
+ * This is a customization, that may be activated by overriding the 'checkbox'
+ * class name as 'dynatree-radio' in the tree options.
+ */
+span.dynatree-radio
+{
+	margin-left: 3px;
+	background-position: 0px -48px;
+}
+span.dynatree-radio:hover
+{
+	background-position: -16px -48px;
+}
+
+.dynatree-partsel span.dynatree-radio
+{
+	background-position: -64px -48px;
+}
+.dynatree-partsel span.dynatree-radio:hover
+{
+	background-position: -80px -48px;
+}
+
+.dynatree-selected span.dynatree-radio
+{
+	background-position: -32px -48px;
+}
+.dynatree-selected span.dynatree-radio:hover
+{
+	background-position: -48px -48px;
+}
+
+/*******************************************************************************
+ * Node type icon
+ * Note: IE6 doesn't correctly evaluate multiples class names,
+ *		 so we create combined class names that can be used in the CSS.
+ *
+ * Prefix: dynatree-ico-
+ * 1st character: 'e': expanded, 'c': collapsed
+ * 2nd character (optional): 'f': folder
+ */
+
+span.dynatree-icon /* Default icon */
+{
+	margin-left: 3px;
+	background-position: 0px 0px;
+}
+
+.dynatree-ico-cf span.dynatree-icon  /* Collapsed Folder */
+{
+	background-position: 0px -16px;
+}
+
+.dynatree-ico-ef span.dynatree-icon  /* Expanded Folder */
+{
+	background-position: -64px -16px;
+}
+
+/* Status node icons */
+
+.dynatree-statusnode-wait span.dynatree-icon
+{
+	background-image: url("loading.gif");
+}
+
+.dynatree-statusnode-error span.dynatree-icon
+{
+	background-position: 0px -112px;
+/*	background-image: url("ltError.gif");*/
+}
+
+/*******************************************************************************
+ * Node titles
+ */
+
+/* @Chrome: otherwise hit area of node titles is broken (issue 133)
+   Removed again for issue 165; (133 couldn't be reproduced) */
+span.dynatree-node
+{
+/*	display: -moz-inline-box; /* issue 133, 165, 172, 192. removed for issue 221*/
+/*	-moz-box-align: start; /* issue 221 */
+/*  display: inline-block; /* Required to make a span sizeable */
+}
+
+
+/* Remove blue color and underline from title links */
+ul.dynatree-container a
+/*, ul.dynatree-container a:visited*/
+{
+	color: black; /* inherit doesn't work on IE */
+	text-decoration: none;
+	vertical-align: top;
+	margin: 0px;
+	margin-left: 3px;
+/*	outline: 0; /* @ Firefox, prevent dotted border after click */
+}
+
+ul.dynatree-container a:hover
+{
+/*	text-decoration: underline; */
+	background-color: #F2F7FD; /* light blue */
+	border-color: #B8D6FB; /* darker light blue */
+}
+
+span.dynatree-node a
+{
+	font-size: 10pt; /* required for IE, quirks mode */
+	display: inline-block; /* Better alignment, when title contains <br> */
+/*	vertical-align: top;*/
+	padding-left: 3px;
+	padding-right: 3px; /* Otherwise italic font will be outside bounds */
+	/*	line-height: 16px; /* should be the same as img height, in case 16 px */
+}
+span.dynatree-folder a
+{
+	font-weight: bold;
+}
+
+ul.dynatree-container a:focus,
+span.dynatree-focused a:link  /* @IE */
+{
+	background-color: #EFEBDE; /* gray */
+}
+
+span.dynatree-has-children a
+{
+}
+
+span.dynatree-expanded a
+{
+}
+
+span.dynatree-selected a
+{
+	color: green;
+	font-style: italic;
+}
+
+span.dynatree-active a
+{
+	background-color: #3169C6 !important;
+	color: white !important; /* @ IE6 */
+}
+
+/*******************************************************************************
+ * Drag'n'drop support
+ */
+
+/*** Helper object ************************************************************/
+div.dynatree-drag-helper
+{
+}
+div.dynatree-drag-helper a
+{
+	border: 1px solid gray;
+	background-color: white;
+	padding-left: 5px;
+	padding-right: 5px;
+	opacity: 0.8;
+}
+span.dynatree-drag-helper-img
+{
+	/*
+	position: relative;
+	left: -16px;
+	*/
+}
+div.dynatree-drag-helper /*.dynatree-drop-accept*/
+{
+
+/*    border-color: green;
+	background-color: red;*/
+}
+div.dynatree-drop-accept span.dynatree-drag-helper-img
+{
+	background-position: -32px -112px;
+}
+div.dynatree-drag-helper.dynatree-drop-reject
+{
+	border-color: red;
+}
+div.dynatree-drop-reject span.dynatree-drag-helper-img
+{
+	background-position: -16px -112px;
+}
+
+/*** Drop marker icon *********************************************************/
+
+#dynatree-drop-marker
+{
+	width: 24px;
+	position: absolute;
+	background-position: 0 -128px;
+	margin: 0;
+/*	border: 1px solid red; */
+}
+#dynatree-drop-marker.dynatree-drop-after,
+#dynatree-drop-marker.dynatree-drop-before
+{
+	width:64px;
+	background-position: 0 -144px;
+}
+#dynatree-drop-marker.dynatree-drop-copy
+{
+	background-position: -64px -128px;
+}
+#dynatree-drop-marker.dynatree-drop-move
+{
+	background-position: -64px -128px;
+}
+
+/*** Source node while dragging ***********************************************/
+
+span.dynatree-drag-source
+{
+	/* border: 1px dotted gray; */
+	background-color: #e0e0e0;
+}
+span.dynatree-drag-source a
+{
+	color: gray;
+}
+
+/*** Target node while dragging cursor is over it *****************************/
+
+span.dynatree-drop-target
+{
+	/*border: 1px solid gray;*/
+}
+span.dynatree-drop-target a
+{
+}
+span.dynatree-drop-target.dynatree-drop-accept a
+{
+	/*border: 1px solid green;*/
+	background-color: #3169C6 !important;
+	color: white !important; /* @ IE6 */
+	text-decoration: none;
+}
+span.dynatree-drop-target.dynatree-drop-reject
+{
+	/*border: 1px solid red;*/
+}
+span.dynatree-drop-target.dynatree-drop-after a
+{
+}
+
+
+/*******************************************************************************
+ * Custom node classes (sample)
+ */
+
+span.custom1 a
+{
+	background-color: maroon;
+	color: yellow;
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/hl/Site.css
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/hl/Site.css	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Content/hl/Site.css	(revision 9215)
@@ -148,5 +148,8 @@
 }
 
-#master-MainContent {
+#master-MainContent 
+{
+  background-repeat: repeat-y;
+  background-image: url("images/bg_main.png");
   padding-left: 12px;
   padding-right: 12px;
@@ -403,2 +406,29 @@
     display: inline
 }
+
+
+.dragables 
+{
+  height :100px;
+  width:100px;
+  border:1px solid #000000;  
+  background: #EEEEEE;  
+  padding: 5px 5px 5px 5px;
+  margin: 5px 5px 5px 5px;
+  float: left;
+}
+
+.clearer 
+{  
+  clear:both;
+}
+
+.treeStyle 
+{
+  border: 1px solid black;
+}
+
+.unseen 
+{
+    display: none;
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/AdminController.cs	(revision 9215)
@@ -13,4 +13,5 @@
 using System.Web.Security;
 using HeuristicLab.Services.Optimization.ControllerService.Model;
+using HeuristicLab.Services.Optimization.Web.Helpers;
 
 namespace HeuristicLab.Services.Optimization.Web.Controllers
@@ -19,26 +20,13 @@
     public class AdminController : Controller
     {
-      public delegate T ControllerServiceDelegate<T>(IControllerService service);
-      public delegate void ControllerServiceDelegate(IControllerService service);
-
-      public T withControllerService<T>(ControllerServiceDelegate<T> del) {
-        using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
-          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
-          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
-          credentialBehaviour.UserName.Password = Session["pw"] as string;
-          var controllerProxy = cf.CreateChannel();
-          return del(controllerProxy);
+      private ControllerServiceHelper ControllerService {
+          get {
+            var helper = new ControllerServiceHelper(Session["pw"] as string);
+            if (!helper.Valid) {
+              Response.Redirect("/Account/Logon");
+            }
+            return helper;
+          }
         }
-      }
-
-      public void withControllerService(ControllerServiceDelegate del) {
-        using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
-          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
-          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
-          credentialBehaviour.UserName.Password = Session["pw"] as string;
-          var controllerProxy = cf.CreateChannel();
-          del(controllerProxy);
-        }
-      }
         //
         // GET: /Admin/
@@ -46,5 +34,5 @@
         public ActionResult Index()
         {
-          var names = withControllerService<IEnumerable<string>>((service) => {            
+          var names = ControllerService.withControllerService<IEnumerable<string>>((service) => {            
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
             return service.GetOptimizationScenarioNames();
@@ -68,5 +56,5 @@
           }
 
-          var ok = withControllerService<bool>((service) => {
+          var ok = ControllerService.withControllerService<bool>((service) => {
             OptimizationModel model = new OptimizationModel();
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
@@ -78,5 +66,5 @@
 
         public ActionResult DeleteScenario(string id) {
-          withControllerService<bool>((service) => {            
+          ControllerService.withControllerService<bool>((service) => {            
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
             return service.DeleteHiveScenario(u, id);
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/ExperimentController.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/ExperimentController.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/ExperimentController.cs	(revision 9215)
@@ -0,0 +1,97 @@
+﻿using System; 
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using HeuristicLab.Services.Optimization.Web.Models;
+using HeuristicLab.Services.Optimization.Web.Helpers;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+using System.Web.Security;
+
+namespace HeuristicLab.Services.Optimization.Web.Controllers
+{
+    [Authorize(Roles = "Web User")]
+    public class ExperimentController : Controller
+    {
+        private ControllerServiceHelper ControllerService {
+          get {
+            var helper = new ControllerServiceHelper(Session["pw"] as string);
+            if (!helper.Valid) {
+              Response.Redirect("/Account/Logon?ReturnUrl=%2fExperiment");
+            }
+            return helper;
+          }
+        }
+
+        //
+        // GET: /Experiment/
+
+        public ActionResult Index()
+        {
+          var model = new ExperimentViewModel();
+          var scenarios = ControllerService.withControllerService<IEnumerable<string>>((service) => {
+            return service.GetOptimizationScenarioNames();
+          });
+          var experiments = ControllerService.withControllerService<IEnumerable<string>>((service) => {
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.GetExperiments(u);
+          });
+          foreach (var experiment in experiments)
+            model.Experiments.Add(experiment);
+          foreach (var scenario in scenarios)
+            model.Scenarios.Add(scenario);
+          return View(model);
+        }
+
+        [HttpPost]
+        public JsonResult Save(ExperimentModel model) {
+          var experiment = new Experiment() { Name = model.Name };
+          var stack = new Stack<Node>();
+
+          foreach (var node in model.Experiment.children)
+            stack.Push(node);
+
+          while (stack.Count > 0) {
+            var currentNode = stack.Pop();
+            // add children to stack
+            if (currentNode.children != null)
+              foreach (var node in currentNode.children)
+                stack.Push(node);
+
+            // TODO: Do we really need a tree of scenarios? Or is it a simple list?
+            // push currentNode to experiment
+            if (currentNode.title == "Experiment")
+              continue;
+            experiment.Scenarios.Add(new OptimizationScenario() { Id = currentNode.title });
+          }
+
+          var ok = ControllerService.withControllerService<bool>((service) => {
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.SaveExperiment(u, experiment);
+          });
+
+          if (ok)
+            return Json(new { success = true, data = model.Name });
+          return Json(new { success = false, error = "Experiment already exists!" });
+        }
+
+        public ActionResult Edit() {
+          var model = new ExperimentViewModel();
+          var experiments = ControllerService.withControllerService<IEnumerable<string>>((service) => {
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.GetExperiments(u);
+          });
+          foreach (var experiment in experiments)
+            model.Experiments.Add(experiment);
+          return View(model);
+        }
+
+        public ActionResult DeleteExperiment(string experiment) {
+          ControllerService.withControllerService<bool>((service) => {
+            User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+            return service.DeleteExperiment(u, experiment);
+          });
+          return RedirectToAction("Edit");
+        }
+    }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/OptimizationController.cs	(revision 9215)
@@ -11,4 +11,5 @@
 using HeuristicLab.Services.Optimization.Web.Models;
 using HeuristicLab.Services.Optimization.ControllerService.General;
+using HeuristicLab.Services.Optimization.Web.Helpers;
 
 namespace HeuristicLab.Services.Optimization.Web.Controllers
@@ -16,41 +17,20 @@
     [Authorize(Roles="Web User")]
     public class OptimizationController : Controller
-    {
-      public static readonly string DEFAULT_CONTROLLER_ENDPOINT = Configuration.ControllerEndpointName;
+    {     
+        private ControllerServiceHelper ControllerService {
+          get {
+            var helper = new ControllerServiceHelper(Session["pw"] as string);
+            if (!helper.Valid) {
+              Response.Redirect("/Account/Logon?ReturnUrl=%2fOptimization");
+            }
+            return helper;
+          }
+        }
 
-      public delegate T ControllerServiceDelegate<T>(IControllerService service);
-      public delegate void ControllerServiceDelegate(IControllerService service);
-
-      public T withControllerService<T>(ControllerServiceDelegate<T> del) {
-        if (Session["pw"] == null)
-          Response.Redirect("/Account/Logon");
-
-        using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {
-          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
-          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
-          credentialBehaviour.UserName.Password = Session["pw"] as string;
-          var controllerProxy = cf.CreateChannel();
-          return del(controllerProxy);
-        }
-      }
-
-      public void withControllerService(ControllerServiceDelegate del) {
-        if (Session["pw"] == null)
-          Response.Redirect("/Account/Logon");
-
-        using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {          
-          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
-          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
-          credentialBehaviour.UserName.Password = Session["pw"] as string;          
-          var controllerProxy = cf.CreateChannel();
-          del(controllerProxy);
-        }
-      }
         //
-        // GET: /Optimization/        
-
+        // GET: /Optimization/   
         public ActionResult Index()
         {
-          var optModel = withControllerService<OptimizationModel>((service) => {
+          var optModel = ControllerService.withControllerService<OptimizationModel>((service) => {
             OptimizationModel model = new OptimizationModel();
             model.Scenarios = service.GetOptimizationScenarios();
@@ -58,10 +38,10 @@
             model.Jobs = service.GetJobs(u);
             return model;
-          });
+          });          
           return View(optModel);
         }
 
         public ActionResult ProblemParameters(string scenario) {
-          var optScenario = withControllerService<OptimizationScenario>((service) => {
+          var optScenario = ControllerService.withControllerService<OptimizationScenario>((service) => {
             return service.GetOptimizationScenarioByName(scenario);
           });
@@ -77,9 +57,9 @@
 
         public ActionResult JobDetails(string jobId) {
-          Job job = withControllerService<Job>((service) => {
+          Job job = ControllerService.withControllerService<Job>((service) => {
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
             return service.GetJob(u, jobId);
           });
-          var runs = withControllerService<IList<Run>>((service) => {
+          var runs = ControllerService.withControllerService<IList<Run>>((service) => {
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
             return service.GetJobResults(u, jobId);
@@ -92,7 +72,7 @@
         [HttpPost]
         public ActionResult JobDetails(Job job) {
-          withControllerService((service) => {
+          ControllerService.withControllerService<bool>((service) => {
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
-            service.DeleteJob(u, job.Id);
+            return service.DeleteJob(u, job.Id);
           });
           return RedirectToAction("Index");
@@ -125,14 +105,10 @@
         [HttpPost]
         public ActionResult ScheduleJob(ScheduleJobModel jobModel) {
-          using (var cf = new ChannelFactory<IControllerService>(OptimizationController.DEFAULT_CONTROLLER_ENDPOINT)) {
-            var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
-            credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;
-            credentialBehaviour.UserName.Password = Session["pw"] as string;
-            var controllerProxy = cf.CreateChannel();
+          var success = ControllerService.withControllerService<bool>((service) => {
             User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
             var scenario = Session["scenario"] as OptimizationScenario;
             var details = new JobExecutionDetails() { Group = jobModel.Group, JobTitle = jobModel.Name, Repititions = jobModel.Repetitions };
-            controllerProxy.ScheduleOptimizationScenario(u, scenario, details);
-          }
+            return service.ScheduleOptimizationScenario(u, scenario, details);
+          });
           return RedirectToAction("Index");
         }
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/StatusController.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/StatusController.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Controllers/StatusController.cs	(revision 9215)
@@ -0,0 +1,56 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using HeuristicLab.Services.Optimization.Web.Models;
+using HeuristicLab.Services.Optimization.Web.Helpers;
+using System.Web.Security;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+
+namespace HeuristicLab.Services.Optimization.Web.Controllers
+{
+  public class StatusController : Controller {
+    private ControllerServiceHelper ControllerService {
+      get {
+        var helper = new ControllerServiceHelper(Session["pw"] as string);
+        if (!helper.Valid) {
+          Response.Redirect("/Account/Logon?ReturnUrl=%2fStatus");
+        }
+        return helper;
+      }
+    }
+
+    //
+    // GET: /Status/
+
+    public ActionResult Index() {
+      var statModel = ControllerService.withControllerService<StatusModel>((service) => {
+        var model = new StatusModel();
+        User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+        model.Jobs = service.GetJobs(u).ToList();
+        return model;
+      });
+      return View(statModel);
+    }
+
+    [HttpGet]
+    public JsonResult GetTasks(string jobId) {      
+      var job = ControllerService.withControllerService<Job>((service) => {        
+        User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };        
+        return service.GetTasks(u, jobId);
+      });
+
+      return Json(job, JsonRequestBehavior.AllowGet);
+    }
+
+    [HttpGet]
+    public JsonResult GetTaskData(string jobId, string taskId) {
+      var t1 = ControllerService.withControllerService<Task>((service) => {
+        User u = new User() { Username = Membership.GetUser().UserName, Password = Session["pw"] as string };
+        return service.GetTaskData(u, jobId, taskId);
+      });
+      return Json(t1, JsonRequestBehavior.AllowGet);
+    }
+  }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Helpers/ControllerService.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Helpers/ControllerService.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Helpers/ControllerService.cs	(revision 9215)
@@ -0,0 +1,41 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using HeuristicLab.Services.Optimization.ControllerService.General;
+using HeuristicLab.Services.Optimization.ControllerService;
+using System.ServiceModel;
+using System.Web.Security;
+using System.ServiceModel.Description;
+
+namespace HeuristicLab.Services.Optimization.Web.Helpers
+{
+    public class ControllerServiceHelper
+    {
+      public static readonly string DEFAULT_CONTROLLER_ENDPOINT = Configuration.ControllerEndpointName;
+
+      public delegate T ControllerServiceDelegate<T>(IControllerService service);
+      
+      private string pw;
+
+      public ControllerServiceHelper(string pw) { 
+        this.pw = pw;
+      }
+
+      public bool Valid { get { return pw != null; } }
+
+      public T withControllerService<T>(ControllerServiceDelegate<T> del) {
+        if (!Valid)
+          return default(T);
+
+        using (var cf = new ChannelFactory<IControllerService>(DEFAULT_CONTROLLER_ENDPOINT)) {
+          var credentialBehaviour = cf.Endpoint.Behaviors.Find<ClientCredentials>();
+          credentialBehaviour.UserName.UserName = Membership.GetUser().UserName;          
+          credentialBehaviour.UserName.Password = pw;
+          var controllerProxy = cf.CreateChannel();
+          return del(controllerProxy);
+        }
+      }
+    }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/HeuristicLab.Services.Optimization.Web.csproj	(revision 9215)
@@ -97,17 +97,30 @@
   </ItemGroup>
   <ItemGroup>
+    <Content Include="Content\dynatree\dist\jquery.dynatree.min.js" />
+    <Content Include="Content\dynatree\src\skin\icons-rtl.gif" />
+    <Content Include="Content\dynatree\src\skin\icons.gif" />
+    <Content Include="Content\dynatree\src\skin\loading.gif" />
+    <Content Include="Content\dynatree\src\skin\ui.dynatree.css" />
+    <Content Include="Content\dynatree\src\skin\vline-rtl.gif" />
+    <Content Include="Content\dynatree\src\skin\vline.gif" />
+    <Content Include="Content\ExperimentSupport.js" />
     <Compile Include="Controllers\AccountController.cs" />
     <Compile Include="Controllers\AdminController.cs" />
     <Compile Include="Controllers\ChartController.cs" />
+    <Compile Include="Controllers\ExperimentController.cs" />
     <Compile Include="Controllers\HomeController.cs" />
     <Compile Include="Controllers\OptimizationController.cs" />
+    <Compile Include="Controllers\StatusController.cs" />
     <Compile Include="Global.asax.cs">
       <DependentUpon>Global.asax</DependentUpon>
     </Compile>
+    <Compile Include="Helpers\ControllerService.cs" />
     <Compile Include="Mockup\MockupMembershipProvider.cs" />
     <Compile Include="Models\AccountModels.cs" />
     <Compile Include="Models\AdminModels.cs" />
     <Compile Include="Models\ChartModels.cs" />
+    <Compile Include="Models\ExperimentModel.cs" />
     <Compile Include="Models\OptimizationModels.cs" />
+    <Compile Include="Models\StatusModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="WebRole.cs" />
@@ -131,4 +144,5 @@
     <Content Include="Content\datatable\images\sort_desc.png" />
     <Content Include="Content\datatable\images\sort_desc_disabled.png" />
+    <Content Include="Content\hl\images\ajax-loader.gif" />
     <Content Include="Content\jqplot\src\changes.txt" />
     <Content Include="Content\jqplot\src\excanvas.js" />
@@ -273,4 +287,42 @@
     <Content Include="Scripts\modernizr-1.7.js" />
     <Content Include="Scripts\modernizr-1.7.min.js" />
+    <Content Include="Views\Account\ChangePassword.cshtml" />
+    <Content Include="Views\Account\ChangePasswordSuccess.cshtml" />
+    <Content Include="Views\Account\LogOn.cshtml" />
+    <Content Include="Views\Account\Register.cshtml" />
+    <Content Include="Views\Admin\Index.cshtml" />
+    <Content Include="Views\Chart\GenerateChart.cshtml" />
+    <Content Include="Views\Experiment\Edit.cshtml" />
+    <Content Include="Views\Experiment\Index.cshtml" />
+    <Content Include="Views\Home\About.cshtml" />
+    <Content Include="Views\Home\Index.cshtml" />
+    <Content Include="Views\Optimization\AlgorithmParameters.cshtml" />
+    <Content Include="Views\Optimization\Copy of JobDetails.cshtml" />
+    <Content Include="Views\Optimization\Index.cshtml">
+      <SubType>Code</SubType>
+    </Content>
+    <Content Include="Views\Optimization\JobDetails.cshtml" />
+    <Content Include="Views\Optimization\ProblemParameters.cshtml" />
+    <Content Include="Views\Optimization\ScheduleJob.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\AlgorithmParameters.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\BoolValue.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\DecimalMatrix.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\DecimalValue.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\DecimalVector.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\ProblemParameters.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\StringValue.cshtml" />
+    <Content Include="Views\Shared\DisplayTemplates\TypeValue.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\AlgorithmParameters.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\BoolValue.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\DecimalMatrix.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\DecimalValue.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\DecimalVector.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\ProblemParameters.cshtml" />
+    <Content Include="Views\Shared\EditorTemplates\TypeValue.cshtml" />
+    <Content Include="Views\Shared\Error.cshtml" />
+    <Content Include="Views\Shared\_Layout.cshtml" />
+    <Content Include="Views\Shared\_LogOnPartial.cshtml" />
+    <Content Include="Views\Web.config" />
+    <Content Include="Views\_ViewStart.cshtml" />
     <Content Include="Web.config">
       <SubType>Designer</SubType>
@@ -293,15 +345,4 @@
     <Content Include="Scripts\MicrosoftMvcValidation.js" />
     <Content Include="Scripts\MicrosoftMvcValidation.debug.js" />
-    <Content Include="Views\_ViewStart.cshtml" />
-    <Content Include="Views\Account\ChangePassword.cshtml" />
-    <Content Include="Views\Account\ChangePasswordSuccess.cshtml" />
-    <Content Include="Views\Account\LogOn.cshtml" />
-    <Content Include="Views\Account\Register.cshtml" />
-    <Content Include="Views\Home\About.cshtml" />
-    <Content Include="Views\Home\Index.cshtml" />
-    <Content Include="Views\Shared\Error.cshtml" />
-    <Content Include="Views\Shared\_LogOnPartial.cshtml" />
-    <Content Include="Views\Shared\_Layout.cshtml" />
-    <Content Include="Views\Web.config" />
   </ItemGroup>
   <ItemGroup>
@@ -310,7 +351,4 @@
   <ItemGroup>
     <Content Include="packages.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Optimization\Index.cshtml" />
   </ItemGroup>
   <ItemGroup>
@@ -321,59 +359,5 @@
   </ItemGroup>
   <ItemGroup>
-    <Content Include="Views\Optimization\ProblemParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Optimization\AlgorithmParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Optimization\ScheduleJob.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\ProblemParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\DecimalValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\BoolValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\TypeValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\DecimalMatrix.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\DecimalVector.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\EditorTemplates\AlgorithmParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\AlgorithmParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\TypeValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\BoolValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\DecimalMatrix.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\DecimalValue.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\DecimalVector.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Shared\DisplayTemplates\ProblemParameters.cshtml" />
-  </ItemGroup>
-  <ItemGroup>
     <Content Include="HeuristicLab 3.3.exe.config" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="Views\Optimization\JobDetails.cshtml" />
   </ItemGroup>
   <ItemGroup>
@@ -384,8 +368,5 @@
       <SubType>Designer</SubType>
     </None>
-    <Content Include="Views\Admin\Index.cshtml" />
-    <Content Include="Views\Chart\GenerateChart.cshtml" />
-    <Content Include="Views\Optimization\Copy of JobDetails.cshtml" />
-    <Content Include="Views\Shared\DisplayTemplates\StringValue.cshtml" />
+    <Content Include="Views\Status\Index.cshtml" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/ExperimentModel.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/ExperimentModel.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/ExperimentModel.cs	(revision 9215)
@@ -0,0 +1,41 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace HeuristicLab.Services.Optimization.Web.Models {
+  public class Node {
+    public string title { get; set; }
+    public List<Node> children { get; set; }
+
+    public string GetTitle { get { return title; } }
+    public List<Node> GetChildren { get { return children; } }
+  }
+
+  public class ExperimentModel {
+    public Node Experiment { get; set; }
+    public string Name { get; set; }
+  }
+
+  public class ExperimentViewModel {
+    private IList<string> scenarios;
+
+    public IList<string> Scenarios {
+      get { return scenarios; }
+      set { scenarios = value; }
+    }
+
+    private IList<string> experiments;
+
+    public IList<string> Experiments {
+      get { return experiments; }
+      set { experiments = value; }
+    }
+
+    public ExperimentViewModel() {
+      experiments = new List<string>();
+      scenarios = new List<string>();
+    }
+
+  }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/StatusModel.cs
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/StatusModel.cs	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Models/StatusModel.cs	(revision 9215)
@@ -0,0 +1,27 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using HeuristicLab.Services.Optimization.ControllerService.Model;
+
+namespace HeuristicLab.Services.Optimization.Web.Models {
+  /*public class Job {
+    public string Id { get; set; }
+    private IList<Task> tasks = new List<Task>();
+
+    public IList<Task> Tasks {
+      get { return tasks; }
+      set { tasks = value; }
+    }
+  }*/
+
+  public class StatusModel {
+    // Jobs
+    private IList<Job> jobs = new List<Job>();
+
+    public IList<Job> Jobs {
+      get { return jobs; }
+      set { jobs = value; }
+    }
+  }
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Account/LogOn.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Account/LogOn.cshtml	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Account/LogOn.cshtml	(revision 9215)
@@ -14,6 +14,5 @@
 
 @Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")
-
-@using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { @class = "hl-signon-form" })) {
+@using (Html.BeginForm("LogOn", "Account", new { ReturnUrl = Request.QueryString["ReturnUrl"] }, FormMethod.Post, new { @class ="hl-signon-form" })) {
         <fieldset>
             <legend>Account Information</legend>
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Edit.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Edit.cshtml	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Edit.cshtml	(revision 9215)
@@ -0,0 +1,21 @@
+﻿@model HeuristicLab.Services.Optimization.Web.Models.ExperimentViewModel
+
+@{
+    ViewBag.Title = "Edit";
+}
+
+<h2>Edit your experiments</h2>
+
+<ul>
+@foreach (var exp in Model.Experiments) {
+   <li>@Html.ActionLink("Delete " + exp, "DeleteExperiment", new { experiment = exp })</li>
+}
+</ul>
+
+@section submenu {
+    <ul>
+        <li>@Html.ActionLink("Build", "Index")</li>    
+        <li class="selected">@Html.ActionLink("Edit", "Edit")</li>
+        <li>@Html.ActionLink("Status", "Index", "Status")</li>
+    </ul>
+}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Index.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Index.cshtml	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Experiment/Index.cshtml	(revision 9215)
@@ -0,0 +1,66 @@
+﻿@model HeuristicLab.Services.Optimization.Web.Models.ExperimentViewModel
+
+@{
+    ViewBag.Title = "Experiments";
+}
+
+<h2>Build your experiment:</h2>
+@using (Html.BeginForm("SaveExperiment", "Experiment"))
+{
+  <fieldset>
+    <legend>Create Template Experiment:</legend>
+    
+    <div class="editor-label">
+      <label for="name">Experiment Template Name:</label>
+    </div>
+
+    <div class="editor-field">
+      <input id="name" name="Name" type="text" value="My Experiment" />
+    </div>
+
+    <div>
+    <p>Experiment Tree:</p>
+    </div>
+
+    <div id="container" class="treeStyle">
+      <ul>
+        <li id="root">Experiment</li>
+      </ul>
+    </div>
+    <input style="margin-top:5px;"  name="RemoveNode" type="button" value="Remove" disabled="disabled" />
+
+    <div id="scenarios">
+    @if (Model.Scenarios.Count > 0) {
+        <p>Choose an algorithm:</p>
+        foreach (var scen in Model.Scenarios) {
+            <div class="dragables" id="@scen"><p>@scen</p></div>
+        }        
+        
+    }
+        <div class="clearer"/>
+    </div>
+    
+    <div id="experiments">
+    @if (Model.Scenarios.Count > 0) {
+        <p>Choose from your stored experiments:</p>
+        foreach (var scen in Model.Experiments) {
+            <div class="dragables" id="@scen"><p>@scen</p></div>
+        }       
+        
+    }   
+        <div class="clearer"/> 
+    </div>
+    <input type="submit" value="Save experiment" class="submitter" />
+    <img src="@Url.Content("~/Content/hl/images/ajax-loader.gif")" alt="Loading animation" class="loader unseen" />
+  </fieldset>
+    <div><p id="jsonMessage"></p></div>
+}
+
+
+@section submenu {
+    <ul>
+        <li class="selected">@Html.ActionLink("Build", "Index")</li>    
+        <li>@Html.ActionLink("Edit", "Edit")</li>
+        <li>@Html.ActionLink("Status", "Index", "Status")</li>
+    </ul>
+}
Index: anches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/DisplayTemplates/InputParameters.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/DisplayTemplates/InputParameters.cshtml	(revision 9214)
+++ 	(revision )
@@ -1,10 +1,0 @@
-﻿@model HeuristicLab.Services.Optimization.ControllerService.Model.InputParameters
-
-@foreach (var itm in Model.Items) {
-    <div class="editor-label param-input">
-        @Html.Label(itm.Value.Name, itm.Value.Name)
-    </div>
-    <div class="editor-label">
-        @Html.DisplayFor(model => itm.Value)
-    </div>
-}
Index: anches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/EditorTemplates/InputParameters.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/EditorTemplates/InputParameters.cshtml	(revision 9214)
+++ 	(revision )
@@ -1,10 +1,0 @@
-﻿@model HeuristicLab.Services.Optimization.ControllerService.Model.InputParameters
-
-@foreach (var itm in Model.Items) {
-    <div class="editor-label">
-        @Html.Label(itm.Value.Name, itm.Value.Name)
-    </div>
-    <div class="editor-field">
-        @Html.EditorFor(model => itm.Value)
-    </div>
-}
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml	(revision 9214)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Shared/_Layout.cshtml	(revision 9215)
@@ -26,4 +26,8 @@
     <script type="text/javascript" src="@Url.Content("~/Content/jqplot/src/plugins/jqplot.donutRenderer.js")"></script>
     <script type="text/javascript" src="@Url.Content("~/Content/jqplot/src/plugins/jqplot.cursor.js")"></script>
+
+    <link href="@Url.Content("~/Content/dynatree/src/skin/ui.dynatree.css")" rel="stylesheet" type="text/css" />
+    <script type="text/javascript" src="@Url.Content("~/Content/dynatree/dist/jquery.dynatree.min.js")"></script>
+    <script type="text/javascript" src="@Url.Content("~/Content/ExperimentSupport.js")"></script>
 </head>
 <body>
@@ -40,6 +44,7 @@
         <div id="master-mainmenu">
             <ul id="menu">
-                <li>@Html.ActionLink("Admin", "Index", "Admin")</li>
                 <li>@Html.ActionLink("Home", "Index", "Home")</li>
+                <li>@Html.ActionLink("Experiment", "Index", "Experiment")</li>                
+                <li>@Html.ActionLink("Admin", "Index", "Admin")</li>                
                 <li>@Html.ActionLink("About", "About", "Home")</li>
             </ul>
@@ -47,5 +52,7 @@
         
         <div id="master-main">
-            <div id="master-submenu"/>
+            <div id="master-submenu">
+                @RenderSection("submenu", required: false)
+            </div>
             <div id="master-MainContent">                
                 @RenderBody()                
Index: /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Status/Index.cshtml
===================================================================
--- /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Status/Index.cshtml	(revision 9215)
+++ /branches/OaaS/HeuristicLab.Services.Optimization.Web/Views/Status/Index.cshtml	(revision 9215)
@@ -0,0 +1,109 @@
+﻿@model HeuristicLab.Services.Optimization.Web.Models.StatusModel
+
+@{
+    ViewBag.Title = "Job Status";
+}
+
+<script type="text/javascript">
+    function convertTaskToNode(task) {
+        var currentTask = { title: task.General.Name, tooltip: task.General.Id };
+        var children = [];
+        for (var i = 0; i < task.Children.length; i++) {
+            var node = convertTaskToNode(task.Children[i]);
+            children.push(node);
+        }
+        if (children.length > 0)
+            currentTask["children"] = children;
+        return currentTask;
+    }
+
+    function convertTaskDataToNodes(taskData) {
+        var children = [];
+        for (var i = 0; i < taskData.Tasks.length; i++) {
+            var node = convertTaskToNode(taskData.Tasks[i]);
+            children.push(node);
+        }
+        return children;
+    }
+
+    function updateTree(jobId) {
+        $.ajax({
+            type: "GET",
+            url: '/Status/GetTasks',
+            data: { jobId: jobId },
+            contentType: "application/json; charset=utf-8",
+            dataType: "json",
+            success: function (result) {
+                var rootNode = $("#container").dynatree("getRoot");
+                rootNode.removeChildren();
+                var children = convertTaskDataToNodes(result);
+                for (var i = 0; i < children.length; i++)
+                    rootNode.addChild(children[i]);
+            }
+        });
+    }
+
+    function updateJobDetails(details) {
+        $('#details').empty();
+        var props = details.General.Properties;
+        for (var i = 0; i < props.length; i++) {
+            $("<p></p>").text(props[i].Key + ": " + props[i].Value).appendTo('#details');
+        }
+
+        $("<p></p>").text("Task state: " + details.State.State).appendTo('#details');
+        $("<p></p>").text("Date created: " + details.State.DateCreated).appendTo('#details');
+        $("<p></p>").text("Date finished: " + details.State.DateFinished).appendTo('#details');
+        $("<p></p>").text("Execution Time: " + details.State.ExecutionTime).appendTo('#details');
+    }
+
+    function updateDetails(taskId) {
+        var jobId = $('.selectedJob').attr("href").substr(1);
+        $.ajax({
+            type: "GET",
+            url: '/Status/GetTaskData',
+            data: { jobId: jobId, taskId: taskId },
+            contentType: "application/json; charset=utf-8",
+            dataType: "json",
+            success: updateJobDetails
+        });
+    }
+
+    $(document).ready(function () {
+        var tree = $('#container').dynatree({
+            onActivate: function (node) {
+                updateDetails(node.data.tooltip);
+            }
+        });  // no special tree required
+        $('a[class="JobRef"]').click(function (e) {
+            $('a[class="JobRef"]').removeClass("selectedJob");
+            $(this).addClass("selectedJob");
+            updateTree($(this).attr("href").substr(1));
+        });
+    });
+  
+</script>
+
+<h2>Job-Status</h2>
+
+@for (var i = 0; i < Model.Jobs.Count; i++ ) {
+    var jobId = "#" + Model.Jobs[i].Id;
+    <a href="@jobId"  class="JobRef">Details Job @i</a>
+}
+
+
+<div id="container" class="treeStyle">
+  <ul>
+  </ul>
+</div>
+
+<div id="details">
+  <p>-</p>
+</div>
+
+@section submenu {
+    <ul>
+        <li>@Html.ActionLink("Build", "Index")</li>    
+        <li>@Html.ActionLink("Edit", "Edit")</li>
+        <li class="selected">@Html.ActionLink("Status", "Index", "Status")</li>
+    </ul>
+}
