

	//--------------------------------------------------
	// Loading setup

		var addLoadEventStack = []; // Array
		var addLoadEventCount = 0;

		function addLoadEvent(func) {
			addLoadEventStack[addLoadEventCount++] = func;
		}

	//--------------------------------------------------
	// Execute the functions when the page has loaded

		var addLoadEventDone = false;
		var addLoadEventSafariTimer;

		function addLoadEventInit() {

			//--------------------------------------------------
			// Do not run the functions twice

				if (addLoadEventDone) {
					return;
				} else {
					addLoadEventDone = true;
				}

			//--------------------------------------------------
			// Remove the loading timer for Safari

				if (addLoadEventSafariTimer) {
					clearInterval(addLoadEventSafariTimer);
				}

			//--------------------------------------------------
			// Execute the functions - cannot use variable 'i'
			// as the executed functions scope could change it

				var addLoadEventProgress;
				for (addLoadEventProgress = 0; addLoadEventProgress < addLoadEventCount; addLoadEventProgress++) {
					addLoadEventStack[addLoadEventProgress]();
				}

		}

	//--------------------------------------------------
	// Triggers for the different browsers

		//--------------------------------------------------
		// For DOM compatible browsers - Firefox and Opera

		 	if (document.addEventListener) {
		 		document.addEventListener('DOMContentLoaded', addLoadEventInit, false);
		 	}

		//--------------------------------------------------
		// For Safari

			if (/WebKit/i.test(navigator.userAgent)) { // sniff
				addLoadEventSafariTimer = setInterval(function() {
					if (/loaded|complete/.test(document.readyState)) {
						addLoadEventInit(); // call the onload handler
					}
				}, 10);
			}

		//--------------------------------------------------
		// For Internet Explorer

			/*@cc_on @*/
			/*@if (@_win32)

				document.write('<script id="addLoadEventIeOnload" defer="defer" src=//:><\/script>');
				var script = document.getElementById("addLoadEventIeOnload");
				script.onreadystatechange = function() {
					if (this.readyState === "complete") {
						addLoadEventInit(); // call the onload handler
					}
				};

			@end @*/

		//--------------------------------------------------
		// Fall back for other browsers

			window.onload = addLoadEventInit;



	function addLinkEvent(link, func) {

		try {
			link.style.cursor = 'pointer';
		} catch (e) {
			try {
				link.style.cursor = 'hand';
			} catch (e) {
			}
		}

		link.onclick = func;

		link.tabIndex = 0;

		link.onkeypress = function (e) {
				var keyCode = e ? e.which : window.event.keyCode;
				if (keyCode != 13 && keyCode != 32) return true;
				this.onclick();
				return false;
			};

	}



	function cssjs(action, object, className) {

		var exp;

		if (action === 'add') {

			if (!cssjs('check', object, className)) {
				object.className += (object.className === '' ? '' : ' ') + className;
			}

		} else if (action === 'remove') {

			exp = new RegExp('(^' + className + '( |$)| ' + className + '\\b)');
			object.className = object.className.replace(exp, '');

		} else if (action === 'check') {

			exp = new RegExp('\\b' + className + '\\b');
			return exp.test(object.className);

		}

		return true;

	}



	function createElement(element) {
		if (typeof document.createElementNS != 'undefined') {
			return document.createElementNS('http://www.w3.org/1999/xhtml', element);
		}
		if (typeof document.createElement != 'undefined') {
			return document.createElement(element);
		}
		return false;
	}



	function addCssRule(cssRule) {

		var styleElement;
		var headRef;

		//var useXmlMethods = (document.contentType && document.contentType.indexOf('xml') > -1);

		var useXmlMethods = (document.xmlVersion && document.xmlVersion.indexOf('1.0') > -1);

		if (useXmlMethods) {

			styleElement = createElement('style');
			styleElement.setAttribute('type', 'text/css');
			styleElement.appendChild(document.createTextNode(cssRule));

			headRef = document.getElementsByTagName('head');
			if (headRef[0]) {
				headRef[0].appendChild(styleElement);
			}

		} else {

			document.write ('<style type="text\/css"> ' + cssRule + ' <\/style>');

		}

	}



	function isEmailAddr(str) {
		var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
		return re.test(str);
	}



	function isValidDate(day, month, year) {
		month--; // JavaScript takes January as "0"
		var dteDate=new Date(year, month, day);
		return ((day === dteDate.getDate()) && (month === dteDate.getMonth()) && (year === dteDate.getFullYear()));
	}



	function printMe() {
		try {
			print();
		} catch(exception){
			alert("To print this page, click file and\n select 'Print' or 'Print Preview' ");
		}
	}



	function findPosX(obj) {
		var curleft = 0;
		if (obj.offsetParent) {
			while(1) {
				curleft += obj.offsetLeft;
				if(!obj.offsetParent) {
					break;
				}
				obj = obj.offsetParent;
			}
		} else if (obj.x) {
			curleft += obj.x;
		}
		return curleft;
	}

	function findPosY(obj) {
		var curtop = 0;
		if (obj.offsetParent) {
			while(1) {
				curtop += obj.offsetTop;
				if (!obj.offsetParent) {
					break;
				}
				obj = obj.offsetParent;
			}
		} else if (obj.y) {
			curtop += obj.y;
		}
		return curtop;
	}



	function getParent(el, pTagName) {
		if (el !== null) {
			if ((el.nodeType === 1) && (el.tagName.toUpperCase() === pTagName.toUpperCase())) {
				return el;
			} else if (el.parentNode) {
				return getParent(el.parentNode, pTagName);
			}
		}
		return null;
	}



	if (!window.console || !console.firebug) {

		var names = ['log', 'debug', 'info', 'warn', 'error', 'assert', 'dir', 'dirxml', 'group', 'groupEnd', 'time', 'timeEnd', 'count', 'trace', 'profile', 'profileEnd'];

		window.console = {};
		for (var i = 0; i < names.length; ++i) {
			window.console[names[i]] = function() {};
		}

	}

