Uncaught ReferenceError when Loading a Bookmarklet
<p>I am trying to build a simple Bookmarklet that will load some external Javascript into a page, the goal is to add a markdown editor like Stackoverflow has to another site.  I have it working but it requires me to click my Bookmarklet button 2 times instead of 1 time.</p>

<p>The first click gives this error...</p>

<pre><code>Uncaught ReferenceError: Markdown is not defined init.js:46
</code></pre>

<p>Line 46 is this...</p>

<pre><code>var converter1 = Markdown.getSanitizingConverter();
</code></pre>

<p>Now after clicking my Bookmarklet for the 2nd time then everything runs perfectly but always the first click will give that error and do nothing.</p>

<p>Here is the code for the Bookmarklet file, please help me to fix, my Javascript skills are not too great.  </p>

<p>Load external JS and CSS files  </p>

<pre><code>function loadScripts(scriptURL) {
    var scriptElem = document.createElement('SCRIPT');
    scriptElem.setAttribute('language', 'JavaScript');
    scriptElem.setAttribute('src', scriptURL);
    void(document.body.appendChild(scriptElem));
}

// Load these 3 Javascript files into the page
// jQuery is already loaded into the page being used so no need to load it
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Converter.js');
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Sanitizer.js');
loadScripts('http://codedevelopr.com/labs/javascript/forrst/Markdown.Editor.js');

// Load the CSS file into the Page
var head = document.getElementsByTagName('head')[0];
$(document.createElement('link')).attr({
    type: 'text/css',
    href: 'http://codedevelopr.com/labs/javascript/forrst/demo.css',
    rel: 'stylesheet'
}).appendTo(head);
</code></pre>

<p>After the files are loaded then we run this...</p>

<pre><code>// Find and replace the curent textarea with the HTML we
// need for our markdown editor to work 
$(document).ready(function () {
    var htmlToReplace = ' \
  &lt;div class="wmd-panel"&gt; \
    &lt;div id="wmd-button-bar"&gt;&lt;/div&gt; \
      &lt;textarea class="wmd-input" id="wmd-input" name="description"&gt;&lt;/textarea&gt; \
  &lt;/div&gt; \
  &lt;div id="wmd-preview" class="wmd-panel wmd-preview"&gt;&lt;/div&gt;';

    $("#description").replaceWith(htmlToReplace);

    //Run the Markdown editor!
    var converter1 = Markdown.getSanitizingConverter();

    var editor1 = new Markdown.Editor(converter1);
    editor1.run();

});
</code></pre>
