

if (typeof Object.create != 'function') {
  Object.create = function(o) {
    var F = function() {};
    F.prototype = o;
    return new F();
  };
}



if (!this.APPION) {
  APPION = {};
}

APPION.utils = {};
(function () {

   function checkHostname(hstr) {
     var name = window.location.hostname.toLowerCase();
     var result = name.indexOf(hstr) + 1;
     return result;
   }

   function getGMapKey()
   {
     var gkey;

     if (checkHostname("appionautomation")) {
       gkey = "ABQIAAAAs9VvkMN7TBaXAFVLgWYUkBRZrduYYwuB8ME_MNN9ZyKlmN6RthSshgIKoH_yNPtEPe2TO4VRgw56-A";
     }
     else if (checkHostname("pagetest.appioninc")) {
       gkey = "ABQIAAAAs9VvkMN7TBaXAFVLgWYUkBQBGdGjARbQoW4sqn4ohmY5YdAc6BRCKJHcmglX5UgUd0pC4SJa3ElCqA";
     }
     else if (checkHostname("appioninc")) {
       gkey = "ABQIAAAAs9VvkMN7TBaXAFVLgWYUkBQiQbUZxb3BJdaejorRMtZx-6JhdBSqKVjyyY34LYieEu4N-wUSGEvLVQ";
     }
     return gkey;
   }

   APPION.googleMapKey = '<script type="text/javascript" ' +
     'src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=' + getGMapKey() + '"></script>';

   // Helper function to add events to DOM elements on a page.
   // Needed to compensate for the epic failure of Internet Explorer.
   APPION.utils.addEvent = function (obj, evType, fn) {
     if (obj.addEventListener) {
       // All the real browsers
       obj.addEventListener(evType, fn, false);
       return true;
     }
     else if (obj.attachEvent) {
       // Internet Explorer
       var r = obj.attachEvent("on"+evType, fn);
       return r;
     } else {
       // Just in case, should never get here.
       alert("Event handler could not be attached");
       return false;
     }
   };

   // Function to determine which html element was
   // the target of an event.
   APPION.utils.eventTarget = function(evt) {
     var result;
     if (!evt) evt = window.event;

     // W3C/Mozilla
     if (evt.target) {
       result = evt.target;
     }
     // Microsoft
     else if (evt.srcElement) {
       result = evt.srcElement;
     }
     // Safari
     if (result.nodeType === 3) {
       result = result.parentNode;
     }
     return result;
   };

 })();

