// Copyright 2011 Google Inc. 
// Google BSD license
// johnjbarton@google.com

/*globals define console require window*/
(function() {
   require({
      paths: {
        'q':'../../lib/MetaObject/q',
        'MetaObject': "../../lib/MetaObject",
        'features': '../../features',
        'editor':'../../editor',
        'q-comm':'../../lib/MetaObject/q-comm',
        'lib': "../../lib",
        'orion': '../../editor/orion.client/bundles/org.eclipse.orion.client.editor/web/orion',
        'compiler': "../../compiler",
        'ui':"../../ui",
      }
    }); 
    
    require(['editor/editorInserter', 'editor/editorCompilerAssembly'], function assemble(editorInserter, editorCompilerAssembly) {
      console.log("editorCompilerAssembly loaded");
      editorCompilerAssembly.initialize();
      var parentElt = window.document.body;
      var url = "./cts.js";
      editorInserter.commands.open(parentElt, '500px', url);
    });


}());
@@ -577,230 +577,602 @@
     
-require(%5B'editor/editorInserter', 'editor/editorCompilerAssembly'%5D, function assemble(editorInserter, editorCompilerAssembly) %7B%0A      console.log(%22editorCompilerAssembly loaded%22);%0A      editorCompilerAssembly.initialize();
+function openEditor(editorInserter, url) %7B%0A      var parentElt = window.document.getElementById('editor');%0A      parentElt.setAttribute('height', '500px');%0A      console.log('inserting editor');%0A      editorInserter.commands.open(parentElt, url);%0A    %7D%0A    %0A    function openOutput(editorInserter, url) %7B%0A      var parentElt = window.document.getElementById('output');%0A      parentElt.setAttribute('height', '500px');%0A      console.log('inserting output');%0A      editorInserter.commands.open(parentElt, url);%0A    %7D%0A    %0A    require(%5B'editor/editorInserter'%5D, function assemble(editorInserter) %7B
 %0A   
@@ -1174,33 +1174,31 @@
 %7B%0A      var 
-parentElt
+baseUrl
  = window.do
@@ -1199,111 +1199,227 @@
 dow.
-document.body;%0A      var url = %22./cts.js%22;%0A      editorInserter.commands.open(parentElt, '500px', url);
+location.toString().split('/');%0A      baseUrl.pop(); // remove filename%0A      baseUrl = baseUrl.join('/');%0A      openEditor(editorInserter, baseUrl+'/cts.js');%0A      openOutput(editorInserter, baseUrl+'/cts.js');%0A      
 %0A   

refactor and add 'output' editor