function addEvent(obj, evType, fn, useCapture)
{
	//-- Default to event bubbling
	if (!useCapture) useCapture = false;

	//-- DOM level 2 method
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, useCapture);
	}
	else
	{
		//-- event capturing not supported
		if (useCapture)
		{
			alert('This browser does not support event capturing!');
		}
		else
		{
			var evTypeRef = '__' + evType;

			//-- create function stack in the DOM space of the element; seperate stacks for each event type
			if (!obj[evTypeRef])
			{
				//-- create the stack if it doesn't exist yet
				obj[evTypeRef] = [];

				//-- if there is an inline event defined store it in the stack
				var orgEvent = obj['on'+evType];
				if (orgEvent) obj[evTypeRef][0] = orgEvent;

				//-- attach helper function using the DOM level 0 method
				obj['on'+evType] = IEEventHandler;
			}
			else
			{
				//-- check if handler is not already attached, don't attach the same function twice to match behavior of addEventListener
				for (var ref in obj[evTypeRef])
				{
					if (obj[evTypeRef][ref] === fn) return;
				}
			}

			//-- add reference to the function to the stack
			obj[evTypeRef][obj[evTypeRef].length] = fn;
		}
	}
}

/**
* removeEvent
*
* Generic function to remove previously attached event listeners.
*
* @param obj The object to which the event listener was attached.
* @param evType The eventtype, eg. 'click', 'mousemove' etcetera.
* @param fn The listener function.
* @param useCapture (optional) Whether event capturing, or event bubbling (default) was used.
*/
function removeEvent(obj, evType, fn, useCapture)
{
	//-- Default to event bubbling
	if (!useCapture) useCapture = false;

	//-- DOM level 2 method
	if (obj.removeEventListener)
	{
		obj.removeEventListener(evType, fn, useCapture);
	}
	else
	{
		var evTypeRef = '__' + evType;

		//-- Check if there is a stack of function references for this event type on the object
		if (obj[evTypeRef])
		{
			//-- iterate through the stack
			for (var ref in obj[evTypeRef])
			{
				//-- if function reference is found, remove it
				if (obj[evTypeRef][ref] === fn)
				{
					try
					{
						delete obj[evTypeRef][ref];
					}
					catch(e)
					{
						obj[evTypeRef][ref] = null;
					}

					return;
				}
			}
		}
	}
}

/**
* IEEventHandler
* 
* IE helper function to execute the attached handlers for events.
* Because of the way this helperfunction is attached to the object (using the DOM level 0 method)
* the 'this' keyword will correctely point to the element that the handler was defined on.
*
* @param e (optional) Event object, defaults to window.event object when not passed as argument (IE).
*/
function IEEventHandler(e)
{
	e = e || window.event;
	var evTypeRef = '__' + e.type, obj;

	//-- check if there is a custom function stack defined for this event type on the object
	if (this[evTypeRef])
	{
		//-- iterate through the stack and execute each function in the scope of the object by using function.call
		var evTypeRefLen = this[evTypeRef].length
		for(var ref = 0; ref < evTypeRefLen; ref++)
		{
		//for (var ref in this[evTypeRef])
		//{
			if (Function.call)
			{
				this[evTypeRef][ref].call(this, e);
			}
			else
			{
				//-- IE 5.0 doesn't support call or apply, so use this
				this.__fn = this[evTypeRef][ref];
				this.__fn(e);
				this.__fn = null;
			}
		}
	}
}

function showSubNav(e)
{
	this.className += ' menu_hover';
	if ( this.parentElement ) {
		this.childNodes[0].className = this.childNodes[0].className.replace(/menu_hover/g,'');
		this.childNodes[0].className += ' menu_hover';
	}
	else {
		this.className = this.className.replace(/menu_hover/g,'');
		this.className += ' menu_hover';
	}
}

function hideSubNav(e)
{
	this.className = this.className.replace(/menu_hover/g,'');
	if ( this.parentElement )
		this.childNodes[0].className = this.childNodes[0].className.replace(/menu_hover/g,'');
	else 
		this.className = this.className.replace(/menu_hover/g,'');
}

/*
* Checking if the selected Country is other than Romania, and doing a collapse or expand depending by selction , for the rest of Countries
*/
function hideShowCountry(e) {
	if(this.parentNode.className.search(/showLayer/) == -1){
		this.parentNode.className = this.parentNode.className.replace(/hideLayer/g,''); 
		this.parentNode.className += ' showLayer'; 
	}
	else {
		this.parentNode.className = this.parentNode.className.replace(/showLayer/g,''); 
		this.parentNode.className += ' hideLayer'; 
	}
}

function initLocations(id) {
	var el = document.getElementById(id);
	var obj = '';
	if(el) {
		var x = el.getElementsByTagName('li');
		for (var i=0;i<x.length;i++)
		{
			addEvent(x[i], 'mouseover', showSubNav);
			addEvent(x[i], 'mouseout', hideSubNav);
			if((x[i].className.search(/fl/) != -1) || (x[i].className.search(/selectedFirst/) != -1)){
				obj = x[i].childNodes[0];
				if(obj.innerHTML.toLowerCase() != 'romania' && obj.innerHTML.toLowerCase() != 'bulgaria'){
					if(obj.parentNode.className.search(/showLayer/) == -1)
						obj.parentNode.className += ' hideLayer'; 
					addEvent(obj, 'click', hideShowCountry);
				}//end if
			}//end if
		}//end for
	}//end if
}