var libraryh3lp = {
  requireJS: function(path, libraryName) {
    var libraryPath = path + 'js/' + libraryName + '.js?_=2009091901';
    document.write('<script type="text/javascript" src="' + libraryPath + '"></script>');
  },

  requireCSS: function(path, libraryName) {
    var libraryPath = path + 'css/' + libraryName + '.css?_=2009091901';
    document.write('<link type="text/css" rel="stylesheet" href="' + libraryPath + '" />');
  },

  getProtocol: function() {
    return location.protocol == 'https:' ? 'https:' : 'http:';
  },

  load: function() {
    var scripts  = document.getElementsByTagName('script');
    var path     = './';
    var includes = [];
    var regexp   = new RegExp('js/libraryh3lp\\.js(\\?.*)?$');
    for (var i = 0; i < scripts.length; ++i) {
      if (scripts.item(i).src && scripts.item(i).src.match(regexp)) {
        path     = scripts.item(i).src.replace(regexp, '');
        includes = scripts.item(i).src.match(/\?([a-z,]*)/);
        break;
      }
    }

    if (typeof window.jQuery != 'function' || window.jQuery().jquery < "1.2") {
      document.write(
        '<script type="text/javascript" src="'+this.getProtocol()+'//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>');
    }

    var files = (includes ? includes[1] : 'presence,popup').split(',');
    for (var i = 0; i < files.length; ++i) {
      if (files[i] == 'presence') {
        document.write(
          '<style type="text/css">\n' +
            '.online, .libraryh3lp_online .offline { display: none; }\n' +
            '.offline, .libraryh3lp_online .online { display: block; }\n' +
            '</style>');
      }

      this[files[i]] = true;
      //this.requireJS(path, files[i]);
    }
    this.requireJS(path, "presence");
  }
};

libraryh3lp.load();
