// JavaScript
	
	// TODO: implement browser check for DOM support: 
	// if(!document.getElementById || !document.getElementsByTagName || !document.createTextNode) {return;}

	
//--- augmenting basic JavaScript types/objects - BEGIN
	Function.prototype.method = function (name, func) {
		if (!this.prototype[name]) {
			this.prototype[name] = func;
			return this;
		}
	}
	
	Number.method('integer', function () {
		return Math[this < 0 ? 'ceiling' : 'floor'](this);
	});
	
	String.method('trim', function () {
		return this.replace(/^\s+|\s+$/g, '');
	});
	//--- augmenting basic JavaScript types/objects - END
	
//--- define the global JSBASE object as container for ALL jsbase vars
	var JSBASE = {};
	
	
	
//--- JSBASE - PHP interface - BEGIN
	JSBASE.PHP = {};
	
	// TODO: the following var is widget specific and should therefor be defined elsewhere
	JSBASE.PHP.activeTabId = 0;


	//--- JSBASE - PHP interface - END
	
	
//--- JSBASE - DOM helper - BEGIN
	JSBASE.DOM = {};
	
	JSBASE.DOM.addEvent = function (elm, eventType, listenerFunction, useCapture) {
	    if (elm.addEventListener) {
	        elm.addEventListener(eventType, listenerFunction, useCapture);
	    } else if (elm.attachEvent) {
	        elm.attachEvent('on' + eventType, listenerFunction);
	    } else {
	        elm['on' + eventType] = listenerFunction; // should return false to prevent standard action of a link (e.g.)
	    }
	};
	// sample usage:
	// JSBASE.DOM.addEvent(document.getElementByID('idname'),'click',idnameClicked,false);
	
	JSBASE.DOM.prevDefault = function (ev) {
	    if (document.body.addEventListener) {
	        ev.preventDefault();
	        //alert('bla');
	    } else if (document.body.attachEvent) {
			ev.returnValue = false;
			//alert('blubb');
	    } else {
	    	// TODO: find solution for non-IE and non-DOM-compliant browsers
	    }
	};
	
	JSBASE.DOM.getTarget = function (ev) {
		var targ;
		if (!ev) { var ev = window.event; }
		if (ev.target) { targ = ev.target; } else if (ev.srcElement) { targ = ev.srcElement; }
		// defeat Safari bug
		if (targ.nodeType == 3) { targ = targ.parentNode; }
		return targ;		
	};
	
	JSBASE.DOM.getMousePos = function (ev) {
		var mouse = {};
		if ( document.captureEvents ) {
			mouse.xCord = ev.pageX;
			mouse.yCord = ev.pageY;
		} else if ( window.event.clientX ) {
			mouse.xCord = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
			mouse.yCord = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
			mouse.xCord += window.event.clientX;
			mouse.yCord += window.event.clientY;
		}
		return mouse;
	};
	
	JSBASE.DOM.getWindowSize = function () {
		// thx to Mark "Tarquin" Wilton-Jones - http://www.howtocreate.co.uk/tutorials/javascript/browserwindow
		var windowSize = {};
		windowSize.width = 0;
		windowSize.height = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			//Non-IE
			windowSize.width = window.innerWidth;
			windowSize.height = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			//IE 6+ in 'standards compliant mode'
			windowSize.width = document.documentElement.clientWidth;
			windowSize.height = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			//IE 4 compatible
			windowSize.width = document.body.clientWidth;
			windowSize.height = document.body.clientHeight;
		}
		return windowSize;
	};
	
	JSBASE.DOM.closestSibling = function(elm, direction) {
		var tempObj;
		if(direction==-1 && elm.previousSibling!=null) {
			tempObj=elm.previousSibling;
			while(tempObj.nodeType!=1 && tempObj.previousSibling!=null) {
				 tempObj=tempObj.previousSibling;
			}
		} else if(direction==1 && elm.nextSibling!=null) {
			tempObj=elm.nextSibling;
			while(tempObj.nodeType!=1 && tempObj.nextSibling!=null) {
				 tempObj=tempObj.nextSibling;
			}
		}
		if (typeof(tempObj) === 'undefined') {return false;}
		return tempObj.nodeType==1?tempObj:false;
	};
	
	/* TODO: check the following $ and $$ - they are taken from micro.js --> CREATE YOUR OWN!!! THOSE ARE BUGGY!!! 
	
	JSBASE.DOM.$ = function () {
		var results = [], element;
		Array.map(arguments, function(element) {
			if (typeof element == 'string')
			element = document.getElementById(element);
			results.push(element);
		});
		return results.length == 1 ? results[0] : results;
	}
	
	
	JSBASE.DOM.$$ = function (className, context) {
		context = context || document;
		var nodeList;
	  
		if (context == document || context.nodeType == 1) {
			if (typeof document.evaluate == 'function') {
				var xpath = document.evaluate(".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]", context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
				var els = [];
				for (var i = 0, l = xpath.snapshotLength; i < l; i++)
				els.push(xpath.snapshotItem(i));
				return els;
			} else nodeList = context.getElementsByTagName('*');
		} else nodeList = context;
	  
		var re = new RegExp('(^|\\s)' + className + '(\\s|$)');
		return Array.filter(nodeList, function(node) {  return node.className.match(re) });
	}
	
	
	*/
	
	//--- JSBASE - DOM helper - END
	
	
//--- JSBASE - Ajax helper - BEGIN
	JSBASE.AJAX = {};
	
	JSBASE.AJAX.instanceArray = new Array();
	
	JSBASE.AJAX.spawnAjaxInstance = function(i, nameOfInstance){
		JSBASE.AJAX.instanceArray[i] = nameOfInstance;
	};
	
	JSBASE.AJAX.getInstanceArray = function() {
		return JSBASE.AJAX.instanceArray;		
	};
	
	JSBASE.AJAX.runAjax = function(serverScriptFilePath, ajaxInstance, async) {
		// set value for optional param if not set
		if (typeof(async) === 'undefined') {async = true;}
		var xmlHttp = this.getHTTPObject();
		if (xmlHttp) {
			// in case of
			xmlHttp.onreadystatechange = function() {
				yAjaxInterface.handleRequestStateChange(xmlHttp, ajaxInstance);
			};
			xmlHttp.open("GET", serverScriptFilePath, async);
			xmlHttp.send(null);
			return true;
		} else {
			return false;
		}
	};
	
	JSBASE.AJAX.getHTTPObject = function() {
		var xmlHttp = false;
		if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			try {
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				try {
					xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch(e) {
					xmlHttp = false;
				}
			}
		}
		return xmlHttp;
	};
	
	JSBASE.AJAX.handleRequestStateChange = function(xmlHttp, ajaxInstance) {
		if (xmlHttp.readyState == 4) {
			if (xmlHttp.status == 200 || xmlHttp.status == 304) {
	
				// after the readyState is 4
				// - which means that the server has completed sending a response -
				// and the status of the server message is 200 or 304
				// - which both indicate the success of the request to the server -
				// just do something with your updated xmlHttp:

	
				// switch between the different ajax instances
				// the called methods are located in the AjaxInstanceResponseHandler class
	
				switch (ajaxInstance) {
					case "sendToBox":			// TODO: implement different ways of handling // using a class i.e.
												break;
												
					default:					alert("oops");
												break;
				}
	
	
				// possible responses:
				// DOMString getAllResponseHeaders();
				// DOMString getResponseHeader(in DOMString header);
				// readonly attribute DOMString responseText;
				// readonly attribute Document responseXML;
				// readonly attribute unsigned short status;
				// readonly attribute DOMString statusText;
	
			}
		}
	};
	//--- JSBASE - Ajax helper - END	
	
	
	
	
	
//--- JSBASE - widget - BEGIN
	JSBASE.widget = {};
	//--- JSBASE - widget - END
	
	
//--- JSBASE - module - BEGIN
	JSBASE.libs = {};
	JSBASE.libs.external = {};
	//--- JSBASE - module - END
	

