

if(typeof Unkom==undefined) Unkom = new Object;
Unkom = {
	DisplayNoneByID: new Object,
	DisplayBlockByID:new Object,
	MonthShow: new Object,
	DisplayNoneDT: new Object,
	AddCSSRules: new Object, 
	BottomLinks: new Object,
	AddMouseListenerAnonsListing: new Object,
	LastNewsAnons: new Object, 
	ReplaceNews: new Object,
	UserBrowser: new Object,
	SetLastNews: new Object,
	ReturnLastNews: new Object,
	SetOnMouseOverListener: new Object,
	Gallery: new Object,
	AddURL: new Object,
	NewWindow:new Object
}

window.onunload = function(){
	Unkom.SetOnMouseOverListener.init();
}
Unkom.UserBrowser = {//определение браузера
		ie: function(){
			if ((navigator.appName.substring (0,3)=='Mic') && !((new Date().getYear().toString()).substring (0,1)=='1')){//определяю год; ie выдаст в формате гггг, а мозилла 1гг
					return true;
			}else{
				return false;
			}
		},
		mozilla: function(){
			if(navigator.appName.substring (0,3)=='Net'){
				return true;
			}else{
				return false;
			}
		},
		opera: function(){
			if((navigator.appName.substring (0,5)=='Opera') || ((navigator.appName.substring (0,3)=='Mic') && (new Date().getYear().toString()).substring (0,1)=='1'))//определяю год; ie выдаст в формате гггг, а мозилла 1гг
			{
				return true;				
			}else{
				return false;
			}
		}	
	}
Unkom.AddCSSRules = {
	init: function(){
		;
	}
}

Unkom.DisplayNoneByID = {
	init: function(obj){
		try{
			document.getElementById(obj).style.display = "none";
		}catch(error){
			;
		}
	}
}
Unkom.DisplayBlockByID = {
	init: function(obj){
		try{
			document.getElementById(obj).style.display = "block";
		}catch(error){
			;
		}
	}
}
Unkom.MonthShow = {
	init: function(obj){
	var parent_li = obj.parentNode;
	var parent_ul = parent_li.parentNode;
	for(var i=0; i<parent_ul.getElementsByTagName('li').length; i++){
		parent_ul.getElementsByTagName('li')[i].firstChild.style.background = 'url("/images/inner/ul_years_a_bg.gif") 0 100% repeat-x';
		parent_ul.getElementsByTagName('li')[i].firstChild.style.color = '#432f5e';
		parent_ul.getElementsByTagName('li')[i].firstChild.style.fontSize = '15px';
		parent_ul.getElementsByTagName('li')[i].firstChild.style.fontWeight = 'normal';
	}
	obj.style.fontSize = '15px';
	obj.style.fontWeight = 'bold';
	obj.style.top = '-5px';
	obj.style.color = 'black';
	obj.style.background = 'none';

	var year = 'year' + obj.firstChild.nodeValue;
	var YearMonth = document.getElementById('YearMonth');
	var ul = YearMonth.getElementsByTagName('ul');
		for(var i=0;i<ul.length;i++){
			ul[i].style.display = 'none';
		}
		document.getElementById(year).style.display = 'block';
	}
}
Unkom.DisplayNoneDT = {
	init:function(tag_name){
	var YearMonth;

		try{
			YearMonth = document.getElementById('YearMonth');
			var dt = YearMonth.getElementsByTagName('dt');
			for(var i=0;i<dt.length;i++){
					dt[i].style.display = 'none';
			}
		}catch(error){
			;
		}
	}
}
Unkom.BottomLinks = {
	changeCSS: function(nr){
		if (document.getElementsByTagName)
			x = document.getElementsByTagName('link');
		else if (document.all)
			x = document.all.tags('link');
		else{
			alert('Простите, этот скрипт не работает в Вашем броузере');
			return;
		}
			for (var i=0;i<x.length;i++){
					if(x[i].title == 'printview'){x[i].disabled = !nr;}
					if(x[i].title == 'screenview'){x[i].disabled = nr;}
			}
	},
	addStandartCSS: function(){
		document.writeln('<div style="margin-bottom:10px;" class="display_none" id="from_print"><a href="javascript:Unkom.BottomLinks.changeCSS(0);" title="Обычная версия"><span>&larr;Обычная версия</span></a></div>');
		document.writeln('<input type="button" value="Печатать" class="display_none" id="print_button" onclick="javascript:window.print();"/>');
	},
	init: function(){
		var text =  '<a href="javascript: print();"  title="Страница автоматически будет отформатированна для печати" id="to_printer"><span>Версия для печати</span></a>';
			text += '<a href="#TB_inline?height=300&width=400&inlineId=SendLink" onclick="Unkom.Gallery.init();" class="thickbox" id="to_mail"><span>Отправить ссылку</span></a>';
			text += '<a href="#TB_inline?height=300&width=400&inlineId=SendErrorMessage" onclick="Unkom.Gallery.init();" class="thickbox" id="find_error"><span>Нашли ошибку?</span></a>';
			text += '<div class="display_none" id="SendLink">';
			text += '   <h2 class="title">Отправить ссылку</h2>';
			text += '   <span id="lableForEmailDescriprtion">Вы можете отправить ссылку на эту страницу вашему другу или знакомому по электронной почте</span>';
			text += '    <form name="SendLinkForm" id="SendLinkForm" action="?action=to_friend" method="post">';
			text += '		 <span id="lableForEmailInput1">E-mail получателя:</span>';
			text += '		 <input type="text" name="SendLinkEmail" id="SendLinkEmail"/>';
			text += '        <span id="InputEmailDescription">Сформированное письмо будет отправленно на этот адрес.</span>';
			text += '        <span id="lableForEmailInput2">Ваш e-mail:</span><input type="text" name="UserEmail" id="UserEmail"/>';
			text += '        <span id="InputUserDescription">В письме Ваш e-mail будет указан как адрес отправителя.</span>';
			text += '        <input type="submit" name="submit" id="UserSubmitMail" value="Отправить&#8594;"/>';
			text += '		<input type="hidden" name="page_url" value="http://'+ location.host + location.pathname +'">';
			text += '    </form>';
			text += '</div>';
			text += '<div class="display_none" id="SendErrorMessage">';
			text += '<h2 class="title">Нашли ошибку?</h2>';
			text += '	<span id="lableForErrorDescriprtion">Если заметили неточность на данной странице, пожалуйста, скажите нам об этом. Заполните поля:</span>';
			text += '	<form name="ErrorForm" name="ErrorForm" action="?action=error" method="post"><span id="lableForErrorInput1">Ваше имя:</span>';
			text += '		<input type="text" name="SendLinkError" id="SendLinkError"/>';
			text += '		<span id="lableForErorrInput2">E-mail для ответа:</span><input type="text" id="UserErorr" name="UserEmail"/>';
			text += '		<span id="lableForErrorTextarea">Ваше замечание или комментарий</span><textarea id="ErrorTextarea" name="UserComment"></textarea>';
            text += '		<input type="hidden" name="page_url" value="http://'+ location.host + location.pathname +'"/>';
            text += '		<input type="submit" name="submit" id="UserSubmitError" value="Отправить&#8594;"/>';
            text += '	</form>';
			text += '</div>';
			document.writeln(text);
	}
}
Unkom.LastNewsAnons = {
	lastNews: '',
	set: function(){
				var ie = Unkom.UserBrowser.ie();
				var	toClone = document.getElementById('lastNews').cloneNode(true);
				this.lastNews = toClone;
	},
	get: function(){
		return this.lastNews;
	}
}
Unkom.AddMouseListenerAnonsListing = {
	createHandler: function(num){
		return function() {
			Unkom.ReplaceNews.init('anons' + num, this, 'divLink' + num, 'link' + num, 'date' + num);
		}
	},
	delHandler: function(){
		Unkom.ReplaceNews.delHendler();
	},
	init: function(){
		var AnonsListing = document.getElementById('AnonsListing');
		var tmp = AnonsListing.getElementsByTagName('li');
		for(var i = 0; i < tmp.length; i++){
			tmp[i].onmouseover = this.createHandler(i);
		}
	}
}
Unkom.ReplaceNews = {
	clone_status: false,
	setCloneStatus: function(status){
		this.clone_status = status; 
	},
	getCloneStatus:function(){
		return this.clone_status;
	},
	setDefaultSetting: function(){
	var ie = Unkom.UserBrowser.ie();
	var anons = 'anons';
	var LI = 'LI';
	var link = 'link';
	var li_img, a;
		try{
		
			for(var i=0;i<3;i++){
				anons += i.toString();
				LI += i.toString();
				link += i.toString();
				document.getElementById(anons).style.display = 'none';
				document.getElementById(LI).style.backgroundColor = 'transparent';
					if(!ie){
						document.getElementById(LI).style.opacity = '0.5';
					}
					if(ie){
						li_img = document.getElementById(LI);
						li_img = li_img.getElementsByTagName('img');
						li_img[0].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
						a =  document.getElementById(LI).getElementsByTagName('a');
						a[0].style.color = '#9f95a7';
					//	document.getElementById(LI).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=50)';
					//	document.getElementById(LI).style.filter='filter:progid:DXImageTransform.Microsoft.Chroma(color=#fff);';
					}
				if(!ie) document.getElementById(link).style.color = '#432f5e';
				anons = 'anons';
				LI = 'LI';
				link = 'link'
			}
		}catch(error){
			;
		}
	},
	init: function(obj_id, li, div_link_id, link_id, date_id){
		var lastNews = document.getElementById('lastNews');
		var lastAnons =  document.getElementById('lastAnons');
		var ie = Unkom.UserBrowser.ie();
		var toClone, li_img, a;
			
			this.setDefaultSetting();
			
			if(!ie) li.style.opacity = '1';
			if(ie){
			//	li.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=100)";
				li_img = li.getElementsByTagName('img');
				li_img[0].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
				a = li.getElementsByTagName('a');
				a[0].style.color = '#432f5e';
			}
	
				
		document.getElementById('LastNews1').style.display = 'none';
		document.getElementById(obj_id).style.display = 'block';
		this.setCloneStatus(true);

	}
}
Unkom.SetLastNews = {
	init: function(){	
		var lastNews = document.getElementById('lastNews');
		var ie = Unkom.UserBrowser.ie();
		var LI = 'LI', li_img, a;
			if(ie){
				Unkom.ReplaceNews.setDefaultSetting();
				for(var i=0;i<3;i++){
					LI += i.toString();
					//document.getElementById(LI).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
					li_img = document.getElementById(LI);
					li_img = li_img.getElementsByTagName('img');
					li_img[0].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
					a =  document.getElementById(LI).getElementsByTagName('a');
					a[0].style.color = '#432f5e';
					LI = 'LI';
				}
			}
			try{
				document.getElementById('LastNews1').style.display = 'block';
			}catch(error){;}

	}
}

Unkom.ReturnLastNews = {
	init:function(){
		var lastNewsValue = Unkom.LastNewsAnons.get();
		var lastNews = document.getElementById('lastNews');
		var ie = Unkom.UserBrowser.ie();
		var LI = 'LI';
		var li_img, a;
			Unkom.ReplaceNews.setDefaultSetting();
			for(var i=0;i<3;i++){
					LI += i.toString();
						if(ie){
							//document.getElementById(LI).style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
							li_img = document.getElementById(LI);
						li_img = li_img.getElementsByTagName('img');
						li_img[0].style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
						a =  document.getElementById(LI).getElementsByTagName('a');
						a[0].style.color = '#432f5e';
						}
						if(!ie){
							document.getElementById(LI).style.opacity = '1';
						}
					LI = 'LI';
				}
				try{
					document.getElementById('LastNews1').style.display = 'block';
				}catch(error){;}
		
	}
}
Unkom.SetOnMouseOverListener = {
	init: function(){
		var index, Bottom, head, TopToMain, TopToNews, TopToAction, TopToAair, TopToForum;
		var TopToOnLine, terraLogotype, newsToday, newsTommorow, newsArj, RSSLine, searchInput;
		var obj_array = new Array();
			searchInput = document.getElementById('searchInput');
			searchInput.onfocus = function(){
				this.value = '';
			}
			try{
				index = document.getElementById('index');
			}catch(error){;}
			if(index){
				try{
					Bottom = document.getElementById('Bottom');
					head = document.getElementById('head');
					TopToMain = document.getElementById('TopToMain');
					TopToNews = document.getElementById('TopToNews');
					TopToAction = document.getElementById('TopToAction');
					TopToAair = document.getElementById('TopToAair');
					TopToForum = document.getElementById('TopToForum');
					TopToOnLine = document.getElementById('TopToOnLine');
					terraLogotype = document.getElementById('terraLogotype');
					newsToday = document.getElementById('newsToday');
					newsTommorow = document.getElementById('newsTommorow');
					newsArj = document.getElementById('newsArj');
					RSSLine = document.getElementById('RSSLine');
					
					obj_array[
								Bottom, 
								head, 
								TopToMain, 
								TopToNews,
								TopToAction,
								TopToAair,
								TopToForum,
								TopToOnLine,
								terraLogotype,
								newsToday,
								newsTommorow,
								newsArj,
								RSSLine
					]
				}catch(error){;}
			}
				
				if(index){
					try{
						for(var i=0;i<obj_array.length;i++){
							obj_array[i].onmouseover = function(i){
								Unkom.ReturnLastNews.init();
							}
						}
					}catch(error){;}
				}	
	}
}

Unkom.Gallery = {
	display_status: true,
	init: function(){
		/*code delete*/
	}
}
Unkom.AddURL = {
	init: function(){
		;
	}
}
Unkom.NewWindow = {
	init: function(url, name, x, y) {
	    var proWindow = window.open("/forum"+url,name,"left=0, top=0, menubar=no, toolbar=no, location=no, directories=no, statusbar=0, scrollbars=0, resizable=0,  width=" + x + ", height=" + y);
	}
}