/** head scripts **/
function displayBox(id, disp) {
	if(disp == 'block')
	document.getElementById('h_'+id).className = 'menu_reg2';
	else {
		if(id == 'box_'+sel) document.getElementById('h_'+id).className = 'menu_reg3';
		else                document.getElementById('h_'+id).className = 'menu_reg';
	}
	document.getElementById(id).style.display = disp;
}



function animated (el_id) {
	var prev_im = null;
	var im1 = null;
	var im2 = null;
	this._init_anim(el_id);
	var last_anim = null;
	var clr = 0;
}
animated.prototype._load_animation = function(im){
	var time = 500;
	var ul = im.up('ul').childElements();
	if ($('expanding')) $('expanding').removeAttribute('id');
	if (this.prev_im == im) {
		if (im.up('li') == ul[0] && !im.hasClassName('active')) {
			im.setAttribute('id','expanding');
			this.im2 = new animatedcollapse('expanding',time,false,'contract');
			this.im2.isExpanded = 'no';
			this.im2.update(ul[ul.length-1].down('img').getHeight());
			this.im2.slidedown();
			im.up('li').addClassName('active');
		}
		return;
	}
	this.prev_im.setAttribute('id','collapsing');
	im.setAttribute('id','expanding');
	ul.each( function (s) {
		s.removeClassName('active')}
	);
	
	$('expanding').up('li').addClassName('active');
	this.im1 = new animatedcollapse('expanding', time, false, 'contract', 'collapsing');
	this.im1.isExpanded = 'no';
	this.im1.update(im.down('img').getHeight());
	this.im1.slidedown();
	this.prev_im.removeAttribute('id');
	
}

animated.prototype._init_anim = function(el){
	var li_all = $(el).childElements();
	this.prev_im = li_all[0].down('.img-cont');
}
animated.prototype.animate = function (el){
	if (this.clr) clearTimeout(this.clr);
	var thisobj = this;
	this.last_anim = function () {
		thisobj._load_animation(el);
		thisobj.prev_im = el;
	};
	this.clr = setTimeout (this.last_anim,450);
}
animated.prototype.reset = function(){
	if (this.clr) clearTimeout(this.clr);
	this.last_anim = null;
}

var rollovers = new Hash();
stopAnim = function(event,ul){
	var n1 = event.relatedTarget || event.toElement;
	if (!n1 || n1.tagName != 'IMG' && n1.tagName != 'DIV') return;
	rollovers.get(ul.id).reset();
}
make_active = function (el){
	var all_elms = el.up().childElements();
	all_elms.each( function (s) {
		s.removeClassName('active')}
	);
	el.addClassName('active');
}

highLht = function(el) {
		var toggle = function(tag,attrs){
			//var gross = el.up('div').down(tag);
			var kleine = el.down(tag);
			//if (!gross || !kleine) return;
			if (!kleine) return;
			while (attrs.length) {
				var attr = attrs.shift();
				//gross.setAttribute(attr, kleine.readAttribute(attr));
			}
		}
		if (!el || el.hasClassName('active')) return false;
			make_active(el);
			toggle('img',['src','alt']);
			//toggle('a',['href']);
}

Event.observe(window, 'load', function() {
	/*
	if ($('box1') && !$('description')) 
			$('box1').observe('mouseover', function(event) {
			highLht(Event.findElement(event,'H3'));
		}
	);
	*/
     $$('ul.anim').each( function (s) {
			if (s.empty()) return;
			var first = s.childElements()[0];
			first.addClassName('active');
			//first.down('.img-cont').setStyle({height:'auto'});
            s.setAttribute('id','a_' + s.up('.itema_content').id);
			//rollovers.set (s.id, new animated(s.id));

			rollovers.set (s.id, new animated(s.id));
			s.observe('mouseover', function(event) {
				highLht(Event.findElement(event,'li'));
			} )
			s.up('.content').observe('mouseout', function(event) {
				stopAnim(event,s);
			} )
		}
	);

} );
/** /head scripts **/


/** google analistic **/
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-16975951-1']);
  _gaq.push(['_setDomainName', '.fedpress.ru']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
  })();
/** /google analistic **/ 

 
  
 


