
currentindex = 0;
lines = new Array;
arraylist = new Array;

// Определяем URL текущей страницы
strURL=document.URL;
arrayURL=strURL.split("/");
current=arrayURL[4];
//document.write(arrayURL[4]);

function Line(paragraf, name, type, submenu, next) //constructor
{
  this.next = next;
  this.type = type;
  this.name = name;
  this.id = currentindex;
  this.submenu = submenu;
  this.paragraf = paragraf; // 0 - отступаем строку;  1 - НЕ отступаем строку 
	this.open = false;
  lines[this.id] = this;
  currentindex++;
  this.OpenMenu = OpenMenu;
  this.CloseMenu = CloseMenu;
  this.DrawLine = DrawLine;
  this.ShowLine = ShowLine;
  this.HideLine = HideLine;
  this.OnLineClick = OnLineClick;
}

function DrawLine(ident)
{
  document.write('<table id="L' + this.id +'" border="0" width="100%" cellpadding="0" cellspacing="0" class="tab-spisok" '); 
  if (arraylist[this.id]==1)
  document.write('style="display:block"><tr>');
  else
   document.write('style="display:none"><tr>');
  document.write('<td width="' + 10 * ident +'"></td>');  //  первоначальное положение (отступ с лева)
		if (this.type==2)
	  	picname = "/gif/menu-close2.gif";
		else
			{
			  if (this.type==0)
				if (arraylist[this.submenu.id]==1)
						{
						picname = "/gif/menu-open2.gif";
						this.open = true;
						}
				else
						picname = "/gif/menu-close2.gif"; 
			  else picname = "/gif/menu-punkt2.gif";
			}
  document.write('<td valign="top" width="1" style="cursor:pointer;"><img alt="" id="P' + this.id +'" border="0" src="' + picname + '" onclick="OnLineClick(' + this.id + ')"> </td>');
  document.write('<td valign="top" width="1"  style="cursor:pointer;" onclick="OnLineClick(' + this.id + ')"></td>');
  document.write('<td style="cursor:pointer;" onclick="OnLineClick(' + this.id + ')">' + this.name + '</td>');
//  document.write('<td onclick="OnLineClick(' + this.id + ')"><A href="JavaScript:OnLineClick(' + this.id + ')">' + this.name + '</A></td>');
  document.write('</table>');
  if (this.paragraf == 0) document.write('<br>');
  //this.lineobj = document.all('L' + this.id); // так не работает в FireFox
  //this.picture = document.all('P' + this.id);
   this.lineobj = document.getElementById('L' + this.id);
  this.picture = document.getElementById('P' + this.id);
 
  if (this.submenu != 0) this.submenu.DrawLine(ident + 2);  // на 2 пункта сдвиг текста вправо
  if (this.next != 0)   this.next.DrawLine(ident);
}


function ShowLine()
{
  	this.lineobj.style.display = "block";
	arraylist[this.id]=1;
	if (this.next != 0) this.next.ShowLine();
	if (this.open) this.submenu.ShowLine();
}

function HideLine()
{
  this.lineobj.style.display = "none";
  arraylist[this.id]=0;
	if (this.submenu != 0) this.submenu.HideLine();
  if (this.next != 0) this.next.HideLine();
}

function OpenMenu()
{
  if ((this.open == false) && (this.submenu != 0)) 
  {
    this.open = true;
    this.picture.src = "/gif/menu-open2.gif";
    this.submenu.ShowLine();
  }
}

function CloseMenu()
{
  if (this.open == true) 
  {
    this.open = false;
    this.picture.src = "/gif/menu-close2.gif";
    this.submenu.HideLine();
  }
}

function OnLineClick(lineid)
{
  var line = lines[lineid]
  if (line.submenu != 0) 
    if (line.open == true) 
      {
		  line.CloseMenu(); 
	  }
	 else 
	 {
		 line.OpenMenu();
	 }
}

function newmenu(paragraf, name, submenu, next)
{
  return new Line(paragraf, name, 0, submenu, next);
}

function newitem(paragraf, name, next)
{
    return new Line(paragraf, name, 1, 0, next);
}
function newitem2(paragraf, name, next)
{
    return new Line(paragraf, name, 2, 0, next);
}


function getLinesOpen() // записать в куки состояния списка, на всех страницах со списком в теге body - свойство onUnload=getLinesOpen()
{
	var list=arraylist[0];
	
	for (ii=1; ii<currentindex; ii++)
	{
	list=list+":"+arraylist[ii];
	}
	//document.form-spisok.getlist.value=list;
	document.cookie='list='+list+'; path=/';
	//domain=http://comptech.nnika.ru/; path='comptech'";
}


function setLinesOpen() // получить из куки состояние списка
{
	savelist=document.cookie;
	var n=savelist.length;
	if (savelist.indexOf('list')!=-1)
	{
	vhod=savelist.indexOf('list');
	savelist=savelist.substring(vhod,n);
	arraylist=savelist.split(":");
	}
	else
	//arraylist=new Array(0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,1,1,1,0,1,1);
	arraylist=new Array(0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1);
}
	
function currentURL(list_name) {
	if (list_name.indexOf(current)>0)
		return '<span class="menu-active-left">'+list_name+'</span>';
	else
		return list_name;
}
	
	items1=newmenu(1,'<h2>Производство сжатого воздуха и газов</h2>',
		   		newmenu(11,'винтовые компрессоры',
					newitem(111,currentURL('<a href="/production/vint_masl/">масляные</a>'),
					newitem(112,currentURL('<a href="/production/vint_bezmasl/">безмасляные</a>'),
					newitem(113,currentURL('<a href="/production/vint_chast/">с частотным регулированием</a>'),0))),
				newmenu(12,'роторно-пластинчатые компрессоры',
					newitem(121,currentURL('<a href="/production/rotor_vozd/">воздушные</a>'),
					newitem(122,currentURL('<a href="/production/rotor_gaz/">газовые</a>'),0)),
				newmenu(13,'поршневые и мембранные компрессоры',
					newitem(131,currentURL('<a href="/production/porsh_vis/">высокого давления</a>'),
					newitem(132,currentURL('<a href="/production/porsh_niz/">низкого давления</a>'),
					newitem(133,currentURL('<a href="/production/porsh_mal/">малой производительности</a>'),0))),
				newitem2(14,currentURL('<a href="/production/mobil/">передвижные компрессоры</a>'),0),
				0))),
    	  	newmenu(2,'<h2>Подготовка воздуха и газов</h2>',
				newmenu(21,'осушители',
					newitem2(211,currentURL('<a href="/production/osush_ref/">рефрижераторные</a>'),
					newmenu(212,'адсорбционные',
						newitem(2121,currentURL('<a href="/production/osush_abs_hol/">с холод. регенерацией</a>'),
						newitem(2122,currentURL('<a href="/production/osush_ads_gor/">с горяч. регенерацией</a>'),
						newitem(2123,currentURL('<a href="/production/osush_ads_vak/">с вакуумной регенерацией</a>'),0))),
					newitem2(213,currentURL('<a href="/production/osush_vis_dav/">высокого давления</a>'),0),
					0)),
				newitem2(22,currentURL('<a href="/production/chiller/">охладители, чиллеры</a>'),
				newitem2(23,currentURL('<a href="/production/filter/">фильтрация</a>'),0)), 
				0),
             newmenu(3,'<h2>Генераторы газа</h2>',
					newitem2(31,currentURL('<a href="/production/gener_azot/">генераторы азота</a>'),
					newitem2(32,currentURL('<a href="/production/gener_vodorod/">генераторы водорода</a>'),
					newitem2(33,currentURL('<a href="/production/gener_null/">генераторы нулевого воздуха</a>'),
					newitem2(34,currentURL('<a href="/production/gener_vozd/">воздух без углекислого газа</a>'),0)))),
             newitem2(4,'<h2><a href="/production/agnks/">Автомобильные газонаполнительные компрессорные станции (АГНКС)</a></h2>',0),
		   0)));
	//var savelist='1111111111';
	// var savelist=<?echo "$getlist";?>;
	setLinesOpen(); 
   items1.DrawLine(1);
   items1.ShowLine();
  
	
