window.onload = function(){
	Pages.Every();
	if(document.getElementById('contacts')){Pages.Contacts()};
	if(document.body.className.indexOf('home') !== -1){Pages.Home()};
};



Pages = {};



Pages.Every = function(){
	(function(){
		if(document.getElementById('footerCounter')){
			document.getElementById('footerCounter').innerHTML = '<a href="http://www.liveinternet.ru/click" '+'target=_blank><img src="http://counter.yadro.ru/hit?t18.16;r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';'+Math.random()+'" alt="liveinternet.ru: iieacaii ?enei oeoia ca 24 ?ana, iinaoeoaeae ca 24 ?ana e ca naaiai\y" '+'border=0 width=88 height=31></a>';
		}
	})();
		
	
	window.toggleParagraph = function(obj_id){
		var header = document.getElementById('h'+obj_id);
		var content = document.getElementById('p'+obj_id);
		
		
		if(header.className == 'minH'){
			document.getElementById('p'+obj_id).style.display = 'block';
			header.className = 'minHCur';
			content.className = 'paragraph minHCur';
		}
		else{
			document.getElementById('p'+obj_id).style.display = 'none';
			header.className = 'minH';
			content.className = 'paragraph minH';
		}
	};
	
	
	
	//pics on hover in menu
	(function(){
		document.getElementById('leftMenu').onmouseover = function(e){
			e = e || window.event;
			var t = e.target || e.srcElement;

			if((t.tagName == 'A' || t.tagName == 'SPAN') && t.parentNode.className =='imaged'){
				//картинка не создана
				if(t.parentNode.lastChild.tagName != 'IMG'){
					var img = document.createElement('IMG');
					img.setAttribute('src', t.parentNode.firstChild.nodeValue);
					t.parentNode.appendChild(img);
				}
				
				//картинка вставлена
				else{
					t.parentNode.lastChild.className = '';
				}
				
				t.onmouseout = function(){
					t.parentNode.lastChild.setAttribute('class', 'hidden');
					t.onmouseout = null;
				};
			}
		}
		
		
		
	})()
	
};



Pages.Contacts = function(){
	(function(){
		document.getElementById('contentBlock').onclick = function(e){
			e = e || window.event;
			var t = e.target || e.srcElement;
			
			if(t.className.indexOf('print') !== -1){
				var paragraph = t.parentNode.cloneNode(true);
				
				paragraph.className = paragraph.className + ' printIt';
				document.body.appendChild(paragraph);
				document.body.originClassName = document.body.className; 
				document.body.className = document.body.originClassName + ' printVersion';
				window.print();
				
				//reset mutations
				window.setTimeout(function(){
					paragraph.parentNode.removeChild(paragraph);
					document.body.className = document.body.originClassName;
				}, 1000);
			};
			
		};
	})();

};



Pages.Home = function(){
	//big image deferred loading
	(function(){
		var img = document.getElementById('homeBPic');
		img.src = "/i/bg/ill.jpg";
	
		img.onload = function(){
			for(i=0; i<=1; i+=(1/30)){
				setTimeout((function(x){
					return function(){
						img.style.opacity = x;
						img.style.MozOpacity = x;
						img.style.KhtmlOpacity = x;
						img.style.filter = "alpha(opacity=" + (x*100) + ")";					
					};
				})(i), i*1000);
			};
		};	
	})();
	
	
	
	//images in paragraph deferred loading
	(function(){
		var divs = document.getElementById('contentBlock').getElementsByTagName('div');
		for(var i=0, l=divs.length; i<l; i++){
			if(divs[i].className.indexOf('img ') != -1){
				divs[i].style.backgroundImage = 'url('+divs[i].firstChild.nodeValue+')';
			}
		}
	})();
	
};





