function init(){
//	document.body.onselectstart=function(){return false};
//	document.body.onselect=function(){return false};

	if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){
		var png=document.getElementsByTagName('img');
		var ext=/\.png$/i;
		for (var i=0;i<png.length;++i){
			if (ext.test(png[i].getAttribute('src'))){
				k=false;
				if (fixPNG(png[i])){k=true}
			};
		};
	};

	newsSetDate();
	document.getElementById('dat').innerHTML="Сегодня: "+vToday()+" | "+iToday();

	var host=new RegExp(window.location.protocol+"\\/\\/"+window.location.hostname,"i");
	var path=String(window.location.pathname).replace(/(\d+)\.htm(l)?/,"");
	var LeftMenu=document.getElementById("submenu");
	var a=LeftMenu.getElementsByTagName("a");
	var i=-1;
	do{i++}while(a[i]&&a[i].getAttribute("href").replace(host,'')!=path&&i<a.length );
	if(a[i]){
		a=a[i];
		if(document.getElementById(a.getAttribute('id').replace(/a/,'img'))){
			fClick(document.getElementById(a.getAttribute('id').replace(/a/,'img')))
		};
		do{
			fClick(document.getElementById(a.parentNode.parentNode.getAttribute('id').replace(/ch/,'img')));
			a=a.parentNode.parentNode
		}while(/^ch(\d+)/i.test(a.parentNode.parentNode.getAttribute("id")));
	};
	if(document.getElementById('IDnewsPages')){
		a=document.getElementById('IDnewsPages').getElementsByTagName('a');
		if( !/\_\d+\.htm$/.test( String(window.location.pathname)) ){a[0].className="active"}
		else{
			for (var i=0;i<a.length;++i){
				if ( new RegExp( a[i].getAttribute("href").replace(host,'') ).test( String(window.location.pathname) ) ){a[i].className="active"};
			};
		};
	};

if(document.getElementById('namaz').getElementsByTagName('p').length>0){document.getElementById('namaz').getElementsByTagName('p')[2].style.marginBottom="55px"}

//	fSetWorkHeight();
//	document.body.style.visibility="visible";
document.getElementById('IDcounters').style.visibility="visible";
};

function newsSetDate(){
	var months=['','января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря'];
	var news=document.getElementById('publ').getElementsByTagName('div');
	var pat=/(\d+)\-(\d+)\-(\d+)\s+(\d+\:\d+\:\d+)/i;
	for (var i=0;i<news.length;++i){
		if (new RegExp('publdate','i').test(news[i].className)){
			pat.exec(news[i].firstChild.nodeValue);
			var day=RegExp["$3"];
			var month=RegExp["$2"];
			var year=RegExp["$1"];
			month=month.replace(/^0(\d)$/,"$1");
			
			news[i].firstChild.nodeValue=day+" "+months[month]+" "+year;
			news[i].style.visibility='visible';
		};
	};
};

function fixPNG(element){
	var src;
	if(element.tagName=='IMG'){
		if (/\.png$/.test(element.src)){
			src = element.src;
			element.src = "/1/tmpl/1/extra/img/blank.gif";
		};
	}
	else{
		src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
		if(src){
			src = src[1];
			element.runtimeStyle.backgroundImage="none";
		};
	};
	if(src){
		element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='image')";
	};
	return true
};

function fonmouseover(el,act){
	if(act=="on"){el.className="H1nameOn"}
	else{el.className="H1name"};
};

function fSBoxSearch(){return false};
function fonclick(el){return false};

function fSetWorkHeight(){
	var IDmain=document.getElementById('IDmain');
	var IDmainLeft=document.getElementById("IDmainLeft");
	var IDmainCenter=document.getElementById("IDmainCenter");
	var IDmainRight=document.getElementById("IDmainRight");
	IDmainCenter.style.top=0;
//	var contH=parseInt(IDmain.offsetTop)+parseInt(IDmain.clientHeight);
	var contH=parseInt(IDmain.offsetTop);
//alert(document.body.clientHeight);
	if(contH<parseInt(document.body.clientHeight)){
//		IDmain.style.height=parseInt(IDmain.clientHeight)+parseInt(document.body.clientHeight)-contH;
		IDmain.style.height=parseInt(document.body.clientHeight)-contH;
	}
	else{
		IDmain.style.height=parseInt(IDmain.clientHeight);
	};
	IDmainRight.style.top=0;
	IDmainLeft.style.height=parseInt(IDmain.offsetHeight);
};

function fClick(el){
	if(new RegExp('img','i').test(el.getAttribute('id'))){
		var img=/img/i;
		var on=/_on$/i;
		var ch=document.getElementById(el.getAttribute('id').replace(img,"ch"));
		if(ch){
			if(on.test(ch.className)){ch.className=ch.className.replace(on,"")}
			else {ch.className+="_on"}
		};
	};
};

function fMouseover(el,act){
	var on=/_on$/i;
	var img=null;
	if (el.getAttribute('id')){img=document.getElementById(el.getAttribute('id').replace(/name/i,"img"))}
	if(on.test(el.className)){
		el.className=el.className.replace(on,"");
		if(img)img.className=img.className.replace(on,"");
	}
	else {
		el.className+="_on";
		if(img)img.className+="_on";
	};
};

function formValid(form,el){
	var fEl=el.split("|");
	var form=document.forms(form);
	for (var i=0;i<form.elements.length;++i){
		if (new RegExp(el,"i").test(form.elements[i].name)){
			if(form.elements[i].value.replace(/\s/g,"").length==0){
				alert('ОШИБКА: поля формы, отмеченные звездочкой (*), обязательны для заполнения');
				form.elements[i].focus();
				return false;
			};
		};
	};
	alert("Спасибо, Ваша информация отправленна!")
	return true;
};

var wndView=null;
function galOpen(el){
	if(wndView&&!wndView.closed){wndView.close()}

	var img=el.getElementsByTagName('img')[0];
	var imgSrc=img.src.replace(/s\.(\w+)$/,"b.$1");
	var txt=img.getAttribute('alt');

	wndView=window.open("","imgView","height=400,width=400,toolbar=0,status=1,location=0,menubar=0,scrollbars=1,resizable=1,directories=0");
	wndView.document.writeln('<html><head><title>'+txt+'</title></head><body style="margin:0px;padding:0px;overflow:auto;"><center><img src="'+imgSrc+'" name=IDimg id=IDimg><div style="height:50px;font-size:12px;padding:3px;margin:0px;width:98%;position:absolute;bottom:0px;left:0px;">'+txt+'</div></center></body></html>');
	wndView.document.close();
	if (!wndView.opener) wndView.opener = self;
	if (window.focus) {wndView.focus()}
	var IDimg=wndView.document.getElementById('IDimg');
	IDimg.onLoad=resizeMe(wndView,IDimg);
	function resizeMe(wndView,IDimg){
		if(IDimg.complete){
			var sW=parseInt(screen.width);
			var sH=parseInt(screen.height);
			var nW,nH,nT,nL;
			if (sW>parseInt(IDimg.width)){
				nW=parseInt(IDimg.width)+100;
			}else{nW=sW+100};
			if (sH>parseInt(IDimg.height)){
				nH=parseInt(IDimg.height)+100;
			}else{nH=sH+100};
			wndView.moveTo(0,0);
			wndView.resizeTo(nW,nH);
				if(wndView.document.body.clientWidth>IDimg.width){
				nW+=-(wndView.document.body.clientWidth-IDimg.width)
			}
			else if((wndView.document.body.clientWidth<IDimg.width)){
				nH+=(IDimg.width-wndView.document.body.clientWidth)
			}
			if(wndView.document.body.clientHeight>IDimg.height){
				nH+=-(wndView.document.body.clientHeight-IDimg.height)
			}
			else if((wndView.document.body.clientHeight<IDimg.height)){
				nH+=(IDimg.height-wndView.document.body.clientHeight)
			}
			wndView.resizeTo(nW,nH+60);
		}
		else{setTimeout(function(){return resizeMe(wndView,IDimg)},50)};
	};
	return false;
}


window.onload=init;
//window.onresize=fSetWorkHeight;