
/************************************************************************
 * Begin file class.autosuggest.js
 ************************************************************************/

/**
 * Autosuggest
 *
 * Usage: See PHP-side autosuggest class
 */
var imsAutoSuggest = Class.create({
	initialize: function(){
		this.suggestTime = 1000;		// We wait this amount of miliseconds before we send an AJAX request for the suggestions
		this.timer = null;
		this.targetId = null;
		this.selectedIdx = -1;
		this.blockBlur = false;
		this.blurFunctions = [];
		this.minCharacters = 1;			// Text field has to contain this amount of characters before autosuggest shows up.
	},

	__handleKeyUp: function() {
		if(!this._verifyTarget())
			return;

		var keyCode = window.ims.events.getEventParams()["keyCode"];
		if (!((keyCode < 13 && keyCode != 8) ||
			(keyCode >=14 && keyCode < 32 && keyCode != 27) ||
			(keyCode >= 33 && keyCode <= 46 && keyCode != 38 && keyCode != 40) ||
			(keyCode >= 112 && keyCode <= 123)))
		{
			if (keyCode == 13) { // Enter was pressed
				if(this.selectedIdx == -1)
					return;

				$(this.targetId).value =
					$(this.targetId + "_sug_" + this.selectedIdx).firstChild.innerHTML.replace(/&amp/, "&");
				this._hideSuggestions();

				__ajaxReq('suggestionPicked', this.targetId);

				window.ims.events.stopEvent();
			} else if(keyCode == 38) { // Up arrow was pressed
				if(this.selectedIdx - 1 <= -1) return;
				if(this.selectedIdx != -1)
					$(this.targetId + "_sug_" + this.selectedIdx).className = "sug";
				this.selectedIdx--;
				$(this.targetId + "_sug_" + this.selectedIdx).className = "sugHl";
			} else if(keyCode == 40){ // Down arrow was pressed
				if(this.selectedIdx + 1 > this.numberOfResults - 1)
					return;

				if(this.selectedIdx != -1)
					$(this.targetId + "_sug_" + this.selectedIdx).className = "sug";

				this.selectedIdx++;
				$(this.targetId + "_sug_" + this.selectedIdx).className = "sugHl";
			} else if(keyCode == 27){
				this._hideSuggestions();
			} else { // We have to get the suggestions
				if(window.ims.events.getEventParams()["target"].value.length >= this.minCharacters)
					this.timer = window.setTimeout("window.ims.autoSuggest.suggest();", this.suggestTime);
			}
		}
	},

	__handleKeyDown: function() {
		window.clearTimeout(this.timer);
		if(!this._verifyTarget())
			return;
		else if(this.selectedIdx >= 0 && window.ims.events.getEventParams()["keyCode"] == 13)
			window.ims.events.stopEvent();
	},

	__handleClick: function() {
		if (typeof window.ims.events.event.findElement("div") != "undefined" &&
			window.ims.events.event.findElement("div").identify() == this.targetId + "_sug"){
			if (this.selectedIdx == -1)
				return;

			$(this.targetId).value = $(this.targetId + "_sug_" + this.selectedIdx).firstChild.innerHTML.replace(/&amp/, "&");
			$(this.targetId).focus();

			__ajaxReq("suggestionPicked", this.targetId);
		}

		setVisibility(this.targetId + "_sug", false);
		if(window.ims.browser.isIE)
			setVisibility(this.targetId + "_if", false);

		this.selectedIdx = -1;
		this.blockBlur = false;
	},

	__handleSuggestionMouseOver: function(event, selectedObj, selectedIdx){
		this.selectedIdx = selectedIdx;
		selectedObj.className = "sugHl";

		this.blockBlur = true;
	},

	__handleSuggestionMouseOut: function(event, selectedObj){
		this.selectedIdx = -1;
		selectedObj.className = "sug";

		this.blockBlur = false;
	},

	__handleBlur: function(){
		window.clearTimeout(this.timer);
		setVisibility(this.targetId + '_sug', false);
		window.ims.autoSuggest.selectedIdx = -1;

		this.blurFunctions[this.targetId]();
	},

	_verifyTarget: function(){
		var targetId = window.ims.events.getEventParams()["target"].identify();
		if($(targetId + "_sug") == null)
			return false;

		this.targetId = targetId;
		return true;
	},

	_hideSuggestions: function(){
		setVisibility(this.targetId + "_sug", false);
		if(window.ims.browser.isIE)
			setVisibility(this.targetId + "_if", false);

		this.selectedIdx = -1;
		this.blockBlur = false;
	},

	setupEvents: function(){
		// Setup onBlur
		if($(this.targetId).onblur != null){
			if(typeof this.blurFunctions[this.targetId] != "undefined"){
				this.blurFunctions[this.targetId] = $(this.targetId).onblur;
				Event.observe($(this.targetId), "blur", this.__handleBlur.bindAsEventListener(this));
			}

			$(this.targetId).onblur = null;
		}

		// Setup mouse events
		for(i = 0; ; i++){
			var obj = $(this.targetId + "_sug_" + i);
			if(obj == null)
				break;

			Event.observe(obj, "mouseover", this.__handleSuggestionMouseOver.bindAsEventListener(this, obj, i));
			Event.observe(obj, "mouseout", this.__handleSuggestionMouseOut.bindAsEventListener(this, obj));
		}
		this.numberOfResults = i;
	},

	suggest: function(){
		return __ajaxReq("suggest", this.targetId);
	}
});

/************************************************************************
 * End file class.autosuggest.js
 ************************************************************************/

/************************************************************************
 * Begin file class.browser.js
 ************************************************************************/

/**
 * Browser Detect  v2.1.6
 * documentation: http://www.dithered.com/javascript/browser_detect/index.html
 * license: http://creativecommons.org/licenses/by/1.0/
 * code by Chris Nott (chris[at]dithered[dot]com)
 *
 * 08-04-2008 NB altered code to prototype style, added MS IE 7 and 8
 */

var imsBrowser = Class.create({
	initialize: function(){
		var ua = navigator.userAgent.toLowerCase();

		// browser engine name
		this.isGecko       = (ua.indexOf('gecko') != -1 && ua.indexOf('safari') == -1);
		this.isAppleWebKit = (ua.indexOf('applewebkit') != -1);

		// browser name
		this.isKonqueror   = (ua.indexOf('konqueror') != -1);
		this.isSafari      = (ua.indexOf('safari') != - 1);
		this.isOmniweb     = (ua.indexOf('omniweb') != - 1);
		this.isOpera       = (ua.indexOf('opera') != -1);
		this.isIcab        = (ua.indexOf('icab') != -1);
		this.isAol         = (ua.indexOf('aol') != -1);
		this.isIE          = (ua.indexOf('msie') != -1 && !this.isOpera && (ua.indexOf('webtv') == -1) );
		this.isMozilla     = (this.isGecko && ua.indexOf('gecko/') + 14 == ua.length);
		this.isFirefox     = (ua.indexOf('firefox/') != -1 || ua.indexOf('firebird/') != -1);
		this.isNS          = ( (this.isGecko) ? (ua.indexOf('netscape') != -1) : ( (ua.indexOf('mozilla') != -1) && !this.isOpera && !this.isSafari && (ua.indexOf('spoofer') == -1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('webtv') == -1) && (ua.indexOf('hotjava') == -1) ) );

		// spoofing and compatible browsers
		this.isIECompatible = ( (ua.indexOf('msie') != -1) && !this.isIE);
		this.isNSCompatible = ( (ua.indexOf('mozilla') != -1) && !this.isNS && !this.isMozilla);

		// rendering engine versions
		this.geckoVersion = ( (this.isGecko) ? ua.substring( (ua.lastIndexOf('gecko/') + 6), (ua.lastIndexOf('gecko/') + 14) ) : -1 );
		this.equivalentMozilla = ( (this.isGecko) ? parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) ) : -1 );
		this.appleWebKitVersion = ( (this.isAppleWebKit) ? parseFloat( ua.substring( ua.indexOf('applewebkit/') + 12) ) : -1 );

		// browser version
		this.versionMinor = parseFloat(navigator.appVersion);

		// correct version number
		if (this.isGecko && !this.isMozilla) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('/', ua.indexOf('gecko/') + 6) + 1 ) );
		}
		else if (this.isMozilla) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('rv:') + 3 ) );
		}
		else if (this.isIE && this.versionMinor >= 4) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('msie ') + 5 ) );
		}
		else if (this.isKonqueror) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('konqueror/') + 10 ) );
		}
		else if (this.isSafari) {
			this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('safari/') + 7 ) );
		}
		else if (this.isOmniweb) {
			this.versionMinor = parseFloat( ua.substring( ua.lastIndexOf('omniweb/') + 8 ) );
		}
		else if (this.isOpera) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('opera') + 6 ) );
		}
		else if (this.isIcab) {
			this.versionMinor = parseFloat( ua.substring( ua.indexOf('icab') + 5 ) );
		}

		this.versionMajor = parseInt(this.versionMinor);

		// dom support
		this.isDOM1 = (document.getElementById);
		this.isDOM2Event = (document.addEventListener && document.removeEventListener);

		// css compatibility mode
		this.mode = document.compatMode ? document.compatMode : 'BackCompat';

		// platform
		this.isWin    = (ua.indexOf('win') != -1);
		this.isWin32  = (this.isWin && ( ua.indexOf('95') != -1 || ua.indexOf('98') != -1 || ua.indexOf('nt') != -1 || ua.indexOf('win32') != -1 || ua.indexOf('32bit') != -1 || ua.indexOf('xp') != -1) );
		this.isMac    = (ua.indexOf('mac') != -1);
		this.isUnix   = (ua.indexOf('unix') != -1 || ua.indexOf('sunos') != -1 || ua.indexOf('bsd') != -1 || ua.indexOf('x11') != -1)
		this.isLinux  = (ua.indexOf('linux') != -1);

		// specific browser shortcuts
		this.isNS4x = (this.isNS && this.versionMajor == 4);
		this.isNS40x = (this.isNS4x && this.versionMinor < 4.5);
		this.isNS47x = (this.isNS4x && this.versionMinor >= 4.7);
		this.isNS4up = (this.isNS && this.versionMinor >= 4);
		this.isNS6x = (this.isNS && this.versionMajor == 6);
		this.isNS6up = (this.isNS && this.versionMajor >= 6);
		this.isNS7x = (this.isNS && this.versionMajor == 7);
		this.isNS7up = (this.isNS && this.versionMajor >= 7);

		this.isIE4x = (this.isIE && this.versionMajor == 4);
		this.isIE4up = (this.isIE && this.versionMajor >= 4);
		this.isIE5x = (this.isIE && this.versionMajor == 5);
		this.isIE55 = (this.isIE && this.versionMinor == 5.5);
		this.isIE5up = (this.isIE && this.versionMajor >= 5);
		this.isIE6x = (this.isIE && this.versionMajor == 6);
		this.isIE6up = (this.isIE && this.versionMajor >= 6);
		this.isIE7x = (this.isIE && this.versionMajor == 7);
		this.isIE7up = (this.isIE && this.versionMajor >= 7);
		this.isIE8x = (this.isIE && this.versionMajor == 8);
		this.isIE8up = (this.isIE && this.versionMajor >= 8);

		this.isIE4xMac = (this.isIE4x && this.isMac);
	}
});
/************************************************************************
 * End file class.browser.js
 ************************************************************************/

/************************************************************************
 * Begin file class.controls.js
 ************************************************************************/

/**
 * Controls - some control-related utility functions
 */
var imsControls = Class.create({
	initialize: function(){

	},

	setVisibility: function(name, visible) {
		var row = $(name);
		if (row == null) return null;
		row.style.visibility = visible ? "visible" : "hidden";
		row.style.display = visible ? "" : "none";
		row.style.height = visible ? "" : "0px";
	},

	checkBoxToggle: function(action, name) {
		var inp = document.getElementsByTagName("input");
		for (c = 0; c < inp.length; c++) {
			if (inp[c].type != "checkbox") continue;
			if (inp[c].name.substring(0, name.length) != name) continue;
			if (action == 1) inp[c].checked = false;		// uncheck all
			if (action == 2) inp[c].checked = true;			// check all
			if (action == 3) inp[c].checked = !inp[c].checked;	// toggle all
		}
	},

	resizeTextarea: function(obj) {
	//	Usage: <textarea name="edtText" rows="6" cols="15" wrap="virtual" onKeyUp="resizeTextarea(this);"></textarea>
	//	Seems not to work with Opera
		a = obj.value.split('\n');
		b = 1;
		for (x = 0; x < a.length; x++) {
			if (a[x].length >= obj.cols)
				b += Math.floor(a[x].length / obj.cols);
		}

		b += a.length;
		if (b > obj.rows && !window.ims.browser.isOpera)
			obj.rows = b;
	},

	selectAll: function(id, copy) {
		var tempval = $(id);
		tempval.focus();
		tempval.select();
		if (document.all && copy) {
			therange = tempval.createTextRange();
			therange.execCommand("Copy");	// to clipboard
			//window.status="Contents highlighted and copied to clipboard!";
		}
	},

	setSelect: function(obj, val, selectFirst) {
		obj = $(obj);

		var found = false;
		for (var index = 0; index < obj.length; index++) {
			if (obj[index].value == val) {
				obj.selectedIndex = index;
				found = true;

				break;
			}
		}
		if (!found) obj.selectedIndex = 0;
	},

	getComboboxItem: function(obj, index){
		obj = $(obj);

		if(typeof index == "undefined")
			index = obj.selectedIndex;

		return obj.options[index];
	},

	// Element creation
	getCheckbox: function(id, checked){
		var obj = new Element("input", {
			id: id,
			type: "checkbox"
		});
		if(checked){
			obj.writeAttribute("selected", "selected");
			obj.checked = true;
		}

		return obj;
	},

	getTextbox: function(id, value, stretchHorizontally){
		var obj = new Element("input", {
			id: id,
			type: "text",
			value: value
		});
		if(typeof stretchHorizontally != "undefined" && stretchHorizontally)
			obj.setStyle({width: "100%"});

		return obj;
	},

	getLookupCombo: function(content, selectedValue){	// TODO: Do something with selected value
		var obj = new Element("select");
		content = $H(content);

		var keys = content.keys();
		for(var i = 0; i < keys.length; i++){
			obj.insert(new Element("option", {
				value: keys[i]
			}).update(content.get(keys[i])));
		}

		return obj;
	},

	getHidden: function(id, value){
		var obj = new Element("input", {
			id: id,
			name: id,
			type: "hidden",
			value: (typeof value == "String" && !value.isEmpty() ? value : "")
		});

		return obj;
	}
});

/**
 * Request wrappers
 */
function setVisibility (name, visible) {
	window.ims.controls.setVisibility(name, visible);
}

/************************************************************************
 * End file class.controls.js
 ************************************************************************/

/************************************************************************
 * Begin file class.dates.js
 ************************************************************************/

/**
 * Date
 *
 * Usage:
 * - Set mask through constructor or one of the properties
 * - Call parseDate or parseDateTime with the user-entered string to get a timestamp that's parsed with the help of the masks
 * - Call isValid to check whether a user-entered date is valid
 * - Use assistUser on blur of date textfield:
 *   + If action == 1 && value control a > control b, control b is emptied.
 *   + If action == 2 && value control a > control b, value of control b is made the same as control a.
 *   + If action == 3 && value control a > control b, date part of control b is made the same as control a but the timepart is left the same
 */
var imsDate = Class.create({
	initialize: function(maskDate, maskDateTime) {
		this.dateArray = [];
		this.dateTimeArray = [];

		if (maskDate != null && maskDate != "" && maskDate != undefined)
			this.maskDate = maskDate;
		else
			this.maskDate = 'dd-mm-yyyy';

		if (maskDateTime != null && maskDateTime != "" && maskDateTime != undefined)
			this.maskDateTime = maskDateTime;
		else
			this.maskDateTime = 'dd-mm-yyyy h:m';
	},

	parseDate: function(toBeParsedDate) {
		var values=[];
		var formats=[];
		this.maskDate = this.maskDate.toLowerCase();
		//var dt = Date.parseDate(toBeParsedDate,this.maskDate);
		//alert(dt.dateFormat('Y-m-d'));
		//Date d=new Date(dt.dateFormat('Y-m-d'));
		//alert(Date.parse(dt.dateFormat('F d,Y')));
		//alert('utc'+Date.UTC(dt.dateFormat('Y-m-d')));
		//alert(dt);
		if(toBeParsedDate.indexOf("-") > 0 )//means - separated
		{
			values = toBeParsedDate.split("-");
			formats = this.maskDate.split("-");

			if(values.length!=3)
				return;
			else
			{
				//alert('in else portion');

				//alert(this.dateArray['dd']);
				//alert(this.dateArray['mm']);
				//alert(this.dateArray['yyyy']);
			}
		}
		else
		{
			values = toBeParsedDate.split(".");
			formats = this.maskDate.split(".");
			if(values.length!=3)
				return;
		}
		this.dateArray[formats[0]]=values[0];
		this.dateArray[formats[1]]=values[1];
		this.dateArray[formats[2]]=values[2];
		if(this.dateArray['mm']>12 || this.dateArray['mm']<=0 || this.dateArray['dd']>31 || this.dateArray['dd']<=0)
		{
			//alert('returning null');
			return;
		}
		var result = Date.UTC(this.dateArray['yyyy'],this.dateArray['mm']-1,this.dateArray['dd'],0,0,0,0)/1000;

		//$('datetest').innerHTML+="epoch "+result;
		return result;

	},

	parseDateTime: function(toBeParsedDateTime) {
		var datevalues=[];
		var timevalues=[];
		var formats=[];
		var tempDateF=[];
		var tempTimeF=[];
		this.maskDateTime = this.maskDateTime.toLowerCase();
		if(toBeParsedDateTime.indexOf("-") > 0 )//means - separated
		{
			var total = toBeParsedDateTime.split(" ");
			var formatTemp = this.maskDateTime.split(" ");
			//not a datetime
			if(total.length>1)
			{
				datevalues = total[0].split("-");
				timevalues = total[1].split(":");
				tempDateF = formatTemp[0].split("-");
				tempTimeF = formatTemp[1].split(":");
				if(datevalues.length!=3 || timevalues.length!=2)
					return;
			}
			else
				return;
		}
		else
		{
			var total = toBeParsedDateTime.split(" ");
			var formatTemp = this.maskDateTime.split(" ");
			if(total.length>1)
			{
				datevalues = total[0].split(".");
				timevalues = total[1].split(".");
				tempDateF = formatTemp[0].split(".");
				tempTimeF = formatTemp[1].split(".");
				if(datevalues.length!=3 || timevalues.length!=2)
					return;
			}
			else
			{
				return;
			}
		}
		this.dateTimeArray[tempDateF[0]]=datevalues[0];
		this.dateTimeArray[tempDateF[1]]=datevalues[1];
		this.dateTimeArray[tempDateF[2]]=datevalues[2];
		this.dateTimeArray[tempTimeF[0]]=timevalues[0];
		this.dateTimeArray[tempTimeF[1]]=timevalues[1];

		if(this.dateTimeArray['mm']>12 || this.dateTimeArray['mm']<=0 || this.dateTimeArray['dd']>31 || this.dateTimeArray['dd']<=0 || this.dateTimeArray['h']>23 || this.dateTimeArray['h']<0 || this.dateTimeArray['m']>59|| this.dateTimeArray['m']<0)
			return;
		//var result = Date.UTC(datevalues[2],datevalues[1]-1,datevalues[0],timevalues[0],timevalues[1],0,0)/1000;
		var result = Date.UTC(this.dateTimeArray['yyyy'],this.dateTimeArray['mm']+1,this.dateTimeArray['dd'],this.dateTimeArray['h'],this.dateTimeArray['m'],0,0)/1000;
		//$('datetest').innerHTML+="epoch2 "+result;
		return result;
	},

	isValid: function(dateTime, isTime){
		var res = isTime ? this.parseDateTime(dateTime) : this.parseDate(dateTime);

		return res != undefined;
	},

	assistUser: function(controlA, controlB, isTime , action){
		var avalue = $(controlA).value;
		var bvalue = $(controlB).value;
		if( this.isValid(avalue,isTime) == false)
		{
			return false;
		}
		if(isTime == false)
		{
			if(action == 1)
			{
				if(this.parseDate(avalue) > this.parseDate(bvalue) )
				{
					//alert('greater');
					$(controlB).value = "";
					//$(controlB).update('');
				}
				else
				{
					//alert("a < b");
				}
			}
			else if(action == 2 )
			{
				if( (bvalue == undefined || bvalue == '') || (this.parseDate(avalue) > this.parseDate(bvalue)) )
				{
					$(controlB).value = $(controlA).value;
				}
				else
				{

				}
			}
			else if ( action == 3 )
			{
				if( (bvalue == undefined || bvalue == '') || (this.parseDate(avalue) > this.parseDate(bvalue)) )
				{
					var avarray = avalue.split(" ");
					var bvarray = bvalue.split(" ");
					if(bvarray.length>1)
						$(controlB).value = avarray[0]+" "+bvarray[1];
					else
						$(controlB).value = avarray[0];
				}
				else
				{

				}
			}
		}
		else
		{
			if(action == 1)
			{
				if(this.parseDateTime(avalue) > this.parseDateTime(bvalue) )
				{
					$(controlB).value = "";
				}
				else
				{
					//alert("a < b");
				}
			}
			else if(action == 2 )
			{
				if( (bvalue == undefined || bvalue == '') || (this.parseDateTime(avalue) > this.parseDateTime(bvalue)) )
				{
					$(controlB).value = $(controlA).value;
				}
				else
				{

				}
			}
			else if ( action == 3 )
			{
				if( (bvalue == undefined || bvalue == '') || ( this.parseDateTime(avalue) > this.parseDateTime(bvalue) ) || this.isValid(bvalue,true) == false )
				{
					var avarray = avalue.split(" ");
					var bvarray = bvalue.split(" ");
					if(bvarray.length>1)
						$(controlB).value = avarray[0]+" "+bvarray[1];
					else
						$(controlB).value = avarray[0]+" "+avarray[1];
				}
				else
				{

				}
			}
		}
	},

	writeDate: function() {
		var date = new Date();
		document.write( date.toLocaleDateString() );
	}
});

/************************************************************************
 * End file class.dates.js
 ************************************************************************/

/************************************************************************
 * Begin file class.events.js
 ************************************************************************/

/**
 * Event handling
 *
 * Usage:
 * - When you want your class to handle events, call window.ims.events.addClient(this)
 * - Then implement some these functions (list may grow later):
 *   + __handleKeyUp
 *   + __handleKeyDown
 *   + __handleClick
 * - When you want an event to stop and prevent default actions from being executed, call window.ims.events.stopEvent() from an event handler
 * - When you want your class to stop handling events, call window.ims.events.removeClient(this);
 */
var imsEvents = Class.create({
	initialize: function() {
		this.clients = [];
		this.event = null;
		this.eventParms = null;
		this.eventStopped = false;
		this.blockEnter = true;

		Event.observe(document, "keyup", this.__handleEvent.bindAsEventListener(this, "__handleKeyUp"));
		Event.observe(document, "keydown", this.__handleEvent.bindAsEventListener(this, "__handleKeyDown"));
		Event.observe(document, "click", this.__handleEvent.bindAsEventListener(this, "__handleClick"));
	},

	addClient: function(obj) {
		if(this.clients.indexOf(obj) == -1)
			this.clients.push(obj);
	},

	removeClient: function(obj) {
		var idx = this.clients.indexOf(obj);
		if(idx > -1)
			this.clients.splice(idx, 1);
	},

	getEventParams: function() {
		if(this.eventParms == null){
			this.eventParms = [];

			if(this.event.keyCode)
				this.eventParms["keyCode"] = this.event.keyCode;
			else if(this.event.which)
				this.eventParms["keyCode"] = this.event.which;

			this.eventParms["target"] = this.event.element();

			if (window.ims.browser.isNS4x) {
				// Netscape 4 code
				var mString = (this.event.modifiers + 32).toString(2).substring(3, 6);
				this.eventParms["shiftPressed"] = (mString.charAt(0) == "1");
				this.eventParms["ctrlPressed"] = (mString.charAt(1) == "1");
				this.eventParms["altPressed"] = (mString.charAt(2) == "1");
			} else {
				// Newer browsers [cross-platform]
				this.eventParms["shiftPressed"] = this.event.shiftKey;
				this.eventParms["altPressed"] = this.event.altKey;
				this.eventParms["ctrlPressed"] = this.event.ctrlKey;
			}
		}

		return this.eventParms;
	},

	stopEvent: function(){
		this.eventStopped = true;
	},

// 	suppressDefault: function(e, flag) {
// 		if (flag && window.ims.browser.isNS4x) {
// 			e.cancelBubble = true;
// 			e.cancel = true;
// 			e.returnValue = false;
// 		}
//
// 		if (e.preventDefault)
// 			e.preventDefault();
// 		if (e.stopPropagation)
// 			e.stopPropagation();
//
// 		return !flag;
// 	},

	__handleEvent: function(e, command){
		if(typeof command == "undefined")
			return;

		// Make event object available for clients and getEventParams() method
		this.event = e;

		// Send event to all clients
		for(i = 0; !this.eventStopped && i < this.clients.length; i++) {
			if(typeof this.clients[i][command] != "undefined")
				this.clients[i][command]();
		}

		// Check whether enter was pressed.
		this.getEventParams();
		this.eventStopped = this.eventStopped || (this.blockEnter &&
			(command == "__handleKeyDown" && this.eventParms["keyCode"] == 13 &&
				["textarea", "button"].indexOf(this.eventParms["target"].tagName.toLowerCase()) == -1)
		);

		// Clear event and it's parameters
		this.event = null;
		this.eventParms = null;

		// If the event was stopped somewhere along the road, do some tricks
		if(this.eventStopped){
			e.stop();
			this.eventStopped = false;
		}
	}
});
/************************************************************************
 * End file class.events.js
 ************************************************************************/

/************************************************************************
 * Begin file class.queue.js
 ************************************************************************/

/**
 * Command queue
 *
 * Usage:
 * - Add commands through enqueCommand()
 * - If no commands are busy, the command will execute immediately
 * - If a command will still be busy after function has been executed(like imsRequests::ajaxRequest), call setCommandBusy(true)
 * - When the command finishes, call setCommandBusy(false) and the remaining commands will be executed
 */
var imsCommandQueue = Class.create({
	initialize: function() {
		this.requestQueue = [];
		this.commandBusy = false;
	},

	setCommandBusy: function(busy) {
		if (typeof busy != "boolean"){
			return;
		}

		this.commandBusy = busy;
		this._execute();
		window.ims.theForm = $("postedData");
},

	enqueCommand: function(command) {
		this.requestQueue.unshift(command);
		this._execute();
	},

	_execute: function() {
		while(this.requestQueue.length > 0 && !this.commandBusy)
			this._dequeCommand();
	},

	_dequeCommand: function(command) {
		if(this.requestQueue.length > 0)
			eval(this.requestQueue.pop());
	}
});

/************************************************************************
 * End file class.queue.js
 ************************************************************************/

/************************************************************************
 * Begin file class.requests.js
 ************************************************************************/

/**
 * Requests
 */
var imsRequests = Class.create({
	initialize: function(){
		this.theForm = window.ims.theForm;
		this.useGetForPostBack = false;
	},

	_setParams: function(eventCmd, eventArgument, eventTarget) {
		this.theForm.__eventCmd.value = eventCmd;
		this.theForm.__eventArgument.value = eventArgument;
		if (typeof eventTarget != "undefined" && eventTarget != null)
			this.theForm.__eventTarget.value = eventTarget;
		if (typeof this.theForm.__scrollPos != "undefined")
			this.theForm.__scrollPos.value = document.body.scrollTop;

		if (typeof this.theForm.__location != "undefined")
			this.theForm.action = this.theForm.__location.value;
		else
			this.theForm.action = document.location;

		var pos = this.theForm.action.indexOf("?");
		if (pos > 0)
			this.theForm.action = this.theForm.action.substring(0, pos);
	},

	//	POST
	postBack: function(eventCmd, eventArgument, eventTarget, blank, useGet) {
		if(typeof eventCmd == "undefined" || eventCmd == null || eventCmd.length == 0)
				return false;

		blank = typeof blank == "boolean" && (blank ?  true : false);
		if(blank)
			this._execPostBack(eventCmd, eventArgument, eventTarget, blank);
		else {
			if(typeof eventArgument == "undefined" || eventArgument == null || eventArgument.length == 0)
				eventArgument = "";

			if(typeof eventTarget == "undefined" || eventTarget == null || eventTarget.length == 0)
				eventTarget = this.theForm.__eventTarget.value;

			var args = "\"" + eventCmd + "\""; // Event command
			args += ", \"" + eventArgument + "\"" // Event argument
			args += ", \"" + eventTarget + "\"";  // Event target
			args += ", false"; // Blank
			args += ", " + this.useGetForPostBack || (typeof useGet != "undefined" && useGet ? "true" : "false");
			window.ims.cmdQueue.enqueCommand("window.ims.requests._execPostBack(" + args + ");");
		}
	},

	//	POST using xAjax
	ajaxReq: function(eventCmd, eventArgument, eventTarget) {
		if(typeof eventCmd == "undefined" || eventCmd == null || eventCmd.length == 0)
			return false;

		if(typeof eventArgument == "undefined" || eventArgument == null || eventArgument.length == 0)
			eventArgument = "";

		if(typeof eventTarget == "undefined" || eventTarget == null || eventTarget.length == 0)
			eventTarget = this.theForm.__eventTarget.value;

		var args = "\"" + eventCmd + "\", \"" + eventArgument + "\", \"" + eventTarget + "\"";
		window.ims.cmdQueue.enqueCommand("window.ims.requests._execAjaxRequest(" + args + ");");
	},

	_execPostBack: function(eventCmd, eventArgument, eventTarget, blank, useGet){
		var orgTarget = this.theForm.target;
		this._setParams(eventCmd, eventArgument, eventTarget);
		this.theForm.method = typeof useGet != "undefined" && useGet ? "get" : "post";
		if (blank)
			this.theForm.target = "_blank";

		this.theForm.submit();
		this.theForm.target = orgTarget;
	},

	_execAjaxRequest: function(eventCmd, eventArgument, eventTarget){
		var orgEventTarget = this.theForm.__eventTarget.value; // Keep original eventTarget

		// txtProcessing is defined in the head of the HTML page
		var msg = $("lblMsg");
		if (msg != null && typeof txtProcessing != "undefined") {
			setVisibility ("lblMsg", true);
			msg.setStyle("color: red;");
			msg.update(txtProcessing);
		}

		this._setParams(eventCmd, eventArgument, eventTarget);
		xajax_processForm(xajax.getFormValues("postedData"));

		this.theForm.__eventTarget.value = orgEventTarget; // Restore original eventTarget

		window.ims.cmdQueue.setCommandBusy(true);
	}
});

/**
 * Request wrappers
 */
function __ajaxReq(eventCmd, eventArgument, eventTarget){
	if (typeof window.ims == "undefined") return false;
	window.ims.requests.ajaxReq(eventCmd, eventArgument, eventTarget);
	return false;
}
function __PostBack(eventCmd, eventArgument, eventTarget, blank){
	window.ims.requests.postBack(eventCmd, eventArgument, eventTarget, blank);
	return false;
}


/************************************************************************
 * End file class.requests.js
 ************************************************************************/

/************************************************************************
 * Begin file class.shortcuts.js
 ************************************************************************/

/**
 * Shortcuts
 *
 * Usage:
 * - Register shortcut with registerShortcut():
 *   + First parameter is key code that you can get through String.charCodeAt(x)
 *   + Second parameter will be passed to eval() when shortcut is pressed
 * - Unregister shortcut with unregisterShortcut(): First parameter is keyCode you passed through registerShortcut()
 */
var imsShortcuts = Class.create({
	initialize: function(){
		this.activated = false;
		this.activeShortcuts = [];
	},

	__handleKeyDown: function(){
		var keyCode = window.ims.events.getEventParams()["keyCode"];
		if(typeof this.activeShortcuts[keyCode] != "undefined" && window.ims.events.getEventParams()["ctrlPressed"]){
			eval(this.activeShortcuts[keyCode]);
			window.ims.events.stopEvent();
		}
	},

	setShortcutsEnabled: function(enabled){
		if(enabled)
			window.ims.events.addClient(this);
		else
			window.ims.events.removeClient(this);

		this.activated = enabled;
	},

	register: function(keyCode, command){
		this.activeShortcuts[keyCode] = command;
	},

	// NOT TESTED
	unregister: function(keyCode){
		if(typeof this.activeShortcuts[keyCode] != "undefined")
			this.activeShortcuts.splice(keyCode, 1);
	}
});
/************************************************************************
 * End file class.shortcuts.js
 ************************************************************************/

/************************************************************************
 * Begin file class.tooltip.js
 ************************************************************************/

/**
 * Based on http://www.dynamicdrive.com/dynamicindex5/dhtmltooltip.htm
 *
 * Usage:
 * ddrivetip("TEXT TO DISPLAY", "OPTIONAL BACKGROUND COLOR", OPTIONAL TIP WIDTH)
 * onMouseover="ddrivetip("JavaScriptKit.com JavaScript tutorials","yellow", 300)";
 * onMouseout="hideddrivetip()"
 *
 * 07-04-2008 NB converted code to prototype style class
 */
var imsTooltip = Class.create({
	initialize: function(){
		this.offsetxpoint = +50; //Customize x offset of tooltip
		this.offsetypoint = -20; //Customize y offset of tooltip
		this.enabletip = false;
		this.tipobj = null;
	},
	ietruebody: function() {
		return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
	},
	show: function(thetext, thecolor, thewidth) {
		this.tipobj = $("dhtmltooltip");
		if (this.tipobj == null) return;
		if (true) { // browser check here?
			if (typeof thewidth != "undefined")
				this.tipobj.setStyle("width:"+thewidth+"px");
			if (typeof thecolor != "undefined" && thecolor != "") {
				this.tipobj.setStyle("background-color:" + thecolor);
			}
			this.tipobj.update(thetext);
			this.enabletip = true;
//			document.onmousemove = ddposition;	//	@todo do it the prototype way
			Event.observe(document, 'mousemove', ddposition);
		}
	},
	hide: function() {
		if (this.tipobj == null) return;
//		document.onmousemove = null;
		Event.stopObserving(document, 'mousemove', ddposition);
		this.enabletip = false;
		setVisibility ("dhtmltooltip", false);
		this.tipobj.setStyle("left:'-1000px'")
// 		this.tipobj.setStyle("background-color:''");
// 		this.tipobj.setStyle("width:''");
	},
	position: function (e) {
		if (this.tipobj == null || !this.enabletip) return;
		var curX = (window.ims.browser.isNS6up) ? e.pageX : e.clientX + this.ietruebody().scrollLeft;
		var curY = (window.ims.browser.isNS6up) ? e.pageY : e.clientY + this.ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=window.ims.browser.isIE && !window.opera? this.ietruebody().clientWidth-e.clientX-this.offsetxpoint : window.innerWidth-e.clientX-this.offsetxpoint-20;
		var bottomedge=window.ims.browser.isIE && !window.opera? this.ietruebody().clientHeight-e.clientY-this.offsetypoint : window.innerHeight-e.clientY-this.offsetypoint-20;
		var leftedge=(this.offsetxpoint<0)? this.offsetxpoint*(-1) : -1000;

		//if the horizontal distance isn"t enough to accomodate the width of the context menu
		if (rightedge<this.tipobj.offsetWidth)
		//move the horizontal position of the menu to the left by it"s width
			this.tipobj.style.left=window.ims.browser.isIE ? ((this.ietruebody().scrollLeft+e.clientX-this.tipobj.offsetWidth)+"px") : (window.pageXOffset+e.clientX-this.tipobj.offsetWidth)+"px"
		else if (curX<leftedge)
			this.tipobj.setStyle("left:5px");
		else {
		//position the horizontal position of the menu where the mouse is positioned
			var s = curX+this.offsetxpoint;
			this.tipobj.setStyle("left:"+s+"px");
		}

		//same concept with the vertical position
		if (bottomedge<this.tipobj.offsetHeight)
			this.tipobj.style.top = window.ims.browser.isIE ? (this.ietruebody().scrollTop+e.clientY-this.tipobj.offsetHeight-this.offsetypoint)+"px" : (window.pageYOffset+e.clientY-this.tipobj.offsetHeight-this.offsetypoint)+"px";
		else {
			var dd = curY+this.offsetypoint;
			//alert("dd"+dd);
			this.tipobj.setStyle("top:"+dd+"px");
		}
		setVisibility(this.tipobj,true);
	}
});

/**
 * Request wrappers
 */
function ddrivetip(thetext, thecolor, thewidth) {
	window.ims.tooltip.show(thetext, thecolor, thewidth);
	return false;
}
function hideddrivetip() {
	window.ims.tooltip.hide();
	return false;
}
function ddposition(e) {
	window.ims.tooltip.position(e);
}

/************************************************************************
 * End file class.tooltip.js
 ************************************************************************/

/************************************************************************
 * Begin file class.utils.js
 ************************************************************************/

var imsUtils = Class.create({
	initialize: function() {
		this.lightBox = null;
		this.lbSettings = [];
	},
	openWindow: function(url, width, height, center, top, left, wname) {
		if (center == undefined) center = true;
		if (wname == undefined) wname = "childWindow";
		options = "resizable=yes,scrollbars=yes,status=no,toolbar=no,location=no,width=";
		options += width.toString();
		options += ",height=";
		options += height.toString();
		if (center) {
			var scrnH = (screen.height / 2) - (height / 2);
			var scrnW = (window.document.body.clientWidth / 2) - (width / 2);
			options += ",top=" + scrnH.toString();
			options += ",left=" + scrnW.toString();
		}
		else {
			options += ",top=" + top.toString();
			options += ",left=" + left.toString();
		}
		window.open(url, wname, options);
	},
	initDownload: function() {
		var dlFr = $('dlFrame');
		var tmp=(new Date()).getTime();
		if (typeof dlFr == "undefined" || dlFr == null) {
			dlFr			= document.createElement('iframe');
			dlFr.id			= 'dlFrame';
			dlFr.style.visibility	= "hidden";
			dlFr.style.display	= "none";
			dlFr.style.height	= "1px";
			dlFr.style.width	= "1px";
			dlFr.style.top		= "-100px";
			dlFr.style.left		= "-100px";
			window.ims.theForm.appendChild(dlFr);
		}
		dlFr.src = "./?module=admin/getFile&" + tmp.toString();
	},
	sizeImage: function(img, url, maxHeight) {
	//	img.style["visibility"] = "hidden";
	//	img.style["display"] = "none";
		if(maxHeight <= 0)
			return;

		var tmpImg = new Image();
		tmpImg.src = url;
		tmpW = tmpImg.width;
		tmpH = tmpImg.height;
		//alert("tmpW 1: " + tmpW.toString());
		//alert("tmpH 2: " + tmpH.toString());
		factor = (tmpH / maxHeight);
		//alert("factor 1: " + factor.toString());
		if (factor <= 0)
			return;

		tmpW = Math.floor(tmpW / factor);
		tmpH = Math.floor(tmpH / factor);
		//alert("tmpW 2: " + tmpW.toString());
		//alert("tmpH 2: " + tmpH.toString());
		img.style["width"] = tmpW.toString() + "px";
		img.style["height"] = tmpH.toString() + "px";
		//img.src = url;
		//var container = $("smallPic")[0];
		//SetVisibility (smallPic, true);
	},
	rand: function(number) {
		return Math.ceil(rnd()*number);
	},
	// This method was only relavant to a datepicker window -> depricated now
	pick: function(retVal, control) {
		if (window.opener && !window.opener.closed) {
			control = window.opener.document.getElementsByName(control)[0];
			if (control != undefined && retVal.length > 0) {
				control.value = retVal;
				control.focus();
			}
		}
		window.close();
	},
	/**
	  * Add array like this one with .js files to a document:
	  *  	var files = Array (
	  *		'/dotnet/scripts/general.js',
	  *		'/dotnet/scripts/jsdomenu.js',
	  *		'/dotnet/scripts/jsdomenubar.js',
	  *		'/dotnet/xajax/xajax_js/xajax.js'
	  *		);
	  */
	addScriptFiles: function(list) {
		if (document.getElementsByTagName && document.createElement) {
		//	if methods getElementsByTagName and createElement exist...
			var head = document.getElementsByTagName('head')[0];
			for (i = 0; i < list.length; i++) {
				var script = document.createElement('script');
				script.setAttribute('type', 'text/javascript');
				script.setAttribute('src', list[i]);
				// If you want to set an embedded script:
			//	script.appendChild( document.createTextNode('string-containing-the-script') );
				head.appendChild(script);
			}
		}
	},
	showModal: function(eventCmd, eventArgument, eventTarget, nWidth, nHeight, elementType) {
		if (typeof elementType == "undefined") elementType = "div";
		// if element type == iframe, then eventCmd should be URL
		this.lbSettings = {
			"cmd": eventCmd,
			"arg": eventArgument,
			"target": eventTarget,
			"width": nWidth,
			"height": nHeight,
			"type": elementType};
		if ($('overlay') == null) {
			this._loadLightBox();
		}
		this.lightbox.show();
	},

	/**
	* sprintf() for JavaScript v.0.4
	*
	* Copyright (c) 2007 Alexandru Marasteanu <http://alexei.417.ro/>
	* Thanks to David Baird (unit test and patch).
	*/
	sprintf: function() {
		var i = 0;
		var a;
		var f = arguments[i++];
		var o = [];
		var m;
		var p;
		var c;
		var x;

		while (f) {
			if (m = /^[^\x25]+/.exec(f))
				o.push(m[0]);
			else if (m = /^\x25{2}/.exec(f))
				o.push('%');
			else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) {
				if (((a = arguments[m[1] || i++]) == null) || (a == undefined))
					throw("Too few arguments.");
				if (/[^s]/.test(m[7]) && (typeof(a) != 'number'))
					throw("Expecting number but found " + typeof(a));

				switch (m[7]) {
					case 'b':
						a = a.toString(2);
						break;

					case 'c':
						a = String.fromCharCode(a);
						break;

					case 'd':
						a = parseInt(a);
						break;

					case 'e':
						a = m[6] ? a.toExponential(m[6]) : a.toExponential();
						break;

					case 'f':
						a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a);
						break;

					case 'o':
						a = a.toString(8);
						break;

					case 's':
						a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a);
						break;

					case 'u':
						a = Math.abs(a);
						break;

					case 'x':
						a = a.toString(16);
						break;

					case 'X':
						a = a.toString(16).toUpperCase();
						break;
				}

				a = (/[def]/.test(m[7]) && m[2] && a > 0 ? '+' + a : a);
				c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' ';
				x = m[5] - String(a).length;
				p = m[5] ? c.times(x) : '';
				o.push(m[4] ? a + p : p + a);
			}
			else
				throw ("Huh ?!");

			f = f.substring(m[0].length);
		}

		return o.join('');
	},

	_loadLightBox: function() {
		this.lightbox = new imsLightbox();
		if (this.lightbox.debug)
			alert("Lightbox succesfully loaded ....");
	}
});

/**
 * Request wrappers
 */
function openWindow(url, width, height, center, top, left, wname) {
	window.ims.utils.openWindow(url, width, height, center, top, left, wname);
}

/************************************************************************
 * End file class.utils.js
 ************************************************************************/

/************************************************************************
 * Begin file class.validation.js
 ************************************************************************/

/**
 * Validation
 *
 * Interesting link: http://developer.apple.com/internet/webcontent/validation.html
 */
var imsValidation = Class.create({
	initialize: function(){
		this.texts = [];
		this.result = "";
		this.needsFocus = "";
	},
	reset: function(language) {
		this.result = "";
		this.needsFocus = "";
		if (typeof language == "undefined") language = 1;
		if (language == 1) {
			this.texts[0] = "Field is empty but should be filled";
			this.texts[1] = "Field does not contain a valid email address";
			this.texts[2] = "Please use only digits for the field";
			this.texts[3] = "Please use the date format \"dd-mm-yyyy\" for the field";
			this.texts[4] = "Please use the date-time format \"dd-mm-yyyy hh:mm\" for the field";
		}
		else if (language == 2) {
			this.texts[0] = "Veld is leeg, maar moet ingevuld zijn";
			this.texts[1] = "Veld bevat geen geldig email adres";
			this.texts[2] = "Vul alleen cijfers in bij veld";
			this.texts[3] = "Vul een datum als \"dd-mm-yyyy\" in bij veld";
			this.texts[4] = "Vul een datum-tijd als \"dd-mm-yyyy hh:mm\" in bij veld";
		}
	},
	addError: function(str) {
		if (this.result.length > 0) {
			this.result += "\n";
		}
		this.result += "- " + str;
	},
	hasError: function() {
		return this.result.length > 0;
	},
	getError: function() {
		if (this.needsFocus.length > 0) $(this.needsFocus).focus();
		return this.result;
	},
	addFocus: function(str) {
		if (this.needsFocus.length == 0) this.needsFocus = str;
	},
	testRegEx: function (toTest, regExStr) {
		return regExStr.test(toTest);
	},
	required: function(objName, caption) {
		object = $(objName);
		if (typeof object == "undefined") return;
		if (object.value.length == 0) {
			this.addFocus(objName);
			this.addError(this.texts[0] + ": " + caption);
		}
	},
	isEmail: function(objName, caption) {
		object = $(objName);
		if (typeof object == "undefined") return;
		if (object.value.length > 0 && !this.testRegEx(object.value, /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/)) {
			this.addFocus(objName);
			this.addError(this.texts[1] + ": " + caption);
		}
	},

// /^[a-zA-Z0-9._-]+:  Means that the email address must begin with alpha-numeric characters (both lowercase and uppercase characters are allowed). It may have periods,underscores and hyphens.
//
// @:   There must be a ‘@’ symbol after initial characters.
//
// [a-zA-Z0-9.-]+: After the ‘@’ sign there must be some alpha-numeric characters. It can also contain period (’.') and and hyphens(’-').
//
// \.: After the second group of characters there must be a period (’.'). This is to separate domain and subdomain names.
//
// [a-zA-Z]{2,4}$/: Finally, the email address must end with two to four alphabets. Having a-z and A-Z means that both lowercase and uppercase letters are allowed.
// {2,4} indicates the minimum and maximum number of characters. This will allow domain names with 2, 3 and 4 characters e.g.; us, tx, org, com, net, wxyz).

	isAmount: function(objName, caption) {
		object = $(objName);
		if (typeof object == "undefined") return;
		if (object.value.length > 0 && this.testRegEx(object.value, "^[0-9\.]+$")) {
			this.addFocus(objName);
			this.addError(this.texts[2] + ": " + caption);
		}
	},
	isInteger: function(objName, caption) {
		object = $(objName);
		if (typeof object == "undefined") return;
		if (object.value.length > 0 && this.testRegEx(object.value, "^[0-9]+$")) {
			this.addFocus(objName);
			this.addError(this.texts[2] + ": " + caption);
		}
	},
	isDate: function(objName, caption) {
		this.isDateTime(objName, caption, false);
	},
	isDateTime: function(objName, caption, shouldBeTime) {
		if (typeof shouldBeTime == "undefined") shouldBeTime = true;
		object = $(objName);
		if (typeof object == "undefined") return;
		if (object.value.length > 0 && !window.ims.date.isValid(object.value, shouldBeTime)) {
			this.addFocus(objName);
			this.addError(this.texts[shouldBeTime ? 4 : 3] + ": " + caption);
		}
	}
});

/************************************************************************
 * End file class.validation.js
 ************************************************************************/

/************************************************************************
 * Begin file class.core.js
 ************************************************************************/

var imsPhrases = Class.create({
	initialize: function(){
		this._phrases = new Hash;
	},

	initComponent: function(module, JSONPhraseArray){
		this._phrases.set(module, JSONPhraseArray.evalJSON());
	},

	getComponent: function(module){
		return this._phrases.get(module);
	}
});

var imsCore = Class.create({
	initialize: function(){
		// We need to create properties here
		this.theForm = $("postedData");
		this.phrases = new imsPhrases;
		this.urls = new Hash;
		this.lurs = new Hash;

		// Since we don't use the real print(), we might as well make it useful
		window.print = typeof console != "undefined" && typeof console.log != "undefined" ?
			console.log : // FireBug is present, so use it.
			function(){}; // No FireBug, everything > /dev/null
		window.printTrace = typeof console != "undefined" && typeof console.trace != "undefined" ?
			console.trace : // FireBug is present, so use it.
			function(){}; // No FireBug, everything > /dev/null
	},

	extendPrototypeElements: function(){
		Element.addMethods({
			// This method gets the dimensions without the border
			getRealDimensions: function(element){
				element = $(element);

				var borderLeft = parseInt(element.style.borderLeftWidth);
				var borderRight = parseInt(element.style.borderRightWidth);
				var borderTop = parseInt(element.style.borderTopWidth);
				var borderBottom = parseInt(element.style.borderBottomWidth);

				var objSize = element.getDimensions();
				if(!isNaN(borderLeft))
					objSize.width -= borderLeft;
				if(!isNaN(borderRight))
					objSize.width -= borderRight;
				if(!isNaN(borderTop))
					objSize.height -= borderTop;
				if(!isNaN(borderBottom))
					objSize.height -= borderBottom;

				return objSize;
			},

			getPosition: function(element){
				element = $(element);

				return {
					x: element.getXPosition(element),
					y: element.getYPosition(element)
				};
			},

			getXPosition: function(element){
				element = $(element);

				return parseInt(element.getStyle("left"));
			},

			getYPosition: function(element){
				element = $(element);

				return parseInt(element.getStyle("top"));
			},

			move: function(element, dX, dY){
				element = $(element);

				var styles = {};
				if(typeof dX != "undefined" && dX != 0)
					styles.left = (element.getXPosition() + dX) + "px";
				if(typeof dY != "undefined" && dY != 0)
					styles.top = (element.getYPosition() + dY) + "px";

				return element.setStyle(styles);
			},

			resize: function(element, dWidth, dHeight){
				element = $(element);

				var dimensions = element.getDimensions();
				var styles = {};
				if(typeof dWidth != "undefined" && dWidth != 0)
					styles.width = (dimensions["width"] + dWidth) + "px";
				if(typeof dHeight != "undefined" && dHeight != 0)
					styles.height = (dimensions["height"] + dHeight) + "px";

				return element.setStyle(styles);
			}
		});
	},

	loadModules: function(){
		this.extendPrototypeElements();

		// Core modules
		this.browser = new imsBrowser;
		this.events = new imsEvents;
		this.cmdQueue = new imsCommandQueue;
		this.requests = new imsRequests;

		// Optional modules that should be instantiated on demand
		this.autoSuggest = new imsAutoSuggest;
		this.shortcuts = new imsShortcuts;
		this.controls = new imsControls;
		this.date = new imsDate;
		this.validation = new imsValidation;
		this.utils = new imsUtils;
		this.tooltip = new imsTooltip;
	},

	loadModule: function(moduleName){
		if(typeof this[moduleName] == "undefined")
			this[moduleName] = eval("new ims" + moduleName.charAt(0).toUpperCase() + moduleName.substr(1));
	},

	setLur: function(module, section, lur){
		var moduleHash = this.lurs.get(module);
		if(moduleHash == null){
			moduleHash = new Hash;
			this.lurs.set(module, moduleHash);
		}

		moduleHash.set(section, lur);
	}
});

/************************************************************************
 * End file class.core.js
 ************************************************************************/

/************************************************************************
 * Begin file general.js
 ************************************************************************/

/************************************************************************
 * @todo in JavaScripts:
 * - keep alive in class
 *  Event handlers - begin
 *******************************************************************************************************/
Event.observe(window, "load", HandlePageLoaded, false);
function HandlePageLoaded(evt) {
	//alert("Page loaded");
	//Event.observe("parent_node", "click", item_clicked, false);

	if (typeof window.ims == "undefined"){
		window.ims = new imsCore;
		window.ims.loadModules();
		window.ims.events.addClient(window.ims.autoSuggest);
	}
	if (typeof imsOnLoad != "undefined") {
		imsOnLoad();
	}
}
/*******************************************************************************************************
 * Event handlers - end
 *
 * Some Xajax-related stuff - begin
 *******************************************************************************************************/
var xajaxDebug = false;
var xajaxStatusMessages = false;
var xajaxWaitCursor = true;
var xajaxDefinedGet = 0;
var xajaxDefinedPost = 1;
var xajaxLoaded = false;

function xajax_ajaxServer() {
	return xajax.call("ajaxServer", arguments, 1);
}
function xajax_processForm() {
	return xajax.call("processForm", arguments, 1);
}
/*******************************************************************************************************
 * Some Xajax-related stuff - end
 *
 * Keep-alive funtionality - begin
 *******************************************************************************************************/
var keepAlive = false;
var keepAliveInterval = 1000 * 60 * 24; // Last request is longer than 24 minutes ago
//keepAliveInterval = 1000 * 5;	// for testing

function setKeepAlive(newKeepAliveValue) {
	if (typeof newKeepAliveValue == "undefined") { // Set keepAlive to the checked state of chkKeepAlive
		chkKeepAlive = $("chkKeepAlive");
		if (chkKeepAlive != null)
			keepAlive = chkKeepAlive.checked;
	} else {
		keepAlive = newKeepAliveValue;
	}
	if (keepAlive) doKeepAlive();
}
function doKeepAlive() {
	if (!keepAlive) return;
	__ajaxReq("keepAlive", "", "ajax/keepAlive");
}
window.setInterval("doKeepAlive()", keepAliveInterval); //@todo
/*******************************************************************************************************
 * Keep-alive funtionality - end
 *******************************************************************************************************/

/************************************************************************
 * End file general.js
 ************************************************************************/

/************************************************************************
 * Begin file jsdomenu.js
 ************************************************************************/

/*

  jsDOMenu Version 1.3.1
  Copyright (C) 2003 - 2005 Toh Zhiqiang
  Released on 12 February 2005
  jsDOMenu is distributed under the terms of the GNU GPL license
  Refer to license.txt for more informatiom

*/

/*
Determine whether the browser is IE5.0.
*/
function isIE50() { // Private method
  return isIE5() && !isIE55();
}

/*
Determine whether the browser is IE5.5.
*/
function isIE55() { // Private method
  return navigator.userAgent.indexOf("MSIE 5.5") > -1;
}

/*
Determine whether the browser is IE5.0 or IE5.5.
*/
function isIE5() { // Private method
  return navigator.userAgent.indexOf("MSIE 5") > -1;
}

/*
Determine whether the browser is IE6.
*/
function isIE6() { // Private method
  return navigator.userAgent.indexOf("MSIE 6") > -1 && navigator.userAgent.indexOf("Opera") == -1;
}

/*
Determine whether the browser is IE.
*/
function isIE() { // Private method
  return isIE5() || isIE6();
}

/*
Determine whether the browser is Opera.
*/
function isOpera() { // Private method
  return navigator.userAgent.indexOf("Opera") > -1;
}

/*
Determine whether the browser is Safari.
*/
function isSafari() { // Private method
  return navigator.userAgent.indexOf("Safari") > -1;
}

/*
Determine the page render mode.

0: Quirks mode.
1: Strict mode.
*/
function getPageMode() { // Private method
  if (document.compatMode) {
    switch (document.compatMode) {
      case "BackCompat":
        return 0;
      case "CSS1Compat":
        return 1;
      case "QuirksMode":
        return 0;
    }
  }
  else {
    if (ie5) {
      return 0;
    }
    if (safari) {
      return 1;
    }
  }
  return 0;
}

/*
Alias for document.getElementById().
*/
function getElmId(id) { // Private method
  return document.getElementById(id);
}

/*
Alias for document.createElement().
*/
function createElm(tagName) { // Private method
  return document.createElement(tagName);
}

/*
Get the x-coordinate of the cursor position relative to the window.
*/
function getX(e) { // Private method
  if (!e) {
    var e = window.event;
  }
  if (safari) {
    return e.clientX - getScrollLeft();
  }
  else {
    return e.clientX;
  }
}

/*
Get the y-coordinate of the cursor position relative to the window.
*/
function getY(e) { // Private method
  if (!e) {
    var e = window.event;
  }
  if (safari) {
    return e.clientY - getScrollTop();
  }
  else {
    return e.clientY;
  }
}

/*
Get the scrollLeft property.
*/
function getScrollLeft() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.scrollLeft;
    case 1:
      if (document.documentElement && document.documentElement.scrollLeft > 0) {
        return document.documentElement.scrollLeft;
      }
      else {
        return document.body.scrollLeft;
      }
  }
}

/*
Get the scrollTop property.
*/
function getScrollTop() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.scrollTop;
    case 1:
      if (document.documentElement && document.documentElement.scrollTop > 0) {
        return document.documentElement.scrollTop;
      }
      else {
        return document.body.scrollTop;
      }
  }
}

/*
Get the clientHeight property.
*/
function getClientHeight() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.clientHeight;
    case 1:
      if (safari) {
        return self.innerHeight;
      }
      else {
        if (!opera && document.documentElement && document.documentElement.clientHeight > 0) {
          return document.documentElement.clientHeight;
        }
        else {
          return document.body.clientHeight;
        }
      }
  }
}

/*
Get the clientWidth property.
*/
function getClientWidth() { // Private method
  switch (pageMode) {
    case 0:
      return document.body.clientWidth;
    case 1:
      if (safari) {
        return self.innerWidth;
      }
      else {
        if (!opera && document.documentElement && document.documentElement.clientWidth > 0) {
          return document.documentElement.clientWidth;
        }
        else {
          return document.body.clientWidth;
        }
      }
  }
}

/*
Convert the string into lower camel case.
*/
function toCamelCase(input) { // Private method
  var inputArray = input.split("-");
  if (inputArray.length == 1) {
    return inputArray[0];
  }
  else {
    var camelCase = inputArray[0];
    for (var i = 1, len = inputArray.length; i < len; i++) {
      camelCase += inputArray[i].charAt(0).toUpperCase() + inputArray[i].substring(1);
    }
    return camelCase;
  }
}

/*
Get the value of the property of the object.
*/
function getPropVal(obj, propertyName) { // Private method
  var propertyValue = obj.style[toCamelCase(propertyName)];
  if (propertyValue) {
    return propertyValue;
  }
  else {
    if (document.defaultView && document.defaultView.getComputedStyle) {
      return document.defaultView.getComputedStyle(obj, null).getPropertyValue(propertyName);
    }
    else {
      if (obj.currentStyle) {
        return obj.currentStyle[toCamelCase(propertyName)];
      }
      else {
        return null;
      }
    }
  }
}

/*
Get the integer value of the property of the object.
*/
function getPropIntVal(obj, propertyName) { // Private method
  return parseInt(getPropVal(obj, propertyName));
}

/*
Get the left position of the pop-up menu.
*/
function getMainMenuLeftPos(menuObj, x) { // Private method
  if (x + menuObj.offsetWidth <= getClientWidth()) {
    return x;
  }
  else {
    return x - menuObj.offsetWidth;
  }
}

/*
Get the top position of the pop-up menu.
*/
function getMainMenuTopPos(menuObj, y) { // Private method
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    return y;
  }
  else {
    return y - menuObj.offsetHeight;
  }
}

/*
Get the left position of the submenu.
*/
function getSubMenuLeftPos(menuObj, x, offset) { // Private method
  if (x + menuObj.offsetWidth - 2 <= getClientWidth()) {
    return x - 2;
  }
  else {
    return x - menuObj.offsetWidth - offset;
  }
}

/*
Get the top position of the submenu.
*/
function getSubMenuTopPos(menuObj, y, offset) { // Private method
  var top = getPropIntVal(menuObj, btw);
  var bottom = getPropIntVal(menuObj, bbw);
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    if (safari) {
      return y - top;
    }
    else {
      return y;
    }
  }
  else {
    if (safari) {
      return y - menuObj.offsetHeight + offset + bottom;
    }
    else {
      return y - menuObj.offsetHeight + offset + top + bottom;
    }
  }
}

/*
Pop up the submenu.
*/
function popUpSubMenu(menuItemObj) { // Private method
  var parentMenuObj = menuItemObj.parent.menuObj;
  var menuObj = menuItemObj.subMenu.menuObj;
  var x;
  var y;
  if (parentMenuObj.style.position == "fixed") {
    x = parentMenuObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, brw);
    y = parentMenuObj.offsetTop + menuItemObj.offsetTop + getPropIntVal(parentMenuObj, btw) - getPropIntVal(menuObj, btw);
    menuObj.style.position = "absolute";
    menuObj.style.left = getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + px;
    menuObj.style.top = getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + px;
    menuObj.style.position = "fixed";
  }
  else {
    if (parentMenuObj.mode == "static" && !ie50) {
      x = menuItemObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, blw) - getPropIntVal(parentMenuObj, brw) - getScrollLeft();
      y = menuItemObj.offsetTop - getPropIntVal(menuObj, btw) - getScrollTop();
      if (ie55 || ie6) {
          x += getPropIntVal(parentMenuObj, blw);
          y += getPropIntVal(parentMenuObj, btw);
      }
      if (safari) {
        x += 8;
        y += getPropIntVal(menuObj, btw) + 13;
      }
      menuObj.style.left = (getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + getScrollLeft()) + px;
      menuObj.style.top = (getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + getScrollTop()) + px;
    }
    else {
      x = parentMenuObj.offsetLeft + parentMenuObj.offsetWidth - getPropIntVal(parentMenuObj, brw) - getScrollLeft();
      y = parentMenuObj.offsetTop + menuItemObj.offsetTop + getPropIntVal(parentMenuObj, btw) - getPropIntVal(menuObj, btw) - getScrollTop();
      menuObj.style.left = (getSubMenuLeftPos(menuObj, x, menuItemObj.offsetWidth) + getScrollLeft()) + px;
      menuObj.style.top = (getSubMenuTopPos(menuObj, y, menuItemObj.offsetHeight) + getScrollTop()) + px;
    }
  }
  if (ie && menuObj.mode == "fixed") {
    menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft();
    menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop();
  }
  menuObj.style.visibility = "visible";
}

/*
Pop up the main menu.
*/
function popUpMainMenu(menuObj, e) { // Private method
  menuObj.style.left = (getMainMenuLeftPos(menuObj, getX(e)) + getScrollLeft()) + px;
  menuObj.style.top = (getMainMenuTopPos(menuObj, getY(e)) + getScrollTop()) + px;
  var display = popUpMenuObj.menuObj.style.display;
  popUpMenuObj.menuObj.style.display = "none";
  popUpMenuObj.menuObj.style.visibility = "visible";
  popUpMenuObj.menuObj.style.display = display;
}

/*
Refresh the menu items.
*/
function refreshMenuItems(menuObj) { // Private method
  for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
    if (menuObj.childNodes[i].enabled) {
      menuObj.childNodes[i].className = menuObj.childNodes[i].itemClassName;
      if (menuObj.childNodes[i].subMenu) {
        menuObj.childNodes[i].arrowObj.className = menuObj.childNodes[i].arrowClassName;
      }
      if (menuObj.childNodes[i].iconObj) {
        menuObj.childNodes[i].iconObj.className = menuObj.childNodes[i].iconClassName;
      }
    }
  }
}

/*
Event handler that handles onmouseover event of the menu item.
*/
function menuItemOver(e) { // Private method
  var previousItem = this.parent.previousItem;
  if (previousItem) {
    if (previousItem.className == previousItem.itemClassNameOver) {
      previousItem.className = previousItem.itemClassName;
    }
    if (previousItem.subMenu) {
      previousItem.className = previousItem.itemClassName;
      previousItem.arrowObj.className = previousItem.arrowClassName;
      if (previousItem.iconObj) {
        previousItem.iconObj.className = previousItem.iconClassName;
      }
    }
    var menuObj = getElmId(this.parent.menuObj.id);
    for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
      if (menuObj.childNodes[i].enabled && menuObj.childNodes[i].subMenu) {
        hideMenus(menuObj.childNodes[i].subMenu.menuObj);
      }
    }
  }
  if (this.enabled) {
    this.className = this.itemClassNameOver;
    if (this.subMenu) {
      this.arrowObj.className = this.arrowClassNameOver;
      popUpSubMenu(this);
    }
    if (this.iconObj && this.iconClassNameOver) {
      this.iconObj.className = this.iconClassNameOver;
    }
  }
  this.parent.previousItem = this;
}

/*
Event handler that handles onclick event of the menu item.
*/
function menuItemClick(e) { // Private method
  if (this.enabled && this.actionOnClick) {
    var action = this.actionOnClick;
    if (action.indexOf("link:") == 0) {                // actionOnClick parameter is being used
      location.href = action.substr(5);
    }
    else {
      if (action.indexOf("code:") == 0) {
        eval(action.substr(5));
      }
      else {
        location.href = action;
      }
    }
  }
  if (!e) {
    var e = window.event;
    e.cancelBubble = true;
  }
  if (e.stopPropagation) {
    e.stopPropagation();
  }
  if (this.parent.menuObj.mode == "cursor") {
    hideCursorMenus();
  }
  if (this.parent.menuObj.mode == "absolute" || this.parent.menuObj.mode == "fixed") {
    hideVisibleMenus();
    if (typeof(hideMenuBarMenus) == "function") {
      hideMenuBarMenus();
    }
  }
}

/*
Event handler that handles onmouseout event of the menu item.
*/
function menuItemOut() { // Private method
  if (this.enabled) {
    if (!(this.subMenu && this.subMenu.menuObj.style.visibility == "visible")) {
      this.className = this.itemClassName;
    }
    if (this.subMenu) {
      if (this.subMenu.menuObj.style.visibility == "visible") {
        this.arrowObj.className = this.arrowClassNameOver;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassNameOver;
        }
      }
    }
    else {
      if (this.iconObj) {
        this.iconObj.className = this.iconClassName;
      }
    }
  }
}

/*
Determine whether any of the tag name/tag id pair in the filter matches the tagName/tagId pair.
*/
function findMatch(tagName, tagId, filter) { // Private method
  for (var i = 0, len = filter.length; i < len; i++) {
    var filterArray = filter[i].toLowerCase().split(".");
    if ((filterArray[0] == "*" && filterArray[1] == "*") ||
        (filterArray[0] == "*" && filterArray[1] == tagId) ||
        (filterArray[0] == tagName && filterArray[1] == "*") ||
        (filterArray[0] == tagName && filterArray[1] == tagId)) {
      return true;
    }
  }
  return false;
}

/*
Determine whether to show or hide the menu.
*/
function canShowMenu(tagName, tagId, allExcept, noneExcept) { // Private method
  if (allExcept.length > 0) {
    return (!findMatch(tagName.toLowerCase(), tagId.toLowerCase(), allExcept));
  }
  else {
    if (noneExcept.length > 0) {
      return findMatch(tagName.toLowerCase(), tagId.toLowerCase(), noneExcept);
    }
    else {
      return true;
    }
  }
}

/*
Shows/Hides the pop-up menu.
*/
function activatePopUpMenu(e) { // Private method
  if (!popUpMenuObj) {
    return;
  }
  var state = popUpMenuObj.menuObj.style.visibility;
  if (state == "visible") {
    for (var i = 1; i <= menuCount; i++) {
      var menuObj = getElmId("DOMenu" + i);
      if (menuObj.mode == "cursor") {
        menuObj.style.visibility = "hidden";
        menuObj.style.left = "0px";
        menuObj.style.top = "0px";
        menuObj.initialLeft = 0;
        menuObj.initialTop = 0;
        refreshMenuItems(menuObj);
      }
    }
  }
  else {
    if (!e) {
      var e = window.event;
    }
    var targetElm = (e.target) ? e.target : e.srcElement;
    if (targetElm.nodeType == 3) {
      targetElm = targetElm.parentNode;
    }
    if (canShowMenu(targetElm.tagName, targetElm.id, popUpMenuObj.menuObj.allExceptFilter, popUpMenuObj.menuObj.noneExceptFilter)) {
      popUpMainMenu(popUpMenuObj.menuObj, e);
    }
  }
}

/*
Event handler that handles left click event.
*/
function leftClickHandler(e) { // Private method
  if (getX(e) > getClientWidth() || getY(e) > getClientHeight()) {
    return;
  }
  if (!e) {
    var e = window.event;
  }
  if (e.button && e.button == 2) {
    return;
  }
  hideVisibleMenus();
  if (typeof(hideMenuBarMenus) == "function") {
    hideMenuBarMenus();
  }
  if (popUpMenuObj) {
    var state = popUpMenuObj.menuObj.style.visibility;
    if (state == "visible" && (hideValue == 0 || hideValue == 2)) {
      activatePopUpMenu(e);
    }
    if ((state == "hidden" || state == "") && (showValue == 0 || showValue == 2)) {
      activatePopUpMenu(e);
    }
  }
}

/*
Event handler that handles right click event.
*/
function rightClickHandler(e) { // Private method
  if (getX(e) > getClientWidth() || getY(e) > getClientHeight()) {
    return;
  }
  hideVisibleMenus();
  if (typeof(hideMenuBarMenus) == "function") {
    hideMenuBarMenus();
  }
  if (popUpMenuObj) {
    var state = popUpMenuObj.menuObj.style.visibility;
    if (state == "visible" && (hideValue == 1 || hideValue == 2)) {
      activatePopUpMenu(e);
      return false;
    }
    if ((state == "hidden" || state == "") && (showValue == 1 || showValue == 2)) {
      activatePopUpMenu(e);
      return false;
    }
  }
}

/*
Event handler that handles scroll event.
*/
function scrollHandler() { // Private method
  for (var i = 1; i <= menuCount; i++) {
      var menuObj = getElmId("DOMenu" + i);
      if (ie && menuObj.mode == "fixed") {
        menuObj.style.left = (menuObj.initialLeft + getScrollLeft()) + px;
        menuObj.style.top = (menuObj.initialTop + getScrollTop()) + px;
      }
  }
  if (typeof(menuBarScrollHandler) == "function") {
    menuBarScrollHandler();
  }
}

/*
Show the icon before the display text.
Arguments:
className          : Required. String that specifies the CSS class selector for the icon.
classNameOver      : Optional. String that specifies the CSS class selector for the icon when
                     the cursor is over the menu item.
*/
function showMenuItemIcon() { // Public method
  var iconElm = createElm("span");
  iconElm.id = this.id + "Icon";
  iconElm.className = arguments[0];
  this.insertBefore(iconElm, this.firstChild);
  var height;
  if (ie) {
    height = getPropIntVal(iconElm, "height");
  }
  else {
    height = iconElm.offsetHeight;
  }
  iconElm.style.top = Math.floor((this.offsetHeight - height) / 2) + px;
  if (ie) {
    var left = getPropIntVal(iconElm, "left");
    if (ie55 || ie6) {
      iconElm.style.left = (left - getPropIntVal(this, "padding-left")) + px;
    }
    else {
      iconElm.style.left = left + px;
    }
  }
  this.iconClassName = iconElm.className;
  if (arguments.length > 1 && arguments[1].length > 0) {
    this.iconClassNameOver = arguments[1];
  }
  this.iconObj = iconElm;
  this.setIconClassName = function(className) { // Public method
    this.iconClassName = className;
    this.iconObj.className = this.iconClassName;
  };
  this.setIconClassNameOver = function(classNameOver) { // Public method
    this.iconClassNameOver = classNameOver;
  };
}

/*
Set the menu object that will show up when the cursor is over the menu item object.
Argument:
menuObj            : Required. Menu object that will show up when the cursor is over the
                     menu item object.
*/
function setSubMenu(menuObj) { // Public method
  var arrowElm = createElm("div");
  arrowElm.id = this.id + "Arrow";
  arrowElm.className = this.arrowClassName;
  this.appendChild(arrowElm);
  var height;
  if (ie) {
    height = getPropIntVal(arrowElm, "height");
  }
  else {
    height = arrowElm.offsetHeight;
  }
  arrowElm.style.top = Math.floor((this.offsetHeight - height) / 2) + px;
  this.subMenu = menuObj;
  this.arrowObj = arrowElm;
  this.setArrowClassName = function(className) { // Public method
    this.arrowClassName = className;
    this.arrowObj.className = this.arrowClassName;
  };
  this.setArrowClassNameOver = function(classNameOver) { // Public method
    this.arrowClassNameOver = classNameOver;
  };
  menuObj.menuObj.style.zIndex = this.parent.menuObj.level + 1;
  menuObj.menuObj.level = this.parent.menuObj.level + 1;
}

/*
Add a new menu item to the menu.
Argument:
menuItemObj        : Required. Menu item object that is going to be added to the menu object.
*/
function addMenuItem(menuItemObj) { // Public method
  if (menuItemObj.displayText == "-") {
    var hrElm = createElm("hr");
    var itemElm = createElm("div");
    itemElm.appendChild(hrElm);
    itemElm.id = menuItemObj.id;
    if (menuItemObj.className.length > 0) {
      itemElm.sepClassName = menuItemObj.className;
    }
    else {
      itemElm.sepClassName = menuItemObj.sepClassName;
    }
    itemElm.className = itemElm.sepClassName;
    this.menuObj.appendChild(itemElm);
    itemElm.parent = this;
    itemElm.setClassName = function(className) { // Public method
      this.sepClassName = className;
      this.className = this.sepClassName;
    };
    itemElm.onclick = function(e) { // Private method
      if (!e) {
        var e = window.event;
        e.cancelBubble = true;
      }
      if (e.stopPropagation) {
        e.stopPropagation();
      }
    };
    itemElm.onmouseover = menuItemOver;
    if (menuItemObj.itemName.length > 0) {
      this.items[menuItemObj.itemName] = itemElm;
    }
    else {
      this.items[this.items.length] = itemElm;
    }
  }
  else {
    var itemElm = createElm("div");
    itemElm.id = menuItemObj.id;
    itemElm.actionOnClick = menuItemObj.actionOnClick;
    itemElm.enabled = menuItemObj.enabled;
    itemElm.itemClassName = menuItemObj.className;
    itemElm.itemClassNameOver = menuItemObj.classNameOver;
    itemElm.className = itemElm.itemClassName;
    itemElm.subMenu = null;
    itemElm.arrowClassName = arrowClassName;
    itemElm.arrowClassNameOver = arrowClassNameOver;
    var textNode = document.createTextNode(menuItemObj.displayText);
    itemElm.appendChild(textNode);
    this.menuObj.appendChild(itemElm);
    itemElm.parent = this;
    itemElm.setClassName = function(className) { // Public method
      this.itemClassName = className;
      this.className = this.itemClassName;
    };
    itemElm.setClassNameOver = function(classNameOver) { // Public method
      this.itemClassNameOver = classNameOver;
    };
    itemElm.setDisplayText = function(text) { // Public method
      if (this.childNodes[0].nodeType == 3) {
        this.childNodes[0].nodeValue = text;
      }
      else {
        this.childNodes[1].nodeValue = text;
      }
    };
    itemElm.setSubMenu = setSubMenu;
    itemElm.showIcon = showMenuItemIcon;
    itemElm.onmouseover = menuItemOver;
    itemElm.onclick = menuItemClick;
    itemElm.onmouseout = menuItemOut;
    if (menuItemObj.itemName.length > 0) {
      this.items[menuItemObj.itemName] = itemElm;
    }
    else {
      this.items[this.items.length] = itemElm;
    }
  }
}

/*
Create a new menu item object.
Arguments:
displayText        : Required. String that specifies the text to be displayed on the menu item. If
                     displayText = "-", a menu separator will be created instead.
itemName           : Optional. String that specifies the name of the menu item. Defaults to "" (no
                     name).
actionOnClick      : Optional. String that specifies the action to be done when the menu item is
                     being clicked. Defaults to "" (no action).
enabled            : Optional. Boolean that specifies whether the menu item is enabled/disabled.
                     Defaults to true.
className          : Optional. String that specifies the CSS class selector for the menu item.
                     Defaults to "jsdomenuitem".
classNameOver      : Optional. String that specifies the CSS class selector for the menu item when
                     the cursor is over it. Defaults to "jsdomenuitemover".
*/
function menuItem() { // Public method
  this.displayText = arguments[0];
  if (this.displayText == "-") {
    this.id = "menuSep" + (++sepCount);
    this.className = sepClassName;
  }
  else {
    this.id = "menuItem" + (++menuItemCount);
    this.className = menuItemClassName;
  }
  this.itemName = "";
  this.actionOnClick = "";
  this.enabled = true;
  this.classNameOver = menuItemClassNameOver;
  this.sepClassName = sepClassName;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0) {
    this.itemName = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.actionOnClick = arguments[2];
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    this.enabled = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    if (arguments[4] == "-") {
      this.className = arguments[4];
      this.sepClassName = arguments[4];
    }
    else {
      this.className = arguments[4];
    }
  }
  if (len > 5 && arguments[5].length > 0) {
    this.classNameOver = arguments[5];
  }
}

/*
Create a new menu object.
Arguments:
width              : Required. Integer that specifies the width of the menu.
mode               : Optional. String that specifies the mode of the menu. Defaults to "cursor".
id                 : Optional, except when mode = "static". String that specifies the id of
                     the element that will contain the menu. This argument is required when
                     mode = "static".
alwaysVisible      : Optional. Boolean that specifies whether the menu is always visible. Defaults
                     to false.
className          : Optional. String that specifies the CSS class selector for the menu. Defaults
                     to "jsdomenudiv".
*/
function jsDOMenu() { // Public method
  this.items = new Array();
  var menuElm;
  var len = arguments.length;
  if (len > 2 && arguments[2].length > 0 && arguments[1] == "static") {
    menuElm = getElmId(arguments[2]);
    if (!menuElm) {
      return;
    }
    staticMenuId[staticMenuId.length] = arguments[2];
  }
  else {
    menuElm = createElm("div");
    menuElm.id = "DOMenu" + (++menuCount);
  }
  menuElm.level = 10;
  menuElm.previousItem = null;
  menuElm.allExceptFilter = allExceptFilter;
  menuElm.noneExceptFilter = noneExceptFilter;
  menuElm.className = menuClassName;
  menuElm.mode = menuMode;
  menuElm.alwaysVisible = false;
  menuElm.initialLeft = 0;
  menuElm.initialTop = 0;
  if (len > 1 && arguments[1].length > 0) {
    switch (arguments[1]) {
      case "cursor":
        menuElm.style.position = "absolute";
        menuMode.mode = "cursor";
        break;
      case "absolute":
        menuElm.style.position = "absolute";
        menuElm.mode = "absolute";
        break;
      case "fixed":
        if (ie) {
          menuElm.style.position = "absolute";
        }
        else {
          menuElm.style.position = "fixed";
        }
        menuElm.mode = "fixed";
        break;
      case "static":
        menuElm.style.position = "static";
        menuElm.mode = "static";
        break;
    }
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    menuElm.alwaysVisible = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    menuElm.className = arguments[4];
  }
  menuElm.style.width = arguments[0] + px;
  menuElm.style.left = "0px";
  menuElm.style.top = "0px";
  if (menuElm.mode != "static") {
    document.body.appendChild(menuElm);
  }
  if (!getPropVal(menuElm, blw)) {
    menuElm.style.borderWidth = menuBorderWidth + px;
  }
  this.menuObj = menuElm;
  this.addMenuItem = addMenuItem;
  this.setClassName = function(className) { // Public method
    this.menuObj.className = className;
  };
  this.setMode = function(mode) { // Public method
    switch (mode) {
      case "cursor":
        this.menuObj.style.position = "absolute";
        this.menuObj.mode = "cursor";
        break;
      case "absolute":
        this.menuObj.style.position = "absolute";
        this.menuObj.mode = "absolute";
        this.menuObj.initialLeft = parseInt(this.menuObj.style.left);
        this.menuObj.initialTop = parseInt(this.menuObj.style.top);
        break;
      case "fixed":
        if (ie) {
          this.menuObj.style.position = "absolute";
          this.menuObj.initialLeft = parseInt(this.menuObj.style.left);
          this.menuObj.initialTop = parseInt(this.menuObj.style.top);
        }
        else {
          this.menuObj.style.position = "fixed";
        }
        this.menuObj.mode = "fixed";
        break;
    }
  };
  this.setAlwaysVisible = function(alwaysVisible) { // Public method
    if (typeof(alwaysVisible) == "boolean") {
      this.menuObj.alwaysVisible = alwaysVisible;
    }
  };
  this.show = function() { // Public method
    this.menuObj.style.visibility = "visible";
  };
  this.hide = function() { // Public method
    this.menuObj.style.visibility = "hidden";
    if (this.menuObj.mode == "cursor") {
      this.menuObj.style.left = "0px";
      this.menuObj.style.top = "0px";
      this.menuObj.initialLeft = 0;
      this.menuObj.initialTop = 0;
    }
  };
  this.setX = function(x) { // Public method
    this.menuObj.initialLeft = x;
    this.menuObj.style.left = x + px;
  };
  this.setY = function(y) { // Public method
    this.menuObj.initialTop = y;
    this.menuObj.style.top = y + px;
  };
  this.moveTo = function(x, y) { // Public method
    this.menuObj.initialLeft = x;
    this.menuObj.initialTop = y;
    this.menuObj.style.left = x + px;
    this.menuObj.style.top = y + px;
  };
  this.moveBy = function(x, y) { // Public method
    var left = parseInt(this.menuObj.style.left);
    var top = parseInt(this.menuObj.style.top);
    this.menuObj.initialLeft = left + x;
    this.menuObj.initialTop = top + y;
    this.menuObj.style.left = (left + x) + px;
    this.menuObj.style.top = (top + y) + px;
  };
  this.setAllExceptFilter = function(filter) { // Public method
    this.menuObj.allExceptFilter = filter;
    this.menuObj.noneExceptFilter = new Array();
  };
  this.setNoneExceptFilter = function(filter) { // Public method
    this.menuObj.noneExceptFilter = filter;
    this.menuObj.allExceptFilter = new Array();
  };
  this.setBorderWidth = function(width) { // Public method
    this.menuObj.style.borderWidth = width + px;
  };
}

/*
Specifies how the pop-up menu shows/hide.
Arguments:
showValue          : Required. Integer that specifies how the menu shows.
hideValue          : Optional. Integer that specifies how the menu hides. If not specified, the
                     menu shows/hides in the same manner.

0: Shows/Hides the menu by left click only.
1: Shows/Hides the menu by right click only.
2: Shows/Hides the menu by left or right click.
*/
function activatePopUpMenuBy() { // Public method
  showValue = typeof(arguments[0]) == "number" && arguments[0] > -1 ? arguments[0] : 0;
  if (arguments.length > 1) {
    hideValue = typeof(arguments[1]) == "number" && arguments[1] > -1 ? arguments[1] : 0;
  }
  else {
    hideValue = showValue;
  }
  if (showValue == 1 || showValue == 2 || hideValue == 1 || hideValue == 2) {
    document.oncontextmenu = rightClickHandler;
  }
}

/*
Hide all menus, except those with alwaysVisible = true.
*/
function hideAllMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if (!menuObj.alwaysVisible) {
      if (menuObj.style.position == "fixed") {
        menuObj.style.position == "absolute";
        menuObj.style.visibility = "hidden";
        menuObj.style.position == "fixed";
      }
      else {
        menuObj.style.visibility = "hidden";
        if (menuObj.mode == "cursor") {
          menuObj.style.left = "0px";
          menuObj.style.top = "0px";
          menuObj.initialLeft = 0;
          menuObj.initialTop = 0;
        }
      }
    }
    refreshMenuItems(menuObj);
  }
  for (var i = 0, len = staticMenuId.length; i < len; i++) {
    refreshMenuItems(getElmId(staticMenuId[i]));
  }
}

/*
Hide all menus with mode = "cursor", except those with alwaysVisible = true.
*/
function hideCursorMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if (menuObj.mode == "cursor" && !menuObj.alwaysVisible) {
      menuObj.style.visibility = "hidden";
      menuObj.style.left = "0px";
      menuObj.style.top = "0px";
      menuObj.initialLeft = 0;
      menuObj.initialTop = 0;
    }
    if (menuObj.mode == "cursor") {
      refreshMenuItems(menuObj);
    }
  }
}

/*
Hide all menus with mode = "absolute" or mode = "fixed" or mode = "static", except those with
alwaysVisible = true.
*/
function hideVisibleMenus() { // Public method
  for (var i = 1; i <= menuCount; i++) {
    var menuObj = getElmId("DOMenu" + i);
    if ((menuObj.mode == "absolute" || menuObj.mode == "fixed") && !menuObj.alwaysVisible) {
      if (menuObj.style.position == "fixed") {
        menuObj.style.position = "absolute";
        menuObj.style.visibility = "hidden";
        menuObj.style.position = "fixed";
      }
      else {
        menuObj.style.visibility = "hidden";
        menuObj.style.left = "0px";
        menuObj.style.top = "0px";
        menuObj.initialLeft = 0;
        menuObj.initialTop = 0;
      }
    }
    if (menuObj.mode == "absolute" || menuObj.mode == "fixed") {
      refreshMenuItems(menuObj);
    }
  }
  for (var i = 0, len = staticMenuId.length; i < len; i++) {
    refreshMenuItems(getElmId(staticMenuId[i]));
  }
  if (typeof(staticMenuBarId) == "object") {
    for (var i = 0, len = staticMenuBarId.length; i < len; i++) {
      refreshMenuBarItems(getElmId(staticMenuBarId[i]));
    }
  }
}

/*
Hide the menu and all its submenus.
Argument:
menuObj            : Required. Menu object that specifies the menu and all its submenus to
                     be hidden.
*/
function hideMenus(menuObj) { // Public method
  refreshMenuItems(menuObj);
  for (var i = 0, len = menuObj.childNodes.length; i < len; i++) {
    if (menuObj.childNodes[i].enabled && menuObj.childNodes[i].subMenu) {
      hideMenus(menuObj.childNodes[i].subMenu.menuObj);
    }
  }
  if (menuObj.style.position == "fixed") {
    menuObj.style.position = "absolute";
    menuObj.style.visibility = "hidden";
    menuObj.style.position = "fixed";
  }
  else {
    menuObj.style.visibility = "hidden";
    menuObj.style.left = "0px";
    menuObj.style.top = "0px";
    menuObj.initialLeft = 0;
    menuObj.initialTop = 0;
  }
}

/*
Set the menu object to be the pop-up menu.
Argument:
menuObj            : Required. Menu object that specifies the pop-up menu.
*/
function setPopUpMenu(menuObj) { // Public method
  popUpMenuObj = menuObj;
}

/*
Check browser compatibility and create the menus.
*/
function initjsDOMenu() { // Public method
  if (document.createElement && document.getElementById) {
    createjsDOMenu();
  }
}

if (typeof(allExceptFilter) == "undefined") {
  var allExceptFilter = new Array("A.*",
                                  "BUTTON.*",
                                  "IMG.*",
                                  "INPUT.*",
                                  "OBJECT.*",
                                  "OPTION.*",
                                  "SELECT.*",
                                  "TEXTAREA.*"); // Public field
}

if (typeof(noneExceptFilter) == "undefined") {
  var noneExceptFilter = new Array(); // Public field
}

if (typeof(menuClassName) == "undefined") {
  var menuClassName = "jsdomenudiv"; // Public field
}

if (typeof(menuItemClassName) == "undefined") {
  var menuItemClassName = "jsdomenuitem"; // Public field
}

if (typeof(menuItemClassNameOver) == "undefined") {
  var menuItemClassNameOver = "jsdomenuitemover"; // Public field
}

if (typeof(sepClassName) == "undefined") {
  var sepClassName = "jsdomenusep"; // Public field
}

if (typeof(arrowClassName) == "undefined") {
  var arrowClassName = "jsdomenuarrow"; // Public field
}

if (typeof(arrowClassNameOver) == "undefined") {
  var arrowClassNameOver = "jsdomenuarrowover"; // Public field
}

if (typeof(menuMode == "undefined")) {
  var menuMode = "cursor"; // Public field
}

if (typeof(menuBorderWidth) == "undefined") {
  var menuBorderWidth = 2; // Public field
}

var ie50 = isIE50(); // Private field
var ie55 = isIE55(); // Private field
var ie5 = isIE5(); // Private field
var ie6 = isIE6(); // Private field
var ie = isIE(); // Private field
var opera = isOpera(); // Private field
var safari = isSafari(); // Private field
var pageMode = getPageMode(); // Private field
var px = "px"; // Private field
var btw = "border-top-width"; // Private field
var bbw = "border-bottom-width"; // Private field
var blw = "border-left-width"; // Private field
var brw = "border-right-width"; // Private field
var menuCount = 0; // Private field
var menuItemCount = 0; // Private field
var sepCount = 0; // Private field
var popUpMenuObj = null; // Private field
var showValue = 0; // Private field
var hideValue = 0; // Private field
var staticMenuId = new Array(); // Private field
document.onclick = leftClickHandler;
window.onscroll = scrollHandler;

/************************************************************************
 * End file jsdomenu.js
 ************************************************************************/

/************************************************************************
 * Begin file jsdomenubar.js
 ************************************************************************/

/*

  jsDOMenuBar Version 1.1.1
  Copyright (C) 2004 - 2005 Toh Zhiqiang
  Released on 12 February 2005
  jsDOMenuBar is distributed under the terms of the GNU GPL license
  Refer to license.txt for more informatiom

*/

/*
Get the left position of the menu bar menu.
*/
function getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) { // Private method
  if (x + menuObj.offsetWidth <= getClientWidth()) {
    return x;
  }
  else {
    return x + menuBarItemObj.offsetWidth - menuObj.offsetWidth + getPropIntVal(menuObj, blw) + getPropIntVal(menuObj, brw);
  }
}

/*
Get the top position of the menu bar menu.
*/
function getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) { // Private method
  if (y + menuObj.offsetHeight <= getClientHeight()) {
    return y;
  }
  else {
    if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 0) {
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
    }
    if ((ie55 || ie6) && menuBarObj.mode == "static" && pageMode == 1) {
      return menuBarItemObj.offsetTop
           - menuObj.offsetHeight
           - getPropIntVal(menuBarObj, pt)
           + getPropIntVal(menuBarItemObj, pt)
           + getPropIntVal(menuBarItemObj, btw)
           - getScrollTop();
    }
    else {
      return y - menuObj.offsetHeight - menuBarObj.offsetHeight;
    }
  }
}

/*
Pop up the menu bar menu.
*/
function popUpMenuBarMenu(menuBarObj, menuBarItemObj, menuObj) { // Private method
  var x;
  var y;
  if (menuBarObj.style.position == "fixed") {
    x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw);
    y = menuBarObj.offsetTop + menuBarObj.offsetHeight;
    if (opera || safari) {
      x -= getPropIntVal(menuBarObj, blw);
    }
    menuObj.style.position = "absolute";
    menuObj.style.left = getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + px;
    menuObj.style.top = getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + px;
    menuObj.style.position = "fixed";
  }
  else {
    if (menuBarObj.mode == "static") {
      x = menuBarItemObj.offsetLeft - getPropIntVal(menuObj, blw) - getScrollLeft();
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
      if (ie55 || ie6) {
        x += getPropIntVal(menuBarObj, blw);
        y = menuBarItemObj.offsetTop + menuBarItemObj.offsetHeight
          + getPropIntVal(menuBarObj, bbw)
          + getPropIntVal(menuBarObj, pb)
          - getPropIntVal(menuBarItemObj, bbw)
          - getScrollTop();
      }
      if (safari) {
        x += 8;
        y += 13;
      }
      menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px;
      menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px;
    }
    else {
      x = menuBarObj.offsetLeft + menuBarItemObj.offsetLeft + getPropIntVal(menuBarObj, blw) - getPropIntVal(menuObj, blw) - getScrollLeft();
      y = menuBarObj.offsetTop + menuBarObj.offsetHeight - getScrollTop();
      if (opera || safari) {
        x -= getPropIntVal(menuBarObj, blw);
      }
      menuObj.style.left = (getMainMenuBarMenuLeftPos(menuBarObj, menuBarItemObj, menuObj, x) + getScrollLeft()) + px;
      menuObj.style.top = (getMainMenuBarMenuTopPos(menuBarObj, menuBarItemObj, menuObj, y) + getScrollTop()) + px;
    }
  }
  if (ie && menuObj.mode == "fixed") {
    menuObj.initialLeft = parseInt(menuObj.style.left) - getScrollLeft();
    menuObj.initialTop = parseInt(menuObj.style.top) - getScrollTop();
  }
  menuObj.style.visibility = "visible";
}

/*
Refresh the menu bar items.
*/
function refreshMenuBarItems(menuBarObj) { // Private method
  for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
    if (menuBarObj.childNodes[i].enabled && menuBarObj.childNodes[i].clicked) {
      menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
      if (menuBarObj.childNodes[i].iconObj) {
        menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
      }
      menuBarObj.childNodes[i].clicked = false;
      if (menuBarObj.childNodes[i].menu) {
        hideMenus(menuBarObj.childNodes[i].menu.menuObj);
      }
      break;
    }
  }
  menuBarObj.activated = false;
}

/*
Event handler that handles onmouseover event of the menu bar item.
*/
function menuBarItemOver(e) { // Private method
  if (this.parent.menuBarObj.activated) {
    if (!this.clicked) {
      var menuBarObj = this.parent.menuBarObj;
      for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
        if (menuBarObj.childNodes[i].enabled && menuBarObj.childNodes[i].clicked) {
          menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
          if (menuBarObj.childNodes[i].iconObj) {
            menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
          }
          menuBarObj.childNodes[i].clicked = false;
          if (menuBarObj.childNodes[i].menu) {
            hideMenus(menuBarObj.childNodes[i].menu.menuObj);
          }
          break;
        }
      }
      if (this.enabled) {
        if (this.menu) {
          this.onclick(e);
        }
        else {
          if (this.actionOnClick) {
            this.className = this.itemClassNameClick;
            if (this.iconObj && this.iconClassNameClick) {
              this.iconObj.className = this.iconClassNameClick;
            }
            this.clicked = true;
          }
        }
      }
    }
  }
  else {
    var menuBarObj = this.parent.menuBarObj;
    for (var i = 0, len = menuBarObj.childNodes.length; i < len; i++) {
      if (menuBarObj.childNodes[i].enabled) {
        menuBarObj.childNodes[i].className = menuBarObj.childNodes[i].itemClassName;
        if (menuBarObj.childNodes[i].iconObj) {
          menuBarObj.childNodes[i].iconObj.className = menuBarObj.childNodes[i].iconClassName;
        }
      }
    }
    if (this.enabled && (this.menu || this.actionOnClick)) {
      switch (menuBarObj.activateMode) {
        case "click":
          this.className = this.itemClassNameOver;
          break;
        case "over":
          if (this.menu) {
            this.onclick(e);
          }
          else {
            this.className = this.itemClassNameOver;
          }
          break;
      }
      if (this.iconObj && this.iconClassNameOver) {
        this.iconObj.className = this.iconClassNameOver;
      }
    }
  }
}

/*
Event handler that handles onclick event of the menu bar item.
*/
function menuBarItemClick(e) { // Private method
  if (this.enabled) {
    if (this.menu) {
      if (this.clicked) {
        this.className = this.itemClassNameOver;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassNameOver;
        }
        hideMenus(this.menu.menuObj);
        this.clicked = false;
        this.parent.menuBarObj.activated = false;
      }
      else {
        this.className = this.itemClassNameClick;
        if (this.iconObj && this.iconClassNameClick) {
          this.iconObj.className = this.iconClassNameClick;
        }
        popUpMenuBarMenu(this.parent.menuBarObj, this, this.menu.menuObj);
        this.clicked = true;
        this.parent.menuBarObj.activated = true;
      }
    }
    else {
      if (this.actionOnClick) {
        var action = this.actionOnClick;
        if (action.indexOf("link:") == 0) {
          location.href = action.substr(5);
        }
        else {
          if (action.indexOf("code:") == 0) {
            eval(action.substr(5));
          }
          else {
            location.href = action;
          }
        }
        this.className = this.itemClassName;
        if (this.iconObj) {
          this.iconObj.className = this.iconClassName;
        }
        this.clicked = false;
        this.parent.menuBarObj.activated = false;
      }
    }
  }
  if (!e) {
    var e = window.event;
    e.cancelBubble = true;
  }
  if (e.stopPropagation) {
    e.stopPropagation();
  }
}

/*
Event handler that handles onmouseout event of the menu bar item.
*/
function menuBarItemOut() { // Private method
  if (!this.parent.menuBarObj.activated) {
    this.className = this.itemClassName;
    if (this.iconObj) {
      this.iconObj.className = this.iconClassName;
    }
  }
}

/*
Event handler that handles onmousedown event of the menu bar.
*/
function menuBarDown(e) { // Private method
  draggingObj = this.parent.menuBarObj;
  var menuBarObj = this.parent.menuBarObj;
  menuBarObj.differenceLeft = getX(e) - menuBarObj.offsetLeft;
  menuBarObj.differenceTop = getY(e) - menuBarObj.offsetTop;
  hideMenuBarMenus();
  document.onmousemove = mouseMoveHandler;
}

/*
Event handler that handles onmouseup event of the menu bar.
*/
function menuBarUp() { // Private method
  draggingObj = null;
  var menuBarObj = this.parent.menuBarObj;
  menuBarObj.differenceLeft = 0;
  menuBarObj.differenceTop = 0;
  menuBarObj.initialLeft = menuBarObj.offsetLeft - getScrollLeft();
  menuBarObj.initialTop = menuBarObj.offsetTop - getScrollTop();
  document.onmousemove = null;
}

/*
Event handler that handles mouse move event.
*/
function mouseMoveHandler(e) { // Private method
  if (draggingObj) {
    draggingObj.style.left = (getX(e) - draggingObj.differenceLeft) + px;
    draggingObj.style.top = (getY(e) - draggingObj.differenceTop) + px;
  }
}

/*
Event handler that handles scroll event.
*/
function menuBarScrollHandler() { // Private method
  for (var i = 1; i <= menuBarCount; i++) {
    var menuBarObj = getElmId("DOMenuBar" + i);
    if (ie && menuBarObj.mode == "fixed") {
      menuBarObj.style.left = (menuBarObj.initialLeft + getScrollLeft()) + px;
      menuBarObj.style.top = (menuBarObj.initialTop + getScrollTop()) + px;
    }
  }
}

/*
Hide all menu bar menus.
*/
function hideMenuBarMenus() { // Public method
  for (var i = 1; i <= menuBarCount; i++) {
    refreshMenuBarItems(getElmId("DOMenuBar" + i));
  }
}

/*
Show the icon before the display text.
Arguments:
className          : Required. String that specifies the CSS class selector for the icon.
classNameOver      : Optional. String that specifies the CSS class selector for the icon when
                     the cursor is over the menu bar item.
classNameClick     : Optional. String that specifies the CSS class selector for the icon when
                     the cursor is clicked on the menu bar item.
*/
function showMenuBarItemIcon() { // Public method
  var iconElm = createElm("span");
  var textNode = document.createTextNode("");
  iconElm.appendChild(textNode);
  iconElm.id = this.id + "Icon";
  iconElm.className = arguments[0];
  this.insertBefore(iconElm, this.firstChild);
  var height;
  var offsetHeight;
  var menuBarObj = this.parent.menuBarObj;
  var offset = getPropIntVal(menuBarObj, btw)
             + getPropIntVal(this, pt)
             - getPropIntVal(menuBarObj, pb)
             - getPropIntVal(menuBarObj, bbw)
             - getPropIntVal(this, pb);
  if (ie55 || ie6) {
    height = getPropIntVal(iconElm, "height");
    offsetHeight = (menuBarObj.mode == "static") ? menuBarObj.offsetHeight + offset : this.offsetHeight + getPropIntVal(this, pt) - getPropIntVal(this, pb);
  }
  else {
    height = iconElm.offsetHeight;
    offsetHeight = this.offsetHeight;
  }
  iconElm.style.top = Math.floor((offsetHeight - height) / 2) + px;
  if (opera && this.parent.menuBarObj.mode != "static") {
    iconElm.style.display = "none";
  }
  this.iconClassName = iconElm.className;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0) {
    this.iconClassNameOver = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.iconClassNameClick = arguments[2];
  }
  this.iconObj = iconElm;
  this.setIconClassName = function(className) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassName = className;
    this.iconObj.className = this.iconClassName;
  };
  this.setIconClassNameOver = function(classNameOver) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassNameOver = classNameOver;
  };
  this.setIconClassNameClick = function(classNameClick) { // Public method
    if (opera && this.parent.menuBarObj.mode != "static") {
      return;
    }
    this.iconClassNameClick = classNameClick;
  };
}

/*
Add a new menu bar item to the menu bar.
Argument:
menuBarItemObj     : Required. Menu bar item object that is going to be added to the menu bar
                     object.
*/
function addMenuBarItem(menuBarItemObj) { // Public method
  var itemElm = createElm("span");
  itemElm.id = menuBarItemObj.id;
  itemElm.menu = menuBarItemObj.menu;
  itemElm.enabled = menuBarItemObj.enabled;
  itemElm.clicked = false;
  itemElm.actionOnClick = menuBarItemObj.actionOnClick;
  itemElm.itemClassName = menuBarItemObj.className;
  itemElm.itemClassNameOver = menuBarItemObj.classNameOver;
  itemElm.itemClassNameClick = menuBarItemObj.classNameClick;
  itemElm.className = itemElm.itemClassName;
  if (ie50) {
    itemElm.style.height = "1%";
  }
  if (ie55) {
    itemElm.style.width = "auto";
  }
  var textNode = document.createTextNode(menuBarItemObj.displayText);
  itemElm.appendChild(textNode);
  this.menuBarObj.appendChild(itemElm);
  itemElm.parent = this;
  itemElm.setClassName = function(className) { // Public method
    this.itemClassName = className;
    this.className = this.itemClassName;
  };
  itemElm.setClassNameOver = function(classNameOver) { // Public method
    this.itemClassNameOver = classNameOver;
  };
  itemElm.setClassNameClick = function(classNameClick) { // Public method
    this.itemClassNameClick = classNameClick;
  };
  itemElm.setDisplayText = function(text) { // Public method
    if (this.childNodes[0].nodeType == 3) {
      this.childNodes[0].nodeValue = text;
    }
    else {
      this.childNodes[1].nodeValue = text;
    }
  };
  itemElm.setMenu = function(menu) { // Public method
    this.menu = menu;
  };
  itemElm.showIcon = showMenuBarItemIcon;
  itemElm.onmouseover = menuBarItemOver;
  itemElm.onclick = menuBarItemClick;
  itemElm.onmouseout = menuBarItemOut;
  if (menuBarItemObj.itemName.length > 0) {
    this.items[menuBarItemObj.itemName] = itemElm;
  }
  else {
    this.items[this.items.length] = itemElm;
  }
  var len = 0;
  for (var x in this.items) {
    ++len;
  }
  if (len == 1 && opera && pageMode == 0) {
    this.dragObj.style.height = (this.dragObj.offsetTop - itemElm.offsetTop) + px;
  }
}

/*
Create a new menu bar item object.
Arguments:
displayText        : Required. String that specifies the text to be displayed on the menu bar item.
menuObj            : Optional. Menu object that is going to be the main menu for the menu bar item.
                     Defaults to null (no menu).
itemName           : Optional. String that specifies the name of the menu bar item. Defaults to ""
                     (no name).
enabled            : Optional. Boolean that specifies whether the menu bar item is enabled/disabled.
                     Defaults to true.
actionOnClick      : Optional. String that specifies the action to be done when the menu item is
                     being clicked if no main menu has been set for the menu bar item. Defaults to
                     "" (no action).
className          : Optional. String that specifies the CSS class selector for the menu bar item.
                     Defaults to "jsdomenubaritem".
classNameOver      : Optional. String that specifies the CSS class selector for the menu item when
                     the cursor is over it. Defaults to "jsdomenubaritemover".
classNameClick     : Optional. String that specifies the CSS class selector for the menu item when
                     the cursor is clicked on it. Defaults to "jsdomenubaritemclick".
*/
function menuBarItem() { // Public method
  this.displayText = arguments[0];
  this.id = "menuBarItem" + (++menuBarItemCount);
  this.itemName = "";
  this.menu = null;
  this.enabled = true;
  this.actionOnClick = "";
  this.className = menuBarItemClassName;
  this.classNameOver = menuBarItemClassNameOver;
  this.classNameClick = menuBarItemClassNameClick;
  var len = arguments.length;
  if (len > 1 && typeof(arguments[1]) == "object") {
    this.menu = arguments[1];
  }
  if (len > 2 && arguments[2].length > 0) {
    this.itemName = arguments[2];
  }
  if (len > 3 && typeof(arguments[3]) == "boolean") {
    this.enabled = arguments[3];
  }
  if (len > 4 && arguments[4].length > 0) {
    this.actionOnClick = arguments[4];
  }
  if (len > 5 && arguments[5].length > 0) {
    this.className = arguments[5];
  }
  if (len > 6 && arguments[6].length > 0) {
    this.classNameOver = arguments[6];
  }
  if (len > 7 && arguments[7].length > 0) {
    this.classNameClick = arguments[7];
  }
}

/*
Create a new menu bar object.
Arguments:
mode               : Optional. String that specifies the mode of the menu bar. Defaults to "absolute".
id                 : Optional, except when mode = "static". String that specifies the id of
                     the element that will contain the menu bar. This argument is required when
                     mode = "static".
draggable          : Optional. Boolean that specifies whether the menu bar is draggable. Defaults to
                     false.
className          : Optional. String that specifies the CSS class selector for the menu bar. Defaults
                     to "jsdomenubardiv".
width              : Optional. Integer that specifies the width of the menu bar. Defaults to "auto".
height             : Optional. Integer that specifies the height of the menu bar. Defaults to "auto".
*/
function jsDOMenuBar() { // Public method
  this.items = new Array();
  var dragElm = createElm("span");
  dragElm.className = menuBarDragClassName;
  var textNode = document.createTextNode("");
  dragElm.appendChild(textNode);
  var menuBarElm;
  var len = arguments.length;
  if (len > 1 && arguments[1].length > 0 && arguments[0] == "static") {
    menuBarElm = getElmId(arguments[1]);
    if (!menuBarElm) {
      return;
    }
    staticMenuBarId[staticMenuBarId.length] = arguments[1];
    menuBarElm.appendChild(dragElm);
  }
  else {
    menuBarElm = createElm("div");
    menuBarElm.appendChild(dragElm);
    menuBarElm.id = "DOMenuBar" + (++menuBarCount);
  }
  menuBarElm.mode = menuBarMode;
  menuBarElm.activateMode = menuBarActivateMode;
  menuBarElm.draggable = false;
  menuBarElm.className = menuBarClassName;
  menuBarElm.activated = false;
  menuBarElm.initialLeft = 0;
  menuBarElm.initialTop = 0;
  menuBarElm.differenceLeft = 0;
  menuBarElm.differenceTop = 0;
  if (len > 0 && arguments[0].length > 0) {
    switch (arguments[0]) {
      case "absolute":
        menuBarElm.style.position = "absolute";
        menuBarElm.mode = "absolute";
        break;
      case "fixed":
        if (ie) {
          menuBarElm.style.position = "absolute";
        }
        else {
          menuBarElm.style.position = "fixed";
        }
        menuBarElm.mode = "fixed";
        break;
      case "static":
        menuBarElm.style.position = "static";
        menuBarElm.mode = "static";
        break;
    }
  }
  if (len > 2 && typeof(arguments[2]) == "boolean") {
    menuBarElm.draggable = arguments[2];
    if (menuBarElm.draggable) {
      dragElm.style.visibility = "visible";
    }
    else {
      dragElm.style.visibility = "hidden";
    }
  }
  if (len > 3 && arguments[3].length > 0) {
    menuBarElm.className = arguments[3];
  }
  if (len > 4 && typeof(arguments[4]) == "number" && arguments[4] > 0) {
    menuBarElm.style.width = arguments[4] + px;
  }
  if (len > 5 && typeof(arguments[5]) == "number" && arguments[5] > 0) {
    menuBarElm.style.height = arguments[5] + px;
  }
  menuBarElm.style.left = "0px";
  menuBarElm.style.top = "0px";
  if (ie50) {
    menuBarElm.style.height = "1%";
  }

  if (opera) {
	document.body.style.height = (window.innerHeight-20) + "px";
  }

  if (menuBarElm.mode != "static") {
    document.body.appendChild(menuBarElm);
  }
  else {
    if (ie) {
      menuBarElm.style.height = "1%";
    }
  }
  if (!getPropVal(menuBarElm, blw)) {
    menuBarElm.style.borderWidth = menuBarBorderWidth + px;
  }
  this.menuBarObj = menuBarElm;
  this.dragObj = dragElm;
  dragElm.parent = this;
  this.addMenuBarItem = addMenuBarItem;
  this.menuBarObj.onclick = function(e) { // Private method
    if (!e) {
      var e = window.event;
      e.cancelBubble = true;
    }
    if (e.stopPropagation) {
      e.stopPropagation();
    }
  };
  dragElm.onmousedown = menuBarDown;
  dragElm.onmouseup = menuBarUp;
  this.setMode = function(mode) { // Public method
    switch (mode) {
      case "absolute":
        this.menuBarObj.style.position = "absolute";
        this.menuBarObj.mode = "absolute";
        this.menuBarObj.initialLeft = parseInt(this.menuBarObj.style.left);
        this.menuBarObj.initialTop = parseInt(this.menuBarObj.style.top);
        break;
      case "fixed":
        if (ie) {
          this.menuBarObj.style.position = "absolute";
          this.menuBarObj.initialLeft = parseInt(this.menuBarObj.style.left);
          this.menuBarObj.initialTop = parseInt(this.menuBarObj.style.top);
        }
        else {
          this.menuBarObj.style.position = "fixed";
        }
        this.menuBarObj.mode = "fixed";
        break;
    }
  };
  this.setActivateMode = function(activateMode) { // Public method
    this.menuBarObj.activateMode = activateMode;
  };
  this.setDraggable = function(draggable) { // Public method
    if (typeof(draggable) == "boolean" && this.menuBarObj.mode != "static") {
      this.menuBarObj.draggable = draggable;
      if (this.menuBarObj.draggable) {
        this.dragObj.style.visibility = "visible";
      }
      else {
        this.dragObj.style.visibility = "hidden";
      }
    }
  };
  this.setClassName = function(className) { // Public method
    this.menuBarObj.className = className;
  };
  this.setDragClassName = function(className) { // Public method
    this.dragObj.className = className;
  };
  this.show = function() { // Public method
    this.menuBarObj.style.visibility = "visible";
  };
  this.hide = function() { // Public method
    this.menuBarObj.style.visibility = "hidden";
  };
  this.setX = function(x) { // Public method
    this.menuBarObj.initialLeft = x;
    this.menuBarObj.style.left = x + px;
  };
  this.setY = function(y) { // Public method
    this.menuBarObj.initialTop = y;
    this.menuBarObj.style.top = y + px;
  };
  this.moveTo = function(x, y) { // Public method
    this.menuBarObj.initialLeft = x;
    this.menuBarObj.initialTop = y;
    this.menuBarObj.style.left = x + px;
    this.menuBarObj.style.top = y + px;
  };
  this.moveBy = function(x, y) { // Public method
    var left = parseInt(this.menuBarObj.style.left);
    var top = parseInt(this.menuBarObj.style.top);
    this.menuBarObj.initialLeft = left + x;
    this.menuBarObj.initialTop = top + y;
    this.menuBarObj.style.left = (left + x) + px;
    this.menuBarObj.style.top = (top + y) + px;
  };
  this.setBorderWidth = function(width) { // Public method
    this.menuBarObj.style.borderWidth = width + px;
  };
}

if (typeof(menuBarClassName) == "undefined") {
  var menuBarClassName = "jsdomenubardiv"; // Public field
}

if (typeof(menuBarItemClassName) == "undefined") {
  var menuBarItemClassName = "jsdomenubaritem"; // Public field
}

if (typeof(menuBarItemClassNameOver) == "undefined") {
  var menuBarItemClassNameOver = "jsdomenubaritemover"; // Public field
}

if (typeof(menuBarItemClassNameClick) == "undefined") {
  var menuBarItemClassNameClick = "jsdomenubaritemclick"; // Public field
}

if (typeof(menuBarDragClassName) == "undefined") {
  var menuBarDragClassName = "jsdomenubardragdiv"; // Public field
}

if (typeof(menuBarMode) == "undefined") {
  var menuBarMode = "absolute"; // Public field
}

if (typeof(menuBarActivateMode) == "undefined") {
  var menuBarActivateMode = "click"; // Public field
}

if (typeof(menuBarBorderWidth) == "undefined") {
  var menuBarBorderWidth = 2; // Public field
}

var pt = "padding-top"; // Private field
var pb = "padding-bottom"; // Private field
var menuBarCount = 0; // Private field
var menuBarItemCount = 0; // Private field
var draggingObj = null; // Private field
var staticMenuBarId = new Array(); // Private field

/************************************************************************
 * End file jsdomenubar.js
 ************************************************************************/

/************************************************************************
 * Begin file xajax.js
 ************************************************************************/

/* xajax Javascript library :: version 0.2.5 */
function Xajax(){this.arrayContainsValue=function(array,valueToCheck){for(i in array){if(array[i]==valueToCheck)return true;}return false;};this.DebugMessage=function(text){if(text.length > 1000)text=text.substr(0,1000)+"...\n[long response]\n...";try{if(this.debugWindow==undefined||this.debugWindow.closed==true){this.debugWindow=window.open('about:blank','xajax-debug','width=800,height=600,scrollbars=1,resizable,status');this.debugWindow.document.write('<html><head><title>Xajax debug output</title></head><body><h2>Xajax debug output</h2><div id="debugTag"></div></body></html>');}debugTag=this.debugWindow.document.getElementById('debugTag');if(!debugTag)throw new Error();text=text.replace(/&/g,"&amp;");text=text.replace(/</g,"&lt;");text=text.replace(/>/g,"&gt;");debugTag.innerHTML=('<b>'+(new Date()).toString()+'</b>: '+text+'<hr/>')+debugTag.innerHTML;}catch(e){alert("Xajax Debug:\n "+text);}
};this.workId='xajaxWork'+new Date().getTime();this.depth=0;this.responseErrorsForAlert=["400","401","402","403","404","500","501","502","503"];this.getRequestObject=function(){if(xajaxDebug)this.DebugMessage("Initializing Request Object..");var req=null;if(typeof XMLHttpRequest!="undefined")
req=new XMLHttpRequest();if(!req&&typeof ActiveXObject!="undefined"){try{req=new ActiveXObject("Msxml2.XMLHTTP");XMLHttpRequest=function(){return new ActiveXObject("Msxml2.XMLHTTP");}
}
catch(e){try{req=new ActiveXObject("Microsoft.XMLHTTP");XMLHttpRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP");}
}
catch(e2){try{req=new ActiveXObject("Msxml2.XMLHTTP.4.0");XMLHttpRequest=function(){return new ActiveXObject("Msxml2.XMLHTTP.4.0");}
}
catch(e3){req=null;}
}
}
}
if(!req&&window.createRequest)
req=window.createRequest();if(!req)this.DebugMessage("Request Object Instantiation failed.");return req;}
this.$=function(sId){if(!sId){return null;}
var returnObj=document.getElementById(sId);if(!returnObj&&document.all){returnObj=document.all[sId];}
if(xajaxDebug&&!returnObj&&sId!=this.workId){this.DebugMessage("Element with the id \""+sId+"\" not found.");}
return returnObj;}
this.include=function(sFileName){var objHead=document.getElementsByTagName('head');var objScript=document.createElement('script');objScript.type='text/javascript';objScript.src=sFileName;objHead[0].appendChild(objScript);}
this.stripOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')==0){sEventName=sEventName.replace(/on/,'');}
return sEventName;}
this.addOnPrefix=function(sEventName){sEventName=sEventName.toLowerCase();if(sEventName.indexOf('on')!=0){sEventName='on'+sEventName;}
return sEventName;}
this.addHandler=function(sElementId,sEvent,sFunctionName){if(window.addEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').addEventListener('"+sEvent+"',"+sFunctionName+",false);");}
else if(window.attachEvent){sAltEvent=this.addOnPrefix(sEvent);if(eval("this.$('"+sElementId+"').attachEvent('"+sAltEvent+"',"+sFunctionName+");"))
window.attachEvent('onunload',
eval("function(){xajax.$('"+sElementId+"').detachEvent('"+sAltEvent+"',"+sFunctionName+");}"));}
else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"')."+sAltEvent+" = "+sFunctionName);}
}
this.removeHandler=function(sElementId,sEvent,sFunctionName){if(window.removeEventListener){sEvent=this.stripOnPrefix(sEvent);eval("this.$('"+sElementId+"').removeEventListener('"+sEvent+"',"+sFunctionName+",false);");}
else if(window.detachEvent){sAltEvent=this.addOnPrefix(sEvent);try{eval("this.$('"+sElementId+"').detachEvent('"+sAltEvent+"',"+sFunctionName+");");}catch(ignore){}
}
else{sAltEvent=this.addOnPrefix(sEvent);eval("this.$('"+sElementId+"')."+sAltEvent+" = null");}
}
this.create=function(sParentId,sTag,sId){var objParent=this.$(sParentId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);if(objParent)
objParent.appendChild(objElement);}
this.insert=function(sBeforeId,sTag,sId){var objSibling=this.$(sBeforeId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling);}
this.insertAfter=function(sAfterId,sTag,sId){var objSibling=this.$(sAfterId);objElement=document.createElement(sTag);objElement.setAttribute('id',sId);objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
this.getInput=function(sType,sName,sId){var Obj;if(!window.addEventListener){Obj=document.createElement('<input type="'+sType+'" id="'+sId+'" name="'+sName+'">');}
else{Obj=document.createElement('input');Obj.setAttribute('type',sType);Obj.setAttribute('name',sName);Obj.setAttribute('id',sId);}
return Obj;}
this.createInput=function(sParentId,sType,sName,sId){var objParent=this.$(sParentId);var objElement=this.getInput(sType,sName,sId);if(objParent&&objElement)
objParent.appendChild(objElement);}
this.insertInput=function(sBeforeId,sType,sName,sId){var objSibling=this.$(sBeforeId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode)
objSibling.parentNode.insertBefore(objElement,objSibling);}
this.insertInputAfter=function(sAfterId,sType,sName,sId){var objSibling=this.$(sAfterId);var objElement=this.getInput(sType,sName,sId);if(objElement&&objSibling&&objSibling.parentNode){objSibling.parentNode.insertBefore(objElement,objSibling.nextSibling);}
}
this.remove=function(sId){objElement=this.$(sId);if(objElement&&objElement.parentNode&&objElement.parentNode.removeChild){objElement.parentNode.removeChild(objElement);}
}
this.replace=function(sId,sAttribute,sSearch,sReplace){var bFunction=false;if(sAttribute=="innerHTML")
sSearch=this.getBrowserHTML(sSearch);eval("var txt=this.$('"+sId+"')."+sAttribute);if(typeof txt=="function"){txt=txt.toString();bFunction=true;}
if(txt.indexOf(sSearch)>-1){var newTxt='';while(txt.indexOf(sSearch)>-1){x=txt.indexOf(sSearch)+sSearch.length+1;newTxt+=txt.substr(0,x).replace(sSearch,sReplace);txt=txt.substr(x,txt.length-x);}
newTxt+=txt;if(bFunction){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
else if(this.willChange(sId,sAttribute,newTxt)){eval('this.$("'+sId+'").'+sAttribute+'=newTxt;');}
}
}
this.getFormValues=function(frm){var objForm;var submitDisabledElements=false;if(arguments.length > 1&&arguments[1]==true)
submitDisabledElements=true;var prefix="";if(arguments.length > 2)
prefix=arguments[2];if(typeof(frm)=="string")
objForm=this.$(frm);else
objForm=frm;var sXml="<xjxquery><q>";if(objForm&&objForm.tagName.toUpperCase()=='FORM'){var formElements=objForm.elements;for(var i=0;i < formElements.length;i++){if(!formElements[i].name)
continue;if(formElements[i].name.substring(0,prefix.length)!=prefix)
continue;if(formElements[i].type&&(formElements[i].type=='radio'||formElements[i].type=='checkbox')&&formElements[i].checked==false)
continue;if(formElements[i].disabled&&formElements[i].disabled==true&&submitDisabledElements==false)
continue;var name=formElements[i].name;if(name){if(sXml!='<xjxquery><q>')
sXml+='&';if(formElements[i].type=='select-multiple'){for(var j=0;j < formElements[i].length;j++){if(formElements[i].options[j].selected==true)
sXml+=name+"="+encodeURIComponent(formElements[i].options[j].value)+"&";}
}
else{sXml+=name+"="+encodeURIComponent(formElements[i].value);}
}
}
}
sXml+="</q></xjxquery>";return sXml;}
this.objectToXML=function(obj){var sXml="<xjxobj>";for(i in obj){try{if(i=='constructor')
continue;if(obj[i]&&typeof(obj[i])=='function')
continue;var key=i;var value=obj[i];if(value&&typeof(value)=="object"&&this.depth <=50){this.depth++;value=this.objectToXML(value);this.depth--;}
sXml+="<e><k>"+key+"</k><v>"+value+"</v></e>";}
catch(e){if(xajaxDebug)this.DebugMessage(e.name+": "+e.message);}
}
sXml+="</xjxobj>";return sXml;}
this._nodeToObject=function(node){if (!node)return '';if(node.nodeName=='#cdata-section'||node.nodeName=='#text'){var data="";for(var j=0;j<node.parentNode.childNodes.length;j++){data+=node.parentNode.childNodes[j].data;}
return data;}
else if(node.nodeName=='xjxobj'){var data=new Array();for(var j=0;j<node.childNodes.length;j++){var child=node.childNodes[j];var key;var value;if(child.nodeName=='e'){for(var k=0;k<child.childNodes.length;k++){if(child.childNodes[k].nodeName=='k'){key=child.childNodes[k].firstChild.data;}
else if(child.childNodes[k].nodeName=='v'){value=this._nodeToObject(child.childNodes[k].firstChild);}
}
if(key!=null&&value!=null){data[key]=value;key=value=null;}
}
}
return data;}
}
this.loadingFunction=function(){};this.doneLoadingFunction=function(){};var loadingTimeout;this.call=function(sFunction,aArgs,sRequestType){var i,r,postData;if(document.body&&xajaxWaitCursor)
document.body.style.cursor='wait';if(xajaxStatusMessages==true)window.status='Sending Request...';clearTimeout(loadingTimeout);loadingTimeout=setTimeout("xajax.loadingFunction();",400);if(xajaxDebug)this.DebugMessage("Starting xajax...");if(sRequestType==null){var xajaxRequestType=xajaxDefinedPost;}
else{var xajaxRequestType=sRequestType;}
var uri=xajaxRequestUri;var value;switch(xajaxRequestType){case xajaxDefinedGet:{var uriGet=uri.indexOf("?")==-1?"?xajax="+encodeURIComponent(sFunction):"&xajax="+encodeURIComponent(sFunction);if(aArgs){for(i=0;i<aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object")
value=this.objectToXML(value);uriGet+="&xajaxargs[]="+encodeURIComponent(value);}
}
uriGet+="&xajaxr="+new Date().getTime();uri+=uriGet;postData=null;}break;case xajaxDefinedPost:{postData="xajax="+encodeURIComponent(sFunction);postData+="&xajaxr="+new Date().getTime();if(aArgs){for(i=0;i <aArgs.length;i++){value=aArgs[i];if(typeof(value)=="object")
value=this.objectToXML(value);postData=postData+"&xajaxargs[]="+encodeURIComponent(value);}
}
}break;default:
alert("Illegal request type: "+xajaxRequestType);return false;break;}
r=this.getRequestObject();if(!r)return false;r.open(xajaxRequestType==xajaxDefinedGet?"GET":"POST",uri,true);if(xajaxRequestType==xajaxDefinedPost){try{r.setRequestHeader("Method","POST "+uri+" HTTP/1.1");r.setRequestHeader("Content-Type","application/x-www-form-urlencoded");}
catch(e){alert("Your browser does not appear to  support asynchronous requests using POST.");return false;}
}
r.onreadystatechange=function(){if(r.readyState!=4)
return;if(r.status==200){if(xajaxDebug)xajax.DebugMessage("Received:\n"+r.responseText);if(r.responseXML&&r.responseXML.documentElement)
xajax.processResponse(r.responseXML);else{var errorString="Error: the XML response that was returned from the server is invalid.";errorString+="\nReceived:\n"+r.responseText;trimmedResponseText=r.responseText.replace(/^\s+/g,"");trimmedResponseText=trimmedResponseText.replace(/\s+$/g,"");if(trimmedResponseText!=r.responseText)
errorString+="\nYou have whitespace in your response.";alert(errorString);document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Invalid XML response error';}
}
else{if(xajax.arrayContainsValue(xajax.responseErrorsForAlert,r.status)){var errorString="Error: the server returned the following HTTP status: "+r.status;errorString+="\nReceived:\n"+r.responseText;alert(errorString);}
document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Invalid XML response error';}
delete r;r=null;}
if(xajaxDebug)this.DebugMessage("Calling "+sFunction+" uri="+uri+" (post:"+postData+")");r.send(postData);if(xajaxStatusMessages==true)window.status='Waiting for data...';delete r;return true;}
this.getBrowserHTML=function(html){tmpXajax=this.$(this.workId);if(!tmpXajax){tmpXajax=document.createElement("div");tmpXajax.setAttribute('id',this.workId);tmpXajax.style.display="none";tmpXajax.style.visibility="hidden";document.body.appendChild(tmpXajax);}
tmpXajax.innerHTML=html;var browserHTML=tmpXajax.innerHTML;tmpXajax.innerHTML='';return browserHTML;}
this.willChange=function(element,attribute,newData){if(!document.body){return true;}
if(attribute=="innerHTML"){newData=this.getBrowserHTML(newData);}
elementObject=this.$(element);if(elementObject){var oldData;eval("oldData=this.$('"+element+"')."+attribute);if(newData!==oldData)
return true;}
return false;}
this.viewSource=function(){return "<html>"+document.getElementsByTagName("HTML")[0].innerHTML+"</html>";}
this.processResponse=function(xml){clearTimeout(loadingTimeout);this.doneLoadingFunction();if(xajaxStatusMessages==true)window.status='Processing...';var tmpXajax=null;xml=xml.documentElement;if(xml==null)
return;var skipCommands=0;for(var i=0;i<xml.childNodes.length;i++){if(skipCommands > 0){skipCommands--;continue;}
if(xml.childNodes[i].nodeName=="cmd"){var cmd;var id;var property;var data;var search;var type;var before;var objElement=null;for(var j=0;j<xml.childNodes[i].attributes.length;j++){if(xml.childNodes[i].attributes[j].name=="n"){cmd=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="t"){id=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="p"){property=xml.childNodes[i].attributes[j].value;}
else if(xml.childNodes[i].attributes[j].name=="c"){type=xml.childNodes[i].attributes[j].value;}
}
if(xml.childNodes[i].childNodes.length > 1&&(xml.childNodes[i].firstChild.nodeName=="#cdata-section"||xml.childNodes[i].firstChild.nodeName=="#text")){data="";for(var j=0;j<xml.childNodes[i].childNodes.length;j++){data+=xml.childNodes[i].childNodes[j].data;}
}
else if(xml.childNodes[i].firstChild&&xml.childNodes[i].firstChild.nodeName=='xjxobj'){data=this._nodeToObject(xml.childNodes[i].firstChild);objElement="XJX_SKIP";}
else if(xml.childNodes[i].childNodes.length > 1){for(var j=0;j<xml.childNodes[i].childNodes.length;j++){if(xml.childNodes[i].childNodes[j].childNodes.length > 1&&(xml.childNodes[i].childNodes[j].firstChild.nodeName=="#cdata-section"||xml.childNodes[i].childNodes[j].firstChild.nodeName=="#text")){var internalData="";for(var k=0;k<xml.childNodes[i].childNodes[j].childNodes.length;k++){internalData+=xml.childNodes[i].childNodes[j].childNodes[k].nodeValue;}
}else{var internalData=xml.childNodes[i].childNodes[j].firstChild.nodeValue;}
if(xml.childNodes[i].childNodes[j].nodeName=="s"){search=internalData;}
if(xml.childNodes[i].childNodes[j].nodeName=="r"){data=internalData;}
}
}
else if(xml.childNodes[i].firstChild)
data=xml.childNodes[i].firstChild.nodeValue;else
data="";if(objElement!="XJX_SKIP")objElement=this.$(id);var cmdFullname;try{if(cmd=="cc"){cmdFullname="addConfirmCommands";var confirmResult=confirm(data);if(!confirmResult){skipCommands=id;}
}
if(cmd=="al"){cmdFullname="addAlert";alert(data);}
else if(cmd=="js"){cmdFullname="addScript/addRedirect";eval(data);}
else if(cmd=="jc"){cmdFullname="addScriptCall";var scr=id+'(';if(data[0]!=null){scr+='data[0]';for(var l=1;l<data.length;l++){scr+=',data['+l+']';}
}
scr+=');';eval(scr);}
else if(cmd=="in"){cmdFullname="addIncludeScript";this.include(data);}
else if(cmd=="as"){cmdFullname="addAssign/addClear";if(this.willChange(id,property,data)){eval("objElement."+property+"=data;");}
}
else if(cmd=="ap"){cmdFullname="addAppend";eval("objElement."+property+"+=data;");}
else if(cmd=="pp"){cmdFullname="addPrepend";eval("objElement."+property+"=data+objElement."+property);}
else if(cmd=="rp"){cmdFullname="addReplace";this.replace(id,property,search,data)
}
else if(cmd=="rm"){cmdFullname="addRemove";this.remove(id);}
else if(cmd=="ce"){cmdFullname="addCreate";this.create(id,data,property);}
else if(cmd=="ie"){cmdFullname="addInsert";this.insert(id,data,property);}
else if(cmd=="ia"){cmdFullname="addInsertAfter";this.insertAfter(id,data,property);}
else if(cmd=="ci"){cmdFullname="addCreateInput";this.createInput(id,type,data,property);}
else if(cmd=="ii"){cmdFullname="addInsertInput";this.insertInput(id,type,data,property);}
else if(cmd=="iia"){cmdFullname="addInsertInputAfter";this.insertInputAfter(id,type,data,property);}
else if(cmd=="ev"){cmdFullname="addEvent";property=this.addOnPrefix(property);eval("this.$('"+id+"')."+property+"= function(){"+data+";}");}
else if(cmd=="ah"){cmdFullname="addHandler";this.addHandler(id,property,data);}
else if(cmd=="rh"){cmdFullname="addRemoveHandler";this.removeHandler(id,property,data);}
}
catch(e){if(xajaxDebug)
alert("While trying to '"+cmdFullname+"' (command number "+i+"), the following error occured:\n"
+e.name+": "+e.message+"\n"
+(id&&!objElement?"Object with id='"+id+"' wasn't found.\n":""));}
delete objElement;delete cmd;delete cmdFullname;delete id;delete property;delete search;delete data;delete type;delete before;delete internalData;delete j;delete k;}
}
delete xml;delete i;document.body.style.cursor='default';if(xajaxStatusMessages==true)window.status='Done';}
}
var xajax=new Xajax();xajaxLoaded=true;

/************************************************************************
 * End file xajax.js
 ************************************************************************/

/************************************************************************
 * Begin file lightbox.js
 ************************************************************************/

/**
 * Created By: Chris Campbell
 * Website: http://particletree.com
 * Date: 2/1/2006
 *
 * Inspired by the lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
 *
 * Edited by Nico den Boer 07-04-2008 + 22-04-2008
 */

Event.observe(window, 'unload', Event.unloadCache, false);

var lb = null;
var imsLightbox = Class.create({
	/**************************************************************************************
	 * Private methods - begin
	 **************************************************************************************/
	// Set height to 100% and overflow hidden to prevent scrolling down past the lightbox
	_prepareWindow: function(height, overflow) {
		bod = document.getElementsByTagName('body')[0];
		bod.style.height = height;
		bod.style.overflow = overflow;

		htm = document.getElementsByTagName('html')[0];
		htm.style.height = height;
		htm.style.overflow = overflow;
	},
	// In IE, select elements hover on top of the lightbox
	_hideSelects: function(visibility) {
		selects = document.getElementsByTagName('select');
		for (i = 0; i < selects.length; i++) {
			setVisibility(selects[i].id, visibility);
		}
	},
	// Taken from lightbox implementation found at http://www.huddletogether.com/projects/lightbox/
	_getScroll: function() {
		if (self.pageYOffset) {
			this.yPos = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){
			this.yPos = document.documentElement.scrollTop;
		} else if (document.body) {
			this.yPos = document.body.scrollTop;
		}
	},
	_setScroll: function(x, y) {
		window.scrollTo(x, y);
	},
	_displayLightbox: function(visibility) {
		setVisibility("overlay", visibility);
		setVisibility("lightbox", visibility);
	},
	/**************************************************************************************
	 * Public methods - begin
	 **************************************************************************************/
	initialize: function() {
		this.debug = false;
		this.yPos = 0;
		if (window.ims.utils.lbSettings["cmd"] != "loadOnly") {
			/**
			* Add in markup necessary to make this work. Basically two divs:
			* 1) Overlay holds the shadow
			* 2) Lightbox is the centered square that the content is put into.
			*/
			ol	 	= document.createElement('div');
			ol.id		= 'overlay';
			window.ims.theForm.appendChild(ol);

			lb		= document.createElement('div');
			lb.id		= 'lightbox';
			lb.className 	= 'loading';
			window.ims.theForm.appendChild(lb);
			lb		= $('lightbox');	// global var, defined at the bottom of this file
		}
		if (this.debug) alert("Lightbox initializes now");
	},
	show: function() {
		if (typeof window.ims.utils.lbSettings == "undefined") return;

		newWidth = window.ims.utils.lbSettings["width"];
		newHeight = window.ims.utils.lbSettings["height"];
		newX = (document.viewport.getWidth() / 2) - (newWidth / 2);
		newY = (document.viewport.getHeight() / 2) - (newHeight / 2);

// 		$('lightbox').absolutize();
		lb = $('lightbox');
		lb.style.height = newHeight + "px";
		lb.style.width = newWidth + "px";
		lb.style.left = newX + "px";
		lb.style.top = newY + "px";
		lb.hideA = this.hide.bindAsEventListener(this);

		if (window.ims.utils.lbSettings["type"] == "iframe") {
		//	We need an iframe to diplay the content
// 		t.contentarea.style.overflow="hidden" //disable window scrollbars, as iframe already contains scrollbars
			lb.className = "done";
			lb.update('');
			ifr = $('lbFrame');
			if (typeof ifr == "undefined" || ifr == null) {
				ifr	 = document.createElement('iframe');
				ifr.id	= 'lbFrame';
// 				ifr.location = window.ims.utils.lbSettings["cmd"];
				lb.appendChild(ifr);
			}
			ifr.src	= window.ims.utils.lbSettings["cmd"];
			ifr.style.padding = "0px";
			ifr.style.border = "0px";
			if (window.ims.browser.isIE) {
				ifr.style.borderStyle = "solid";
				ifr.style.scrolling = "no";
			}
			ifr.style.margin = "0px";
			ifr.style.height = newHeight + "px";
			ifr.style.width = newWidth + "px";
			ifr.style.overflow = "hidden";
		}
		else {
			lb.className = "loading";
			lb.update('<br /><br />&nbsp;&nbsp;&nbsp;' + 'Data is loading now...');
		}

		this._getScroll();
		this._prepareWindow('100%', 'hidden');
		this._setScroll(0,0);
		if (window.ims.browser.isIE) {
			this._hideSelects(false);
		}
		this._displayLightbox(true);
		lb.setStyle({
			height: newHeight + "px"
		});
		if (false || this.debug) {
			lb.setStyle({
				border: "2px solid red"
			});
			console.info("Control width", newWidth, "height", newHeight);
			console.info("Control left", newX, "top", newY);
			console.info("Viewport width", window.document.body.clientWidth, ", height", document.viewport.getHeight());
		}
		if (window.ims.utils.lbSettings["type"] != "iframe") __ajaxReq(
			window.ims.utils.lbSettings["cmd"],
			window.ims.utils.lbSettings["arg"],
			window.ims.utils.lbSettings["target"]);	// get content
		window.ims.utils.lbSettings = null;
	},
	// onclick code for link - Turn everything on - mainly the IE fixes
	hide: function() {
		$('lightbox').update("");
		this._setScroll(0, this.yPos);
		this._prepareWindow("auto", "auto");
		if (window.ims.browser.isIE) {
			this._hideSelects(true);
		}
		this._displayLightbox(false);
		if (this.debug) alert("Lightbox should be hidden now");
	},
	// VdB: Display Ajax response
	displayResponse: function() {
		$('lightbox').className = "done";
		//this.actions();
	}

	// Search through new links within the lightbox, and attach click event
// 	actions: function() {
// 		lbActions = $$('.lbAction');
//
// 		for(i = 0; i < lbActions.length; i++) {
// 			Event.observe(lbActions[i], 'click', this[lbActions[i].rel].bindAsEventListener(this, lbActions[i]), false);
// 			if(typeof lbActions[i].onclick == "undefined")
// 				lbActions[i].onclick = function(){ return false; };
// 		}
//
// 	},

	// Example of creating your own functionality once lightbox is initiated
// 	insert: function(e) {
// 		link = Event.element(e).parentNode;
// 		$('lightbox').update("");
//
// 		var myAjax = new Ajax.Request(
// 			link.href,
// 			{method: 'post', parameters: "", onComplete: this.processInfo.bindAsEventListener(this)}
// 		);
// 	},

	// Example of creating your own functionality once lightbox is initiated
// 	deactivate: function(dummy, linkObject) {
// 		__ajaxReq(linkObject.id);
// 		this.hide();
// 	}
});

/************************************************************************
 * End file lightbox.js
 ************************************************************************/
