   base = document if not base?
   base.querySelectorAll sel
 
+HTMLElement::on = (evt, func, bubble) ->
+  if evt.constructor.name is 'Array'
+    this.addEventListener e, func, bubble for e in evt
+  else
+    # add a touchend event automatically for click events
+    if evt is 'click'
+      this.addEventListener 'touchend', func, bubble
+    this.addEventListener evt, func, bubble
+  
 ajaxPost = (path, data, async, callbacks) ->
   x = new XMLHttpRequest()
 
-  switch typeof(callbacks)
-    when 'object'
-      x.addEventListener(evt, callback, false) for evt, callback of callbacks
-
-    when 'function'
-      x.addEventListener 'load', callbacks, true
+  if callbacks?
+    switch typeof(callbacks)
+      when 'object'
+        x.addEventListener(evt, callback, false) for evt, callback of callbacks
+
+      when 'function'
+        x.addEventListener 'load', callbacks, true
 
   x.open 'post', path, async
 

      else
        resp = JSON.parse x.response
        alert resp.msg

main = ->
  pairs = [

      console.log "Element: #{pair[0]}"
      console.log e.stack

  if (page = $('body').getAttribute 'id').length > 0
    THIS = new pageObjects[page]()

window.addEventListener 'load', main, true
window.addEventListener 'load', ->
  $('head').appendChild make 'script',
