//Contact web-master: zubber@mail.ru

//public info arrays
var

paTopMenu = {
				'about'			: { 'text' : 'About the company' },
//				'diler'			: { 'text' : 'Наши дилеры' },
				'scheme'		: { 'text' : 'How to get to us (Location)' },
				'dogovor.doc'	: { 'text' : 'Model agreement (Word)' },
				'lic'			: { 'text' : 'License' },
				'blanc.doc'		: { 'text' : 'Order form (Word)' }
},

paProfMenu = {
	'complete'	: { 'text' : 'Finished commodity', 'item_class' : 'Item_Main', 'Sub' :
					{
					'bytovka'	: { 'text' : 'Cabins', 'item_class' : 'Item_Sub1', 'Sub' :
								{
								'byt_m' : { 'text' : 'metal', 'item_class' : 'Item_Sub2' },
								'dbyt'	: { 'text' : 'wooden', 'item_class' : 'Item_Sub2' },
								'pbyt'	: { 'text' : 'mobile', 'item_class' : 'Item_Sub2' }
								}
					},
					'kiosk'	: { 'text' : 'Stands', 'item_class' : 'Item_Sub1', 'Sub' :
								{
								'kiosk01' : { 'text' : 'Type S-1', 'item_class' : 'Item_Sub2' },
								'kiosk02' : { 'text' : 'Type S-2', 'item_class' : 'Item_Sub2' },
								'kiosk03' : { 'text' : 'Type S-3', 'item_class' : 'Item_Sub2' },
								'kiosk04' : { 'text' : 'Type S-4', 'item_class' : 'Item_Sub2' },
								'kiosk05' : { 'text' : 'Type S-5', 'item_class' : 'Item_Sub2' },
								'kiosk06' : { 'text' : 'Type S-6', 'item_class' : 'Item_Sub2' },
								'kiosk07' : { 'text' : 'Type S-7', 'item_class' : 'Item_Sub2' }
								}
					},
					'post'	: { 'text' : 'Guard stations', 'link' : 'post', 'item_class' : 'Item_Sub1', 'Sub' :
								{
								'post01' : { 'text' : 'Type G-1', 'item_class' : 'Item_Sub2' },
								'post02' : { 'text' : 'Type G-2', 'item_class' : 'Item_Sub2' },
								'post03' : { 'text' : 'Type G-3', 'item_class' : 'Item_Sub2' },
								'post04' : { 'text' : 'Type G-4', 'item_class' : 'Item_Sub2' },
								'post05' : { 'text' : 'Type G-5', 'item_class' : 'Item_Sub2' },
								'post06' : { 'text' : 'Type G-6', 'item_class' : 'Item_Sub2' },
								'post07' : { 'text' : 'Type G-7', 'item_class' : 'Item_Sub2' },
								'post08' : { 'text' : 'Type G-8', 'item_class' : 'Item_Sub2' },
								'post09' : { 'text' : 'Type G-9', 'item_class' : 'Item_Sub2' }
								}
					}
					}
	},
	'module'	: { 'text' : 'Modular buildings', 'item_class' : 'Item_Main', 'Sub' :
					{
					'mod01' : { 'text' : 'Type M-1', 'item_class' : 'Item_Sub2' },
					'mod02' : { 'text' : 'Type M-2', 'item_class' : 'Item_Sub2' },
					'mod03' : { 'text' : 'Type M-3', 'item_class' : 'Item_Sub2' }
					}
	},
	'remont'	: { 'text' : 'Repairs and building', 'item_class' : 'Item_Main' },	
//	'stroymat'	: { 'text' : 'Building materials', 'item_class' : 'Item_Main' },
	'pvhpanel'	: { 'text' : 'Polyvinylchloride panels', 'item_class' : 'Item_Main' },
	'linoleum'	: { 'text' : 'Linoleum', 'item_class' : 'Item_Main' },
	'polymet'	: { 'text' : 'Metal with polymeric coating', 'item_class' : 'Item_Main' },
	'pnd'		: { 'text' : 'LPP (low pressure polyethylene) pipes', 'item_class' : 'Item_Main' },
	'metall'	: { 'text' : 'Metal ware','item_class' : 'Item_Main' },
	'pvh'		: { 'text' : 'Polyvinylchloride constructions','item_class' : 'Item_Main' },
	'links'		: { 'text' : 'References', 'item_class' : 'Item_Main' }

},

paNews = [
	{ 'text' : 'English version of site is now available.', 'date' : '28.01.2006', 'type' : 'add' },
	{ 'text' : 'We are working hard on English version of a site. Please, do not worry, if any pages will not open. Updating will be finished soon.', 'date' : '01.12.2005', 'type' : 'add' }
//	{ 'text' : 'Добалена информация о <a href=diler.html>дилерах</a>', 'date' : '11.07.2005', 'type' : 'add' },
//	{ 'text' : 'Обновлён раздел "Посты охраны" <a href=post04.html>ТИП П-4</a>', 'date' : '4.07.2005', 'type' : 'edit' }
],

pcFileName = location.pathname.replace( /^.*\//g, '' );
pcFileName = pcFileName.replace( /^.*\\/g, '' );	//for localfiles - IE

aLinks = [];
function getArrayPath( cTargetLink )
{
	arrayWalk( cTargetLink, paProfMenu );
	arrayWalk( cTargetLink, paTopMenu );
}

function arrayWalk( cTargetLink, aArray )
{
	for ( var i in aArray )
	{

		aLinks.push( aArray[i] );
		if ( i + '_en.html'  == cTargetLink ) {
			return true;
		}
		if ( typeof( aArray[i].Sub ) == 'object' )
			if ( arrayWalk( cTargetLink, aArray[i].Sub ) )
				return true;
		aLinks.pop();
	}

}

function initMenu( cClass )
{
	for ( var i in paTopMenu )
	{
		document.write(
			"<TD width=15%></TD><TD>" +
			"<A class='Item " + cClass + ( pcFileName == i + '_en.html' ? " LinkSelected" : "" ) +
			"' href=" + i + ( i.indexOf( "." ) != -1 ? "" : "_en.html" ) + ">" + paTopMenu[i].text + "</A></TD>\n"
		);
	}
}

function initProfMenu( aProfMenu )
{
	
	for( var i in aProfMenu )
	{
		var lcOut = "<TR><TD class='Item ";
		if ( pcFileName.indexOf( i ) != -1 )
			lcOut += "ProfMenuLISelected";
		else
			lcOut += "ProfMenuLI";
		lcOut += "'>&bull;</TD><TD><A href='" + i + "_en.html' class='";
		switch( aProfMenu[i].item_class )
		{
			case 'Item_Main' : 
				lcOut += "Item Link'";
				break;
			case 'Item_Sub1' : 
				lcOut += "Item ItemSub1' style='margin-left:10px;'";
				break;
			case 'Item_Sub2' : 
				lcOut += "Item ItemSub2' style='margin-left:20px;'";
				break;

		}
		lcOut +=">" + aProfMenu[i].text + "</A></TD></TR>\n";
		document.write( lcOut );
		if ( typeof( aProfMenu[i].Sub ) == 'object' )
			initProfMenu( aProfMenu[i].Sub );
	}
}

function initNews()
{
	for ( var i = 0; i < paNews.length; i++ )
	{
		document.write(
							"<DIV align=left style='float: left;' class='Item NewsDate'>" + paNews[i].date + "</DIV>\n" +
							"<IMG align=right src=images/" + paNews[i].type + ".gif><BR><BR>\n" +
							"<DIV align=justify class='Item Text'>&nbsp;" + paNews[i].text + "</DIV><BR><BR>\n"
		);
	}
}

function initNavBar()
{
	if ( pcFileName.search( /index/ ) == -1 )
	{
		getArrayPath( pcFileName );
		for ( var i = 0; i < aLinks.length; i++ )
		{
			document.write(
			 			"<A class='Item ItemNav'>| &nbsp;</a><A class='Item ItemNav' href='" + pcFileName + "'>" + aLinks[i].text + "</A>\n"
			);
		}
	}

}
