function Content(){}

Content.fixFrame = function()
{
 _$("docFrame").style.top=(getWinHeight()-180-50)+"px";
 setTimeout("Content.fixFrame()", 300);
 
if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
	_$("docFrame").innerHTML="";
}

Content.preloadImages = Array();
Content.docFrames = Array();

Content.docFrame = function(frame)
{
if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
{
	_$("docFrame").style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+Content.docFrames[frame].src+"', sizingMethod='scale')";
	/*<div style="height:210px; width:200px;         
  filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/images/k16.png', sizingMethod='scale');">
</div>*/	
}
else
{
a=_$("docImg");
a.src=Content.docFrames[frame].src;
}
}

Content.preload = function(imagesrc)
{

   Content.docFrames[imagesrc[0]]=new Image;   
   Content.docFrames[imagesrc[0]].onload = Content.preloadNext;
   Content.docFrames[imagesrc[0]].src = imagesrc[1];
   
}

Content.preloadNext = function()
{
	if (Content.preloadImages.length)
	{
	id=Content.preloadImages.pop();
	Content.preload(id);
	}
	else
	Content.preloadDone();
}


Content.docPreload = function()
{
for (var i=1; i<=9; i++)
Content.preloadImages.push(Array(i,"/images/frames/test/"+i+".png"));
Content.preloadNext();
}

Content.preloadDone=function()
{
_$("docFrame").style.display="block";
Content.fixFrame();
Content.docFrame(1);
Content.docStart(1.1);
}

function opac(el,op)
{
return;
if (op==1)
{
el.style.filter="";
el.style.mozOpacity=""; 
el.style.opacity="";
el.style.khtmlOpacity="";
}
else
{
el.style.filter="alpha(opacity="+(op*100)+")";
el.style.mozOpacity=op; 
el.style.opacity=op;
el.style.khtmlOpacity=op;
}
}

Content.docStart = function(op)
{
if (op==1.1) Content.docAct();
opac(_$("docFrame"),op);
setTimeout("Content.docStart("+(op+0.1)+")", 100);
}

// ÍÈÈÁÀÒÜ ÏÈÇÄÅÖ ÏÎØÅË!!!

Content.docBusy = false;

Content.docPlay = function (cur, to)
{
	
//document.getElementById("lc_5_sub").style.display="block";
	Content.docFrame(cur);
	if (cur!=to)
	{
	cur=cur>to ? cur-1 : cur+1;
	setTimeout("Content.docPlay("+(cur)+", "+to+")", 50);
	}
	else
	if (to!=1)
	lc(5);
	
}

Content.docAct = function()
{
	_$("docFrame").onclick=Content.docTest;
}

Content.docTest = function()
{
	if (Content.docBusy) return;
	Content.docBusy = true;
	Content.docPlay(1,9);
	setTimeout("Content.docPlay(9,1);Content.docBusy=false;", 5000);
}


// ÍÈÈÁÀÒÜ ÏÈÇÄÅÖ ÊÎÍ×ÈËÑß!!!


Content.verifyform = function()
{
t=0;

	if (_$("r_fam").value.length<2)
	{
	_$("r_fam").style.background="#FF9999";
	t=1;
//	window.alert("a");
	}
	if (_$("r_name").value.length<2)
	{
	_$("r_name").style.background="#FF9999";
	t=1;
//	window.alert("9");
	}
	if (_$("r_ot").value.length<2)
	{
	_$("r_ot").style.background="#FF9999";
	t=1;
//	window.alert("8");
	}
	if (parseInt(_$("r_year").value)<1900)
	{
	_$("r_year").style.background="#FF9999";
	t=1;
//	window.alert("7");
	}
	if (_$("r_okr").value=="p")
	{
	_$("r_okr").style.background="#FF9999";
	t=1;
//	window.alert("okr");
	}
	if (_$("r_town").value.length<2)
	{
	_$("r_town").style.background="#FF9999";
	t=1;
//	window.alert("town");
	}
	if (_$("r_prof").value.length<2)
	{
	_$("r_prof").style.background="#FF9999";
	t=1;
//	window.alert("6");
	}
	if (_$("r_edu").value.length<2)
	{
	_$("r_edu").style.background="#FF9999";
	t=1;
//	window.alert("5");
	}
	if (_$("r_org").value.length<2)
	{
	_$("r_org").style.background="#FF9999";
	t=1;
//	window.alert("4");
	}
	if (_$("r_post").value.length<2)
	{
	_$("r_post").style.background="#FF9999";
	t=1;
//	window.alert("3");
	}
	if (_$("r_job").value.length<2)
	{
	_$("r_job").style.background="#FF9999";
	t=1;
//	window.alert("2");
	}
	if (_$("r_email").value.length<2)
	{
	_$("r_email").style.background="#FF9999";
	t=1;
//	window.alert("1");
	}
	if (t==0)
	{
	$('reg_form').send({
				
				evalResponse: true,
				onComplete: function() {
			
				}
				});
			
	}
return;
	
}

Content.sendAsk = function(){
	
	$('ask_form').send({
				
				evalResponse: true,
				onComplete: function() {
			
				}
				});
}

Content.activeMail = new Array();

Content.delMail = function()
{
	$('delmail').send({
				onComplete: function() {
				Content.documentHandler("!email",0);
				}
				});
}

Content.openMail = function(id){
	if (Content.activeMail[id]!=1)
	{
	Content.activeMail[id]=1;
new Ajax(Content.nocache_url("/aj-wmail-"+id+"/"), {method: 'get',  
	evalScripts:true,
	onComplete: function(){
	}
	,update: $('msg_'+id)
		}).request();
		}
		else
		{
		$('msg_'+id).setText("");
		Content.activeMail[id]=0;
		}
}

// Óïðàâëåíèå ïðàâîé êîëîíêîé. 1 - ïîêàçàòü, 0 - ñïðÿòàòü

Content.sh_reg = function (c)
{
	if (c)
	{
		_$("registered").style.display="none";
		_$("unregistered").style.display="block";		
	}
}

var fx_duration = 400;

Content.fx_rc = function (c)
{
			if (c)
			msrc.slideIn();
			else
			msrc.slideOut();
}

Content.fx_banner = function (c)
{	
			if (c)
			mstb.slideIn();
			else
			mstb.slideOut();
}


Content.fx_hmenu = function (c)
{
			if (c)
			mshm.slideIn();
			else
			mshm.slideOut();
}


Content.fx_lmenu = function (c)
{
			if (c)
			mslm.slideIn();
			else
			mslm.slideOut();
}


//1 - âñåõ ñïðÿòàòü, 0 - ïîêàçàòü
Content.fx_kill = function(c)
{
	//Content.fx_banner(!c);
	
	Content.fx_rc(!c);
	
	Content.fx_lmenu(!c);
	
	Content.fx_hmenu(!c);
}



Content.HMenuCur = -1;
Content.HMenuHover = 0;

Content.rc_hs = function(id)
{
	if (_$("rc_hidable_"+id))
	{
		if (_$("rc_hidable_"+id).style.display=="none")
		{
			if (id==2 || id==3)
				_$("RTime").style.display="none";
				_$("rc_hidable_"+id).style.display="block";
			if (id!=3)
				_$("rc_arr_"+id).src="/images/rc/top_arr0.gif";
		}
		else
		{
			if (id==2 || id==3)
				_$("RTime").style.display="block";
				_$("rc_hidable_"+id).style.display="none";
			if (id!=3)
				_$("rc_arr_"+id).src="/images/rc/top_arr1.gif";
		}
	}
	if (id==2){
		if (_$("RTime").style.display=="block"){
			_$("RTime").style.display="none";
			_$("rc_arr_"+id).src="/images/rc/top_arr1.gif";
		}
		else{
			_$("RTime").style.display="block";
			_$("rc_arr_"+id).src="/images/rc/top_arr0.gif";
		}
		/* Ïîêà ýòî íå íàäî.. íî ìàëî ëè?
		if (_$("rc_hidable_3").style.display=="block") 
			_$("rc_hidable_3").style.display="none";*/
	}	
}

Content.loopGallery = function()
{
	if (_$("gallery_container"))
	{
	//Content.putLoading('gallery_container');
	new Ajax(Content.nocache_url("/aj-gallerysmall/"), {method: 'get',  
	onComplete: function(){
	
	}
	,update: $('gallery_container')
		}).request();
	}
	setTimeout("Content.loopGallery()", 5000);
}

Content.prepareCalendar = function()
{
	
	new Ajax(Content.nocache_url("/aj-calendar/"), {method: 'get',  
	onComplete: function(){
	
	}
	,update: $('calendar_container')
		}).request();		
}

Content.cal = function(month, year)
{
	Content.putLoading('calendar_container');
	
	new Ajax(Content.nocache_url("/cal-"+month+"-"+year+"/"), {method: 'get',  
	onComplete: function(){
	
	}
	,update: $('calendar_container')
		}).request();		

}

Content.activate = function()
{
	Content.loopGallery();
	new Ajax(Content.nocache_url("/aj-gallerysmall2/"), {method: 'get',  
	onComplete: function(){
	
	}
	,update: $('gallery_container2')
		}).request();
	Content.prepareCalendar();
}

Content.findAnchor = function (anchor)
{
return;
	try{
	if (anchor == 0) return;
	if (anchor == null) return;
	if (_$(anchor))
	{
		var Y=0;
		theElement = _$(anchor);
		while(theElement != null)
		{
			Y += theElement.offsetTop;
			theElement = theElement.offsetParent;
		}

		//window.scrollTo(0,Y);
	}
	}catch(e){}

}

Content.updateNewsControls = function(){

var kwicks = $$(".toclick");
kwicks.each(function(kwick, i) {
		
		kwick.addEvent("click", function(event) {
			
			var shows = $$(".toshow");
			shows.each(function(show, n) {
					
					if (n==i)
					{
						if (show.getStyle("display")=="none")
							show.setStyles({"display" : "block"});
							else
							show.setStyles({"display" : "none"});
					}
					
					});
		
		});
		});
		
var kwicks = $$(".toshow");
kwicks.each(function(kwick, i) {
			kwick.setStyles({"display" : "none"});
		});
return;


	if (_$("newsDiv"))
	{
	try{
	var accordion = new Accordion('div.newsHeader', 'div.newsBody', {
	opacity: false,
	fixedWidth: true,
	onActive: function(toggler, element){
			toggler.setStyle('color', '');
			element.setStyle('display', 'block');
			element.setStyle('height', '0px');
		},

	onBackground: function(toggler, element){
			toggler.setStyle('color', '');
			//element.setStyle('display', 'none');
		}
	}, $('newsDiv'));
	}catch(e){window.alert(e)}
	}
	
	if (_$("newsDiv2"))
	{
	try{
	var accordion2 = new Accordion('div.newsHeader', 'div.newsBody', {
	opacity: false,
	fixedWidth: true,
	onActive: function(toggler, element){
			toggler.setStyle('color', '');
			element.setStyle('display', 'block');
			element.setStyle('height', '0px');
		},

	onBackground: function(toggler, element){
			toggler.setStyle('color', '');
			//element.setStyle('display', 'none');
		}
	}, $('newsDiv2'));
	}catch(e){window.alert(e)}
	}
	
	if (_$("newsDiv3"))
	{
	try{
	var accordion3 = new Accordion('div.newsHeader', 'div.newsBody', {
	opacity: false,
	fixedWidth: true,
	onActive: function(toggler, element){
			toggler.setStyle('color', '');
			element.setStyle('display', 'block');
			element.setStyle('height', '0px');
		},

	onBackground: function(toggler, element){
			toggler.setStyle('color', '');
			//element.setStyle('display', 'none');
		}
	}, $('newsDiv3'));
	}catch(e){window.alert(e)}
	}
}

Content.putLoading = function(obj)
{
	if (_$(obj) && _$(obj).innerHTML)
	_$(obj).innerHTML = "<img src='/images/loading.gif' width=32 height=32 alt='Çàãðóæàåòñÿ'>";
}

Content.nocache_url = function (url)
{
        var sep    = ( -1 < url.indexOf("?") ) ? "&" : "?";
        var mydate = new Date();
        var newurl = url + sep + "__=" + mydate.getTime();
        return newurl;
}

Content.newsHandler = function (id, anchor)
{
			Content.showBClose(0);
			Content.showBPDF(0);
			Content.showBPrint(0);
			Content.closePDFDownload();
			ClayerBG.start({
				'opacity' : 0
			});
			ClayerTX.start({
				'opacity' : 0
			}).chain(function(){
		
			_$("contentText").innerHTML='';	
			//try{
			//_$("contentLayer").style.height=getWinHeight();
			//}catch(e){}
			});
			
	Content.putLoading('MainPageContent');
	new Ajax(Content.nocache_url("/jsnews-"+id+"/"), {method: 'get', encoding: 'windows-1251', onComplete : function(){
			Content.updateNewsControls();
			if (id!=0)
			Content.findAnchor(anchor);
		}, update: $('MainPageContent')
		}).request();
	
	//Content.documentHandler("n"+id, anchor);
}

Content.newspage = function(page)
{
			Content.showBClose(0);
			Content.showBPDF(0);
			Content.showBPrint(0);
			Content.closePDFDownload();
			ClayerBG.start({
				'opacity' : 0
			});
			ClayerTX.start({
				'opacity' : 0
			}).chain(function(){
		
			_$("contentText").innerHTML='';	
			try{
			_$("contentLayer").style.height=getWinHeight();
			}catch(e){}
			});
			
	Content.putLoading('MainPageContent');
	new Ajax(Content.nocache_url("/jsnews--1/page-"+page+"/"), {method: 'get', encoding: 'windows-1251', onComplete : function(){
			Content.updateNewsControls();
			
		}, update: $('MainPageContent')
		}).request();
	
	
}

Content.makeClickable = function(id)
{
	if (_$(id))
	$(id).addEvent('click', function(e) {
					new Event(e).stop();
					SqueezeBox.fromElement($(id));
				});
}

Content.showBClose = function (c)
{
	if (c)
	_$("button_close").style.display = "block";
	else
	_$("button_close").style.display = "none";	
}

Content.showBPrint = function (c)
{
	if (c)
	_$("button_print").style.display = "block";
	else
	_$("button_print").style.display = "none";	
}


Content.showBPDF = function (c)
{
	if (c)
	_$("button_pdf").style.display = "block";
	else
	_$("button_pdf").style.display = "none";	
}

function getWinHeight()
{
if (window.getHeight()>_$("mainTable").offsetHeight)
return window.getHeight();
else
return _$("mainTable").offsetHeight;
}

Content.documentShowAsLayer = function (anchor)
{
	Content.activeMail = new Array();
        _$("contentLayer").style.height=getWinHeight();

		_$("contentText").style.width="918px";
		_$("contentText").style.marginLeft="-481px";
		_$("button_close").style.marginLeft="367px";
		
			_$("contentText").style.width="884px";
			_$("contentText").style.marginLeft="-465px";
			_$("button_close").style.marginLeft="351px";
				_$("contentText").style.top = "146px";
				_$("button_close").style.top="143px";

		
		if (Content.documentInfo['type']=='doc')
		{
			//_$("contentText").style.top = "75px";
			//_$("button_close").style.top="76px";
			ClayerBG.start({
				'opacity' : 0.8
			});
			ClayerTX.start({
				'opacity' : 1
			});
		}
		else
		{
			_$("contentText").style.width="884px";
			_$("contentText").style.marginLeft="-465px";
			_$("button_close").style.marginLeft="351px";
			if (Content.documentInfo['type']!='news'){
				_$("contentText").style.top = "146px";
				_$("button_close").style.top="143px";
				ClayerBG.start({
					'opacity' : 0
				});
				ClayerTX.start({
					'opacity' : 0.95
				});
			}
		}
		
		//Content.putLoading('contentText');
		new Ajax(Content.nocache_url("/aj-getdoccontents/id-"+Content.documentInfo['id']+"/"), {method: 'get', encoding: 'windows-1251', onComplete : function(){
			Content.findAnchor(anchor);
			//if (Content.documentInfo['type']!='allnews1')
			Content.updateNewsControls();
			var bounds = getBounds(_$("contentText"));
			if (getWinHeight() < bounds['height']+130)
			_$("contentLayer").style.height = bounds['height']+130+'px';
			else
			_$("contentLayer").style.height =getWinHeight();
			
			
			Content.showBClose(1);
			if (Content.documentInfo['type']=='doc')
			Content.showBPrint(1);
			_$("button_printa").href="/jspdoc-"+Content.documentInfo['id']+"/";
			if (Content.documentInfo['pdf']!=0)
			{
			Content.showBPDF(1);
			_$("button_pdfa").href="/pdf/"+Content.documentInfo['pdf'];
			}
			
		}, update: $('contentText')
		}).request();
}

Content.ch_banner = function (banner)
{
	if (banner=='') banner='default_big.jpg';
	if (banner=='none') banner='default_big.jpg';
	_$("TopBanner_img").src='/images/mainpic/'+banner;
	if (banner=='default.jpg')
	_$("TopBanner_img").style.width='700px';
	else
	_$("TopBanner_img").style.width='930px';
}

Content.documentShowInline = function (anchor)
{
	Content.fx_kill(1);
	Content.ch_banner(Content.documentInfo['banner']);
	if (Content.mainpage==1)
	{
	 _$("LMenu_td").style.display="none";
	 _$("MainPageContent").style.width="920px";
	 _$("ContentTableT").style.width="930px";
	}
	Content.putLoading('MainPageContent');
		new Ajax(Content.nocache_url("/aj-getdoccontentsb/id-"+Content.documentInfo['id']+"/"), {method: 'get', encoding: 'windows-1251', onComplete : function(){
			Content.findAnchor(anchor);
			_$("contentLayer").style.height=_$("mainTable").offsetHeight  + 'px';
			}, update: $('MainPageContent')
		}).request();
	Content.mainpage=0;
}


Content.gotoMainPage = function()
{
	Content.ch_banner('default.jpg');
	
	 _$("LMenu_td").style.display="block";
	 _$("MainPageContent").style.width="490px";
	 _$("ContentTableT").style.width="700px";
	 _$("RightColumnDiv").style.display="block";
	 _$("HMenu_div").style.display="block";
	 _$("LMenu_td").style.width="200px";
	Content.fx_kill(0);	 
	Content.putLoading('MainPageContent');
		new Ajax(Content.nocache_url("/jsnews-0/"), {method: 'get', encoding: 'windows-1251', onComplete : function(){
			Content.updateNewsControls();
			_$("contentLayer").style.height=_$("mainTable").offsetHeight + 'px';
			}, update: $('MainPageContent')
		}).request();
	 Content.mainpage=1;
}



Content.showPDFDownload = function (link)
{
	_$("contentLayer").style.height=getWinHeight();
		ClayerBG.start({
			'opacity' : 0.8
		});
	_$("onlypdf").style.display="block";
	_$("link_pdfonly").href="/pdf/"+link;
			Content.findAnchor("toptoptop");
}

Content.closePDFDownload = function ()
{
	_$("onlypdf").style.display="none";
}

Content.documentHandler = function(id, anchor)
{
MenuTop.killPopup();

var docAjax= new Ajax(Content.nocache_url("/aj-getdoc/id-"+id+"/"), {
				method: 'get', 
				evalScripts : true, 
				onComplete: function(){
								if (Content.documentInfo['file']==0)
								{
									if (Content.documentInfo['pdf']>"")
									Content.showPDFDownload(Content.documentInfo['pdf']);
									
								}
								else
								if (Content.documentInfo['layer'])
								Content.documentShowAsLayer(anchor);
								else
								Content.documentShowInline(anchor);
							}
				});
	docAjax.request();
	
	
}

Content.HMenuOver = function (id, h, c)
{
    if (c)
    _$("hmenu_"+id).style.background='url("/images/hmenu/'+h+'/background.gif") repeat-x';
    else
    if (Content.HMenuCur!=id)
    _$("hmenu_"+id).style.background='url("/images/hmenu/0/background.gif") repeat-x';
    Content.HMenuHover = c;
}


Content.scTop = function()
{
var offset=0;
w = window;
if(w.document.documentElement && w.document.documentElement.scrollTop) offset=w.document.documentElement.scrollTop;
else 
if(w.document.body && w.document.body.scrollTop) 
offset=w.document.body.scrollTop;

return offset
}

Content.HMenuClick = function (id)
{
    if (Content.HMenuCur!=-1)
    {
        if (Content.HMenuCur==id)
        {
            _$("hmenu_div_"+id).style.display = "none";
            Content.HMenuCur = -1;
            Content.HMenuOver(id, 0, 0);
            return;
        }
        else
        {
            _$("hmenu_div_"+Content.HMenuCur).style.display = "none";
            tmp = Content.HMenuCur;
            Content.HMenuCur = -1;
            Content.HMenuOver(tmp, 0, 0);
        }
    }
    _$("hmenu_div_"+id).style.display = "block";
    _$("hmenu_div_"+id).style.position = "absolute";
    bounds = getBounds(_$("hmenut_"+id));
    
    //_$("hmenu_div_"+id).style.left = bounds['left']+"px";
    _$("hmenu_div_"+id).style.width = bounds['width']-2+"px";
    //_$("hmenu_div_"+id).style.top = bounds['top']+bounds['height']+"px";
    Content.HMenuCur = id;
    
    Content.HMenuHover=1;
}


Content.onresize = function()
{
return;
    if (Content.HMenuCur!=-1)
    {
        id = Content.HMenuCur;
        bounds = getBounds(_$("hmenut_"+id));
        //_$("hmenu_div_"+id).style.left = bounds['left']-1+"px";
        _$("hmenu_div_"+id).style.width = bounds['width']+2+"px";
        //_$("hmenu_div_"+id).style.top = bounds['top']+bounds['height']+"px";
    }
}

Content.kill = function()
{
    if (Content.HMenuHover==0 && Content.HMenuCur!=-1)
    Content.HMenuClick(Content.HMenuCur);
}


					function checkfield(fname)
					{
						if ($(fname).value.length<2)
						{
						$(fname).style.background="#FFAAAA";
						return 0;
						}
						else
						{
						$(fname).style.background="#FFFFFF";
						return 1;
						}
					}
					
					function checknsubmit()
					{
					y=1;
						y=checkfield("lk_fam") && y;
						y=checkfield("lk_name") && y;
						y=checkfield("lk_otch") && y;
						y=( checkfield("lk_republic") || checkfield("lk_kray") || checkfield("lk_obl")) && y;
						y=checkfield("lk_position") && y;
						y=checkfield("lk_email") && y;
						y=checkfield("lk_workplace") && y;
						if (y)
						$("formid").submit();
					}