mainpath="";
OpenedMenu=-1;
AlertMenu=-1;


function MainMenuItemSelect(n)
{
	MenuClose();
	if (Page==n) state=3; else state=1;
	document.images['mg'+n].src='http://www.avedesign.ru/mg'+n+'_'+state+'.gif';
	AlertMenu=n;
	MouseOnMainMenu=1;
}

function MenuClose()
{
	if (AlertMenu!=-1)
	{
		if (Page==AlertMenu) state=2; else state=0;
		document.images['mg'+AlertMenu].src='http://www.avedesign.ru/mg'+AlertMenu+'_'+state+'.gif';
	}
	if (OpenedMenu!=-1)
	{
		document.all['menubar'+OpenedMenu].style.display="none";
		OpenedMenu=-1;
	}
}

function MainMenu(ref,alt)
{
	if (MainMenuCount==Page) state=2; else state=0;
	html+='<td onmouseover="MainMenuItemSelect('+MainMenuCount+')" onmouseout="MouseOnMainMenu=0"><a href="../'+ref+'"><img border=0 src="http://www.avedesign.ru/mg'+MainMenuCount+'_'+state+'.gif" alt="'+alt+'" name=mg'+MainMenuCount+'></a></td>';
	MenuHTML[MainMenuCount]='';
	MainMenuCount++;
}


function SubItemSelect(obj,state)
{
	if (state)
	{
		obj.style.color="#009AFF";
	}
	else
	{
		obj.style.color="#FFFFFF";

	}
}

function LeftMenuSelect(n,state)
{
//alert(n);

	if (state)
	{       
		document.all['ddaa'+n].style.color="#6386C6";
		document.all['ddab'+n].style.color="#6386C6";


	}
	else
	{
		document.all['ddaa'+n].style.color="#B5B2B5";
		document.all['ddab'+n].style.color="#B5B2B5";

	}
}


function SubItemClick(ref)
{
	location=ref;
}

subitemcount=0;
function SubItem(img,text, ref)
{

	MenuHTML[MainMenuCount-1]+='<tr><td onmouseover="SubItemSelect(this,1)" onmouseout="SubItemSelect(this,0)" onclick="SubItemClick(&quot;'+ref+'&quot;)">&nbsp;'+text+'<img height=1 width=50 src="http://www.avedesign.ru/1.gif"></td></tr>';
	if (MainMenuCount-1 == Page)
	{
		if (subitemcount==SubPage)

			SubHTML+='<tr><td id=ddaa'+subitemcount+' class=leftmenusel><img width=1 height=22 src="http://www.avedesign.ru/1.gif"></td>'+
			'<td id=ddab'+subitemcount+' align=right class=leftmenusel>'+text+'</td></tr>';
		else
			SubHTML+='<tr><td id=ddaa'+subitemcount+' class="leftmenu" onmouseover="LeftMenuSelect('+subitemcount+',1)" onmouseout="LeftMenuSelect('+subitemcount+',0)" onclick="location=&quot;'+ref+'&quot;"><img width=1 height=22 src="http://www.avedesign.ru/1.gif"></td>'+
			'<td id=ddab'+subitemcount+' align=right class="leftmenu" onmouseover="LeftMenuSelect('+subitemcount+',1)" onmouseout="LeftMenuSelect('+subitemcount+',0)" onclick="location=&quot;'+ref+'&quot;">'+text+'</td></tr>';
		subitemcount++;
	}
}

function SubItemLine()
{
	MenuHTML[MainMenuCount-1]+='<tr><td class=menuitem><hr color=black size=1></td></tr>';
}

function OnTimer()
{
	if (!MouseOnMenuBar && !MouseOnMainMenu)
	{
		MenuClose();
	}
}

function LeftMenu()
{
	document.write('<table width=100% bgcolor=#ffffff cellspacing=0 cellpadding=0 border=0>'+SubHTML+'</table>');
}


function BEGIN(page,subpage)
{
	Page=page;
	SubPage=subpage;

	MainMenuCount=0;
	MenuHTML = new Array();
	SubHTML='';

	MouseOnMainMenu=0;
	MouseOnMenuBar=0;

	menuhtml='';


html=''+

	'<table height=23 valign=top cellspacing=0 cellpadding=0 border=0>';
html+='<td bgcolor="#262626" width=215><img src="http://www.avedesign.ru/1.gif"></td>';

	MainMenu('about.php',"О Компании");

	MainMenu('news.php',"Новости");

	MainMenu('portfolio.php',"Портфолио");
		SubItem('st.gif','Веб-сайты','portfolio.php');
		SubItem('st.gif','Полиграфия','poligraph.php');
		SubItem('st.gif','Логотипы','logo.php');


	MainMenu('project.php',"Проекты");


	MainMenu('price.php',"Расценки");

html+='<td bgcolor="#777777" width=100><img src="http://www.avedesign.ru/1.gif"></td>';

	
	MainMenu('/cgi-bin/forum1.pl',"Форум");

	MainMenu('contact.php',"Координаты");

	html+='</tr></table>';

	document.write(html);
}


function END()
{
	ImgList = new Array();
	for (i=0;i<MainMenuCount;i++)
	{
		if (MenuHTML[i]!='')
			document.write('<table border=0 cellspacing=0 cellpadding=0 id=menubar'+i+' style="display:none; position:absolute" bordercolor=black cellspacing=0 cellpadding=0 onmouseover="MouseOnMenuBar=1" onmouseout="MouseOnMenuBar=0"><tr><td>'+
			'<table border=0 cellspacing=2 cellpadding=2 class="vip" width=120%>'+
MenuHTML[i]
+'</table></td></tr></table>');
		for (j=0;j<=3;j++)
		{
			ImgList[i*4+j]=new Image();
			ImgList[i*4+j].src='mg'+i+'_'+j+'.gif';
		}
	}
	setInterval('OnTimer()',500);


var html='<img width=10 height=40 src="http://www.avedesign.ru/1.gif">'+
'';
document.write(html);


}



function CaricaFoto(img){
  foto1= new Image();
  foto1.src=(img);
  Controlla(img);
}
function Controlla(img){
  if((foto1.width!=0)&&(foto1.height!=0)){
    viewFoto(img);
  }
  else{
    funzione="Controlla('"+img+"')";
    intervallo=setTimeout(funzione,20);
  }
}
function viewFoto(img){
  largh=foto1.width+20;
  altez=foto1.height+20;
  stringa="width="+largh+",height="+altez;
  finestra=window.open(img,"",stringa);
}
