MugShotWidget1 = new function() {
  var BASE_URL = 'http://www.mugshotsgainesville.com/';
  var STYLESHEET = 'http://www.mugshotsgainesville.com/wp-content/themes/mugshots/style-2.css';
  var CONTENT_URL = 'http://www.mugshotsgainesville.com/?widget=true&script=true';
  var ROOT = 'Mugshots-Gainesville-Widget';

  function requestStylesheet(stylesheet_url) {
    stylesheet = document.createElement("link");
    stylesheet.rel = "stylesheet";
    stylesheet.type = "text/css";
    stylesheet.href = stylesheet_url;
    stylesheet.media = "all";
    document.lastChild.firstChild.appendChild(stylesheet);
  }

  function requestContent( local ) {
    var script = document.createElement('script');
    // How you'd pass the current URL into the request
    // script.src = CONTENT_URL + '&url=' + escape(local || location.href);
    script.src = CONTENT_URL;
    // IE7 doesnÍt like this: document.body.appendChild(script);
    // Instead use:
    document.getElementsByTagName('head')[0].appendChild(script);
  }

  this.serverResponse = function( data ) {
    if (!data) return;
    var div = document.getElementById(ROOT);
    var txt = '';
    for (var i = 0; i < data.length; i++) {
      if (txt.length > 0) { txt += " "; }
      txt += data[i];
    }
    div.innerHTML = txt;
    div.style.display = 'block'; 
  }

  requestStylesheet(STYLESHEET);
  document.write("<div id='" + escape(ROOT) + "' ></div>");
  requestContent();
}


