docs: function simulateUIEvent(target /*:HTMLElement*/, type /*:String*/,
                                     bubbles /*:Boolean*/,  cancelable /*:Boolean*/,
                                     view /*:Window*/,        detail /*:int*/) /*:Void*/
      {
  
          //check target
          if (!target){
              throw new Error("simulateUIEvent(): Invalid target.");
          }
  
          //check event type
          if (typeof type == "string"){
              type = type.toLowerCase();
  
              //make sure it's a supported mouse event
              if (!uiEvents[type]){
                  throw new Error("simulateUIEvent(): Event type '" + type + "' not supported.");
              }
          } else {
              throw new Error("simulateUIEvent(): Event type must be a string.");
          }
  
          //try to create a mouse event
          var customEvent = null;
  
  
          //setup default values
          if (typeof bubbles != "boolean"){
              bubbles = (type in bubbleEvents);  //not all events bubble
          }
          if (typeof cancelable != "boolean"){
              cancelable = (type == "submit"); //submit is the only one that can be cancelled
          }
          if (typeof view != "object" || view != null){
              view = window; //view is typically window
          }
          if (typeof detail != "number"){
              detail = 1;  //usually not used but defaulted to this
          }
  
          //check for DOM-compliant browsers first
          if (typeof document.createEvent == "function"){
  
              //just a generic UI Event object is needed
              customEvent = document.createEvent("UIEvents");
              customEvent.initUIEvent(type, bubbles, cancelable, view, detail);
  
              //fire the event
              target.dispatchEvent(customEvent);
  
          } else if (typeof document.createEventObject != "undefined"){ //IE
  
              //create an IE event object
              customEvent = document.createEventObject();
  
              //assign available properties
              customEvent.bubbles = bubbles;
              customEvent.cancelable = cancelable;
              customEvent.view = view;
              customEvent.detail = detail;
  
              //fire the event
              target.fireEvent("on" + type, customEvent);
  
          } else {
              throw new Error("simulateUIEvent(): No event simulation framework present.");
          }
      }