/* 
 * Copyright (c) 1995-2009, Index Data
 * All rights reserved.
 * See the file LICENSE for details.
 */

/*
 * This file will include and initlize all nessasary components.
 */
var MK2_UI_CORE_BASE="/mk2-ui-core";

mk_main();

function mk_main() {
  mk_include("/pazpar2/js/pz2.js");
  mk_include(MK2_UI_CORE_BASE+"/js/split.js");
  mk_include(MK2_UI_CORE_BASE+"/js/helper.js");
  mk_include(MK2_UI_CORE_BASE+"/js/templates.js");
  mk_include(MK2_UI_CORE_BASE+"/js/components.js");
  mk_include(MK2_UI_CORE_BASE+"/js/controls.js");
  
  mk_prependOnLoad(mk_onLoad);
}


function mk_onLoad() {
    // parse HTTP GET params (!!!)
    window.location.parameters = parseQueryString(window.location.search);
    // load templating components
    loadComponents();
}


/**
 * Alters the dom to include scipts
 */
function mk_include(file) {
  document.write('<script type="text/javascript" src="'+ file +'"></script>');
}

/**
 * Prepends any onLoad handlers with the specified function
 */
function mk_prependOnLoad(func) {
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    var oldonload = window.onload;
	window.onload = function() {
      func();
      if (oldonload) oldonload();
    }
  }
}

