var mm = function ()
{
	this.delay = 1000;
	this.timers = [];
	this.instance == null;
	
	this.set = function (id, num)
	{
		var tmp = this;
		this.timers[id] = setTimeout( function(){tmp.hideDiv(tmp, id, num);}, this.delay);
	}
	
	this.get = function(id)
	{
		return this.timers[id];
	}

	this.hideDiv = function(obj, id, num)
	{
		delete obj.timers[id];
		for (i=1;i<=num;i++){
			jQuery("#"+id+"_"+i).addClass("hidden");
		}
//		alert('removed '+id.replace(/sub/,'main'));
		jQuery("#"+id.replace(/sub/,'main')).removeClass("top_menu_selected");		
	}

}

mm.getInstance = function(e)
{
	if (mm.instance == null)
	{
		mm.instance = new mm(); 
	}
	return mm.instance; 
}

mm.show = function(id, num)
{
	for (i=1;i<=num;i++){
		jQuery("#"+id+"_"+i).removeClass("hidden");	
	}
}

mm.hide = function(id, num)
{
	var om = mm.getInstance();
	om.set(id, num);
}

mm.clear = function(id)
{
	var om = mm.getInstance();
	clearTimeout(om.get(id));
//		alert('added '+id.replace(/sub/,'main'));
	jQuery("#"+id.replace(/sub/,'main')).addClass("top_menu_selected");		
}

// language switcher
function switchTo(lang){
var href = location.href;
var href = href.replace('_ro.html','.html');
var href = href.replace('_ru.html','.html');

var pos = href.indexOf('.html');
if (pos == -1) {
   href = href + '/index.html';
}

if (lang!='en')
{
  var href = href.replace('.html', '_'+lang+'.html');
}

window.location.href = href;
return false;
}
 
