function Tmenu(){
	this.items = new Array();
	this.captions = new Array();
	this.captions2 = new Array();
	this.submenus = new Array();
	this.additem = additem;}
	
function additem(item, caption, caption2, submenu){
	this.items[this.items.length]=item;
	this.captions[this.captions.length]=caption;
	this.captions2[this.captions2.length]=caption2;
	this.submenus[this.submenus.length]=submenu;}


var mLibY = new Tmenu();
with(mLibY) {
	additem('algYA', 'Alg YA', 'AlgYA<br>Алгоритм YA', null);
	additem('algYB', 'Alg YB', 'AlgYB<br>Алгоритм YB', null);
}

var mLibZ = new Tmenu();
with(mLibZ) {
	additem('algZA', 'Alg ZA', 'AlgZA<br>Алгоритм ZA', null);
	additem('algZB', 'Alg ZB', 'AlgZB<br>Алгоритм ZB', null);
}

var mainmenu = new Tmenu();
with(mainmenu) {
	additem('index', 'Содержание',   'Библиотеки алгоритмов', null);
	additem('libY',  'Библиотека Y', 'LibY<br>Библиотека методов того-сего', mLibY);
	additem('libZ',  'Библиотека Z', 'LibZ<br>Вторая библиотека того-сего',  mLibZ);
}

var d = document;
var loc = new String(" "+window.location);
var curlang = ((loc.indexOf('english')>=0)?'english':((loc.indexOf('russian')>=0)?'russian':'undefined')).toLowerCase();
var i1=loc.lastIndexOf('/')+1;
var i2=loc.lastIndexOf('.html')-i1;
var subtopic=(loc.substr(i1,i2)); //.toLowerCase();

function gettopic(st){
	for (i=0; i<mainmenu.items.length; i++)
		if (st==mainmenu.items[i]) return(mainmenu.items[i]);
		else if (mainmenu.submenus[i]!=null) for(j=0; j<mainmenu.submenus[i].items.length; j++)
												if (st==mainmenu.submenus[i].items[j]) return(mainmenu.items[i]);
	return('about');}

function getcaption2(st){
	for(i=0; i<mainmenu.items.length; i++)
		if (st==mainmenu.items[i]) {if (mainmenu.captions2[i]=='') return(mainmenu.captions[i]); else return(mainmenu.captions2[i]);}
		else if (mainmenu.submenus[i]!=null) for(j=0; j<mainmenu.submenus[i].items.length; j++)
												if (st==mainmenu.submenus[i].items[j]) {if (mainmenu.submenus[i].captions2[j]=='') return(mainmenu.submenus[i].captions[j]);
																						else return(mainmenu.submenus[i].captions2[j]);}
	return('');}
	
var topic=gettopic(subtopic);

function changelanguage(){
	if (curlang=="russian") return("<a class='clang' href='../english/"+subtopic+".html'>english version</a>");
	else if (curlang=="english") return("<a class='clang' href='../russian/"+subtopic+".html'>russian version</a>");
	else return('');
}
	
function writemenu(){
//	d.write('<a class="menu" href="intro.html"><img src="images/logo.gif" width="180" height="143" border="0px" alt=""/></a>');
	for(i=0; i<mainmenu.items.length; i++){
		if (mainmenu.items[i]==topic) {
			d.write("<div class='smenu'><a href='"+mainmenu.items[i]+".html'>"+mainmenu.captions[i]+"</a></div>");
			if (mainmenu.submenus[i]!=null)
				for(j=0; j<mainmenu.submenus[i].items.length; j++){
					if (mainmenu.submenus[i].items[j]==subtopic)
						d.write("<div class='ssubmenu'><a href='"+mainmenu.submenus[i].items[j]+".html'>"+mainmenu.submenus[i].captions[j]+"</a></div>");
					else
						d.write("<div class='submenu'><a href='"+mainmenu.submenus[i].items[j]+".html'>"+mainmenu.submenus[i].captions[j]+"</a></div>");
				}
		}
		else d.write("<div class='menu'><a href='"+mainmenu.items[i]+".html'>"+mainmenu.captions[i]+"</a></div>");
	}
    d.write('<div class="menu"><a href="../maCom/content.html">Стандарт maCom</a></div>');
}

function writebegin(){
	d.write('<table  width=0 height="100%" border="0" cellspacing="0" cellpadding="0">');
	d.write('<tr><td width=0 height="12" colspan="2" class="dectop"><b>Библиотеки алгоритмов</b></td></tr>');
	d.write('<tr><td width=0 valign="top" id="menucontainer">');
	writemenu();
	d.write('</td><td valign="top" id="contentcontainer" background="images/'+topic+'.jpg">');
	d.write('<div class="btitle">'+getcaption2(subtopic)+'</div>');
}

function writeend(){
	d.write('</td></tr>');
	d.write('<tr><td align="left" class="bottom" colspan="2" height="12"><a class="copyright" href="mailto:frc@ccas.ru">frc@ccas.ru</a></td></tr></table>');
}

function writesitemap() {
	d.write('<ul>');
	for(i=0; i<mainmenu.items.length; i++) {
		d.write('<li><a class="smlink" href="'
			+ mainmenu.items[i]
			+ '.html">'
			+ mainmenu.captions2[i]
			+ '</a>');
		if (mainmenu.submenus[i]!=null) {
			d.write('<ul>');
			for(j=0; j<mainmenu.submenus[i].items.length; j++)
				d.write('<li><a class="smlink2" href="'
					+ mainmenu.submenus[i].items[j]
					+ '.html">'
					+ mainmenu.submenus[i].captions2[j]
					+ '</a></li>');
			d.write('</ul>');
		}
//		else d.write('<br/>');
		d.write('</li>');
	}
	d.write('</ul>');
	d.write('<br/>');
}