function pastMenu(q,z)
{
	
	
	(!q?q=1:'');
	if(numb!=q){document.getElementById('past'+numb).style.zIndex=0;numb=q}
	
	
	resiz(q);
	
	x=document.getElementById('past'+q).style;
	
	if(z)
	{
		
		x.zIndex=3;
		MenuOpac=0;
		MenuOpacDel(1);
	}
	if(!z)
	{
		MenuOpac=1;
		MenuOpacDel();
	}
}

function resiz(q)
{
	(!q?q=1:'');
	x=document.getElementsByTagName('table')[0];
	xX=Math.round(x.clientWidth/2)-360-zX;
	yY=Math.round(x.clientHeight/2)-107-zY;
	x=document.getElementById('past'+q).style;
	x.top=yY+'px';
	x.left=xX+'px';
}




function MenuOpacDel(q)
{
	z=document.getElementById('past'+numb).style;
		
	if(MenuOpac>0&&!q)
	{
		MenuOpac=MenuOpac-0.1;
		setElementOpacity('zzz'+numb,MenuOpac);
		setTimeout("MenuOpacDel()", 50);
	}
	else if(!q){z.zIndex=0;MenuOpac=0;setElementOpacity('zzz'+numb,1);}

	if(MenuOpac<1&&q)
	{
		MenuOpac=MenuOpac+0.1;
		setElementOpacity('zzz'+numb,MenuOpac);
		setTimeout("MenuOpacDel(1)", 50);
	}
	else if(q){MenuOpac=1;}

}









function start()
{
pag = document.location;
pag+='';
pag=pag.split('/');
pag=pag[pag.length-1];
if(pag&&pag!='index.html')titl(1);
}

width=855;Opac=0;bottom=700;
function titl(q)
{
	if(q){document.getElementsByTagName('div')[0].innerHTML+='<img src="http://lyudovik.kiev.ua/templates/images/gl/titl.jpg" style="position:relative;bottom:700px" />'}
	f=document.getElementsByTagName('img')[0].style;
	
	if(document.cookie=='foo=bar'){f.width='415px';f.bottom='665px';return;}
	
	if(width>415)
	{
		width=width-10;Opac=Opac+0.03;
		f.width=width+'px';
		setElementOpacity(Opac)
		setTimeout("titl()",50);
	}
	else{setTimeout("titl2()",1500);}
}

function titl2(q)
{
	f=document.getElementsByTagName('img')[0].style;
	if(bottom>665)
	{
		bottom=bottom-5;
		f.bottom=bottom+'px';
		setTimeout("titl2()",20);
	}
	else{document.cookie="foo=bar; path=/;"}
}



////////////////////////////////////////////////////////////////////////////////////////////////////

var numbFOTO=0;
var numbFOTOmemory=0;
delFOTOopac=1;
razreshauPokazFOTO=0;


imgLoad=new Image();
imgLoad.src='http://lyudovik.kiev.ua/templates/images/foto/loading.gif';


function playFoto(q)
{
	if(q=='+')
	{
		numbFOTO++;
		if(numbFOTO>=arhFOTO.length)numbFOTO=0;
	}
	if(q=='-')
	{
		numbFOTO--
		if(numbFOTO<0)numbFOTO=arhFOTO.length-1;
	}
	
	if(q!='-'&&q!='+')numbFOTO=q;
	if(q=='begin')numbFOTO=0;
	
	hiddenImgLoad()
}
function hiddenImgLoad(q)
{
	hiddenImg=new Image();
	hiddenImg.src=arhFOTO[numbFOTO];
	checkLoad(q);
	
}
function playFotoPart2()
{
	if(numbFOTO!=numbFOTOmemory)
	{
		
		document.getElementById('windo4').style.background="#000 url("+arhFOTO[numbFOTO]+") no-repeat center";
		document.getElementById('windo5').style.background="#000 url("+arhFOTO[numbFOTOmemory]+") no-repeat center";
		//document.getElementById('windo6').innerHTML="Фото№"+(numbFOTO+1);
		numbFOTOmemory=numbFOTO;
		delfoto()
	}
}
/// загрузка в кеш 
function checkLoad(q)
{
	x=document.getElementById('windo3').style;
	if(hiddenImg.complete)
	{
		x.background='';
		(q?razreshauPokazFOTO=1:playFotoPart2())
	}
	else
	{
		x.background='url(http://lyudovik.kiev.ua/templates/images/foto/loading.gif) no-repeat bottom right';
		setTimeout("checkLoad("+q+")", 50);
	}
} 

function delfoto()
{
	if(delFOTOopac>0)
	{
		delFOTOopac=delFOTOopac-0.1;
		setElementOpacity('windo5', delFOTOopac);
		setTimeout("delfoto()", 50);
	}
	else
	{
		delFOTOopac=1;
		document.getElementById('windo5').style.background='';
		setElementOpacity('windo5',1);
	}
}
function clientW_H(q) 
{
	(q?b=document.getElementById(q):b=document.body);
	return {"x":b.clientWidth,"y":b.clientHeight}
}
////////////////////////////////////////////////////////////////////////////////////////////

opac=0;wid_T=120;heig_T=0;
function displ_out(q,Tid) 
{
	if(opac==0&&q==1)
	{
		x=clientW_H().x;
		y=clientW_H().y;
		
		
	if(Tid>=0)numbFOTO=numbFOTOmemory=Tid;

		t='';
		t+="<table cellpadding=0 cellspacing=0 style='position:absolute;width:"+x+"px;height:"+y+"px;top:0px;left:0px;z-index:1000;background:#000' id=windo2><tr><td>";
		t+="</td></tr></table>";


		t+="<table cellpadding=0 cellspacing=0 style='position:absolute;width:"+x+"px;height:"+y+"px;top:0px;left:0px;z-index:1001' id=windo3><tr><td align=center>";

		t+="<table cellpadding=0 cellspacing=0 style=cursor:default>";
		t+="<tr><td width=70 rowspan=6></td><td align=center colspan=3 height=68 valign=bottom>"
		
		//t+="<div style='position:relative;top:80px;font-size:15px;font-weight:bold;color:#f6ff00;font-family:Times New Roman' id=windo6>Фото№"+(numbFOTO+1)+"</div>"
		
		t+="<img src=http://lyudovik.kiev.ua/templates/images/foto/foto1.gif width=90 height=46 style='position:relative;top:8px' /></td></tr>";
		t+="<tr><td width=10 height=10 background=http://lyudovik.kiev.ua/templates/images/foto/f1.gif></td><td bgcolor=#000000></td><td width=10 background=http://lyudovik.kiev.ua/templates/images/foto/f2.gif></td><td width=70 rowspan=6 valign=top align=center><b onclick=displ_out(0) style='color:#FFF;cursor:pointer'>Закрыть</b></td></tr>";

		
		t+="<tr bgcolor=#000000><td></td><td width=120 id=windo4 valign=top style=\"background:#000 url("+arhFOTO[numbFOTO]+") no-repeat center\"></td><td></td></tr>";/// paste
		
		t+="<tr><td colspan=3 bgcolor=#000000 height=38 valign=middle>";
		t+="<table width=100%><tr height=19><td width=33% align=left><div align=center style=width:70%><img src=http://lyudovik.kiev.ua/templates/images/foto/strl.gif style='background:#ff9c00;cursor:pointer' id=stR1 width=20 height=19 onmouseover='strelk1()' onmouseout='strelk1(1)' onclick=\"playFoto('-')\" /></div></td><td width=33% style='cursor:pointer;color:white' align=center><b onclick=\"playFoto('begin')\">В&nbsp;начало</b></td><td width=33% align=right><div align=center style='width:70%'><img src=http://lyudovik.kiev.ua/templates/images/foto/strl2.gif width=20 height=19 style='background:#ff9c00;cursor:pointer' id=stR2 onmouseover=strelk2() onmouseout=strelk2(1) onclick=\"playFoto('+')\" /></div></td></tr></table>";
		t+="</td></tr>";
		t+="<tr><td width=10 height=10 background=http://lyudovik.kiev.ua/templates/images/foto/f3.gif></td><td bgcolor=#000000></td><td width=10 background=http://lyudovik.kiev.ua/templates/images/foto/f4.gif></td></tr>";
		t+="<tr><td align=center colspan=3 height=68><img  src=http://lyudovik.kiev.ua/templates/images/foto/foto2.gif width=137 height=68 style='position:relative;bottom:13px' /></td></tr></table>";
	
		t+="</td></tr></table>";		
		//alert(arhFOTO[numbFOTO]+' | '+numbFOTO)
		document.getElementById('windo').innerHTML=t;
		resizes();
	}
	if(Tid>=0)hiddenImgLoad(1);

	
	if(opac<1.01&&q==1)
	{
		setElementOpacity('windo3', opac);
		if(opac<0.65){setElementOpacity('windo2', opac);}
		opac=opac+0.1;
		setTimeout("displ_out(1)",100);
	}
	else if(opac>=0.65&&q==1)displ_out2();//уходим дальше
	
	if(opac>0&&q==0)
	{
		(opac>1?opac=0.60:'');
		setElementOpacity('windo2', opac);
		setElementOpacity('windo3', opac);
		opac=opac-0.1;
		setTimeout("displ_out(0)",100);
		
	}
	if(opac<0){opac=0;document.getElementById('windo').innerHTML='';}
}
function displ_out2()//щирина
{
	if(wid_T<500)
	{
		x=document.getElementById('windo4').style;
		wid_T=wid_T+20;
		x.width=wid_T+'px';
		setTimeout("displ_out2()",20);
	}
	else (razreshauPokazFOTO==1?setTimeout("displ_out3()",400):setTimeout("displ_out2()",50));//тормоз что ли
}
function displ_out3()//высота
{
	x=document.getElementById('windo4');
	if(heig_T<600)
	{
		heig_T=heig_T+30;
		x.style.zoom='100%';x.style.zoom='normal';
		x.style.height=heig_T+'px';
		setTimeout("displ_out3()",40);
	}
	else
	{
		wid_T=120;heig_T=0;strelk1(1);setTimeout("strelk2(1)",1000);//////////// Переход на стрелки

		x.innerHTML="<div style='width:500px;height:600px' id=windo5></div>";
		setElementOpacity('windo4',1);
	}//обнуляем
}
////////////////////////белки стрелки
strK1=strK2=tCle1=tCle2=tCle1b=tCle2b=105;
function strelk1(q)
{
	if(!q)
	{
		if(strK1<235)
		{
			clearTimeout(tCle2);
			strK1=strK1+20;document.getElementById('stR1').style.background=rgb2hex(233,strK1,0);
			tCle1=setTimeout("strelk1()",20);
		}

	}
	if(q)
	{
		if(strK1>50)
		{
			clearTimeout(tCle1);
			strK1=strK1-5;document.getElementById('stR1').style.background=rgb2hex(233,strK1,0);
			tCle2=setTimeout("strelk1(1)",20);
		}
	}
}
function strelk2(q)
{
	if(!q)
	{
		if(strK2<235)
		{
			clearTimeout(tCle2b);
			strK2=strK2+20;document.getElementById('stR2').style.background=rgb2hex(233,strK2,0);
			tCle1b=setTimeout("strelk2()",20);
		}

	}
	if(q)
	{
		if(strK2>50)
		{
			clearTimeout(tCle1b);
			strK2=strK2-5;document.getElementById('stR2').style.background=rgb2hex(233,strK2,0);
			tCle2b=setTimeout("strelk2(1)",20);
		}
	}
}
function resizes() 
{
	if(q=document.getElementById('windo2'))
	{
		q=q.style;
		
		x=clientW_H().x;
		y=clientW_H().y;
		(x<900?x=900:'');
		(y<800?y=830:'');
		
		q.width=x
		q.height=y
		
		q=document.getElementById('windo3').style;
		q.width=x;
		q.height=y;
	}
	x=document.body.style;x.zoom='100%';x.zoom='normal'
}





















function rgb2hex(r,g,b)
{
  return Number(r).toString(16).toUpperCase().replace(/^(.)$/,'0$1') + 
         Number(g).toString(16).toUpperCase().replace(/^(.)$/,'0$1') +
         Number(b).toString(16).toUpperCase().replace(/^(.)$/,'0$1');
}
function setElementOpacity(sElemId, nOpacity)
{
  var opacityProp = getOpacityProperty();
  var elem = document.getElementById(sElemId);

  if (!elem || !opacityProp) return; // Если не существует элемент с указанным id или браузер не поддерживает ни один из известных функции способов управления прозрачностью
  
  if (opacityProp=="filter")  // Internet Exploder 5.5+
  {
    nOpacity *= 100;
	
    // Если уже установлена прозрачность, то меняем её через коллекцию filters, иначе добавляем прозрачность через style.filter
    var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
    if (oAlpha) oAlpha.opacity = nOpacity;
    else elem.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity="+nOpacity+")"; // Для того чтобы не затереть другие фильтры используем "+="
  }
  else // Другие браузеры
    elem.style[opacityProp] = nOpacity;
}

function getOpacityProperty()
{
  if (typeof document.body.style.opacity == 'string') // CSS3 compliant (Moz 1.7+, Safari 1.2+, Opera 9)
    return 'opacity';
  else if (typeof document.body.style.MozOpacity == 'string') // Mozilla 1.6 и младше, Firefox 0.8 
    return 'MozOpacity';
  else if (typeof document.body.style.KhtmlOpacity == 'string') // Konqueror 3.1, Safari 1.1
    return 'KhtmlOpacity';
  else if (document.body.filters && navigator.appVersion.match(/MSIE ([\d.]+);/)[1]>=5.5) // Internet Exploder 5.5+
    return 'filter';

  return false; //нет прозрачности
}





































posDem=widthDem=heightDem=nex=nOpadem=0;
function demoFOTO(q,p,z)
{

	if(!z&&nex==0&&posDem==0)
	{
		widthDem=clientW_H(q).x;
		heightDem=clientW_H(q).y;
		
		x='';
		x=posCurs(p);
		
		if(XposCurs>x.x){k=XposCurs-x.x;nextX=0;}
		else{k=x.x-XposCurs;nextX=1;}
		if(YposCurs>x.y){l=YposCurs-x.y;nextY=0;}
		else{l=x.y-YposCurs;nextY=1;}

		if(k>l&&nextX==0)nex=2;
		if(k>l&&nextX==1)nex=4;
		if(k<l&&nextY==0)nex=3;
		if(k<l&&nextY==1)nex=1;
	//	alert(nex)
		
	}

	x=document.getElementById(q);
	x.title='Нажми лев кл мыши что бы сотреть галерею';
	x=x.style;
	x.cursor='pointer';
	
	if(nex==1)
	{
		if(posDem<heightDem)
		{
			nOpadem=nOpadem+0.02
			setElementOpacity(q,nOpadem)
			posDem=posDem+2;
			x.backgroundPosition='0 '+posDem+'px';
			setTimeout("demoFOTO("+q+",1,1)", 10);
		}
		else {posDem=0;nex=0;x.backgroundPosition='';setElementOpacity(q,1);nOpadem=0;}
	}
	if(nex==3)
	{
		if(posDem>heightDem-(heightDem*2))
		{
			nOpadem=nOpadem+0.02
			setElementOpacity(q,nOpadem)
			posDem=posDem-2;
			x.backgroundPosition='0 '+posDem+'px';
			setTimeout("demoFOTO("+q+",1,1)", 10);
		}
		else {posDem=0;nex=0;x.backgroundPosition='';setElementOpacity(q,1);nOpadem=0;}
	}
	
	
	
	
	
	
	if(nex==4)
	{
		if(posDem<widthDem)
		{
			nOpadem=nOpadem+0.02
			setElementOpacity(q,nOpadem)			
			posDem=posDem+2;
			x.backgroundPosition=posDem+'px';
			setTimeout("demoFOTO("+q+",1,1)", 10);
		}
		else {posDem=0;nex=0;x.backgroundPosition='';setElementOpacity(q,1);nOpadem=0;}
	}
	
	if(nex==2)
	{
		if(posDem>widthDem-(widthDem*2))
		{
			nOpadem=nOpadem+0.02
			setElementOpacity(q,nOpadem)			
			posDem=posDem-2;
			x.backgroundPosition=posDem+'px';
			setTimeout("demoFOTO("+q+",1,1)", 10);
		}
		else {posDem=0;nex=0;x.backgroundPosition='';setElementOpacity(q,1);nOpadem=0;}
	}
	
	
	
}


function posCurs(q)
{
	var html = document.documentElement; 
	var body = document.body;

	x=q.clientX+(html && html.scrollLeft || body && body.scrollLeft || 0) - (html.clientLeft || 0);
	y=q.clientY+(html && html.scrollTop || body && body.scrollTop || 0) - (html.clientTop || 0);
	
	return {"x":x,"y":y}
}

