enyo.kind({
	name: "App",
	kind: "FittableRows",
	fit: true,
  tokens: [],
	components:[
		{kind: "onyx.Toolbar", content: "WebLetter"},
		{kind: "enyo.Scroller", fit: true,
      components: [
      //{name: "mylogger", content: "log", allowHtml: true},
			{name: "main", classes: "nice-padding", allowHtml: true, components: [
        {kind: "onyx.Groupbox", name: "settings", components: [
          {kind: "WebLetter.BooleanToken", key: "folding", description: "Folding Marks"},
          {kind: "WebLetter.BooleanToken", key: "togglefromphone", description: "Phone"},
          {kind: "WebLetter.BooleanToken", key: "togglefromlogo", description: "Logo"}
          ]
        },
        {kind: "WebLetter.AddressToken", name: "addresser", description: "Addresser", key: "from"},
        {kind: "WebLetter.AddressToken", name: "addressee", description: "Addressee", key: "to"},
        {kind: "onyx.Groupbox", name: "contentGroup", components: [
          {kind: "WebLetter.TextToken", description: "Subject", key: "subject", isOptional: true},
          {kind: "WebLetter.TextToken", description: "Opening", key: "opening"},
          {kind: "WebLetter.TextAreaToken", name: "lettercontent", allowHtml: true, key: "content", description: "Content", inputWidth: "800px", inputHeight: "400px"},
          {kind: "WebLetter.TextToken", key: "closing", description: "Closing"}
          ]
        },
        {tag: "form", name: "pdfform", attributes: {action: "http://localhost/webletter/server/letter.php", method: "post"}, showing: false},
          {kind: "onyx.Button", name: "go", content: "Generate PDF", ontap: "go"}
        ]
      }
		]}
	],
  create: function() {
    this.inherited(arguments);
    this.$.tokens = new Array();
  },
  handlers: {
    onNewToken: "registerToken",
    onDisableToken: "deregisterToken"
  },
  registerToken: function(inSender, inEvent) {
    this.tokens.push(inEvent.originator);
  },
  deregisterToken: function(inSender, inEvent) {
    var index = this.tokens.indexOf(inEvent.originator);
    while (index != -1) {
      this.tokens.splice(index, 1);
      index = this.tokens.indexOf(inEvent.originator);
    }
  },
  go: function() {
    //this.$.mylogger.addContent(this.$.lettercontent.getValue());
    this.$.pdfform.destroyComponents();
    for (i in this.tokens) {
      var type;
      var content = "";
      var value = "";
      if (this.tokens[i].multiline) {
        type = "textarea";
        content = this.tokens[i].getInput();
      } else {
        type = "input";
        value = this.tokens[i].getInput();
      }
      this.$.pdfform.createComponent({tag: type, attributes: {name: this.tokens[i].key, value: value}, content: content});
    }
    this.$.pdfform.render();
    document.getElementById(this.$.pdfform.getAttribute("id")).submit();
  }

});

@@ -2567,24 +2567,104 @@
 ();%0A      %7D%0A
+      var keyprefix = %22token-%22;%0A      var key = keyprefix + this.tokens%5Bi%5D.key;%0A
       this.$
@@ -2719,31 +2719,16 @@
  %7Bname: 
-this.tokens%5Bi%5D.
 key, val

add the 'token-' prefix to all token keys