// JavaScript Document
function CSMMenu()
{
	var SMMenuName="";
	var SMMenuMenus=new Array();
	var SMMenuWidth=new Array();
	var SMMenuHeight=new Array();
	
	this.SMMenu_Init=function(Name,Width0,Height0,Width1,Height1,Width2,Height2,Width3,Height3)
	{
		SMMenuName=Name;
		
		SMMenuWidth[0]=Width0;
		SMMenuHeight[0]=Height0;
		
		SMMenuWidth[1]=Width1;
		SMMenuHeight[1]=Height1;
		
		SMMenuWidth[2]=Width2;
		SMMenuHeight[2]=Height2;
		
		SMMenuWidth[3]=Width3;
		SMMenuHeight[3]=Height3;
	}
	
	this.SMMenu_MakeMenu=function(Id,ParentId,Text,Link)
	{
		var Menu={"Id":"","ParentId":"","Text":"","Link":""};
		Menu.Id=Id;
		Menu.ParentId=ParentId;
		Menu.Text=Text;
		Menu.Link=Link;
		
		SMMenuMenus[SMMenuMenus.length]=Menu;
	}
		
	this.SMMenu_HasChild=function(Id)
	{
		var res=false;
		
		for(var i=0;i<SMMenuMenus.length;i++)
		{
			var Menu=SMMenuMenus[i];
			
			if (Menu.ParentId==Id)
			{
				res=true;
				break;
			}
		}
		
		return res;
	}
		
	this.SMMenu_GetMenuShow=function()
	{
		var res="";
		
		var RootId="";
		for(var i=0;i<SMMenuMenus.length;i++)
		{
			var Menu=SMMenuMenus[i];
			
			if (Menu.ParentId=="0")
			{
				RootId=Menu.Id;
				break;
			}
		}
			
		var Top=0;
		var Level=0;
		
		for(var i=0;i<SMMenuMenus.length;i++)
		{
			var Menu=SMMenuMenus[i];
	
			if (Menu.ParentId==RootId)
			{
				var arraw="";
				if (this.SMMenu_HasChild(Menu.Id))
				{
					arraw="<img src='images/arrow1.gif'/>";
				}
				
				res=res+"<div id='"+SMMenuName+"_"+Menu.Id+"' class='SMMenu"+Level+"' style='height:"+SMMenuHeight[Level]+"px;width:"+SMMenuWidth[Level]+"px;' onmouseover=\"$('#"+SMMenuName+"_"+Menu.Id+"_Sub').show();$('.SMMenu"+Level+"over').attr('class','SMMenu"+Level+"');$('#"+SMMenuName+"_"+Menu.Id+"').attr('class','SMMenu"+Level+"over');\" onmouseout=\"$('#"+SMMenuName+"_"+Menu.Id+"_Sub').hide();\" onclick=\"location=href='"+Menu.Link+"';\"><div>"+Menu.Text+arraw+"</div></div>";
				
				res=res+this.SMMenu_GetSubMenuShow(Menu.Id,Top,SMMenuWidth[Level],Level);
				
				Top=Top+SMMenuHeight[Level];
			}
		}
		
		return res;
	}
	
	this.SMMenu_GetSubMenuShow=function(ParentId,Top,Left,Level,ParentShow)
	{
		var res="";
	
		var bFind=false;
		for(var i=0;i<SMMenuMenus.length;i++)
		{
			var Menu=SMMenuMenus[i];
			
			if (Menu.ParentId==ParentId)
			{
				bFind=true;
			}
		}
		
		if (!bFind)
		{
			return res;
			
		}
		
		if (Level>=1)
		{
			ParentShow=ParentShow+"$('#"+SMMenuName+"_"+ParentId+"_Sub').show();";
		}
		Level++
	
		res=res+"<div id='"+SMMenuName+"_"+ParentId+"_Sub' class='SMMenu"+Level+"border' style='position:absolute;left:"+Left+"px;top:"+Top+"px;display:none' onmousemove=\"$('#"+SMMenuName+"_"+ParentId+"_Sub').show();"+ParentShow+"\">";
		
		var Top=0;
		
		for(var i=0;i<SMMenuMenus.length;i++)
		{
			var Menu=SMMenuMenus[i];
			
			if (Menu.ParentId==ParentId)
			{
				var arraw="";
				if (this.SMMenu_HasChild(Menu.Id))
				{
					arraw="<img src='images/arrow1.gif'/>";
				}
				
				res=res+"<div id='"+SMMenuName+"_"+Menu.Id+"' class='SMMenu"+Level+"' style='height:"+SMMenuHeight[Level]+"px;width:"+SMMenuWidth[Level]+"px;' onmouseover=\"$('#"+SMMenuName+"_"+Menu.Id+"_Sub').show();$('.SMMenu"+Level+"over').attr('class','SMMenu"+Level+"');$('#"+SMMenuName+"_"+Menu.Id+"').attr('class','SMMenu"+Level+"over');\" onmouseout=\"$('#"+SMMenuName+"_"+Menu.Id+"_Sub').hide();\" onclick=\"location=href='"+Menu.Link+"';\"><div>"+Menu.Text+arraw+"</div></div>"
				
				res=res+this.SMMenu_GetSubMenuShow(Menu.Id,Top,SMMenuWidth[Level],Level);
				
	
				Top=Top+SMMenuHeight[Level];
			}
		}
		
		res=res+"</div>";
		
		return res;	
	}
}
