(function($) {

  $.fn.dispatchEvent = function(params) {

    // called with one argument
    if(typeof params == "string"){
      params = {eventType:params};
    }

    params = $.extend( {eventType: 'click'}, params);

    this.each(function() {

      // special treatment for click
      if(params.eventType == 'click'){

        if(this.click) {
          this.click();
        }
        else if(this.nodeName == "A") {
          window.location = this.href;
        }
        else {
          $(this).click();
        }
      }
      else {

        $(this).trigger(params.eventType);
      }

    });

    return this;
  };
})(jQuery);




