function process()
{	
	if (MyMenu.step<0)
	{
		MyMenu.step = Math.min(MyMenu.outcurX-MyMenu.incurX,MyMenu.step);
	}
	else
	{
		MyMenu.step = Math.max(MyMenu.outcurX-MyMenu.incurX,MyMenu.step);
	}
	
	MyMenu.backk.style.left = (MyMenu.incurX-MyMenu.step)+'px';
	MyMenu.incurX = MyMenu.incurX-MyMenu.step;
	MyMenu.backk.style.width = (MyMenu.incurSize-MyMenu.stepSize)+'px';
	MyMenu.incurSize = MyMenu.incurSize-MyMenu.stepSize;
	MyMenu.processtep++;
	if (MyMenu.processtep>=MyMenu.maxstep || MyMenu.outcurX == MyMenu.incurX)
	{
		MyMenu.clear();
		MyMenu.backk.style.left = MyMenu.outcurX+'px';
		MyMenu.incurX = MyMenu.outcurX;
		MyMenu.backk.style.width = MyMenu.outcurSize+'px';
		MyMenu.incurSize = MyMenu.outcurSize;
		if (MyMenu.needDropMenu==1)
		{
			MyMenu.showdropmenu();
		}
	}
	else
	{
		MyMenu.timer = setTimeout(process,1);
	}
}
function slide()
{
	MyMenu.move_allow=0;
	MyMenu.dm.style.marginTop=Math.min((MyMenu.stepH-MyMenu.height_l),0)+'px';
	MyMenu.height_l = Math.max(MyMenu.height_l-MyMenu.stepH,0);
	if (MyMenu.height_l>0)
	{
		this.timer = setTimeout(slide,1);
	}
	else
	{
		MyMenu.dm.style.marginTop=0+'px';
		MyMenu.move_allow=1;
	}
}
function action_return_current()
{
	if (MyMenu.needclose == 1)
	{
		//if (MyMenu.needDropMenu == 1)
		//{
			MyMenu.closedropmenu();
		//}
		MyMenu.current = layer(MyMenu.getElementsByClass(MyMenu.tablemenu,MyMenu.CurId,'LI'));
		MyMenu.needDropMenu = 0;
		MyMenu.move();
	}
}
var MyMenu = {
	CurId : 'current',
	IdMenu : 'menu',
	IdTableMenu : 'menu_table',
	IdDropDownMenu : 'dropdownmenu',
	IdBackground : 'back',
	timer: 1,
	duration : 750,
	maxstep : 18,
	maxstepslide: 7,
	move_allow: 1,
	needDropMenu: 1,
	size: function()
	{
		this.backk.style.width = this.current.getWidth()+'px';
		this.backk.style.height = this.current.getHeight()+'px';
	},
	move: function()
	{
		//this.debug.innerHTML+='function move '+this.current.object.id+'<br>';
		this.processtep = 0;
		this.incurX = this.backk.getAbsoluteLeft();
		this.incurY = this.current.getAbsoluteTop();
		this.outcurX = this.current.getAbsoluteLeft();
		this.incurSize = this.backk.getWidth();
		this.outcurSize = this.current.getWidth();
		this.targetSize = this.incurSize-this.outcurSize;
		this.stepSize = this.targetSize/this.maxstep;
		this.lehght = this.incurX-this.outcurX;
		this.step = this.lehght/this.maxstep;
		//this.clear();
		this.timer = setTimeout(process,1);
		//this.debug.innerHTML='';
	},
	getElementsByClass: function(tablemenu,CurId,curtag)
	{
		node = tablemenu;
		tag = curtag;
        var els = node.getElementsByTagName(tag);
        var elsLen = els.length;
        var pattern = new RegExp("(^|\\s)"+CurId+"(\\s|$)");
        var i;
        for (i = 0; i < elsLen; i++)
        {
          if (pattern.test(els[i].className))
          {
            var classElements = els[i];
          }
        }
       	return classElements.id;
	},
	showdropmenu: function()
	{
		this.incurX = this.backk.getAbsoluteLeft();
		this.incurY = this.current.getAbsoluteTop();
		
		this.dm_mask = layer(this.current.object.id+'_mask');
		if (this.dm_mask.object.id!='')
		{
		this.dm_mask.style.width = this.current.getWidth()+'px';
		this.dm_mask.style.height = 248+'px';
		this.dm_mask.style.left = this.incurX+'px';
		this.dm_mask.style.top = this.incurY+this.current.getHeight()+'px';
		this.dm = layer(this.current.object.id+'_d');
		this.height_l = this.dm.getHeight();
		this.stepH = Math.round(this.height_l/this.maxstepslide,2);
		this.dm.style.marginTop = -this.height_l+'px';
		this.dm.show();
		this.dm_mask.show();
		this.is_show_menu = 1;
		this.timer = setTimeout(slide,1);
		}
		//this.debug.innerHTML+='function showdropmenu '+this.current.object.id+'<br>';
		return null;
	},
	closedropmenu: function()
	{
		if (this.dm)
		{
			this.dm.hide();
			this.dm_mask.style.left=0+'px';
			this.dm_mask.style.top=0+'px';
			this.is_show_menu = 0;
		//this.debug.innerHTML+='function closedropmenu '+this.current.object.id+'<br>';
		}
		return null;
	},
	initialize: function()
	{
		this.menu = layer(this.IdMenu);
		this.tablemenu = document.getElementById(this.IdTableMenu);
		
		this.debug = document.getElementById('debug');
		
		this.current = layer(this.getElementsByClass(this.tablemenu,this.CurId,'LI'));
		
		this.current_menu = this.current;
		
		this.dropdownmenu = document.getElementById(this.IdDropDownMenu);
		this.backk = layer(this.IdBackground);
		this.size();
		this.backk.style.top = this.current.getAbsoluteTop()+'px';
		this.backk.style.left = this.current.getAbsoluteLeft()+'px';
		this.backk.style.zIndex = 8;
		this.menu.style.zIndex = 10;
		this.backk.show();
		this.needDropMenu = 1;
		this.needclose = 0;
		this.is_show_menu = 0;
		//this.debug.innerHTML+='function initialize '+this.current.object.id+'<br>';
		return true;
	},
	moveto: function(el,needD)
	{
		//alert(this.current.object.id != el);
		//this.debug.innerHTML+='function moveto '+this.current.object.id+'<br>';
		if (this.current.object.id != el)
		{
			this.clear();
			if (this.is_show_menu==1)
			{
				this.closedropmenu();
			}
			this.current = layer(el);
			this.needDropMenu = needD;
			this.move();
		}
		else if (this.is_show_menu==0)
		{
			this.showdropmenu();
		}
		else
		{
			this.needclose = 0;
		}
	},
	return_current: function()
	{
		//this.debug.innerHTML+='function return_current '+this.current.object.id+'<br>';
		this.needclose = 1;
		this.timer = setTimeout(action_return_current,1);
	},
	clear: function()
	{
		//this.debug.innerHTML+='function clear '+this.current.object.id+'<br>';
		//this.processtep=0;
		clearTimeout(this.timer);
		clearInterval(this.timer);
		return null;
	}
};
addEvent(window,'resize',function(){MyMenu.initialize()},false);