var EnlargeImage = new Class({
	initialize: function(element,options) {
		this.options = options;
		this.enlarge(element,this.options.duration,this.options.position);
	},
	enlarge: function(element,duration,position) {
		var coordinates = $(element).getCoordinates();
		
		var image = document.createElement("img");
			image.src = element.src;
			image.style.position = "absolute";
			image.style.top = "0px";
			image.style.zIndex = "-10";
			
			document.body.appendChild(image);
			image_width = image.width;
			image_height = image.height;
		var browser_width = window.getWidth();
			
			image.style.top = coordinates.top+"px";
			image.style.left = coordinates.left+"px";
			image.style.width = coordinates.width+"px";
			image.style.cursor = "pointer";
			image.style.border = "medium solid #aea074";
			image.style.zIndex = "1";
			
		if(position == "this") topPosition = (coordinates.top-(image_height/2)+(coordinates.height/2));
		else topPosition = position+"px";
			
		var enlargeImage = new Fx.Styles(image,{duration: duration,onComplete: function() {
			image.onclick = function() { 
				var contractImage = new Fx.Styles(image,{duration: duration,onComplete: function() {
					document.body.removeChild(image);
				}});
				contractImage.start({
					'top': [topPosition,coordinates.top],
					'left': [((browser_width/2)-(image_width/2)),coordinates.left],
					'width': [image_width,coordinates.width],
					'height': [image_height,coordinates.height]
				});
			}
		}});
		enlargeImage.start({
			'top': [coordinates.top,topPosition],
			'left': [coordinates.left,((browser_width/2)-(image_width/2))],
			'width': [coordinates.width,image_width],
			'height': [coordinates.height,image_height]
		});
	}
});