var MAG = Object.extend({}, MAG || {});
MAG.lightbox = {

	initialize: function(options)
	{
		/*

		this.get_pictures();
		this.brum = $$(".galleries_cats img");
		this.parent = new Element('div', { 'class': 'lightbox_overlay', 'style': 'height:'+document.body.offsetHeight+'px' });
		this.child_parent = new Element('div', { 'class': 'parent_img', 'style':'visibility:hidden' });
		this.x_img = new Element('img', { 'src': options.root+'public/images/site_images/close.gif', 'class':'close_img' });
		this.info_browser();
		this.flag = false;
		this.current_ind = 0;
*/


	},


	get_pictures: function()
	{/*
		$$('.galleries_cats img').each(function(el){
			el.observe('click', function (){
				this.show_img(el);
			}.bind(this));
		}.bind(this));
	*/
	},


	show_img: function (what)
	{
		if(this.img && this.flag)this.img.remove();
		this.img = new Element('img', { 'class': 'lightbox', 'src':what.src.replace("insite.", "") });
		this.flag = true;
		document.body.appendChild(this.parent);

		document.body.appendChild(this.child_parent);
		this.child_parent.appendChild(this.x_img);
		this.child_parent.appendChild(this.img);

		if(this.ie6){
			this.child_parent.setStyle({marginTop: '-'+this.img.getHeight()/2+'px', marginLeft: '-'+this.img.getWidth()/2+'px', 'visibility':'visible'});
		}else{
			this.img.observe('load', function (){
				this.child_parent.setStyle({marginTop: '-'+this.img.getHeight()/2+'px', marginLeft: '-'+this.img.getWidth()/2+'px', 'visibility':'visible', 'display':'block'});
			}.bind(this));
		}

		[this.parent, this.x_img].each(function(e) {
			e.observe('click', function (){
				this.hide_img();
			}.bind(this));
		}.bind(this));
	},



	hide_img: function (){
		if(this.flag){
			this.img.remove();
			this.parent.remove();
			this.x_img.remove();
			this.child_parent.remove();
			this.flag = false;
		}
	},


	info_browser: function (){
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 var version=new Number(RegExp.$1) // capture x.x portion and store as a number
		 //this.ie6 = (version == 6) ? true : false;
		}

	}

};



