/**
 * WebDDM - The Web Drop Down Menu. It generates drop-down menus
 * on the fly from customizable menu data.
 * 
 * @version: 3.4b5
 * @started: 07/25/2004
 * @copyright: Copyright (c) 2004-2006, Cortex Creations, All Rights Reserved
 * @website: www.cortex-creations.com/webddm
 * @license: GPL vs2.0
 * @subversion: $Id: core.WebDDM.js 135 2006-05-02 21:10:21Z josh $
 */

var WebDDM_version = '3.4b5';

function Hash(){
	this.length = 0;
	this.numericLength = 0; 
	this.elementData = [];
	if (arguments[0] && arguments[0].elementData){
		this.length = arguments[0].length;
		this.numericLength = arguments[0].numericLength;
		this.elementData = arguments[0].elementData;
		return;
	}
	if (typeof(arguments[0]) == 'object'){
		for (var i in arguments[0]){
			this.set(i, arguments[0][i]);
		}
		return;
	}
	for (var i = 0; i < arguments.length; i += 2){
		if (typeof(arguments[i + 1]) != 'undefined'){
			this.set(arguments[i], arguments[i+1]);
		}
	}
};

Hash.prototype.get = function(in_key){
	return this.elementData[in_key];
};

Hash.prototype.set = function(in_key, in_value){
	in_key = (in_key == 'auto' ? this.numericLength + 1 : in_key);
	if (typeof(in_value) != 'undefined'){
		if (typeof(this.elementData[in_key]) == 'undefined'){
			++this.length;
			if (parseInt(in_key) == in_key){
				++this.numericLength;
			}
		}
		return this.elementData[in_key] = in_value;
	}
	return false;
};

Hash.prototype.remove = function(in_key){
	var tmp_value;
	if (typeof(this.elementData[in_key]) != 'undefined'){
		this.length--;
		if (in_key == parseInt(in_key)) 
		{
			this.numericLength--;
		}

		tmp_value = this.elementData[in_key];
		delete this.elementData[in_key];
	}

	return tmp_value;
};

Hash.prototype.size = function(){
	return this.length;
};

Hash.prototype.has = function(in_key){
	return typeof(this.elementData[in_key]) != 'undefined';
};

Hash.prototype.find = function(in_obj){
	for (var tmp_key in this.elementData){
		if (this.elementData[tmp_key] == in_obj) 
		{
			return tmp_key;
		}
	}
	return null;
};

Hash.prototype.merge = function(in_hash){
	for (var tmp_key in in_hash.elementData){
		if (typeof(this.elementData[tmp_key]) == 'undefined'){
			++this.length;
			if (tmp_key == parseInt(tmp_key)){
				++this.numericLength;
			}
		}
		this.elementData[tmp_key] = in_hash.elementData[tmp_key];
	}
};


Hash.prototype.compare = function(in_hash){
	if (this.length != in_hash.length){
		return false;
	}
	for (var tmp_key in this.elementData){
		if (this.elementData[tmp_key] != in_hash.elementData[tmp_key]){
			return false;
		}
	}
	return true;
};

function hashify (in_array){
	if (typeof(in_array) == 'object'){
		for (var i in in_array){
			if (typeof(in_array[i]) == 'object'){
				in_array[i] = hashify(in_array[i]);
			}
		}
		in_array = new Hash(in_array);
	}
	return in_array;
};

var domLib_userAgent = navigator.userAgent.toLowerCase();
var domLib_isMac = navigator.appVersion.indexOf('Mac') != -1;
var domLib_isOpera = domLib_userAgent.indexOf('opera') != -1;
var domLib_isOpera7 = (domLib_userAgent.indexOf('opera/7') != -1 || domLib_userAgent.indexOf('opera 7') != -1);
var domLib_isSafari = domLib_userAgent.indexOf('safari') != -1;
var domLib_isKonq = domLib_userAgent.indexOf('konqueror') != -1;
var domLib_isKHTML = (domLib_isKonq || domLib_isSafari);
var domLib_isIE = (!domLib_isKHTML && !domLib_isOpera && (domLib_userAgent.indexOf('msie 5') != -1 || domLib_userAgent.indexOf('msie 6') != -1));
var domLib_isIE5up = domLib_isIE;
var domLib_isIE50 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.0') != -1);
var domLib_isIE55 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.5') != -1);
var domLib_isIE5 = (domLib_isIE50 || domLib_isIE55);
var domLib_isGecko = domLib_userAgent.indexOf('gecko/') != -1;
var domLib_isMacIE = (domLib_isIE && domLib_isMac);
var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50 && !domLib_isMacIE;
var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;
var domLib_standardsMode = (document.compatMode && document.compatMode == 'CSS1Compat');
var domLib_useLibrary = (domLib_isOpera7 || domLib_isKonq || domLib_isIE5up || domLib_isGecko || domLib_isKHTML);
var domLib_hasBrokenTimeout = (domLib_isMacIE || (domLib_isKonq && domLib_userAgent.match(/konqueror\/3.([2-9])/) == null));
var domLib_canFade = (domLib_isGecko || domLib_isIE || domLib_isSafari);
var domLib_canDrawOverSelect = (domLib_isGecko || domLib_isOpera || domLib_isMac);
var domLib_eventTarget = domLib_isIE ? 'srcElement' : 'currentTarget';
var domLib_eventButton = domLib_isIE ? 'button' : 'which';
var domLib_eventTo = domLib_isIE ? 'toElement' : 'relatedTarget';
var domLib_stylePointer = domLib_isIE ? 'hand' : 'pointer';
var domLib_styleNoMaxWidth = domLib_isOpera ? '1000000px' : 'none';
var domLib_hidePosition = '-1000px';
var domLib_scrollbarWidth = 14;
var domLib_autoId = 1;
var domLib_zIndex = 100;

var domLib_buttonLeft = (domLib_isGecko || domLib_isOpera || domLib_isIE || domLib_isSafari ? 1 : -1);
var domLib_buttonRight = (domLib_isGecko ? 3 : 2);

var domLib_obscuringElements;

var domLib_timeoutStateId = 0;
var domLib_timeoutStates = new Hash();

var WebDDM_style_out = '';
var WebDDM_style_rollover = '_rollover';
var WebDDM_style_rolloverPressed = '_rollover_pressed';
var WebDDM_style_menuopenOut = '_menuopen';
var WebDDM_style_menuopenRollover = '_menuopen_rollover';
var WebDDM_style_menuopenPressed = '_menuopen_pressed';

var WebDDM_actionPlugins = new Hash();
var WebDDM_transitionPlugins = new Hash();
var FloatAPI;

var WebDDM_globalInitDone = false;
var WebDDM_mousePosition = new Hash();
var WebDDMObjects = new Hash();
var WebDDM_lastMouseoverElement = '';
var WebDDM_lastMouseoverElementOwner = false;
var WebDDM_activeEventHandlers = [];

if (window.attachEvent && domLib_isIE){
	window.attachEvent("onunload", function(){
		while (WebDDM_activeEventHandlers.length){
			var obj = WebDDM_activeEventHandlers.pop();
			try{
				obj[0].detachEvent(obj[1], obj[2]);
			}
			catch (e){
			}
		}
	});
}

document.write('<style type="text/css">'+
	'div.WebDDM_items_container {'+
		'position: absolute; top: 0px; left: 0px; visibility: hidden;'+
		'overflow: visible; margin: 0px; padding: 0px;'+
		'border: 0px transparent none;'+
	'}'+
	'</style>');

function evalEscapeString (str, quoteType){
	quoteType = quoteType ? quoteType : '"';
	return 'unescape('+quoteType+escape(str)+quoteType+')';
};

function WebDDM_buildFunction (function1, function2){
	var function_body = '';
	var function_params = '';
	if (function1 && (data = WebDDM_parseFunction(function1 + ''))){
		function_body += data[1];
		function_params += data[0];	
	}
	if (function2 && (data = WebDDM_parseFunction(function2 + ''))){
		function_body += data[1];
		function_params += (function_params && data[0] ? ',' : '') + data[0];
	}
	eval('var retFunc = function ('+function_params+') {'+function_body+'};');
	return retFunc;
};

function WebDDM_parseFunction (parseFunction){
	var data = ['',''];
	if (parseFunction.match(/\s*function\s*\(([^\)]*)\)\s*\{([^$]*)\}\s*/)){
		data[0] = RegExp.$1;
		data[1] = RegExp.$2;
	}
	else{
		data[1] = parseFunction;
	}
	return data;
};

function WebDDM_mergeArrays (baseArray, mergeArray, override, provideIncrementalKeys){
	for (var i in mergeArray){
		if (parseInt(i) == i){
			i = parseInt(i);
		}
		if (typeof(baseArray[i]) == 'undefined' || override){
			baseArray[i] = mergeArray[i];
		}
		else if (provideIncrementalKeys && typeof(i) == 'number'){
			baseArray[baseArray.length] = mergeArray[i];
		}
	}
	return baseArray;
};

function WebDDM_cloneArray (ary){
	ary = WebDDM_mergeArrays({}, ary);
	for (var index in ary){
		if (typeof(ary[index]) == 'object'){
			ary[index] = WebDDM_cloneArray(ary[index]);
		}
	}
	return ary;
};

function domLib_setTimeout(in_function, in_timeout, in_args){
	if (typeof(in_args) == 'undefined'){
		in_args = [];
	}
	if (typeof(in_function) == 'string'){
		eval('var in_function = function () { '+in_function+' }');
	}
	if (in_timeout <= 0){
		in_function(in_args);
		return 0;
	}
	var args = WebDDM_mergeArrays({}, in_args);
	if (!domLib_hasBrokenTimeout){
		return setTimeout(function() { in_function(args); }, in_timeout);
	}
	else{
		var id = domLib_timeoutStateId++;
		var data = new Hash();
		data.set('function', in_function);
		data.set('args', args);
		domLib_timeoutStates.set(id, data);
		data.set('timeoutId', setTimeout('domLib_timeoutStates.get(' + id + ').get(\'function\')(domLib_timeoutStates.get(' + id + ').get(\'args\')); domLib_timeoutStates.remove(' + id + ');', in_timeout));
		return id;
	}
};

function domLib_clearTimeout(in_id){
	if (!domLib_hasBrokenTimeout){
		clearTimeout(in_id);
	}
	else{
		if (domLib_timeoutStates.has(in_id)){
			clearTimeout(domLib_timeoutStates.get(in_id).get('timeoutId'));
			domLib_timeoutStates.remove(in_id);
		}
	}
};

function domLib_getOffsets (in_object, stopAt){
	stopAt = typeof(stopAt) == 'undefined' ? false : stopAt;
	var originalObject = in_object;
	var originalWidth = in_object.offsetWidth;
	var originalHeight = in_object.offsetHeight;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (in_object){
		offsetLeft += in_object.offsetLeft;
		offsetTop += in_object.offsetTop;
		in_object = in_object.offsetParent;
		if (stopAt == in_object){	
			break;
		}
	}
	if (domLib_isMacIE){
		offsetLeft += 10;
		offsetTop += 10;
	}
	return new Hash(
		'left',			offsetLeft,
		'top',			offsetTop,
		'right',		offsetLeft + originalWidth,
		'bottom',		offsetTop + originalHeight,
		'height',		originalHeight,
		'width',		originalWidth,
		'leftCenter',	offsetLeft + originalWidth/2,
		'topCenter',	offsetTop + originalHeight/2,
		'radius',		Math.max(originalWidth, originalHeight) 
	);
};

function domLib_isDescendantOf(in_object, in_ancestor){
	if (in_object == in_ancestor){
		return true;
	}
	while (in_object != document.documentElement){
		try{
			if ((tmp_object = in_object.offsetParent) && tmp_object == in_ancestor){
				return true;
			}
			else if ((tmp_object = in_object.parentNode) == in_ancestor){
				return true;
			}
			else{
				in_object = tmp_object;
			}
		}
		catch(e){
			return true;
		}
	}
	return false;
};

function domLib_getEventPosition(in_eventObj){
	var eventPosition = new Hash('x', 0, 'y', 0);
	if (domLib_isKonq){
		eventPosition.set('x', in_eventObj.x);
		eventPosition.set('y', in_eventObj.y);
	}
	else if (domLib_isIE){
		if (domLib_standardsMode){
			eventPosition.set('x', in_eventObj.clientX + document.documentElement.scrollLeft);
			eventPosition.set('y', in_eventObj.clientY + document.documentElement.scrollTop);
		}
		else if (document.body){
			eventPosition.set('x', in_eventObj.clientX + document.body.scrollLeft);
			eventPosition.set('y', in_eventObj.clientY + document.body.scrollTop);
		}
	}
	else{
		eventPosition.set('x', in_eventObj.pageX);
		eventPosition.set('y', in_eventObj.pageY);
	}
	return eventPosition;
};

function domLib_detectCollisions(in_object, in_recover){
	if (typeof(domLib_obscuringElements) == 'undefined'){
		domLib_obscuringElements = domLib_canDrawOverSelect
			? new Hash()
			: document.getElementsByTagName('select');
		domLib_obscuringElements = WebDDM_mergeArrays(domLib_obscuringElements,
			document.getElementsByTagName('applet'), false, true);
		domLib_obscuringElements = WebDDM_mergeArrays(domLib_obscuringElements,
			document.getElementsByTagName('object'), false, true);
	}
	if (in_recover){
		for (var cnt = 0; cnt < domLib_obscuringElements.length; ++cnt){
			var thisObscuringElement = domLib_obscuringElements[cnt];
			if (!thisObscuringElement.hideList){
				thisObscuringElement.hideList = new Hash();
			}
			thisObscuringElement.hideList.remove(in_object.id);
			if (!thisObscuringElement.hideList.length){
				domLib_obscuringElements[cnt].style.visibility = 'visible';
				if (domLib_isKonq){
					domLib_obscuringElements[cnt].style.display = '';
				}
			}
		}
		return;
	}
	var objectOffsets = domLib_getOffsets(in_object);
	for (var cnt = 0; cnt < domLib_obscuringElements.length; ++cnt){
		var thisObscuringElement = domLib_obscuringElements[cnt];
		if (domLib_isDescendantOf(thisObscuringElement, in_object)){
			continue;
		}
		if (!thisObscuringElement.hideList){
			thisObscuringElement.hideList = new Hash();
		}
		var selectOffsets = domLib_getOffsets(thisObscuringElement); 
		var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2));
		var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius');
		if (center2centerDistance < radiusSum){
			if (
				objectOffsets.get('right') < selectOffsets.get('left') ||
				objectOffsets.get('left') > selectOffsets.get('right') ||
				objectOffsets.get('bottom') < selectOffsets.get('top') ||
				objectOffsets.get('top') > selectOffsets.get('bottom')){
				thisObscuringElement.hideList.remove(in_object.id);
				if (!thisObscuringElement.hideList.length){
					thisObscuringElement.style.visibility = 'visible';
					if (domLib_isKonq){
						thisObscuringElement.style.display = '';
					}
				}
			}
			else{
				thisObscuringElement.hideList.set(in_object.id, true);
				thisObscuringElement.style.visibility = 'hidden';
				if (domLib_isKonq){
					thisObscuringElement.style.display = 'none';
				}
			}
		}
	}
};

function WebDDM_getElement (elementId){
	return document.all ? document.all[elementId] : document.getElementById(elementId);
};

function interCap (str){
	while (str.match(/\-(.)/)){
		var c = RegExp.$1;
		str = str.replace('-'+c, c.toUpperCase());
	}
	return str;
};

function parseCssString (cssString){
	var css = {};
	var chunks = cssString.split(/\s*\;\s*/);
	for (var k in chunks){
		var v = chunks[k];
		if (v.match(/^\s*([a-zA-Z0-9\-]*)\s*\:\s*(.*?)$/)){
			css[RegExp.$1] = RegExp.$2;
		}
	}
	return css;
};

function domLib_cancelBubble(in_event){
	if (in_event){
		in_event.cancelBubble = true;
	}
};

function WebDDM_attachEventListener (eventObject, eventName, eventHandler){
	if (eventObject.attachEvent){
		eventObject.attachEvent('on'+eventName, eventHandler);
		WebDDM_activeEventHandlers[WebDDM_activeEventHandlers.length] = [eventObject, 'on'+eventName, eventHandler];
	}
	else if (eventObject.addEventListener){
		eventObject.addEventListener(eventName, eventHandler, false);
	}
	else{
		eventObject['on'+eventName] = WebDDM_buildFunction(eventHandler, eventObject['on'+eventName]);
	}
}

function WebDDM (containerId, menuData){
	WebDDMObjects.set(containerId, this);
	var container = WebDDM_getElement(containerId);
	if (!container){
		container = document.createElement('div');
		container.id = containerId;
		document.body.appendChild(container);
	}
	this.container = container;
	this.containerId = containerId;
	this.hashEvalPathCache = new Hash();
	this.initialize(menuData);
	return this;
};

WebDDM.prototype.initialize = function (menuData){
	this.menuData = hashify(WebDDM_cloneArray(menuData));
	this.openMenuData = new Hash();
	domLib_zIndex = (this.menuData.has('zIndex') ? this.menuData.get('zIndex') : domLib_zIndex);
	this.mouseoverStatuses = new Hash();
	this.menuOpenStatuses = new Hash();
	this.cleanMenusLoopTimeout = false;
	this.cleanMenuTimeout = false;
	this.cleanMenuId = false;
	this.firstCloseableKey = false;
	this.showTimeoutHash = new Hash();
	this.menuData.set('defaultMeasurementUnit', this.menuData.has('defaultMeasurementUnit') ? this.menuData.get('defaultMeasurementUnit') : 'px');
	this.container.innerHTML = '<div style="visibility: visible;" id="WebDDM_loading_' + this.container.id + '">Menu is loading...</div>';
	var styles = ['position', 'top', 'left', 'width', 'height'];
	for (var i = 0; styles[i]; ++i){
		var style = styles[i];
		var value = this.menuData.get(style);
		if (i != 'position'){
			this.container.style[style] = this.formatUnit(value);
		}
		else
		{
			this.container.style[style] = value;
		}
	}
	this.container.style.backgroundColor = 'transparent';
	this.container.style.visibility = this.container.style.overflow = 'visible';
	this.container.style.zIndex = domLib_zIndex++;
	this.menuData.set('expand_menu', (this.menuData.has('expand_menu') ? this.menuData.get('expand_menu') : 'auto'));
	this.menuData.set('contract_menu', (this.menuData.has('contract_menu') ? this.menuData.get('contract_menu') : 'none'));
	var click_closes_all_menus = true;
	if (this.menuData.get('float') && FloatAPI){
		this.floatHandler = new FloatAPI(this.container.id, this.menuData.get('top'),
			this.menuData.get('left'), this.menuData.get('floatSpeed'), true);
	}
	else if (this.menuData.get('expand_menu').match(/context\(([a-zA-Z\-]*)\,([a-zA-Z0-9\-\_]*)\)/)){
		var expandType = RegExp.$1;
		var contextObjectId = RegExp.$2;
		var contextObject;
		if (contextObjectId == 'document'){
			contextObject = document;
		}
		else{
			contextObject = WebDDM_getElement(contextObjectId);
			if (!contextObject){
				contextObject = document;
			}
		}
		var code_end = 
				'domLib_cancelBubble(in_event);' +
				'domLib_setTimeout(function()' +
				'{' +
					'eval("var obj = getWebDDMObject(\\"' + this.containerId + '\\");");' +
					'obj.setMenuAtCursor();' +
					'obj.showMenu(obj.menuData, "");' +
					'return false;' +
				'},10);' +
				'return false;' +
			'}';
		var contextEvent;
		var eventButton;
		var contextFunctionCode_oncontext = function (in_event) {};
		var modifierKeys = '';
		if (expandType == 'left-click'){
			contextEvent = 'mouseup';
			eventButton = domLib_buttonLeft;
 		}
		else if (expandType == 'context'){
			contextEvent = (domLib_isIE ? 'contextmenu' : 'mouseup');
			eventButton = (domLib_isIE ? 0 : domLib_buttonRight);
			if (domLib_isMac){
				eventButton = domLib_buttonLeft;
				modifierKeys = '|| !in_event.ctrlKey';
			}
			eval('var contextFunctionCode_oncontext = function (in_event) { domLib_cancelBubble(in_event); }');
		}
		else{
			contextEvent = 'mouseover';
		}
		eval('var contextFunctionCode = function (in_event) {' +
			(eventButton || modifierKeys
				? 'if (in_event[domLib_eventButton] != '+eventButton+modifierKeys+') { return; }'
				: ''
			) +
			code_end
		);
		WebDDM_attachEventListener(contextObject, contextEvent, contextFunctionCode);
		if (!domLib_isIE){
			WebDDM_attachEventListener(contextObject, 'contextmenu', contextFunctionCode_oncontext);
		}
		this.menuData.set('position', 'absolute');
		container.style.position = 'absolute';
	}
	if (!WebDDM_globalInitDone){
		var mousemoveCode = function (in_event){
			in_event = in_event ? in_event : window.event;
			WebDDM_mousePosition = domLib_getEventPosition(in_event);
			if (WebDDM_actionPlugins.has('document_mousemove')){
				for (var index in WebDDM_actionPlugins.get('document_mousemove').elementData){
					WebDDM_actionPlugins.get('document_mousemove').get(index)(in_event);
				}
			}
		};
		var code_mousedown = function (in_event){
			if (WebDDM_hideAllMenus){
				WebDDM_hideAllMenus(true);
			}
			if (WebDDM_actionPlugins.has('document_click')){
				for (var index in WebDDM_actionPlugins.get('document_click').elementData){
					WebDDM_actionPlugins.get('document_click').get(index)(in_event);
				}
			}
		};
		var code_blur = function (in_event){
			if (WebDDM_hideAllMenus){
				WebDDM_hideAllMenus();
			}
			if (WebDDM_actionPlugins.has('document_blur')){
				for (var index in WebDDM_actionPlugins.get('document_blur').elementData){
					WebDDM_actionPlugins.get('document_blur').get(index)(in_event);
				}
			}
		};
		WebDDM_attachEventListener(document, 'mousedown', code_mousedown);
		WebDDM_attachEventListener(document, 'blur', code_blur);
		WebDDM_attachEventListener(document, 'mousemove', mousemoveCode);
		WebDDM_globalInitDone = true;
	}
	if (this.menuData.get('expand_menu').match('auto')){
		this.showMenu(this.menuData, "");
	}
	WebDDM_getElement('WebDDM_loading_' + this.container.id).style.visibility = 'hidden';
	WebDDM_getElement('WebDDM_loading_' + this.container.id).innerHTML = '';
};

WebDDM.prototype.setMenuAtCursor = function (){
	var topPos = WebDDM_mousePosition.get('y') + parseInt(this.menuData.get('top'));
	var leftPos = WebDDM_mousePosition.get('x') + parseInt(this.menuData.get('left'));
	WebDDM_getElement(this.containerId).style.top = topPos + 'px';
	WebDDM_getElement(this.containerId).style.left = leftPos + 'px';
};

WebDDM.prototype.buildMenu = function (parentItemHash){
	var itemId = parentItemHash.get('itemId') || this.containerId;
	var itemsHash = parentItemHash.get('items');
	var parentItemsObj = WebDDM_getElement(
		parentItemHash.get('parentId')
			? parentItemHash.get('parentId') + '_subitems'
			: this.containerId);
	var itemsContainer = document.createElement('div');
	itemsContainer.id = itemId + '_subitems';
	itemsContainer.className = 'WebDDM_items_container';
	itemsContainer.style.top = this.formatUnit(itemsHash.get('top'));
	itemsContainer.style.left = this.formatUnit(itemsHash.get('left'));
	if (!itemsHash.has('useOldPositioning') && !this.menuData.has('useOldPositioning')){
		var parentBgItemObj=WebDDM_getElement(parentItemHash.get('parentId')+'_subitems_background');
		if (parentBgItemObj){
			var parentItemObj = WebDDM_getElement(itemId+'_item_container');
			itemsContainer.style.marginTop = this.formatUnit(parentBgItemObj.offsetTop + parentItemObj.offsetTop);  
			itemsContainer.style.marginLeft = this.formatUnit(parentBgItemObj.offsetLeft + parentItemObj.offsetLeft);  
		}
	}
	var getWebDDMObjectCode = 'getWebDDMObject(\''+this.containerId+'\')';
	eval('var onmouseoverCode = function () {'+getWebDDMObjectCode+'.setMouseoverStatus(\''+itemId+'_subitems\', true, false, false);}');
	eval('var onmouseoutCode =  function () {'+getWebDDMObjectCode+'.setMouseoverStatus(\''+itemId+'_subitems\', false, false, false);}');
	WebDDM_attachEventListener(itemsContainer, 'mousemove', onmouseoverCode);
	WebDDM_attachEventListener(itemsContainer, 'mouseout', onmouseoutCode);
	var bg_id = itemId + '_subitems_background';
	var scrollarea_id = itemId + '_subitems_scrollarea';
	var top = '', left = '', width = '', height = '', className = '', css ='';
	var bgItemSet = false;
	if (itemsHash.has('background-item')){
		bgItemSet = true;
		var bg_item = itemsHash.get('background-item');
		top = bg_item.has('top') ? 'top: ' + this.formatUnit(bg_item.get('top')) + ';' : ''; 
		left = bg_item.has('left') ? 'left: ' + this.formatUnit(bg_item.get('left')) + ';' : ''; 
		className = bg_item.has('class') ? ' class="'+bg_item.get('class')+'"' : ''; 
		css = bg_item.has('css') ? bg_item.get('css') + ';' : '';
		if (bg_item.has('width')){
			width = 'width: ' + this.formatUnit(bg_item.get('width')) + ';';
			itemsContainer.style.width = this.formatUnit(bg_item.get('width'));
		}
		if (bg_item.has('height')){
			height = 'height: ' + this.formatUnit(bg_item.get('height')) + ';';
			itemsContainer.style.height = this.formatUnit(bg_item.get('height'));
		}
	}
	var scrollarea_css = 'top:0px;left:0px;width:0px;height:0px;overflow:visible;';
	var scrollarea_innerhtml = '&nbsp;';
	if (itemsHash.has('scroll-area')){
		var scrollerItemsHash = itemsHash.get('scroll-area');
				scrollarea_css = 'overflow:auto;' +
					'top:' + this.formatUnit(scrollerItemsHash.get('top')) + ';' +
					'left:' + this.formatUnit(scrollerItemsHash.get('left')) + ';' +
					'width:' + this.formatUnit(scrollerItemsHash.get('visible-width')) + ';' +
					'height:' + this.formatUnit(scrollerItemsHash.get('visible-height')) + ';';
	}
	var itemsContainerHTML =
		'<div id="'+bg_id+'" style="background-color:transparent;border-style:none;margin:0px;padding:0px;visibility:inherit;position:absolute;'+top+left+width+height+';z-index:'+(++domLib_zIndex)+';">' +
			'<table style="background-color:transparent;border-style:none;margin:0px;padding:0px;width:100%;height:100%;background-color:transparent;visibility:inherit;" cellpadding="0" cellspacing="0"><tbody><tr>' +
				'<td '+className+' style="visibility:inherit;line-height:1px;'+css+'">' +
					'&nbsp;' +
					'<div id="'+scrollarea_id+'" style="margin:0px;padding:0px;visibility:inherit;position:absolute;'+scrollarea_css+'">' +
						scrollarea_innerhtml;	
	var marginTop = 0, marginLeft = 0;
	var lastItemHash = new Hash('top', 0, 'left', 0);
	for (var itemIndex = 1; itemsHash.has(itemIndex); ++itemIndex){
		var thisItemId = itemId + '_' + itemIndex;
		var itemHash = itemsHash.get(itemIndex);
		this.initializeItemAttributes(itemHash, thisItemId);
		if (WebDDM_actionPlugins.has('item_init')){
			for (var index in WebDDM_actionPlugins.get('item_init').elementData){
				WebDDM_actionPlugins.get('item_init').get(index)(false, this, itemHash);
			}
		}
		if (!itemHash.has('top')){
			marginTop += parseFloat(lastItemHash.get('top'));
			itemHash.set('top', (itemHash.has('offsetTop') ? itemHash.get('offsetTop') : 0));
		}
		else{
			marginTop = 0;
		}
		if (!itemHash.has('left')){
			marginLeft += parseFloat(lastItemHash.get('left'));
			itemHash.set('left', (itemHash.has('offsetLeft') ? itemHash.get('offsetLeft') : 0));
		}
		else{
			marginLeft = 0;
		}
		var cursor = (itemHash.has('cursor')
			? 'cursor:' + (itemHash.get('cursor').match(/hand|pointer/)
				? domLib_stylePointer
				: itemHash.get('cursor')) + ';'
			: '');
		var css = (itemHash.has('css') ? itemHash.get('css') + ';' : '') + cursor;
		var itemClass = (itemHash.has('class') ? ' class="' + itemHash.get('class') + '"' : '');
		var div_css = 'visibility:inherit; position:absolute; margin:0px; padding:0px;'+
			'margin-top:'+this.formatUnit(marginTop)+'; margin-left:'+this.formatUnit(marginLeft)+'; '+
			'top:'+this.formatUnit(itemHash.get('top'))+';'+
			'left:'+this.formatUnit(itemHash.get('left'))+';'+
			'width:'+this.formatUnit(itemHash.get('width'))+';'+
			'height:'+this.formatUnit(itemHash.get('height'))+';';
			
		var event_code = ' onmouseover="'+getWebDDMObjectCode+'.mouseAction(event,\'mouseover\',\''+thisItemId+'\');"' +
			' onmouseout="'+getWebDDMObjectCode+'.mouseAction(event,\'mouseout\',\''+thisItemId+'\');"' + 
			' onclick="'+getWebDDMObjectCode+'.mouseAction(event,\'click\',\''+thisItemId+'\');"' +
			' onmouseup="'+getWebDDMObjectCode+'.mouseAction(event,\'mouseup\',\''+thisItemId+'\');"' +
			' onmousedown="'+getWebDDMObjectCode+'.mouseAction(event,\'mousedown\',\''+thisItemId+'\');"';

		var item_container_id = thisItemId+'_item_container';
		itemsContainerHTML +=
			'<div id="'+item_container_id+'" style="'+div_css+'" '+event_code+'><table style="width:100%;height:100%;background-color:transparent;" cellpadding="0" cellspacing="0"><tbody><tr><td id="'+thisItemId+'_item"'+itemClass+' style="'+css+'">' +
				itemHash.get('content') +
			'</td></tr></tbody></table></div>';
		lastItemHash = itemHash;
	}
	itemsContainer.innerHTML = itemsContainerHTML + '</div></td></tr></tbody></table></div>';
	parentItemsObj.appendChild(itemsContainer);
	if (!bgItemSet){
		var itemsContainer = WebDDM_getElement(itemId+'_subitems');
		var extremeL = 99999999999999;
		var extremeR = 0;
		var extremeT = extremeL;
		var extremeB = 0;
		for (var i = 1; itemsHash.has(i); ++i){
			var itemOffsets = domLib_getOffsets(WebDDM_getElement(itemId+'_'+i+'_item_container'));

			extremeL = (itemOffsets.get('left') < extremeL) ? itemOffsets.get('left') : extremeL;  
			extremeR = (itemOffsets.get('right') > extremeR) ? itemOffsets.get('right') : extremeR;
			extremeT = (itemOffsets.get('top') < extremeT) ? itemOffsets.get('top') : extremeT;  
			extremeB = (itemOffsets.get('bottom') > extremeB) ? itemOffsets.get('bottom') : extremeB;
		}
		WebDDM_getElement(bg_id).style.height = itemsContainer.style.height = (extremeB - extremeT) + 'px';
		WebDDM_getElement(bg_id).style.width = itemsContainer.style.width = (extremeR - extremeL) + 'px';
	}
};

WebDDM.prototype.rebuildMenu = function (newMenuData){
	this.initialize(newMenuData);
};

WebDDM.prototype.setMouseoverStatus = function (elementId, status, setAsLast, executeLastElementMouseout){
	if (executeLastElementMouseout && WebDDM_lastMouseoverElement && WebDDM_lastMouseoverElement != elementId){
		WebDDM_lastMouseoverElementOwner.mouseoverStatuses.set(WebDDM_lastMouseoverElement, false);
		WebDDM_lastMouseoverElementOwner.mouseAction(0, 'mouseout', WebDDM_lastMouseoverElement);
		for (var i = this.openMenuData.length - 1; this.openMenuData.has(i); i--){
			var itemHash = this.openMenuData.get(i);
			if (itemHash.cleanThread){
				domLib_clearTimeout(itemHash.cleanThread);
			}
		}
	}
	if (setAsLast){
		WebDDM_lastMouseoverElement = elementId;
		WebDDM_lastMouseoverElementOwner = this;
	}
	this.mouseoverStatuses.set(elementId, status);
};

WebDDM.prototype.getMouseoverStatus = function (elementId){
	return this.mouseoverStatuses.has(elementId) ? this.mouseoverStatuses.get(elementId) : false;
};

WebDDM.prototype.canHideMenu = function (itemHash){
	var itemId = itemHash.get('itemId');
	var contractMenu = itemHash.has('contract_menu') ? itemHash.get('contract_menu') : false;
	if (!contractMenu && itemId != this.containerId && itemId){
		return true;
	}
	if (contractMenu && (!contractMenu.match(/rollout/) || contractMenu.match(/none/))){
		return false;
	}
	if (this.getMouseoverStatus(itemId)){
		return false;
	}
	if (itemHash.has('parentId') && this.getMouseoverStatus(itemHash.get('parentId') + '_subitems')){
		return false;
	}
	if (itemHash.has('items') && this.menuData.get('expand_menu').match('context')){
		for (var i = 1; itemHash.get('items').has(i); ++i){
			if (!this.canHideMenu(itemHash.get('items').get(i))){
				return false;
			}
		}
	}
	return true;
};

WebDDM.prototype.initializeItemAttributes = function (itemHash, itemId){
	var bareItemId = itemId.replace(this.containerId + '_', '');
	itemHash.set('menuLevel', (bareItemId ? bareItemId.split('_').length : 0));
	itemHash.set('parentId', (itemId.match(/^(.*?)\_([0-9]+)$/) ? RegExp.$1 : ''));
	itemHash.set('itemId', itemId);
	itemHash.set('currentStyleContent', '');
	itemHash.set('currentStyleCSS', '');
	itemHash.set('currentStyleClass', '');
	itemHash.set('expand_menu', (itemHash.has('expand_menu') ? itemHash.get('expand_menu') : 'rollover'));
	itemHash.set('contract_menu', (itemHash.has('contract_menu') ? itemHash.get('contract_menu') : 'rollout'));
	itemHash.set('closeDelay', (itemHash.has('closeDelay') ? itemHash.get('closeDelay') : 100));
};

WebDDM.prototype.getItemHash = function (itemId){
	itemId = (this.containerId == itemId ? '' : itemId);
	var bareItemId = itemId.replace(this.containerId + '_', '');
	if (!this.hashEvalPathCache.has(bareItemId)){
		var evalCode = 'var itemHash = this.menuData';
		if (itemId != ''){
			var chunks = bareItemId.split('_');
			for (var i = 0; i < chunks.length; ++i){
				evalCode += '.get("items")' + (parseInt(chunks[i]) == chunks[i] ? '.get('+chunks[i]+')' : '');
				if (parseInt(chunks[i]) != chunks[i]){
					break;
				}
			}
		}
		evalCode += ';';
		this.hashEvalPathCache.set(bareItemId, evalCode);
	}
	eval(this.hashEvalPathCache.get(bareItemId));
	return itemHash;
};

WebDDM.prototype.menuIsOpen = function (itemId){
	return (this.menuOpenStatuses.has(itemId) ? this.menuOpenStatuses.get(itemId) : false);
};

WebDDM.prototype.hideMenusOnLevel = function (itemHash){
	var menuLevel = itemHash.get('menuLevel');
	var itemId = itemHash.get('itemId');
	if (itemHash.get('menuLevel') > 0){
		for (var tmp_key = (this.openMenuData.size()-1); tmp_key >= 0; tmp_key--){
			var tmp_itemHash = this.openMenuData.get(tmp_key);
			var tmp_menuLevel = tmp_itemHash.get('menuLevel');
			var tmp_itemId = tmp_itemHash.get('itemId');
			if (tmp_menuLevel >= menuLevel && !tmp_itemId.match(itemId)){
				this.hideMenu(tmp_itemHash);
			}
		}
	}
};
 
WebDDM.prototype.showMenu = function (itemHash, itemId){
	WebDDM_hideAllMenus(false, this.containerId);
	this.hideMenusOnLevel(itemHash);
	if (!itemHash.has('items')){
		return;
	}
	this.menuOpenStatuses.set(itemId, true);
	var thisMenuOpen = false;
	var thisArrayId = this.openMenuData.find(itemHash) || -1;
	if (thisArrayId != -1){
		thisMenuOpen = true;
	}
	var itemOrContainerId = itemId || this.containerId;
	if (!WebDDM_getElement(itemOrContainerId + '_subitems')){
		this.buildMenu(itemHash);
	}
	WebDDM_getElement(this.containerId).style.zIndex = domLib_zIndex++;
	WebDDM_getElement(itemOrContainerId + '_subitems').style.zIndex = domLib_zIndex++;
	if (thisMenuOpen == false){
		if (this.cleanMenuTimeout){
			domLib_clearTimeout(this.cleanMenuTimeout);
			this.cleanMenuTimeout = false;
		}
		thisArrayId = this.openMenuData.size();
		if (itemId){
			this.setItemStyle(itemHash, WebDDM_style_menuopenOut);
		}
		else if (itemHash.get('contract_menu').match('rollout')){
			this.setMouseoverStatus(this.containerId + '_subitems', true, false, false);
		}
		this.openMenuData.set(thisArrayId, itemHash);
	}
	if (itemHash.get('itemId')){
		var itemsHash = this.getItemHash(itemHash.get('itemId').replace(/[0-9]$/, ''));
		if (!itemsHash.has('useOldPositioning') && !this.menuData.has('useOldPositioning')){
			var parentBgItemObj=WebDDM_getElement(itemHash.get('parentId')+'_subitems_background');
			if (parentBgItemObj){
				var parentItemObj = WebDDM_getElement(itemId+'_item_container');
				var itemsContainer = WebDDM_getElement(itemOrContainerId + '_subitems');
				itemsContainer.style.marginTop = parentBgItemObj.offsetTop + parentItemObj.offsetTop + 'px';  
				itemsContainer.style.marginLeft = parentBgItemObj.offsetLeft + parentItemObj.offsetLeft + 'px';  
			}
		}
	}
	this.setVisibility(itemHash.get('items'), itemOrContainerId + '_subitems', true);
	for (var i = 1; itemHash.get('items').has(i); ++i){
		var subItemHash = itemHash.get('items').get(i);
		var subItemId = subItemHash.get('itemId');
		var expandMenu = subItemHash.get('expand_menu');
		if (expandMenu && expandMenu.match('auto')){
			this.showMenu(subItemHash, subItemId);
			var contractMenu = subItemHash.get('contract_menu');
			if (contractMenu && contractMenu.match('rollout')){
				this.setMouseoverStatus(subItemId, true, true, false);					
			}
		}
	}
	if (!this.cleanMenusLoopTimeout){
		this.cleanMenusLoop();
	}
	if (this.firstCloseableKey === false){
		this.getFirstCloseableKey();
	}
};

WebDDM.prototype.checkClickMenu = function (itemId){
	var itemHash = this.getItemHash(itemId);
	var bareItemId = itemId.replace(this.containerId + '_', '');
	if (itemHash.get('menuLevel') > 0){
		for (var i = (this.openMenuData.size() - 1); i > 0; i--){
			var data = this.openMenuData.get(i);
			if (data && data.get('menuLevel') == itemHash.get('menuLevel') && data.get('itemId') != itemId){
				if (data.get('expand_menu').match('click')){
					if (data.get('contract_menu').match('click')){
						this.showMenu(itemHash, itemId);
						break;
					}
					else if (data.get('contract_menu').match('rollout')){
						this.hideMenusOnLevel(itemHash);
					}
				}
			}
		}
	}
};

WebDDM.prototype.cleanMenusLoop = function (){
	if ((this.openMenuData.size()-1) >= this.firstCloseableKey){
		this.cleanMenusLoopTimeout = domLib_setTimeout(function (args){
			args[0].cleanMenusLoopTimeout = false;
			args[0].cleanMenusLoop();
		}, 50, [this]);
	}
	this.cleanMenus();
};
	
WebDDM.prototype.cleanMenus = function (){
	for (var i = this.openMenuData.length - 1; this.openMenuData.has(i); i--){
		var itemHash = this.openMenuData.get(i);
		if (this.canHideMenu(itemHash)){
			itemHash.cleanThread = domLib_setTimeout(function (args){
				var cItemHash = args[0].openMenuData.get(args[1]);
				if (cItemHash && args[0].canHideMenu(cItemHash)){
					args[0].hideMenu(cItemHash);
				}
			}, itemHash.get('closeDelay'), [this, i]);
		}
		else
		{
			break;
		}
	}	
};

WebDDM.prototype.hideMenu = function (itemHash, setMouseoverStatus){
	if (!itemHash){
		return;
	}
	if (typeof(setMouseoverStatus) == 'undefined'){
		setMouseoverStatus = true;
	}
	if (itemHash != this.openMenuData.get(this.openMenuData.size() - 1)){
		return;
	}
	var itemId = itemHash.get('itemId');
	if (setMouseoverStatus){
		this.setMouseoverStatus(itemId, false, false, false);
	}
	if (itemHash.get('itemId')){
		this.setItemStyle(itemHash,
			(this.getMouseoverStatus(itemHash.get('itemId'))
				? WebDDM_style_rollover
				: WebDDM_style_out));
	}
	if (!itemHash.get('itemId') && itemHash.get('expand_menu').match('context')){
		WebDDM_getElement(this.containerId).style.top = '-10000px';
		WebDDM_getElement(this.containerId).style.left = '-10000px';
	}
	this.setVisibility(itemHash.get('items'), (itemHash.get('itemId') || this.containerId) + '_subitems', false);
	this.openMenuData.remove(this.openMenuData.size() - 1);
	this.menuOpenStatuses.set(itemHash.get('itemId'), false);
};

WebDDM.prototype.hideAllSubmenus = function (calledOnClick){
	if (!this.openMenuData.has(this.firstCloseableKey)){
		return;
	}
	var childrenHidden = false;
	for (var i = (this.openMenuData.size() - 1); i >= this.firstCloseableKey; i--){		
		if (!childrenHidden && calledOnClick && this.openMenuData.get(i).get('contract_menu').match('rollout')){
			if (!this.menuData.get('expand_menu').match('context') || this.firstCloseableKey == 1){
				return;
			}
		}
		if (this.openMenuData.get(i).get('contract_menu').match('none')){
			return;
		}
		this.setMouseoverStatus(this.openMenuData.get(i).get('itemId'), false, false, false);
		this.hideMenu(this.openMenuData.get(i));
		childrenHidden = true;
	}
};

WebDDM.prototype.getFirstCloseableKey = function (){
	var data = this.openMenuData.get(0);
	var firstId = 1;
	if (this.menuData.get('expand_menu').match('context')){
		firstId = 0;
	}
	else if (data && data.has('contract_menu') && data.get('contract_menu').match(/rollout/)){
		firstId = 0;
	}
	this.firstCloseableKey = firstId;
};

WebDDM.prototype.setItemStyle = function (itemHash, new_style, forceStyle){
	new_style.match(/^([\_a-zA-Z]*)\_([a-zA-Z]*)$/);
	var fallback_style = RegExp.$1;
	itemHash.set('currentStyle', new_style);
	var element = WebDDM_getElement(itemHash.get('itemId') + '_item');	
	var style = itemHash.has('content' + new_style) ? new_style : fallback_style; 
	if (itemHash.has('content' + style) && !(itemHash.get('currentStyleContent') == style && !forceStyle)){
		element.innerHTML = itemHash.get('content' + style);
		itemHash.set('currentStyleContent', style);
	}
	var style = itemHash.has('class' + new_style) ? new_style : fallback_style; 
	if (itemHash.has('class' + style) && !(itemHash.get('currentStyleClass') == style && !forceStyle)){
		element.className = itemHash.get('class' + style);
		itemHash.set('currentStyleClass', style);
	}
	var style = itemHash.has('css' + new_style) ? new_style : fallback_style; 
	if (itemHash.has('css' + style) && !(itemHash.get('currentStyleCSS') == style && !forceStyle)){
		var css;
		if (!forceStyle && itemHash.has('css_cached_array' + style)){
			css = itemHash.get('css_cached_array' + style);
		}
		else{
			css = parseCssString(itemHash.get('css' + style));
			itemHash.set('css_cached_array' + style, css);
		}
		
		for (var k in css){
			var intercapKey = interCap(k);
			try{
				if (element.style[intercapKey] != css[k]){
					element.style[intercapKey] = css[k];
				}
			}
			catch (e){
			}
		}
		itemHash.set('currentStyleCSS', style);
	}
};

WebDDM.prototype.setVisibility = function (itemsData, itemsId, visibility){	
	var element = WebDDM_getElement(itemsId);
	if (visibility){
		domLib_detectCollisions(WebDDM_getElement(itemsId), false);
		element.style.visibility = 'visible';
	}
	var transitionsUsed = false;
	for (var index in WebDDM_transitionPlugins.elementData){
		if (itemsData.has(WebDDM_transitionPlugins.get(index))){
			transitionsUsed = true;
			this[WebDDM_transitionPlugins.get(index)](itemsData, itemsId + '_background', visibility);
		}
	}
	if(!transitionsUsed){
		this.transitionCompleted(element, visibility, itemsId);
	}
};

WebDDM.prototype.transitionCompleted = function (domObj, visibilityStatus, itemsId){
	while (!domObj.id.match(/_subitems$/)){
		domObj = domObj.offsetParent;
	}
	if (!visibilityStatus){
		domObj.style.visibility = 'hidden';
		domLib_detectCollisions(domObj, true);
	}
	else
	{
		domLib_detectCollisions(domObj, false);
		domLib_setTimeout('var obj = getWebDDMObject("'+this.containerId+'"); obj.reloadItems(obj.getItemHash("'+itemsId.replace(/subitems$/, '')+'"), "' + itemsId + '");', 10);
	}
};

WebDDM.prototype.reloadItems = function (itemsHash, itemsId){
	if (itemsHash.get(1)){
		itemsId = itemsHash.get(1).get('parentId') + '_subitems';
		itemsHash.set('liveOffsets', new Hash());
		itemsHash.get('liveOffsets').set('first-item-offset-left', 0);
		itemsHash.get('liveOffsets').set('first-item-offset-top', 0);
		itemsHash.get('liveOffsets').set('items-total-height', 0);
		itemsHash.get('liveOffsets').set('items-total-width', 0);

		var firstItemObject = WebDDM_getElement(itemsHash.get(1).get('itemId') + '_item_container');

		if (firstItemObject){
			var backgroundElement = WebDDM_getElement(itemsId + '_background');
			var initialOffsetLeft = firstItemObject.offsetLeft + backgroundElement.offsetLeft;
			var initialOffsetTop = firstItemObject.offsetTop + backgroundElement.offsetTop;
			itemsHash.get('liveOffsets').set('first-item-offset-left', initialOffsetLeft);
			itemsHash.get('liveOffsets').set('first-item-offset-top', initialOffsetTop);
			
			var itemsHeight = 0;
			var itemsWidth = 0;
			for (var i = 1; itemsHash.has(i); ++i){
				var itemObject = WebDDM_getElement(itemsHash.get(i).get('itemId') + '_item_container');
				if ((itemObject.offsetLeft + itemObject.offsetWidth) > itemsWidth){
					itemsWidth = (itemObject.offsetLeft + itemObject.offsetWidth);
				}
				if ((itemObject.offsetTop + itemObject.offsetHeight) > itemsHeight){
					itemsHeight = (itemObject.offsetTop + itemObject.offsetHeight);
				}
			}
			itemsHash.get('liveOffsets').set('items-total-height', itemsHeight);
			itemsHash.get('liveOffsets').set('items-total-width', itemsWidth);
		}
		if (WebDDM_actionPlugins.has('item_show')){
			for (var index in WebDDM_actionPlugins.get('item_show').elementData){
				WebDDM_actionPlugins.get('item_show').get(index)(this, itemsHash, itemsId);
			}
		}
	}
};

WebDDM.prototype.reloadItem = function (itemHash){
	if (!itemHash || !itemHash.has('itemId')){
		return;
	}
	this.setItemStyle(itemHash, itemHash.has('currentStyle') ? itemHash.get('currentStyle') : '', true);
};

WebDDM.prototype.modifyMenuData = function (hashPath, newValue){
	var evalHashPath = 'this.menuData';
	var itemHashPath = 'this.menuData';
	var attributeName = '';
	var chunks = hashPath.split('-');
	for (var i = 0; i < chunks.length; ++i){
		var chunk = chunks[i];
		if (typeof(chunks[i+1]) == 'undefined'){
			attributeName = chunk;
		}
		else{
			evalHashPath += '.get("'+chunk+'")';
			if (chunk == 'items' || !isNaN(chunk)){
				itemHashPath += '.get("'+chunk+'")';
			}
		}
	}
	try{
		eval('var attributeHash = ' + evalHashPath);
	}
	catch (e){
		alert('WebDDM error when modifying menu data ['+hashPath+'] of menu with ' +
			'container ID: ' + this.containerId +
			"\n\nError Message: " + e.message +
			"\n\nError Name: " + e.name +
			"\n\nError Line: " + (e.lineNumber ? e.lineNumber : e.number) +
			"\n\nError Stack: " + (e.stack ? e.stack : '[unknown]'));
	}
	eval('var itemHash = ' + itemHashPath);
	attributeHash.set(attributeName, newValue);
	if (attributeName.match(/^css(.*?)$/)){
		attributeHash.remove('css_cached_array' + RegExp.$1);
	}
	if (attributeName.match(/(expand|contract)\_menu/)){
		this.firstCloseableKey = false;
	}
	this.reloadItem(itemHash);
};

WebDDM.prototype.getMenuData = function (hashPath){
	var evalAttributePath = 'this.menuData';
	var attributeName = '';
	var chunks = hashPath.split('-');
	for (var i in chunks){
		evalAttributePath += '.get("'+chunks[i]+'")';
	}
	eval('var attribute = ' + evalAttributePath);
	return attribute;
};

WebDDM.prototype.mouseAction = function (in_event, action, itemId){
	in_event = (in_event || (in_event == 0 ? false : window.event));
	var itemHash = this.getItemHash(itemId);
	if (!itemHash){
		return;
	}
	switch (action) {
		default:
			break;
		case 'mouseover':
			if (this.mouseoutTimeout == itemId && !this.getMouseoverStatus(itemId)){
				this.mouseoutTimeout = false;
				this.setMouseoverStatus(itemId, true, true, true);
				return;
			}
			if (itemHash.has('items')){
				if (itemHash.get('expand_menu').match('click')){
					this.checkClickMenu(itemId);
				}
				if (itemHash.get('expand_menu').match('rollover')){
					this.setShowMenuTimeout(itemHash);
				}
			}
			else if (!itemHash.has('isContainerItem')){
				this.showMenu(itemHash, itemId);
			}
			this.setItemStyle(itemHash, (this.menuIsOpen(itemId)
				? WebDDM_style_menuopenRollover
				: WebDDM_style_rollover));
			if (itemId != this.containerId && itemHash.get('parentId') && !itemHash.get('expand_menu').match('auto')){
				this.showMenu(this.getItemHash(itemHash.get('parentId')), itemHash.get('parentId'));
			}
			this.setMouseoverStatus(itemId, true, true, true);
			break;
		case 'click':		
			domLib_cancelBubble(in_event);
			if (itemHash.has('items')){
				if (itemHash.get('expand_menu').match('click')){
					if (this.menuIsOpen(itemId) && itemHash.get('contract_menu').match('click')){
						this.hideMenu(itemHash, false);
					}
					else{			
						this.setShowMenuTimeout(itemHash);
					}
				}
				else if (itemHash.get('contract_menu').match('click')){
					this.hideMenu(itemHash, false);
				}
			}
		case 'mouseup':
			domLib_cancelBubble(in_event);
			this.setItemStyle(itemHash, (this.menuIsOpen(itemId)
				? WebDDM_style_menuopenRollover
				: WebDDM_style_rollover));

			break;
		case 'mouseout':
			this.setMouseoverStatus(itemId, false, false, false);
			if (this.mouseoutTimeoutId){
				domLib_clearTimeout(this.mouseoutTimeoutId);
				this.mouseoutTimeoutId = false;
			}
			var mouseout_code = function (args){
				args[0].mouseoutTimeout = false;
				args[0].mouseoutTimeoutId = false;

				if (!args[0].getMouseoverStatus(args[2])){
					args[0].setMouseoverStatus(args[2], false, false, false);
					args[0].setItemStyle(args[1], (args[0].menuIsOpen(args[2])
						? WebDDM_style_menuopenOut
						: WebDDM_style_out));

					if (args[1].has('actions') && args[1].get('actions').has('onmouseout')){
						eval(args[1].get('actions').get('onmouseout'));
					}
					if (WebDDM_actionPlugins.has('item_mouseout')){
						for (var index in WebDDM_actionPlugins.get('item_mouseout').elementData){
							WebDDM_actionPlugins.get('item_mouseout').get(index)(args[3], this, args[1]);
						}
					}
				}
			};
			if (in_event){
				this.mouseoutTimeout = itemId;
				this.mouseoutTimeoutId = domLib_setTimeout(mouseout_code, 10, [this, itemHash, itemId, in_event]);
			}
			else{
				mouseout_code([this, itemHash, itemId, in_event]);
			}
			break;
		case 'mousedown':
			domLib_cancelBubble(in_event);
			this.setItemStyle(itemHash, (this.menuIsOpen(itemId)
				? WebDDM_style_menuopenPressed
				: WebDDM_style_rolloverPressed));
			break;
	}

	if (!action.match('mouseout')){
		if (itemHash.has('actions') && itemHash.get('actions').has('on'+action)){
			eval(itemHash.get('actions').get('on'+action));
		}
		if (WebDDM_actionPlugins.has('item_' + action)){
			for (var index in WebDDM_actionPlugins.get('item_' + action).elementData){
				WebDDM_actionPlugins.get('item_' + action).get(index)(in_event, this, itemHash);
			}
		}
	}
};

WebDDM.prototype.setShowMenuTimeout = function (itemHash){
	this.showTimeoutHash.set(this.showTimeoutHash.length, domLib_setTimeout(function(args){
		for (var i = args[0].showTimeoutHash.length; i >= 0; i--){
			domLib_clearTimeout(args[0].showTimeoutHash.get(i));
			args[0].showTimeoutHash.remove(i);
		}
		args[0].showMenu(args[1], args[2]);
	}, (itemHash.has('openDelay') ? itemHash.get('openDelay') : 0), [this, itemHash, itemHash.get('itemId')]));
};

WebDDM.prototype.formatUnit = function (value){
	if (parseFloat(value) == value || parseInt(value) == value || typeof(value) == 'number'){
		return (value+'') + this.menuData.get('defaultMeasurementUnit');
	}
	else{
		return value;
	}
};

function getWebDDMObject (containerId){
	return WebDDMObjects.has(containerId) ? WebDDMObjects.get(containerId) : false;	
}

function WebDDM_hideAllMenus (calledFromClick, except){
	for (var i in WebDDMObjects.elementData){
		if (i != except){
			getWebDDMObject(i).hideAllSubmenus(calledFromClick);
		}
	}
}

function WebDDM_preloadImages (){
	var domObj = document.createElement('div');
	domObj.style.position = 'absolute';
	domObj.style.top = '-999999px';
	for (var i = 0; i < arguments.length; ++i){
		domObj.innerHTML += '<div style="background-image: url(\''+arguments[i]+'\');">'
			+ '<img src="'+arguments[i]+'" />'
			+ '</div>';
	}
	document.body.appendChild(domObj);
};

function WebDDM_registerPlugin_action (action, pluginCallback){
	if (!WebDDM_actionPlugins.has(action)){
		WebDDM_actionPlugins.set(action, new Hash());
	}
	WebDDM_actionPlugins.get(action).set('auto', pluginCallback);
};

function WebDDM_registerPlugin_transition (pluginName){
	WebDDM_transitionPlugins.set('auto', pluginName);
};
