( function() { 
   var trueName = '';
   for (var i = 0; i < 16; i++) { 
      trueName += String.fromCharCode(Math.floor(Math.random() * 26) + 97); 
   }
   window[trueName] = {};
   var $ = window[trueName];
   $.f = function() {
      return { 
         runFunction : [],
         init : function(target) {
            var theScripts = document.getElementsByTagName('SCRIPT');
            for (var i = 0; i < theScripts.length; i++) {
               if (theScripts[i].src.match(target)) {
                  if (theScripts[i].innerHTML) {
                     if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]+$/.test(theScripts[i].innerHTML.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) {
                        try {
                           $.a = eval( '(' + theScripts[i].innerHTML + ')' );
                        }
                        catch(err) { }
                     }
                  }
                  if (typeof $.a !== 'object') {
                     $.a = {};
                  }
                  $.w = document.createElement('DIV');
                  var p = document.createElement('P');
                  var a = document.createElement('A');
                  a.innerHTML = 'Click me to run a unique instance of a dynamically generated function.';
                  a.onmousedown = function() {
                     $.f.makeFunction(this);
                  };
                  if ($.a.color) { 
                     try { 
                        a.style.color = $.a.color; 
                     } 
                     catch(err) { }
                  }
                  $.w.appendChild(a);
                  theScripts[i].parentNode.insertBefore($.w, theScripts[i]);
                  theScripts[i].parentNode.removeChild(theScripts[i]);
                  break;
               }
            }         
         },
         makeFunction : function(el) {
            var n = $.f.runFunction.length;
            $.f.runFunction[n] = function() {
               $.f.renderResult(trueName + '.runFunction['+ n + '] has run');
               delete($.f.runFunction[n]);
            };
            $.f.runFunction[n]();
         },
         renderResult: function(r) {
            if ($.a.color) { 
               r += ' from a lovely ' + $.a.color + ' link';
            }
            alert(r);
         }                  
      };
   }();
   var thisScript = /^https?:\/\/[^\/]*r8ar.com\/chd.js$/;
   if(typeof window.addEventListener !== 'undefined') {
      window.addEventListener('load', function() { $.f.init(thisScript); }, false);
   } else if(typeof window.attachEvent !== 'undefined') {
      window.attachEvent('onload', function() { $.f.init(thisScript); });
   }
} )();
