function createMenu(data, id, label)  {  var func = new String();   switch(id)  
{   

	case 16 : func = MenuComponent16(data, label);  break;  
	case 40 : func = MenuComponent40(data, label);  break;  
        case 50 : func = MenuComponent50(data, label);  break;  


}   
return func;  }       

function MenuComponent16(data, label)  
{  
	var func = new String();       
	with(preferences)  
	{  
		template = Template9;  
		buffer = Buffer9;  
		style.text.normal = ''; 
		style.text.hover = ''; 
		node.normal.src = '/nvss/ikar/js/template10/node.gif'; 
		node.normal.width = 4; 
		node.normal.height = 5; 
		node.hover.src = '/nvss/ikar/js/template10/node.gif'; 
		node.hover.width = 4; 
		node.hover.height = 5;  
		cursor.normal = 'menuText1'; 
		cursor.hover = 'menuText1Hover';   
		style.filter = 'progid:DXImageTransform.Microsoft.Shadow(color="#aaaaaa",Direction="270",Strength="6"), progid:DXImageTransform.Microsoft.Alpha(Opacity="90",Style="0")';   
		tolerance.x = 7;  
		tolerance.y = 2;  
	}    
	cuted = new Array();  
	cuted = cut(data);       
	hov = new menulist();   
	hov.style = new Object();   
	hov.style.position = 'absolute';  
	hov.style.visibility = 'hidden';  
	hov.template = Hover10;   
	hov.css = extendcss;    
	hov.generate(cuted);  
	hov.css();   
	hov.build();       
	obj = new menulist();   
	obj.style.position = 'relative';  
	obj.style. visibility = 'visible';  
	obj.style.zIndex = obj.zIndex;  
	obj.style.filter = '';  
	obj.template = Template10;  
	obj.open_time_delay = 300;  
	obj.close_time_delay = 200;  
	obj.tolerance.y = 0;  
	obj.tolerance.x = (Is.IE5&&Is.IeVer!=5)&&!window.opera?-6:0; 
	obj.cursor.normal = 'menuText1';  
	obj.cursor.hover = 'menuText1';   
	obj.oHover = hov;  
	obj.select = obj.layerselect;  
	obj.deselect = obj.layerdeselect;  
	obj.position = obj.aligning;    
	obj.generate(data);  
	obj.css();    
	obj.build(); 
	obj.layover(obj.obj); 
	obj.events(obj.obj); 
	obj.outclick(); 
	return func;  
}

/**********************     ВЕРТИК МЕНЮ   40     *****************/
/*****************************************************************/
/*****************************************************************/
/*****************************************************************/
/*****************************************************************/


function MenuComponent40(data) 
{ 
 
	obj2 = new CreateMenuEngine40(); 

	obj = new CreateCollapseMenu40(); 
	
  obj.template = CollapseTemplate40;

	obj2.draft(data, -1, new Array(), obj);

  obj.selectedstyle = "current";

	obj.css(); 
  obj.activelink();
	
	output = obj.build(new String()); 

	document.write(output); 
} 


function CreateMenuEngine40()
{ 
	this.path = '/nvss/js/template4/';
	this.space = new declare(); 
	this.list = new declare( { path:this.path, source:['space.gif', 0, 9] } ); 
	this.list1 = new declare( { path:this.path, source:['space.gif',0, 10] } ); 
  this.list2 = new declare( { path:this.path, source:['space.gif', 0, 9] } ); 
	
	this.draft = function(data, the_depth, transfer, is_obj) 
	{ 
		the_depth++; 
		is_obj.depth = the_depth; 
		
		for(var i = 0; i < data.length; i++) 
		{ 
			var it_have_array = typeof(data[i][4])=="object"?true:false; 
			var next = new Array(); 
			var draft = new Array(); 
			
			if(the_depth) 
			{
				draft = transfer.concat(draft); 
			}



			if( the_depth == 0)	
					draft[draft.length] = new Array(this.list); 
			else 
					draft[draft.length] = new Array(this.list2); 




			if (it_have_array )
					draft[draft.length] = new Array(this.list1); 
			else 
                          draft[draft.length] = new Array(this.list); 
			
			if(it_have_array) 
			{ 
				next[next.length] = new Array( this.space ); 
				next = transfer.concat(next); 
				
				child_obj = new CreateCollapseMenu40(is_obj); 

        child_obj.indent = i;
				
				is_obj.add(draft, data[i], child_obj); 
				
				this.draft( data[i][4] , the_depth, next, child_obj); 
			} 
			else 
			{ 
				is_obj.add(draft, data[i]); 
			} 
		} 
	} 
} 

function declare() 
{ 
	system = { path:'/nvss/js/template4/', source:['space.gif', 1, 8] }; 
	current = arguments.length?arguments[0]:system; 
	
	with(current) 
	{ 
		images = new Image(source[1], source[2]); 
		images.src = path+ source[0]; 
	} 
	
	return images; 
}
var MenuCountNew = 0;
function CreateCollapseMenu40(parent, data)
{
MenuCountNew++;
this.name = "MenuCollapse" + MenuCountNew;	 
this.obj = this.name + "Object";  
this.index = MenuCountNew;
this.depth = null;
this.parent = parent;
this.indent = '';
eval(this.obj+"=this");
this.template = CollapseTemplate40_2;  
this.container = '<DIV ID="'+this.name+'">{OBJECT}</DIV>';  
this.style = new Object();
this.style.display = 'block';
this.path = 'images/template10/';
this.icon = new Object();
this.icon.src = this.path+ "icon/icon.gif";
this.icon.width = 16;
this.icon.height = 16;
this.items = new Array(); 

this.selectedstyle = "current";

this.selectedstyle1 = "oneLevel";
this.selectedstyle2 = "twoLevel";
this.selectedstyle3 = "threeLevel";
this.selectedstyle4 = "fourLevel";

this.selectedstyle11 = "onecurrent";
this.selectedstyle22 = "twocurrent";
this.selectedstyle33 = "threecurrent";
this.selectedstyle44 = "fourcurrent";



this.add = function(draft, data, is_child)
{
var j = this.items.length;
this.items[j] = new Object();
this.items[j].draft = draft;
this.items[j].type = new Array();
this.items[j].key = 0;
this.items[j].open = false;
this.items[j].text = data[0];
this.items[j].alttext = data[1];
this.items[j].actived = false;
this.items[j].reference = data[2];
this.items[j].have_child = is_child?true:false;  
this.items[j].is_child = is_child;  
this.items[j].icon = new Object();
this.items[j].icon.src = data[5];  
this.items[j].icon.width = data[6]; 
this.items[j].icon.height = data[7];  
this.items[j].div = new Array();
this.items[j].div.name = this.name+ 'ItemBlock'+ j;
this.items[j].div.link = this.name+ 'ItemLink'+ j;
this.items[j].div.image = this.name+ 'ItemImages'+ j;
this.items[j].div.text = this.name+ 'ItemText'+ j;
}
this.build = function ()
{
var output = new String();
var menulist = new String();
var menuitem = new String();
var re1 = new RegExp("{item}(.*)\\{/item}", "gi");
var re2 = new RegExp("{object}", "gi");
menulist = this.template.replace(re1, '{content}');
menulist = this.container.replace(re2, menulist);
var re1 = new RegExp("{item}(.*)\\{/item}", "gi");
var re2 = new RegExp("{content}", "gi"); 
var re3 = new RegExp("{draft}", "gi"); 
var re4 = new RegExp("{text}", "gi"); 
var re5 = new RegExp("{block([-:;%\\s\\w=\"\']*)}", "gi"); 
var re6 = new RegExp("{/block}", "gi"); 
var re7 = new RegExp("{link([-:;%\\s\\w=\"\'_]*)}", "gi"); 
var re8 = new RegExp("{/link}", "gi"); 
var re9 = new RegExp("{textarea([-:;%\\s\\w=\"\']*)}", "gi"); 
var re10 = new RegExp("{/textarea}", "gi"); 
var re11 = new RegExp("{icon}", "gi"); 
menuitem = re1.exec(this.template);
for(var i=0; i < this.items.length; i++)
{
with(this.items[i])
{
layout = menuitem[1];
layout = layout.replace(re3, this.draft(i));
layout = layout.replace(re4, text);
// первый уровень, с потомками
if(have_child && !actived && this.depth==0){
layout = layout.replace(re9, '<DIV style="padding-left:10px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV  $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle1 +'">');
layout = layout.replace(re6, '</DIV>');
}

// первый уровень, без потомков
else if(!have_child && !actived && this.depth==0){

layout = layout.replace(re9, '<DIV style="padding-left:10px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle1 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}
// второй уровень, с потомками
else if(have_child && !actived && this.depth==1){
layout = layout.replace(re9, '<DIV style="padding-left:27px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle2 +'">');
layout = layout.replace(re6, '</DIV>');
}

// второй уровень, без потомков
else if(!have_child && !actived && this.depth==1){

layout = layout.replace(re9, '<DIV style="padding-left:27px" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle2 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}

// 3 уровень, с потомками
else if(have_child && !actived && this.depth==2){
layout = layout.replace(re9, '<DIV style="padding-left:39px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle3 +'">');
layout = layout.replace(re6, '</DIV>');
}

// 3 уровень, без потомков
else if(!have_child && !actived && this.depth==2){

layout = layout.replace(re9, '<DIV style="padding-left:39px" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle3 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}


// 4 и остальные уровень, с потомками
else if(have_child && !actived && this.depth!=0 && this.depth!=1 && this.depth!=2){
layout = layout.replace(re9, '<DIV style="padding-left:40px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle4 +'">');
layout = layout.replace(re6, '</DIV>');
}

// 4 и остальные уровень, без потомков
else if(!have_child && !actived && this.depth!=0 && this.depth!=1 && this.depth!=2){

layout = layout.replace(re9, '<DIV style="padding-left:40px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle4 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}





//*********************************************
//текущая 1 уровня
else if(actived && this.depth==0){
layout = layout.replace(re9, '<DIV style="padding-left:10px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle11 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 2 уровня
else if(actived && this.depth==1){
layout = layout.replace(re9, '<DIV style="padding-left:27px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle22 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 3 уровня
else if(actived && this.depth==2){
layout = layout.replace(re9, '<DIV style="padding-left:39px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle33 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 4 и остальные уровни
else if(actived && this.depth!=0 && this.depth!=1 && this.depth!=2){
layout = layout.replace(re9, '<DIV style="padding-left:40px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle44 +'">');
layout = layout.replace(re6, '</DIV>');
}







layout = layout.replace(re11, this.inserticon(i));
output += layout;
if(have_child)
{
output += '<TR><TD>';
output += is_child.build();
output += '</TD></TR>';
}
}
}
output = menulist.replace(re2, output);
return output;
}
this.draft = function(j)
{
plan = new String();
with(this.items[j])
{
var index = open ? 0 : 1;
for(var i = 0; i < draft.length; i++)
{
type[type.length] = div.image+ 'Draft'+ i;
if( draft[i][1] )
key = index;
else 
key = 0;
plan += '<IMG SRC="'+ draft[i][key].src+ '" WIDTH="'+ draft[i][key].width+ '" HEIGHT="'+ draft[i][key].height+ '" BORDER="0" ALT="" '+
'NAME="'+ type[type.length-1]+ '" '+
'>';
}
}
return plan;
}
this.inserticon = function(j)
{
var temp = new String();
if(this.icon.src)
{
with(this.items[j])
{
if(icon.src)  temp += '<IMG SRC="'+ icon.src+ '" WIDTH="'+ icon.width+ '" HEIGHT="'+ icon.height+ '">'; 
else  temp += '<IMG SRC="'+ this.icon.src+ '" WIDTH="'+ this.icon.width+ '" HEIGHT="'+ this.icon.height+ '">'; 
}
}
return temp;
}
this.css = function()
{
var output = setStyleSheet(this.name, this.style);
for(var i=0; i < this.items.length; i++)
{
with( this.items[i] )
{
if(have_child)
{
output += is_child.css(1);
}
}
}
if(!arguments.length)	 
{
document.write('<style type="text/css">'+ output+ '</style>');
}
return output;
}
this.init = function()
{
for(var i=0; i < this.items.length; i++)
{
with(this.items[i])
{
document.getElementById(div.name).onclick = new Function(this.obj+ '.click('+i+'); return true; ');
if(have_child)
{
document.getElementById(div.name).onclick = new Function(this.obj+ '.activated('+ i+ '); ');
is_child.init();
}
}
}
}
this.activated = function(i)
{
this.action(i);
this.reimage(i);
this.items[i].open = !this.items[i].open;
}
this.action = function(j)
{
with( this.items[j] )
{
if( open )
{
document.getElementById(is_child.name).style.display = 'none';
}
else
{
document.getElementById(is_child.name).style.display = 'block';
}
}
}
this.reimage = function(j)
{
with(this.items[j])
{
index = open ? 1 : 0;
for(var i = 0; i < draft.length; i++)
{
if( draft[i][1] )
{ 
document.images[type[i]].src = draft[i][index].src;
}
}
}
}
this.click = function(j)
{
document.links(this.items[j].div.link).click();
}
this.outblock = function()
{
for(var i =0; i < this.items.length; i++)
{
this.reimage(i);
if(this.items[i].have_child)
{
this.items[i].is_child.outblock();
}
}
}
this.setmouseevent = function()
{
for(var i=0; i < this.items.length; i++)
{  
with(this.items[i])
{
document.getElementById(div.name).onmouseover = new Function(this.obj+ '.selection('+i+'); return true; ');
document.getElementById(div.name).onmouseout = new Function(this.obj+ '.unselection('+i+'); return true; ');
if(have_child)
{
is_child.setmouseevent();
}
}
}
}
this.selection = function(j)
{
}
this.unselection = function(j)
{
}
}


   /*

    */

    CreateCollapseMenu40.prototype.activelink = function()
    {
       var oItem = this.pathfinder();
       
       //this.setactivegroup(oItem);
    }

   /*

    */

    CreateCollapseMenu40.prototype.pathfinder = function()
    {
       var oActive =  false;

       for(var i = 0; i < this.items.length; i++)
       {
          with(this.items[i])
          {
             if(this.defineactive(reference))
             {
                actived = true;

                this.style.visibility = "visible";

                return this;
             }

          	 if(have_child)  oActive = is_child.pathfinder();

          	 if(oActive)  return oActive;
          }
       }
    }

   /*

    */

    CreateCollapseMenu40.prototype.defineactive = function(reference)
    {
       var re = new RegExp(reference, "gi");

       if( location.href.search(re) > -1 )	return true;

       return false;
    }

   /*

    */

    CreateCollapseMenu40.prototype.selector = null;

    CreateCollapseMenu40.prototype.setactivegroup = function(oItem)
    {
       while( oItem && oItem.indent!=null )
       {
          var indent = oItem.indent;

          var oPrevious = oItem;
          oItem = oItem.parent;

          if(indent)
          	oItem.items[indent].actived = true;
       }

       if(oPrevious)
       {
          this.selector = oPrevious.indent;
       }
    }

   /*

    */
/*для второго уровня и ниже*/
var CollapseTemplate40_2 = ''+ 

'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'{ITEM}'+ 

'<TR>'+ 
'<TD STYLE="padding:0px 0px 0px 0px">'+ 

'{BLOCK}'+ 
'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'<TR>'+ 


'<TD STYLE="padding:5px 5px 5px 0px;" WIDTH="100%">'+ 
'{TEXTAREA}{LINK CLASS="itemMenuCollapse"}{TEXT}{/LINK}{TEXTAREA}'+ 
'</TD>'+ 

'</TR>'+ 
'</TABLE>'+ 
'{/BLOCK}'+ 

'</TD>'+ 
'</TR>'+ 

'{/ITEM}'+ 
'</TABLE>';  

/*для первого уровня*/
var CollapseTemplate40 = ''+ 

'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'{ITEM}'+ 

'<TR>'+ 
'<TD STYLE="padding:0px 0px 0px 0px">'+ 

'{BLOCK}'+ 
'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'<TR>'+ 


'<TD STYLE="padding:5px 5px 5px 0px;" WIDTH="100%">'+ 
'{TEXTAREA}{LINK CLASS="itemMenuCollapse"}{TEXT}{/LINK}{TEXTAREA}'+ 
'</TD>'+ 

'</TR>'+ 
'</TABLE>'+ 
'{/BLOCK}'+ 

'</TD>'+ 
'</TR>'+ 

'{/ITEM}'+ 
'</TABLE>';
/**********************     ВЕРТИК МЕНЮ   50     *****************/
/*****************************************************************/
/*****************************************************************/
/*****************************************************************/
/*****************************************************************/


function MenuComponent50(data) 
{ 
 
	obj2 = new CreateMenuEngine50(); 

	obj = new CreateCollapseMenu50(); 
	
  obj.template = CollapseTemplate40;

	obj2.draft(data, -1, new Array(), obj);

  obj.selectedstyle = "current";

	obj.css(); 
  obj.activelink();
	
	output = obj.build(new String()); 

	document.write(output); 
} 


function CreateMenuEngine50()
{ 
	this.path = '/nvss/js/template4/';
	this.space = new declare(); 
	this.list = new declare( { path:this.path, source:['space.gif', 0, 9] } ); 
	this.list1 = new declare( { path:this.path, source:['space.gif',0, 10] } ); 
  this.list2 = new declare( { path:this.path, source:['space.gif', 0, 9] } ); 
	
	this.draft = function(data, the_depth, transfer, is_obj) 
	{ 
		the_depth++; 
		is_obj.depth = the_depth; 
		
		for(var i = 0; i < data.length; i++) 
		{ 
			var it_have_array = typeof(data[i][4])=="object"?true:false; 
			var next = new Array(); 
			var draft = new Array(); 
			
			if(the_depth) 
			{
				draft = transfer.concat(draft); 
			}



			if( the_depth == 0)	
					draft[draft.length] = new Array(this.list); 
			else 
					draft[draft.length] = new Array(this.list2); 




			if (it_have_array )
					draft[draft.length] = new Array(this.list1); 
			else 
                          draft[draft.length] = new Array(this.list); 
			
			if(it_have_array) 
			{ 
				next[next.length] = new Array( this.space ); 
				next = transfer.concat(next); 
				
				child_obj = new CreateCollapseMenu50(is_obj); 

        child_obj.indent = i;
				
				is_obj.add(draft, data[i], child_obj); 
				
				this.draft( data[i][4] , the_depth, next, child_obj); 
			} 
			else 
			{ 
				is_obj.add(draft, data[i]); 
			} 
		} 
	} 
} 

function declare() 
{ 
	system = { path:'/nvss/js/template4/', source:['space.gif', 1, 8] }; 
	current = arguments.length?arguments[0]:system; 
	
	with(current) 
	{ 
		images = new Image(source[1], source[2]); 
		images.src = path+ source[0]; 
	} 
	
	return images; 
}
var MenuCountNew = 0;
function CreateCollapseMenu50(parent, data)
{
MenuCountNew++;
this.name = "MenuCollapse" + MenuCountNew;	 
this.obj = this.name + "Object";  
this.index = MenuCountNew;
this.depth = null;
this.parent = parent;
this.indent = '';
eval(this.obj+"=this");
this.template = CollapseTemplate40_2;  
this.container = '<DIV ID="'+this.name+'">{OBJECT}</DIV>';  
this.style = new Object();
this.style.display = 'block';
this.path = 'images/template10/';
this.icon = new Object();
this.icon.src = this.path+ "icon/icon.gif";
this.icon.width = 16;
this.icon.height = 16;
this.items = new Array(); 

this.selectedstyle = "current";

this.selectedstyle5 = "oneLevel";
this.selectedstyle6 = "twoLevelSM";
this.selectedstyle7 = "threeLevelSM";
this.selectedstyle8 = "fourLevelSM";

this.selectedstyle55 = "onecurrentSM";
this.selectedstyle66 = "twocurrentSM";
this.selectedstyle77 = "threecurrentSM";
this.selectedstyle88 = "fourcurrentSM";



this.add = function(draft, data, is_child)
{
var j = this.items.length;
this.items[j] = new Object();
this.items[j].draft = draft;
this.items[j].type = new Array();
this.items[j].key = 0;
this.items[j].open = false;
this.items[j].text = data[0];
this.items[j].alttext = data[1];
this.items[j].actived = false;
this.items[j].reference = data[2];
this.items[j].have_child = is_child?true:false;  
this.items[j].is_child = is_child;  
this.items[j].icon = new Object();
this.items[j].icon.src = data[5];  
this.items[j].icon.width = data[6]; 
this.items[j].icon.height = data[7];  
this.items[j].div = new Array();
this.items[j].div.name = this.name+ 'ItemBlock'+ j;
this.items[j].div.link = this.name+ 'ItemLink'+ j;
this.items[j].div.image = this.name+ 'ItemImages'+ j;
this.items[j].div.text = this.name+ 'ItemText'+ j;
}
this.build = function ()
{
var output = new String();
var menulist = new String();
var menuitem = new String();
var re1 = new RegExp("{item}(.*)\\{/item}", "gi");
var re2 = new RegExp("{object}", "gi");
menulist = this.template.replace(re1, '{content}');
menulist = this.container.replace(re2, menulist);
var re1 = new RegExp("{item}(.*)\\{/item}", "gi");
var re2 = new RegExp("{content}", "gi"); 
var re3 = new RegExp("{draft}", "gi"); 
var re4 = new RegExp("{text}", "gi"); 
var re5 = new RegExp("{block([-:;%\\s\\w=\"\']*)}", "gi"); 
var re6 = new RegExp("{/block}", "gi"); 
var re7 = new RegExp("{link([-:;%\\s\\w=\"\'_]*)}", "gi"); 
var re8 = new RegExp("{/link}", "gi"); 
var re9 = new RegExp("{textarea([-:;%\\s\\w=\"\']*)}", "gi"); 
var re10 = new RegExp("{/textarea}", "gi"); 
var re11 = new RegExp("{icon}", "gi"); 
menuitem = re1.exec(this.template);
for(var i=0; i < this.items.length; i++)
{
with(this.items[i])
{
layout = menuitem[1];
layout = layout.replace(re3, this.draft(i));
layout = layout.replace(re4, text);
// первый уровень, с потомками
if(have_child && !actived && this.depth==0){
layout = layout.replace(re9, '<DIV style="padding-left:10px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV  $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle5 +'">');
layout = layout.replace(re6, '</DIV>');
}

// первый уровень, без потомков
else if(!have_child && !actived && this.depth==0){

layout = layout.replace(re9, '<DIV style="padding-left:10px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle5 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}
// второй уровень, с потомками
else if(have_child && !actived && this.depth==1){
layout = layout.replace(re9, '<DIV style="padding-left:20px" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle6 +'">');
layout = layout.replace(re6, '</DIV>');
}

// второй уровень, без потомков
else if(!have_child && !actived && this.depth==1){

layout = layout.replace(re9, '<DIV style="padding-left:20px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle6 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}

// 3 уровень, с потомками
else if(have_child && !actived && this.depth==2){
layout = layout.replace(re9, '<DIV style="padding-left:30px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle7 +'">');
layout = layout.replace(re6, '</DIV>');
}

// 3 уровень, без потомков
else if(!have_child && !actived && this.depth==2){

layout = layout.replace(re9, '<DIV style="padding-left:30px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle7 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}


// 4 и остальные уровень, с потомками
else if(have_child && !actived && this.depth!=0 && this.depth!=1 && this.depth!=2){
layout = layout.replace(re9, '<DIV style="padding-left:40px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN  class="haveChild">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle8 +'">');
layout = layout.replace(re6, '</DIV>');
}

// 4 и остальные уровень, без потомков
else if(!have_child && !actived && this.depth!=0 && this.depth!=1 && this.depth!=2){

layout = layout.replace(re9, '<DIV style="padding-left:40px;" ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');                       
layout = layout.replace(re5, '<DIV ID="'+ div.name+ '" CLASS="'+ this.selectedstyle8 +'" STYLE="cursor:hand;">');
layout = layout.replace(re6, '</DIV>');
layout = layout.replace(re7, '<A $1 HREF="'+ reference+ '" NAME="'+ div.link+ '">');
layout = layout.replace(re8, '</A>');
}





//*********************************************
//текущая 1 уровня
else if(actived && this.depth==0){
layout = layout.replace(re9, '<DIV style="padding-left:10px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle55 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 2 уровня
else if(actived && this.depth==1){
layout = layout.replace(re9, '<DIV style="padding-left:20px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle66 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 3 уровня
else if(actived && this.depth==2){
layout = layout.replace(re9, '<DIV style="padding-left:30px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle77 +'">');
layout = layout.replace(re6, '</DIV>');
}
//текущая 4 и остальные уровни
else if(actived && this.depth!=0 && this.depth!=1 && this.depth!=2){
layout = layout.replace(re9, '<DIV style="padding-left:40px;" $1 ID="'+ div.text+ '">');
layout = layout.replace(re10, '</DIV>');
layout = layout.replace(re7, '<SPAN class="currentFont">');
layout = layout.replace(re8, '</SPAN>');
layout = layout.replace(re5, '<DIV $1 ID="'+ div.name+ '" CLASS="'+ this.selectedstyle88 +'">');
layout = layout.replace(re6, '</DIV>');
}







layout = layout.replace(re11, this.inserticon(i));
output += layout;
if(have_child)
{
output += '<TR><TD>';
output += is_child.build();
output += '</TD></TR>';
}
}
}
output = menulist.replace(re2, output);
return output;
}
this.draft = function(j)
{
plan = new String();
with(this.items[j])
{
var index = open ? 0 : 1;
for(var i = 0; i < draft.length; i++)
{
type[type.length] = div.image+ 'Draft'+ i;
if( draft[i][1] )
key = index;
else 
key = 0;
plan += '<IMG SRC="'+ draft[i][key].src+ '" WIDTH="'+ draft[i][key].width+ '" HEIGHT="'+ draft[i][key].height+ '" BORDER="0" ALT="" '+
'NAME="'+ type[type.length-1]+ '" '+
'>';
}
}
return plan;
}
this.inserticon = function(j)
{
var temp = new String();
if(this.icon.src)
{
with(this.items[j])
{
if(icon.src)  temp += '<IMG SRC="'+ icon.src+ '" WIDTH="'+ icon.width+ '" HEIGHT="'+ icon.height+ '">'; 
else  temp += '<IMG SRC="'+ this.icon.src+ '" WIDTH="'+ this.icon.width+ '" HEIGHT="'+ this.icon.height+ '">'; 
}
}
return temp;
}
this.css = function()
{
var output = setStyleSheet(this.name, this.style);
for(var i=0; i < this.items.length; i++)
{
with( this.items[i] )
{
if(have_child)
{
output += is_child.css(1);
}
}
}
if(!arguments.length)	 
{
document.write('<style type="text/css">'+ output+ '</style>');
}
return output;
}
this.init = function()
{
for(var i=0; i < this.items.length; i++)
{
with(this.items[i])
{
document.getElementById(div.name).onclick = new Function(this.obj+ '.click('+i+'); return true; ');
if(have_child)
{
document.getElementById(div.name).onclick = new Function(this.obj+ '.activated('+ i+ '); ');
is_child.init();
}
}
}
}
this.activated = function(i)
{
this.action(i);
this.reimage(i);
this.items[i].open = !this.items[i].open;
}
this.action = function(j)
{
with( this.items[j] )
{
if( open )
{
document.getElementById(is_child.name).style.display = 'none';
}
else
{
document.getElementById(is_child.name).style.display = 'block';
}
}
}
this.reimage = function(j)
{
with(this.items[j])
{
index = open ? 1 : 0;
for(var i = 0; i < draft.length; i++)
{
if( draft[i][1] )
{ 
document.images[type[i]].src = draft[i][index].src;
}
}
}
}
this.click = function(j)
{
document.links(this.items[j].div.link).click();
}
this.outblock = function()
{
for(var i =0; i < this.items.length; i++)
{
this.reimage(i);
if(this.items[i].have_child)
{
this.items[i].is_child.outblock();
}
}
}
this.setmouseevent = function()
{
for(var i=0; i < this.items.length; i++)
{  
with(this.items[i])
{
document.getElementById(div.name).onmouseover = new Function(this.obj+ '.selection('+i+'); return true; ');
document.getElementById(div.name).onmouseout = new Function(this.obj+ '.unselection('+i+'); return true; ');
if(have_child)
{
is_child.setmouseevent();
}
}
}
}
this.selection = function(j)
{
}
this.unselection = function(j)
{
}
}


   /*

    */

    CreateCollapseMenu50.prototype.activelink = function()
    {
       var oItem = this.pathfinder();
       
       //this.setactivegroup(oItem);
    }

   /*

    */

    CreateCollapseMenu50.prototype.pathfinder = function()
    {
       var oActive =  false;

       for(var i = 0; i < this.items.length; i++)
       {
          with(this.items[i])
          {
             if(this.defineactive(reference))
             {
                actived = true;

                this.style.visibility = "visible";

                return this;
             }

          	 if(have_child)  oActive = is_child.pathfinder();

          	 if(oActive)  return oActive;
          }
       }
    }

   /*

    */

    CreateCollapseMenu50.prototype.defineactive = function(reference)
    {
       var re = new RegExp(reference, "gi");

       if( location.href.search(re) > -1 )	return true;

       return false;
    }

   /*

    */

    CreateCollapseMenu50.prototype.selector = null;

    CreateCollapseMenu50.prototype.setactivegroup = function(oItem)
    {
       while( oItem && oItem.indent!=null )
       {
          var indent = oItem.indent;

          var oPrevious = oItem;
          oItem = oItem.parent;

          if(indent)
          	oItem.items[indent].actived = true;
       }

       if(oPrevious)
       {
          this.selector = oPrevious.indent;
       }
    }

   /*

    */
/*для второго уровня и ниже*/
var CollapseTemplate40_2 = ''+ 

'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'{ITEM}'+ 

'<TR>'+ 
'<TD STYLE="padding:1px 0px 1px 0px">'+ 

'{BLOCK}'+ 
'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'<TR>'+ 


'<TD STYLE="padding:1px 5px 0px 1px;" WIDTH="100%">'+ 
'{TEXTAREA}{LINK CLASS="itemMenuCollapse"}{TEXT}{/LINK}{TEXTAREA}'+ 
'</TD>'+ 

'</TR>'+ 
'</TABLE>'+ 
'{/BLOCK}'+ 

'</TD>'+ 
'</TR>'+ 

'{/ITEM}'+ 
'</TABLE>';  

/*для первого уровня*/
var CollapseTemplate40 = ''+ 

'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'{ITEM}'+ 

'<TR>'+ 
'<TD STYLE="padding:0px 0px 0px 0px">'+ 

'{BLOCK}'+ 
'<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="100%">'+ 
'<TR>'+ 


'<TD STYLE="padding:13px 5px 13px 0px;" WIDTH="100%">'+ 
'{TEXTAREA}{LINK CLASS="itemMenuCollapse"}{TEXT}{/LINK}{TEXTAREA}'+ 
'</TD>'+ 

'</TR>'+ 
'</TABLE>'+ 
'{/BLOCK}'+ 

'</TD>'+ 
'</TR>'+ 

'{/ITEM}'+ 
'</TABLE>';
 