// xSmartLoadScript, Copyright 2005-2007 Brendan Richards
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xSmartLoadScript(url)
{
  var loadedBefore = false;
  if (typeof(xLoadedList) != "undefined") {
  for (i=0; i<xLoadedList.length; i++) {
    if (xLoadedList[i] == url) {
      loadedBefore = true;
      break;
    }
  }
  }
  if (document.createElement && document.getElementsByTagName && !loadedBefore) {
    var s = document.createElement('script');
    var h = document.getElementsByTagName('head');
    if (s && h.length) {
      s.src = url;
      h[0].appendChild(s);
      if (typeof(xLoadedList) == "undefined") xLoadedList = new Array();
      xLoadedList.push(url);
    }
  }
}
