bName = navigator.appName;
bVer = parseInt(navigator.appVersion); 
if  ((bName=="Netscape" && bVer>=3) || (bName=="Microsoft Internet Explorer" && bVer>=4)) ver="good"; else ver="bad"; 

function View_Foto(Wid,Hei,ImageName,Tit) {
	Wid2=Wid;
	Hei2=Hei;
	newWindow=window.open("","","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width="+Wid2+",height="+Hei2+"");
       var newContent = "<html><head>\n"
       newContent += "<title>" + Tit + "</title></head>\n"
       newContent += "<body bgcolor=\"#ffffff\" marginheight=\"0\" marginwidth=\"0\" topmargin=\"0\" leftmargin=\"0\">\n"
       newContent += "<img border=0 src=\"" + ImageName + "\"" + " width=\"" + Wid + "\" height=\"" + Hei + "\"></a>\n"
	newContent+="<div style=\"position:absolute;left:0px;top:0px;\"><img src=\"/images/1x1.gif\" width="+Wid+" height="+Hei+"></div>"
       newWindow.document.writeln(newContent)
       newWindow.document.writeln("</body></html>")
       newWindow.document.close()
  }



function img_over(imgName,src) {
document.images[imgName].src=src;
return true;
}

function menuOpen(id)
	{
	HideRazdel();
	OpenClose(eval('razdel'+id));
	}
function OpenClose(obj,close)
	{
	if( (obj.style.visibility!='visible') )
		{
		obj.style.visibility='visible';
		obj.style.position='static';
		lastobj=obj;
		}
	else
		{
		obj.style.visibility='hidden';
		obj.style.position='absolute';
		lastobj.style.visibility='hidden';
		lastobj.style.position='absolute';
		}
	}
function HideRazdel()
{
for (i in razdel)
	{
	document.getElementById('razdel'+i).style.visibility='hidden';
	document.getElementById('razdel'+i).style.position='absolute';
	}
}	

function fixPNG(element)
{
  //Если браузер IE версии 5.5-6
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
	
    if (element.tagName=='IMG') //Если текущий элемент картинка (тэг IMG)
    {
      if (/\.png$/.test(element.src)) //Если файл картинки имеет расширение PNG
      {
        src = element.src;
        element.src = "/images/blank.gif"; //заменяем изображение прозрачным gif-ом
      }
    }
    else //иначе, если это не картинка а другой элемент
    {
	  //если у элемента задана фоновая картинка, то присваеваем значение свойства background-шmage переменной src
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1]; //берем из значения свойства background-шmage только адрес картинки
        element.runtimeStyle.backgroundImage="none"; //убираем фоновое изображение
      }
    }
    //если, src не пуст, то нужно загрузить изображение с помощью фильтра AlphaImageLoader
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "'";
  }
}

function Gallery(flat,photo) {
window.open("/cgi-bin/photo.cgi?id="+flat+"&photo="+photo,"Фотогалерея","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width=950,height=730");
  }

function OpenGallery(flat,photo) {
window.open("/cgi-bin/photo.cgi?id="+flat+"&photo="+photo,"Фотогалерея","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width=950,height=730");
  }
  
function ViewMetro(id)
{
window.open("/cgi-bin/viewmetro.cgi?id="+id+"#Metro","Фотогалерея","toolbar=no,location=no,directories=no,status=no,menubar=no,fullscreen=no,scrollbars=yes,resizable=yes,width=800,height=800");
}


// Функции для поля ввода даты
var Mdays=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var Month=new Array('январь','февраль','март','апрель','май','июнь','июль','август','сентябрь','октябрь','ноябрь','декабрь');
var Day=new Array('пн','вт','ср','чт','пт','сб','вс');

function DateDivClose(divid)
{
document.getElementById("selyear_"+divid).style.visibility='hidden';
document.getElementById("selmonth_"+divid).style.visibility='hidden';
document.getElementById(divid).style.visibility='hidden';
curdatediv='';
}

function InsertDate(d,divid,inputid)
{
document.getElementById(inputid).value=d;
document.getElementById(divid).style.visibility='hidden';
if(document.getElementById("Period"))
	{
	ChangePeriod2();
	}
}

function SelectYear(d,divid,inputid)
{
date=new Date();
document.getElementById("selmonth_"+divid).style.visibility='hidden';
document.getElementById("selyear_"+divid).style.visibility='visible';
var cc='<center>';
gyear=date.getYear();
if(bName=="Netscape") gyear+=1900;
ddd=d.substring(0,6);
for(gy=gyear;gy>gyear-100;gy--)
	{
		dddd=ddd+gy;
		if(gy==gyear)
			{
			cc=cc+'<a href="javascript:ChangeYear('+"'"+gy+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+gy+'</b></a><br>';
			}
		else
			{
			cc=cc+'<a href="javascript:ChangeYear('+"'"+gy+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+gy+'</a><br>';
			}
	}
document.getElementById("selyear_"+divid).innerHTML=cc;
}
function ChangeYear(y,inputid)
{
var v=document.getElementById(inputid).value;
document.getElementById(inputid).value=v.substring(0,6)+y;
}
function ChangeMonth(m,inputid)
{
var v=document.getElementById(inputid).value;
var month=''+m;
document.getElementById(inputid).value=v.substring(0,2)+"/"+month+"/"+v.substring(6,10);
}
function SelectMonth(d,divid,inputid)
{
date=new Date();
document.getElementById("selyear_"+divid).style.visibility='hidden';
document.getElementById("selmonth_"+divid).style.visibility='visible';
var cc='<center>';
gyear=date.getMonth();
ddd1=d.substring(0,2)+'/';
ddd2='/'+d.substring(6,11);
for(gy=0;gy<12;gy++)
	{
		m=gy+1;
		m=(m>9?m:'0'+m);
		dddd=ddd1+m+ddd2;
		if(gy==gyear)
			{
			cc=cc+'<a href="javascript:ChangeMonth('+"'"+m+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+Month[gy]+'</b></a><br>';
			}
		else
			{
			cc=cc+'<a href="javascript:ChangeMonth('+"'"+m+"'"+','+"'"+inputid+"'"+');SelectDate('+"'"+dddd+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+Month[gy]+'</a><br>';
			}
	}
document.getElementById("selmonth_"+divid).innerHTML=cc;
}
var curdatediv='';
function MouseClick(e)
{
	if(curdatediv!='')
		{
			DateDivClose(curdatediv);
			curdatediv='';
		}
}

function SelectDate(d,divid,inputid)
{
curdatediv='';
Event.add(document.body,"click",MouseClick);
var cod='';
var div=document.getElementById(divid);
var bgcolor='#ffffff';
var textcolor='#0000ff';
var curbgcolor='#0066cc';
var curtextcolor='#ffffff';
var tdhovercolor='#dddddd';
var day,month,year;
var dat=new String();
var dd=1;
var m1;
var m2;
var mday;
var f=0;
dat=""+d;
//alert(document.getElementById(inputid).value);
var cur=""+document.getElementById(inputid).value;
if(dat=="" || dat=="//") f=1;
if(dat.substr(0,2)=="00") f=1;
if(dat.substr(3,2)=="00") f=1;
if(dat.substr(6,4)=="0000") f=1;
bName = navigator.appName;
if(f==1) 
	{
	date=new Date();
	year=date.getYear();
	if(bName=="Netscape") year+=1900;
	month=date.getMonth();
	day=date.getDate();
	date1=new Date(year,month,1,0,0,0);
	}
else
	{
	day=dat.substr(0,2);
//	month=parseInt(""+dat.substr(3,2))-1;
	month=dat.substr(3,2)-1;
	year=dat.substr(6,4);
	date=new Date(year,month,day,0,0,0);
	date1=new Date(year,month,1,0,0,0);
	}
if(cur=="") 
	{
	curdat=new Date();
	curyear=curdat.getYear();
	if(bName=="Netscape") curyear+=1900;
	
	curmonth=curdat.getMonth();
	curday=curdat.getDate();
	}
else
	{
	curday=parseInt(cur.substr(0,2));
	curmonth=Math.ceil(parseFloat(cur.substr(3,2)))-1;
	curyear=parseInt(cur.substr(6,4));
	curdat=new Date(curyear,curmonth,curday,0,0,0);
	}
	if(bName=="Netscape") 
		{
			document.getElementById(divid).style.height="260";
		}
	
//	if(bName=="Netscape") 
//		{
		cd=''+curday;
		curday=(curday<10 && cd.substring(0,1)!='0')?'0'+curday:curday;
//		}

document.getElementById(inputid).value=""+curday+"/"+((curmonth+1)>9?(curmonth+1):'0'+(curmonth+1))+"/"+curyear;
if(year%4>0){Mdays[1]=29;}
//curdate=(curday<10?"0"+curday:curday)+'/'+((curmonth+1)<10?"0"+(curmonth+1):(curmonth+1))+'/'+curyear;
curdate=''+curday+'/'+((curmonth+1)<10?"0"+(curmonth+1):(curmonth+1))+'/'+curyear;
day1=date1.getDay();
if(day1==0) {day1=6;} else {day1--;}
MonthName=Month[month];
nyear=parseInt(""+year);
pyear=parseInt(""+year);
pmonth=parseInt(""+month)+1;
nmonth=parseInt(""+month)+1;
prevyear=parseInt(""+year)-1;
nextyear=parseInt(""+year)+1;
prevmonth=parseInt(""+month);
nextmonth=parseInt(""+month)+2;
if(prevmonth==0) {prevmonth=12;pyear--;}
if(nextmonth==13) {nextmonth=1;nyear++;}
pday=parseInt(""+day);
nday=parseInt(""+day);
if(day==29 && (pyear%4)>0) {pday=28;}
if(day==29 && (nyear%4)>0) {nday=28;}
y1=(pday<10?"0"+pday:pday)+'/'+(pmonth<10?"0"+pmonth:pmonth)+'/'+prevyear;
y2=(nday<10?"0"+nday:nday)+'/'+(nmonth<10?"0"+nmonth:nmonth)+'/'+nextyear;
m1=(pday<10?"0"+pday:pday)+'/'+(prevmonth<10?"0"+prevmonth:prevmonth)+'/'+pyear;
m2=(nday<10?"0"+nday:nday)+'/'+(nextmonth<10?"0"+nextmonth:nextmonth)+'/'+nyear;
cod+='<table width=100% border=0 ><tr><td width=100% align=right><a href="javascript:DateDivClose('+"'"+divid+"'"+');"><img src="/images/close.jpg" border=0 alt="закрыть"></a></td></tr></table><table><tr><td><a href="javascript:SelectDate('+"'"+y1+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><<</a></td><td width=100%><center><a title="Выбрать год" href="javascript:SelectYear('+"'"+curdate+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+')"><b>'+year+'</b></a><div id="selyear_'+divid+'" style="position:absolute;display:inline-block;visibility:hidden;width:110;height:300;overflow:scroll;z-index:100;background-color:#ffffff;border:1px dotted #000000;padding:7;"></div></td><td><a href="javascript:SelectDate('+"'"+y2+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">>></a></td></tr></table><table><tr><td><a href="javascript:SelectDate('+"'"+m1+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><<</a></td><td width=100%><center><a title="Выбрать месяц" href="javascript:SelectMonth('+"'"+curdate+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><b>'+MonthName+'</b></a><div id="selmonth_'+divid+'" style="position:absolute;display:inline-block;visibility:hidden;width:110;height:300;overflow:scroll;z-index:100;background-color:#ffffff;border:1px dotted #000000;padding:7;"></div></center></td><td><a href="javascript:SelectDate('+"'"+m2+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">>></a></td></table><br>';
cod+='<table cellpadding=5 width=100%><tr>';
mday=Mdays[month];
for(i=0;i<7;i++)
	{
	cod+='<td><b><center>'+Day[i]+'</b></center></td>';
	}
cod+='</tr><tr>';
for(j=0;j<day1;j++){cod+='<td></td>';}
while(dd<=mday)
	{
	if(j==0) {cod+='<tr>';}
	dt=""+(dd>9?dd:'0'+dd)+'/'+((month+1)>9?(month+1):'0'+(month+1))+'/'+year;
	lstyle='';
	style='cursor:hand;';
	if(dt==cur)
		{
		style='style="background-color:'+curbgcolor+';cursor:hand;"';
		lstyle='style="color:'+curtextcolor+';font-weight:bold;"';
		cod+='<td style="cursor:hand;" bgcolor='+curbgcolor+' onmouseover="this.setAttribute('+"'bgcolor','"+tdhovercolor+"',0"+');" onmouseout="this.setAttribute('+"'bgcolor','"+curbgcolor+"',0"+');" '+style+' onclick="InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><center><a '+lstyle+' href="javascript:InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+dd+'</a></td>';
		}
	else
		{
		cod+='<td style="cursor:hand;" bgcolor='+bgcolor+' onmouseover="this.setAttribute('+"'bgcolor','"+tdhovercolor+"',0"+');" onmouseout="this.setAttribute('+"'bgcolor','"+bgcolor+"',0"+');" '+style+' onclick="InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');"><center><a '+lstyle+' href="javascript:InsertDate('+"'"+dt+"'"+','+"'"+divid+"'"+",'"+inputid+"'"+');">'+dd+'</a></td>';
		}
	dd++;
	j++;
	if(j>6) {cod+='</tr>';j=0;}
	}
cod+='</table>';	
div.innerHTML=cod;
div.style.visibility='visible';
}

Event=(function(){var a=0;function c(f){f=f||window.event;if(f.isFixed){return f}f.isFixed=true;f.preventDefault=f.preventDefault||function(){this.returnValue=false};f.stopPropagation=f.stopPropagaton||function(){this.cancelBubble=true};if(!f.target){f.target=f.srcElement}if(!f.relatedTarget&&f.fromElement){f.relatedTarget=f.fromElement==f.target?f.toElement:f.fromElement}if(f.pageX==null&&f.clientX!=null){var e=document.documentElement,d=document.body;f.pageX=f.clientX+(e&&e.scrollLeft||d&&d.scrollLeft||0)-(e.clientLeft||0);f.pageY=f.clientY+(e&&e.scrollTop||d&&d.scrollTop||0)-(e.clientTop||0)}if(!f.which&&f.button){f.which=(f.button&1?1:(f.button&2?3:(f.button&4?2:0)))}return f}function b(i){i=c(i);var d=this.events[i.type];for(var h in d){var f=d[h];var e=f.call(this,i);if(e===false){i.preventDefault();i.stopPropagation()}}}return{add:function(f,e,d){if(f.setInterval&&(f!=window&&!f.frameElement)){f=window}if(!d.guid){d.guid=++a}if(!f.events){f.events={};f.handle=function(g){if(typeof Event!=="undefined"){return b.call(f,g)}}}if(!f.events[e]){f.events[e]={};if(f.addEventListener){f.addEventListener(e,f.handle,false)}else{if(f.attachEvent){f.attachEvent("on"+e,f.handle)}}}f.events[e][d.guid]=d},remove:function(g,f,e){var d=g.events&&g.events[f];if(!d){return}delete d[e.guid];for(var h in d){return}if(g.removeEventListener){g.removeEventListener(f,g.handle,false)}else{if(g.detachEvent){g.detachEvent("on"+f,g.handle)}}delete g.events[f];for(var h in g.events){return}delete g.handle;delete g.events}}}());