title: Javascript document.write('HTML CODE HERE') and using a var grabbed by flash
body: <p>so this is 2 questions in one. My first question is how would I do this?</p>
  
  <pre><code>    document.write('
  &lt;div id="jwplayer"&gt;
  &lt;center&gt;
  &lt;div id='mediaplayer'&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    jwplayer('mediaplayer').setup({
      'flashplayer': 'jwplayer/player.swf',
      'id': 'playerID',
      'width': '640',
      'height': '580',
      'provider': 'rtmp',
      'streamer': 'rtmp://domain/recorder/_definst_',
  'file': 'onSaveOk("+streamName+")'
    });
  &lt;/script&gt;
  &lt;/center&gt;
  &lt;/div&gt;
  ');
  </code></pre>
  
  <p>I basically just want to print out that code when the function is called.</p>
  
  <p>This is the second part of my question, this function runs when the flash video recorder finishes saving the recorded video. It grabs all of the variables in the functions arguments from the flash player. I want to use one of the variables in my jwplayer code, how would I do this?</p>
  
  <p>Here is the function:</p>
  
  <pre><code>    function onSaveOk(streamName,streamDuration,userId,cameraName,micName,recorderId){
          //alert("onSaveOk("+streamName+","+streamDuration+","+userId+","+cameraName+","+micName+")");
  
          //the user pressed the [save] button inside the recorder and the save_video_to_db.XXX script returned save=ok
          //recorderId: the recorderId sent via flash vars, to be used when there are many recorders on the same web page
              $('#record').hide();
      document.write('
  &lt;div id="jwplayer"&gt;
  &lt;center&gt;
  &lt;div id='mediaplayer'&gt;&lt;/div&gt;
  &lt;script type="text/javascript"&gt;
    jwplayer('mediaplayer').setup({
      'flashplayer': 'jwplayer/player.swf',
      'id': 'playerID',
      'width': '640',
      'height': '580',
      'provider': 'rtmp',
      'streamer': 'rtmp://domain/recorder/_definst_',
  'file': 'onSaveOk("+streamName+")'
    });
  &lt;/script&gt;
  &lt;/center&gt;
  &lt;/div&gt;
  ');
  
  
      }
  </code></pre>
  
  <p>This is where I try to use the streamName function, but it doesnt work:</p>
  
  <pre><code>'file': 'onSaveOk("+streamName+")'
  </code></pre>
  
  <p>How would I do this? Thanks.</p>