var osc = {staticmap: {}};
  osc.staticmap.load_js = function(src, onload_callback) {
    var script = document.createElement('script');
    script.setAttribute('src', src);
    script.setAttribute('type','text/javascript');
    script.onload = onload_callback;
    script.onreadystatechange = onload_callback;
    document.body.appendChild(script);
  };
  osc.staticmap.load_ol_map_called = false;
  osc.staticmap.load_ol_map = function() {
    if (osc.staticmap.load_ol_map_called) {
      return;
    }
    osc.staticmap.load_ol_map_called = true;
    document.getElementById('loader').style.display = 'block';
    var map_loaded = false;
    var load_map_function = function() {
      if (map_loaded) {
        return;
      }
      if (typeof(OpenLayers) !== "undefined" &&
          typeof(osc.staticmap.init) !== "undefined") {
        map_loaded=true;
        osc.staticmap.init(function() {
          // remove img after map was loaded
          var img = document.getElementById("mapimg");
          if (img) {
            img.parentNode.removeChild(img);
          }
        });
      };
    }
    osc.staticmap.load_js('static/javascript/OpenLayers_local.js', load_map_function);
    osc.staticmap.load_js('static/javascript/static_map.js', load_map_function);
  };
