  /* 
     LONG BORING NOTE:
     There is apparently no good way to upload a file via Ajax.
     Instead we use a hidden iframe as the target for the handleUpload.php
     action.  The iframe will stay hidden, but the event will trigger a
     tooltip that get's it content from the iframe.  Thus achieving the 
     appearance of an Ajax file upload.  Whew!
  */

  var intervalId;

  /* This function is call via setInterval when the form button is clicked.
   * It checks every half second or so for results from the server.  If
   * results are available it displays the tool tip and then cancels.
   */
  function checkForFinishedUpload()
  {
    if (document.getElementById("upload_target").contentWindow.document.getElementById("upload_results") != null)
    {
      $("#upload_target").btOn();
      clearInterval(intervalId);
      $("input").attr("value","");
      $("#sendfile").attr("value","Submit");
      $("textarea").attr("value","");
      //$("textarea").attr("
    }
  }

  $(document).ready(function(){
    // set iframe as target for submit action
    $("#yourform").submit(function() { $("#yourform").attr("target","upload_target"); });

    // define tool tip properties
    $('#upload_target').bt({
      shadow: true,
      padding: 20,
      animate: true,
      distance: 0,
      speed: 500,
      width: 180,
      spikeLength: 0,
      spikeGirth: 0,
      cornerRadius: 40,
      fill: 'rgba(0, 0, 0, .8)',
      strokeWidth: 3,
      positions: ['right'],
      strokeStyle: '#0a0',
      contentSelector: "document.getElementById('upload_target').contentWindow.document.getElementById('upload_results').childNodes[0].nodeValue",
      cssStyles: {color: '#FFF', fontWeight: 'bold'}
    });

		$("div.type3").append("Confirm Email Address:<br/><input type=\"text\" name=\"confirm-email\" /><br/>\n");
  });


