title: Javascript Delegate issue
body: <p>So far I haven't been able to grok any Delegate function tutorials out there for Javascript. Even less so the ones with parameters.</p>
  
  <p>Hopefully my current problem will provide a good example. (XXXX() is a function I am passing to Fee())</p>
  
  <p>The way I have it now, my "delegate", (XXXX()) executes as soon as Fee() is called, not when I want it to be called (somewhere inside of Fee())</p>
  
  <p>line of code that calls function:</p>
  
  <pre><code>Fee(prod, item, "usage", i, y, XXXX(prod, y));
  </code></pre>
  
  <p>Function: </p>
  
  <pre><code>function Fee(prod, item, name, i, y, func) {
  
      var open = false;
      var prefix = "#" + prod + name;
  
      $(prefix + y).click(function () {
          var feeBoxName = prefix + "FeeBox" + y;
  
          if (open == false) {
  
              FeeOpen(prefix, y);
  
              func; //delegate is called here
  
              AddFeeButton(feeBoxName, "addFeeBtn2");
              open = true;
          } else {
  
              FeeClosed(prefix, y);
              open = false;
          }
      });
  }
  </code></pre>
  
  <p>Delegate function:</p>
  
  <pre><code>function XXXX(prod, y) {
      var deducedFeeBoxName = "#" + prod + "usageFeeBox" + y;
      alert(deducedFeeBoxName); //at present, this is called immediately when Fee is executed 
  
      UsageFeeBoxHeader(deducedFeeBoxName);
      UsageFeeBoxData(deducedFeeBoxName, prod, y);
  }
  </code></pre>
  
  <p>Comments?</p>