/*
    * JS HELPER MODULE
    * Collection of helper functions/properties   
  */
  var JShelperFunctions = function () {

    // ADD/REMOVE CROSS BROWSER EVENT
    // Native JS handler function
    var _addXEvent, _removeXEvent;
    if (window.addEventListener) {
      _addXEvent = function (obj, type, fn) {
        obj.addEventListener(type, fn, false);
      }
      _removeXEvent = function (obj, type, fn) {
        obj.removeEventListener(type, fn, false);
      }
    } else if (document.attachEvent) {
      _addXEvent = function (obj, type, fn) {
        var eProp = type + fn;
        obj['e' + eProp] = fn;
        obj[eProp] = function () { obj['e' + eProp](window.event); }
        obj.attachEvent('on' + type, obj[eProp]);
      }
      _removeXEvent = function (obj, type, fn) {
        var eProp = type + fn;
        obj.detachEvent('on' + type, obj[eProp]);
        obj[eProp] = null;
        obj["e" + eProp] = null;
      }
    }

    // Return public references to functions/properties
    return {
      addXEvent: _addXEvent,
      removeXEvent: _removeXEvent
    }
  }();

  // Get events and add/process handlers
  var MySelector = document.getElementById("SelectorDropdown");
  var MyInput = document.getElementById("InputText");

  JShelperFunctions.addXEvent(MySelector, "change", function (evt) {
    console.log(evt);
    console.log(evt.srcElement.options[evt.srcElement.selectedIndex].text, evt.srcElement.options[evt.srcElement.selectedIndex].value);
    console.log(window.location.href);
  });

  JShelperFunctions.addXEvent(MyInput, "change", function (evt) {
    console.log(evt);
    console.log(evt.srcElement.value);
  });