var enlargeImage = new Class({
	/* 	This Mootools class is made by the fifth generation Lutz, wizzard in the Algo solarsystem.
		Use this with caution for it is entangled with magic from the old times.

		Licence:
		You may not distribute this class too Dark Force (The black energy wave) or any of his
		followers (Absolutely not Zio. For he lives!). You may not use the code in any dark
		or semidark ritual involving the dark side. Please respect my wishes in these matters
		and you may use it in any other way. thanks.

		v. 1.1
	*/
	initialize: function(element,options) {
		this.element = element;
		this.options = options;
		this.enlarge();

		$$('select').each(function(el){
				el.setStyle('zIndex','-99');
			});
	},
	enlarge: function() {

		// There must only be one.
		if($("EnlargedImage")) $("EnlargedImage").remove();

		// Collect position and size information from the element thou clicked upon.
		var coordinates = ($(this.element))?$(this.element).getCoordinates():$('img_framed').getCoordinates();
		var coordinatesTop = coordinates.top;
		var coordinatesLeft = coordinates.left;
		var coordinatesWidth = coordinates.width;
		var coordinatesHeight = coordinates.height;

		var src = ($(this.element))?$(this.element).src:$('img_framed').src;
		// Create an element which will shine upon thee and be embraced by the browser as a larger image.
		var image = new Element('img', {
			'styles': {
				'position': 'absolute',
				'top': '0px',
				'z-index': '-99',
				'cursor': 'pointer'
			},
			'src': src+'&box_width=600',  // <--- 3oxa
			'id': 'EnlargedImage'
		})
		// Let the image turn alive and appear into your browser.
		document.body.appendChild(image)

		// The size of the image is needed for the grand plan and will be saved here.
		imageWidth = image.width;
		imageHeight = image.height;

		// As will the width of the browser.
		var browserWidth = window.getWidth();

		// Let new styles shine down and entagle the image.
		image.setStyles({
			'top': coordinatesTop+"px",
			'left': coordinatesLeft+"px",
			'width': coordinatesWidth+"px",
			'height': coordinatesHeight+"px",
			'z-index': '+99'
		})
		// Calculates the image position if though choose too.
		var position;
		var imageHeight = (imageHeight>0)?imageHeight:600;
		var imageWidth = (imageWidth>0)?imageWidth:600;
		var top = (imageHeight>0)?coordinatesTop:364;

		if(this.options.position == "this") position = (coordinatesTop-(imageHeight/2)+(coordinatesHeight/2));
		else position = (10+this.options.position)+"px";

		// Make it grow,
		// make it rise,
		// it must flow,
		// really nice.

		var animationDuration = this.options.duration;
		var text = this.options.text;
		var enlargeImage = new Fx.Styles(image,{duration: animationDuration,onComplete: function() {

			var imageCoordinates = image.getCoordinates();
			var divBg = ( $('frameit_wall').getStyle('background-color') )
				? $('frameit_wall').getStyle('background-color')
			    :'#fff';
			var div = new Element('div',{
					'styles': {
					'position': 'absolute',
					'top': ((top*.5)-10)+"px",
					'left':	(324-10)+"px",
					'z-index': "+99",
					'padding': '25px',
					'background':'url(/skin/shared/images/loading.gif) 250px 25px no-repeat',
					'background-color': divBg,
					'text-align':'center',
					'vertical-align':'middle',
					'border':'2px solid #ccc',
					'width': 600,
					'height': 'auto'
				}
			});
			image.setStyles({
				'top': "",
				'left': "",
				'width': "",
				'height': "",
				'z-index': '1',
				'position': 'relative'
			})
			var p = new Element('p',{
				'styles': {
					'margin': '0px',
					'padding': '0px'
				}
			});

			image.injectInside(div);
			p.injectInside(div);
			document.body.appendChild(div);
			p.setHTML(text);

			image.addEvent('click', function() {
				document.body.appendChild(image);
				div.remove();
				image.setStyles({
					'top': coordinatesTop+"px",
					'left': coordinatesLeft+"px",
					'width': coordinatesWidth+"px",
					'height': coordinatesHeight+"px",
					'z-index': '+99',
					'position': 'absolute'
				})
				var contractImage = new Fx.Styles(image,{duration: animationDuration,onComplete: function() {
					image.remove();
					if(window.ie6){
					    $$('select').setStyle('opacity',1);
					}


				}});
				contractImage.start({
					'top': [position,coordinatesTop],
					'left': [((browserWidth/2)-(imageWidth/2)),coordinatesLeft],
					'width': [imageWidth,coordinatesWidth],
					'height': [imageHeight,coordinatesHeight]
				});
			});

		}});
		if(window.ie6){
		    $$('select').setStyle('opacity',0);
		}
		enlargeImage.start({
			'top': [coordinatesTop,position.toInt()-60],
			'left': [coordinatesLeft,((browserWidth/2)-(imageWidth/2))],
			'width': [coordinatesWidth,imageWidth],
			'height': [coordinatesHeight,imageHeight]
		});
	}
});