SEQ.Screenshot = function(id, image, fullWidth, fullHeight)
{
	this.id = id;
	this.image = image
	this.fullWidth = fullWidth;
	this.fullHeight = fullHeight;
	this.isThumbnail = true;
	
	this.element = YAHOO.util.Dom.get ( id )
	YAHOO.util.Dom.addClass ( this.element, 'screenshot-zoom' );
	
	YAHOO.util.Event.on ( id, 'click', function(event, obj) { obj.click(); }, this );
};

SEQ.Screenshot.prototype = {
	click: function()
	{
		if ( this.isThumbnail )
		{
			var viewportWidth = YAHOO.util.Dom.getViewportWidth();
			var viewportHeight = YAHOO.util.Dom.getViewportHeight();
			
			YAHOO.util.Dom.setStyle('image-loader', 'visibility', 'visible' );
			YAHOO.util.Dom.setStyle('image-loader-image', 'visibility', 'visible' );
			YAHOO.util.Dom.setXY ( 'image-loader-loading', [viewportWidth / 2 - 100, viewportHeight / 2 - 100] );
			YAHOO.util.Dom.get('image-loader-image').src = this.element.src
			
			YAHOO.util.Dom.setStyle('image-loader-image', 'width', YAHOO.util.Dom.getStyle(this.element, 'width') );
			YAHOO.util.Dom.setStyle('image-loader-image', 'height', YAHOO.util.Dom.getStyle(this.element, 'height') );
			YAHOO.util.Dom.setXY('image-loader-image', YAHOO.util.Dom.getXY(this.element) );
			
			var imageLoader = new YAHOO.util.ImageLoader.group ( null, null, -1 );
			imageLoader.registerSrcImage ( 'image-loader-image', this.image + '.png' );
			imageLoader.fetch ();
			
			var x = 0;
			var y = 0;
			if ( this.fullWidth < viewportWidth )
			{
				x = (viewportWidth - this.fullWidth) / 2;
			}
			if ( this.fullHeight < viewportHeight )
			{
				y = (viewportHeight - this.fullHeight) / 2;
			}

			/*
			var anim = new YAHOO.util.ColorAnim ( 'image-loader', { opacity: { to: 0.30 } } );
			anim.animate ();
			*/
			
			var anim = new YAHOO.util.Motion ( 'image-loader-image', { points: { to: [x, y] },
																						  width: { to: this.fullWidth, unit: 'px' },
																						  height: { to: this.fullHeight, unit: 'px' } }, 0.4 );
			anim.animate ();

			YAHOO.util.Event.on ( 'image-loader-image', 'click', function(event, obj) { obj.click(); }, this ); 
		}
		else
	   {
			var anim = new YAHOO.util.Motion ( 'image-loader-image', { points: { to: YAHOO.util.Dom.getXY(this.element) },
																						  width: { to: YAHOO.util.Dom.getStyle(this.element, 'width').replace('px', ''), unit: 'px' },
																						  height: { to: YAHOO.util.Dom.getStyle(this.element, 'height').replace('px', ''), unit: 'px' } }, 0.4 );
			anim.onComplete.subscribe ( function() {
					YAHOO.util.Dom.setStyle('image-loader-image', 'visibility', 'hidden' );
					YAHOO.util.Dom.setStyle('image-loader', 'visibility', 'hidden' );
					YAHOO.util.Event.removeListener ( 'image-loader-image', 'click' );
				} );
			anim.animate ();
		}
		this.isThumbnail = !this.isThumbnail;
	}
};

SEQ.Screenshot.NAME = 'Screenshot';

YAHOO.util.Event.on ( 'image-loader-image', 'load', function() { YAHOO.util.Dom.setStyle('image-loader', 'visibility', 'hidden' ); } );
