// JavaScript Document
//<meta charset=windows-1251">
// menu1
var colors = ['#000000', '#030303', '#060606', '#090909', '#0B0B0B', '#0E0E0E', '#121212', '#151515','#181818', '#1A1A1A'];
var positions = ['10px', '13px', '16px', '19px', '22px', '25px', '28px', '31px','34px', '36px'];
var dirs = new Array();
var poss = new Array();
var activity_all=0;
var tout;

function generate_items(N)
{
	for (var i=1;i<=N;i++) {
//		document.getElementById("mm"+i).setAttribute("onMouseOver", "FOver("+i+")");
//		document.getElementById("mm"+i).setAttribute("onMouseOut", "FOut("+i+")");
//		document.getElementById("mm"+i).setAttribute("onClick", "window.location='"+document.getElementById("mm"+i).firstChild.getAttribute('href')+"'");
		document.getElementById("mm"+i).style.cursor='pointer';
		dirs[i]=0;
		poss[i]=0;
	}
}

function FOver(itm)
{
//poss[itm]=9;
if (!(dirs[itm]==1)) {dirs[itm]=1;}
if (activity_all==0) {FChange()};
}

function FOut(itm)
{
//poss[itm]=0;
if (!(dirs[itm]==-1)) {dirs[itm]=-1;};
if (activity_all==0) {FChange()};
}

function FChange()
{activity=0; clearTimeout(tout);
	for (var i=1;i<=5;i++) {
		if ((poss[i]>=9)&&(dirs[i]==1)) {poss[i]=9;dirs[i]=0}
		else if ((poss[i]<=0)&&(dirs[i]==-1)) {poss[i]=0;dirs[i]=0}
			 else if (!(dirs[i]==0))	{
					activity=1;
					poss[i]=poss[i]+dirs[i];
					document.getElementById('mm'+i).firstChild.style.paddingLeft=positions[poss[i]];
					document.getElementById('mm'+i).style.backgroundColor=colors[poss[i]];
				   }
	}

	if (activity==1) {
		tout=setTimeout("FChange()", 20);
	} else {activity_all=0};

}


// Select catalog items
function select_catalog(obj1)
{
for (i=first1; i<=last1; i++){
document.getElementById('cat'+i).style.borderColor="#1A1A1A";
}
obj1.parentNode.style.borderColor="#CCCCCC";
document.getElementById('popup1').style.visibility='hidden';
}


// управление окошком описания продукта
var timevars = new Array ();
var pflag = new Array (false,false,false,false);
var poptyme;
var poptimeall;

function showpopup(N)
{
	//for (i=0;i<=3;i++) 
	clearTimeout(poptimeall);
	pflag[N]=true;
	poptimeall=setTimeout("hidepopupall()",10000);
}

function hidepopup(N)
{
	clearTimeout(timevars[N]);
	if(N==1) timevars[1]=setTimeout("pflag[1]=false;",500);
	if(N==2) timevars[2]=setTimeout("pflag[2]=false;",3000);// загрузка
	if(N==3) timevars[3]=setTimeout("pflag[3]=false;",500);
}

function hidepopupall()
{
	clearTimeout(timevars[1]);	pflag[1]=false;
	clearTimeout(timevars[3]);	pflag[3]=false;
// 2 - загрузка - не убираем пока не загрузится
	clearTimeout(poptimeall);
}

function popupcontrol()
{
	clearTimeout(poptyme);
	fl=false;
	
	for (i=1;i<=3;i++) if (pflag[i]) fl=true;
 	if (fl) { 
		img1=document.getElementById('product_item');	
		if(window.imageCheck) {
		document.getElementById('prod_descr').innerHTML='<p>'+descr_arr[current_product]+'</p>';
		} else {document.getElementById('prod_descr').innerHTML='<p>Загружается...</p>';}
		document.getElementById('popup1').style.visibility='visible';
 	} else document.getElementById('popup1').style.visibility='hidden';
	poptyme=setTimeout("popupcontrol();",300);
}