function importJS(jsFile)
{
  var scriptElt = document.createElement('script');
  scriptElt.type = 'text/javascript';
  scriptElt.src = jsFile;
  document.getElementsByTagName('head')[0].appendChild(scriptElt);
}

function importCSS(cssFile)
{
  var cssElt = document.createElement('link');
  cssElt.rel = 'stylesheet';
  cssElt.type = 'text/css';
  cssElt.href = cssFile;
  document.getElementsByTagName('head')[0].appendChild(cssElt);
}

function init(imports)
{
  if (imports) {var arr = imports.split(','); for (x in arr) importJS('j/' + arr[x] + '.js');}
}

/*
 *  Which javascripts to load for which pages:
 */
with (window)
{
  switch(location.pathname.replace('/', ''))
  {
    case 'media.asp': onload = function() {init('pscs')}; break;
    case 'ministries.asp':
    case 'discipleship.asp':
    case 'leadership.asp': onload = function() {init('pcs')}; break;
    case 'about.asp':
    case 'calendar.asp':
      onload = function() {init('')}; break;
    default: onload = function() {init('pss')}; break;
  }
}


