Index: js/viewer-f0/js/main.js
===================================================================
--- js/viewer-f0/js/main.js	(revision 161)
+++ js/viewer-f0/js/main.js	(revision 172)
@@ -1,7 +1,13 @@
-var geneWindow =
+var Viewer =
 {
+
+    Mode: {
+        LINK: 0,
+        EMBEDDED: 1,
+        TEXTAREA: 2,
+        CODE : 3
+    },
     context: undefined,
-    urlToXML: "f0def.xml",
-    debugCreatureName: "test",
+    urlToXML: "f0def.xml",//"http://www.framsticks.com/files/apps/config/f0def.xml",
     xml: undefined,
     model: new Model(),
@@ -14,5 +20,5 @@
     neurons: [],
     neuroConns: [],
-    neuroClasses: [],
+    neuroClasses: {},
     modelOne: undefined,
     _graphicsEngine: new GraphicsEngine(),
@@ -21,5 +27,5 @@
         var local = this;
         $.ajax({
-            url: "http://www.framsticks.com/files/apps/config/f0def.xml",
+            url: local.urlToXML,
             dataType: "xml",
             async: false,
@@ -66,7 +72,8 @@
         {
             var neuroClass = new NeuroClass();
+            this.neuroClasses[data[i].attributes[0].value] = neuroClass;
             neuroClass.setModel(data);
-            this.neuroClasses.push(neuroClass);
-        }
+        }
+
     },
     analyseLine: function (line) {
@@ -119,8 +126,25 @@
             })
     },
-    downloadCreature: function () {
-        var lines;
+    getCreature: function (mode, content) {
+
+        var lines = undefined;
+        if(mode == this.Mode.LINK)
+            lines = this._getCreatureFromLink(content);
+        else if(mode == this.Mode.EMBEDDED)
+            lines = this._getCreatureFromEmbeddedCode(content);
+        else if (mode == this.Mode.TEXTAREA)
+            lines = this._getCreatureFromTextArea(content);
+        else if(mode == this.Mode.CODE)
+            lines = this._getCreatureFromCode(content);
+        else
+        {
+            throw "Wrong mode in function getCreature";
+        }
+        return lines;
+    },
+    _getCreatureFromLink: function(link){
+        var lines = undefined;
         $.ajax({
-            url: "http://localhost:63343/FramestickFavi/creatures/" + this.debugCreatureName + ".txt",
+            url: link,
             async: false,
             dataType: "text",
@@ -132,14 +156,39 @@
                 alert("Can't download creature");
             }
-
-        });
-
-        //lines = $("#geno").val();
-        //lines = lines.split("\n");
-
-        return lines;
-    },
-    parseCreature: function () {
-        var lines = this.downloadCreature();
+        });
+        return lines;
+    },
+    _getCreatureFromTextArea: function(area){
+        var lines = undefined;
+        lines = area.val();
+        lines = lines.split("\n");
+        return lines;
+    },
+    _getCreatureFromCode: function(code){
+        var lines = code;
+        lines = lines.split("\n");
+        return lines;
+    },
+    _getCreatureFromEmbeddedCode: function(link){
+        var lines = undefined;
+
+        $.ajax({
+            url: link,
+            async: false,
+            dataType: "html",
+            success: function (data) {
+                var geno = $($(data).find("div")[0]).comments().html();
+                geno = geno.replace("FRED_GEN", "");
+                lines = geno.split("\n");
+            },
+            error: function () {
+                alert("Can't download creature");
+            }
+        });
+
+        return lines;
+    },
+    parseCreature: function (mode, content) {
+        var lines = this.getCreature(mode, content);
         lines.splice(0, 1);
         var local = this;
@@ -164,21 +213,26 @@
         this._graphicsEngine.initializeScene();
         this.renderCreature();
-        //this._graphicsEngine.debugTest();
+        this._graphicsEngine.debugTest();
         this._graphicsEngine.renderScene();
 
         this._neuronDrawer.initializeScene();
         new SmartLayout(this.neurons, this.neuroConns);
-        this._neuronDrawer.drawNetwork(this.neurons, this.neuroConns, einfos);
+        this._neuronDrawer.drawNetwork(this.neurons, this.neuroConns, einfos, this.neuroClasses);
         this._neuronDrawer.renderScene();
 
     }
-
 }
 
 function openWindow() {
-    geneWindow.downloadXML();
-    geneWindow.parseGeneXml();
-    geneWindow.parseCreature();
-    geneWindow.mainLoop();
+    var debugCreatureName = "example4";
+    Viewer.downloadXML();
+    Viewer.parseGeneXml();
+    //Viewer.parseCreature(Viewer.Mode.LINK, "http://localhost:63343/FramestickFavi/creatures/" + debugCreatureName + ".txt");
+    //Viewer.parseCreature(Viewer.Mode.TEXTAREA, $("#geno"));
+    //Viewer.parseCreature(Viewer.Mode.CODE, "//0\np:\np: x=1");
+    Viewer.parseCreature(Viewer.Mode.EMBEDDED, "http://ec.framsticks.com/www/index.php?PAGE=view_genotype&ID=55")
+    Viewer.mainLoop();
+
+
 
 }
