//
function fade_in(el, dur)
{
	// ie eseten csak sima kirakas lehet, amig nincs fix a fade antialias bugra
	if (Browser.ie)
		el.setStyle('display', 'block');
	else
	{
		// eloszor nemlatszik
		el.setStyle('opacity', 0);
		// effektet gyartunk neki
		var dFX = new Fx.Tween(el, {duration: dur});
		// blockra
		el.setStyle('display', 'block');
		// fade-in
		dFX.start('opacity', 0, 1);
	}

}
//

// full oldal cover  
var FullCover = new Class
({
	// johet onclick fuggveny
	initialize: function(onclick_function)
	{
		//
		this.cover = $('Overlay');
		this.coverId = 'Overlay';

		// stilus
		this.cover.set(
			{'styles':{
				'width':window.getScrollSize().x,
				'height':window.getScrollSize().y,
				'opacity': 0.5
			}}
		)

		// onclick
		if (onclick_function)
			this.cover.addEvent('click', function(){eval(onclick_function())});
	},


	// bekapcsol
	show: function()
	{
		this.cover.setStyle('display', 'block');

		// selectek elrejtese ie6 alatt
		if (Browser.ie6)
		{
			this.selects = document.getElements('select');
			this.selects.each
			(
			function(s)
			{
				s.setStyle('visibility', 'hidden');
			}
			)
		}
	},


	// kikapcsol
	hide: function()
	{
		this.cover.setStyle('display', 'none');
		this.cover.removeEvent('click');

		// selectek visszarakasa ie6 alatt
		if (Browser.ie6)
		{
			this.selects.each
			(
			function(s)
			{
				s.setStyle('visibility', 'visible');
			}
			)
		}
	},


	// meret beallitas
	updateSize: function(w, h)
	{
		if (w>0)
			this.cover.setStyle('width', w);
		if (h>0)
			this.cover.setStyle('height', h);
	},


	// meret reset: az ablakhoz igazija
	resetSize: function()
	{
		this.cover.setStyle('width', window.getScrollSize().x);
		this.cover.setStyle('height', window.getScrollSize().y);
	}
});




//
var EnlargePics = new Class
({

	initialize: function()
	{
		this.picLinks = $$('a.PicThumb');
		if (this.picLinks.length>0)
		{
			// elemek
			this.gallery = $('Img_layer');
			this.galleryTable = this.gallery.getElement('table');
			this.galleryLink = this.gallery.getElement('a');
			this.galleryPic = this.gallery.getElement('img');

			// overlay
			this.cover = new FullCover();
			$(this.cover.coverId).addEvent('click', function(){this.close()}.bind(this));

			// bezaras a kepen, tablazaton
			this.galleryLink.addEvent('click', function(e){e.stop();this.close()}.bind(this));
			this.galleryTable.addEvent('click', function(e){e.stop();this.close()}.bind(this));

			// megnyitasok
			this.picLinks.each(function(a)
			{
				a.addEvent('click', function(e)
				{
					e.stop();
					var src = a.getElement('img').get('src');
					src = src.replace('.thu', '.gal');
					this.showPic(src);
				}.bind(this))
			}.bind(this))
		}
	},


	showPic: function(src)
	{
		// y pos kozepre az ablakhoz
		ypos = window.getScroll().y + ( (window.getSize().y/2)-510/2 );
		this.gallery.setStyle('top', ypos);
		this.galleryPic.set('src', src);
		this.gallery.setStyle('display', 'block');
		this.cover.show();

	},


	close: function()
	{
		this.galleryPic.set('src', '');
		this.gallery.setStyle('display', 'none');
		this.cover.hide();
	}

});
//





//
var picPopup = new Class
({
	initialize: function()
	{
		// elemek
		this.gallery = $('Img_layer');
		this.galleryTable = this.gallery.getElement('table');
		this.galleryLink = this.gallery.getElement('a');
		this.galleryPic = this.gallery.getElement('img');

		// overlay
		this.cover = new FullCover();
		$(this.cover.coverId).addEvent('click', function(){this.close()}.bind(this));

		// bezaras a kepen, tablazaton
		this.galleryLink.addEvent('click', function(e){e.stop();this.close()}.bind(this));
		this.galleryTable.addEvent('click', function(e){e.stop();this.close()}.bind(this));
	},


	showPic: function(src)
	{
		// y pos kozepre az ablakhoz
		ypos = window.getScroll().y + ( (window.getSize().y/2)-510/2 );
		this.gallery.setStyle('top', ypos);
		this.galleryPic.set('src', src);
		this.gallery.setStyle('display', 'block');
		this.cover.show();
	},


	close: function()
	{
		this.galleryPic.set('src', '');
		this.gallery.setStyle('display', 'none');
		this.cover.hide();
	}

});
//






