/**
 * Imtech JavaScript library
 * Composed 2006 by Waldek Mastykarz | Imtech ICT BS
 * All rights reserved  
 * @created		2006-11-03 18:00:00
 * @modified	2006-11-15 08:30:00
 * @version		1.4
 * 
 * CHANGES LOG:
 * 1.5              JKA: + loadQuerystring()
 * 1.4		~ Imtech. replaced with this. (bug fix)
 * 			~ AJAX-based script loading replaced with document.write (IE bug fix)  
 * 1.3		+ AJAX-based script loading implemented
 * 1.2		+ modules namespaces added
 * 			~ modules saved externally 
 * 1.1		+ $() for getting objects added      
 */
// Declare the Imtech namespace
var Imtech = {
	version: "1.4",
	loadPath: "",
	load: function() {
		this.loadPath = window.Imtech.loadPath || ""; // declare the load path for the library files
		
		for (var i = 0; i < this.load.arguments.length; i++) {
			document.write("<script type=\"text/javascript\" src=\"" + this.loadPath + "imtech." + this.load.arguments[i] + ".lib.js\"></script>");
		}
	}
}

/****** GENERAL ******/

/**
 * is... functions
 */
Imtech.isArray = function(a) {
	return isObject(a) && a.constructor == Array;
}

Imtech.isBoolean = function(a) {
	return typeof a == 'boolean';
}

Imtech.isFunction = function(a) {
	return typeof a == 'function';
}

Imtech.isNull = function(a) {
	return a === null;
}

Imtech.isObject = function(a) {
	return (a && typeof a == 'object') || this.isFunction(a);
}
		 				
Imtech.isString = function(a) {
	return typeof a ==  "string";
}

Imtech.isUndefined = function(a) {
	return typeof a == "undefined";
}

/**
 * Returns object. If no such object found returns bool(false)
 * @author		Waldek Mastykarz | Imtech ICT BS
 * @version		1.1 		 
 * @param		string|object		Object to return
 * @dependency	Imtech.isFunction 
 * @dependency	Imtech.isObject
 * @dependency	Imtech.isUndefined 
 * 
 * CHANGES LOG:
 * 1.1		+ parameters recognition   
 */ 
Imtech.$ = function(obj) {
	if (!this.isUndefined(obj) &&
		this.isFunction &&
		this.isFunction(this.isObject)) {
		if (this.isObject(obj))
			return obj;
		else if (document.getElementById &&
			document.getElementById(obj))
			return document.getElementById(obj);
		else
			return false;
	}
	else
		return false;
}


/**
 * Loads querysting into Array Query. 
 * @author		Johan Kanselaar | Imtech ICT BS
 * @version		0.9 		 
 * @param		
 * @dependency	 
 * @dependency	
 * @dependency	
 * 
 * CHANGES LOG:
 * 0.9		first implementation   
 */

Imtech.Query = new Array();

function loadQuerystring() {
  // get querystring info from URL
  var sURL = window.location.search.substring(1);
  // split parameters into string array
  var sQuerystring = sURL.split('&');

  //for each param in querystring
  for (var i=0; i<sQuerystring.length; i++) {
    var iPos = sQuerystring[i].indexOf('=');
    //split into key/value pair
    if (iPos > 0) {
      var sKey = sQuerystring[i].substring(0, iPos);
      var sVal = sQuerystring[i].substring(iPos + 1);
      Imtech.Query[sKey] = sVal;
    }
  }
}
