Event.observe(window, 'load',
	function() { 
		$$('.zoomable').each( function(item) {
			new ZoomImage(item, 69, 29, 138, 58);
		} );
		$$('.rotationLogo').each( function(item) {
			new ZoomImage(item.down(1).next(), 139, 59, 194, 83);
		} );
	}
);
	

var ZoomImage = Class.create();
Object.extend(
	ZoomImage.prototype, {
		initialize: function(img, width, height, zoomWidth, zoomHeight) {
			this._img = img;
			this._zoomWidth = zoomWidth;
			this._zoomHeight = zoomHeight;
			this._width = width;
			this._height = height;
			
			this._over = false;

			this._img.setOpacity(0);
			this._img.show();

			this._eL1 = this.mouseOver.bindAsEventListener(this);
			this._eL2 = this.mouseOut.bindAsEventListener(this);	
			Event.observe(this._img, 'mouseover', this._eL1);
		},
		mouseOver: function(mouseEvent) {
			if ((!this._over)) {
				Event.stopObserving(this._img, 'mouseover', this._eL1);
				Event.observe(this._img, 'mouseout', this._eL2);	
				
				this._over = true;
				
				//this._img.setOpacity(1);
				
				this._img.addClassName('ontop');
				this._img.up().addClassName('ontop');
				this._img.up(1).addClassName('ontop');
				//this._img.up(2).addClassName('ontop');
				//this._img.up(3).addClassName('ontop');
				//this._img.up(4).addClassName('ontop');
				//this._img.up(5).addClassName('ontop');
				
				
				
				style = 'width:' + this._zoomWidth + 'px;height:' + this._zoomHeight + 'px;top:' + ((this._height - this._zoomHeight )/2) + 'px;left:' + ((this._width - this._zoomWidth )/2) + 'px;';
				
				try {
					this._effect.cancel()
		
				} catch (e) {
					
				}
				this._effect = 	new Effect.Parallel(
					[
						new Effect.Opacity( this._img, { sync: true, from: 0, to: 1 }),
						new Effect.Morph( this._img, {sync: true, style: style}	)
					],
					{
						duration: 0.5
						
					}
				);
				
			}
		},
		mouseOut: function(mouseEvent) {
			if ((this._over)) {
				Event.observe(this._img, 'mouseover', this._eL1);
				Event.stopObserving(this._img, 'mouseout', this._eL2);
				
				this._over = false;
				
				//this._img.setOpacity(0);
				
				
				this._img.removeClassName('ontop');
				this._img.up().removeClassName('ontop');
				this._img.up(1).removeClassName('ontop');								
				//this._img.up(2).removeClassName('ontop');								
				//this._img.up(3).removeClassName('ontop');								
				//this._img.up(4).removeClassName('ontop');								
				//this._img.up(5).removeClassName('ontop');								

				
				
				
				style = 'width:' + (this._width) + 'px;height:' + (this._height) + 'px;top:0px;left:0px;';

				try {
					this._effect.cancel()
				} catch (e) {
					
				}
				this._effect = 	new Effect.Parallel(
					[
						new Effect.Opacity( this._img, { sync: true, from: 1, to: 0 }),
						new Effect.Morph( this._img, { sync: true, style: style } )
					],
					{
						duration: 0.5
					}
				);
				
			}
		}
	}
);
