window.addEvent('domready', function() {
	$$('#topmenu img').addEvent('mouseenter', function() {
		if (!this.initsrc) this.initsrc = this.src;
		this.src = this.src.replace(/text_/, "texta_");
	}).addEvent('mouseleave', function() {
		this.src = this.initsrc;
	});

	if (document.body.className == 'type12' || document.body.className == 'type2') {
		//catalog
		window.ulopened = $$('li.active div.name a')[0];

		if ($('labelblock')) {

			$('labelblock').addClass('closed').setStyles({display: 'block', cursor: 'pointer'});


			$$('#labelblock .pod').addEvent('click', function(e) {
				lb = $('labelblock_b');

				if ( $('labelblock').className == 'closed' ) {
					e.stop();
					lb.tween('height', lb.getScrollSize().y);
					$('labelblock').setStyle('cursor', '');
					$('labelblock').className = 'opened';
				}

				else if ( $('labelblock').className == 'opened' ) {
					e.stop();
					$('labelblock').className = 'closed';
					$('labelblock').setStyle('cursor', 'block');
					lb.tween('height', 14);
				}

			});

		}

		$$('div.name a').addEvent('click', function(e) {
			opened = window.ulopened.getParent().getParent().getLast();
			cur = this.getParent().getParent().getLast().setStyle('display', 'block');
			cur.link = this;

			if (cur == opened) return true;

			if (cur.className == 'name') {
				e.stop();
				return;
			}

			cur.set('tween', {onComplete: function() {
				location = this.element.link.href;
			}});
			opened.tween('height', 0);
			cur.tween('height', cur.getScrollSize().y);

			window.ulopened = this;
			e.stop();
		});

		$$('ul.thumbs a').addEvent('click', function(e) {
			var newimg_src = this.href.replace(/(.*)\./, '$1_normal.');
			$('bigimage').getFirst().set('href', this.href);
			var newimage = new Asset.image(newimg_src, {'class': 'w439', onload: function() {
				this.setStyle('opacity', 0);
				$(this).inject($('bigimage').getFirst());
				$(this).set('tween', {onComplete: function() {
					$(this).element.getParent().getFirst().destroy();
				}});
				$(this).fade('in');
			}}

			);
			e.stop();
		});


	}



});