/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Varien
 * @package     js
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
if(typeof Product=='undefined') {
    var Product = {};
}

/*
Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

 */
/********************* IMAGE ZOOMER ***********************/

/**
 * Image zoom control
 *
 * @author      Magento Core Team <core@magentocommerce.com>
 */
//Product.Zoom = Class.create();
Product.Zoom.prototype = {
	initialize: function(element, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){
		$$('.zoom').first().hide();

		this.smoothMove = 3;
		this.currPositionLeft = 0;
		this.currPositionTop = 0;
		this.left = 0;
		this.top = 0;
		this.image    = $(element);
		this.element    = $$('.product-image-zoom').first();
		$('zoomBoxImage').src = this.image.src;
		if($('zoomBoxImage').width > parseInt($('zoom_width_magnific').getValue())) {
			var scale = parseInt($('zoom_width_magnific').getValue()) / $('zoomBoxImage').width;
			$('zoomBoxImage').setStyle({width: $('zoomBoxImage').width * scale + 'px', height: $('zoomBoxImage').height * scale + 'px'});
		}
		if($('zoomBoxImage').height > parseInt($('zoom_height_magnific').getValue())) {
			var scale = parseInt($('zoom_height_magnific').getValue()) / $('zoomBoxImage').height;
			$('zoomBoxImage').setStyle({width: $('zoomBoxImage').width * scale + 'px', height: $('zoomBoxImage').height * scale + 'px'});
		}

		this.source     = {
			large: this.image.src
		}
		
		this.selected = 'small';

		this.options = Object.extend({
			trigger:        null,
			afterZoomIn:    null,
			afterZoomOut:   null
		}, {});

		this.position = this.element.cumulativeOffset();

		this.dimensions = {
			small: {
				width: this.element.getWidth(),
				height: this.element.getHeight()
			},
			big: {
				width: this.image.getWidth(),
				height: this.image.getHeight()
			}
		}
		var imageRatio = this.dimensions.small.width/this.dimensions.big.width;
		this.image.setStyle({width: this.dimensions.small.width + 'px', height: imageRatio * this.dimensions.big.height + 'px'});
		this.element.setStyle({height: imageRatio * this.dimensions.big.height + 'px'});
		this.dimensions.small.height = imageRatio * this.dimensions.big.height;
//		$$('.product-img-box').first().setStyle({height: this.dimensions.big.height, width: this.dimensions.big.width});
		
		this.scaleReport = 1;


		// Large image preloading
		this.preload        = new Image();
		this.preload.id     = 'bigImage';
		this.preload.src    = this.source.large;
		// IE > 6 workarond
		var IEVersion = parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5));
		if(IEVersion > 6) {
			var self = this;
			setTimeout(function(){self.testImg(self)}, 200);
		} else {
			this.preload.onload = this.loaded.bind(this);
		}


		this.loadingGif = new Image();
		this.loadingGif.id = 'loading';
		this.loadingGif.src = $('media_path').getValue() + '/loading.gif';
		
		Element.setStyle(this.loadingGif, { left: ((this.element.getWidth()/2) - 18) + 'px',
											top: ((this.element.getHeight()/2) - 18) + 'px'}
						);

		this.loadingGif.hide();
		this.element.appendChild(this.loadingGif);

		// Wrappers
		this.scroller = (new Element('div')).setStyle({
			overflow: 'hidden',
			width: this.dimensions.small.width + 20 + 'px',
			height: this.dimensions.small.height + 20 + 'px'
		});
		this.element.wrap(this.scroller);
		this.wrapper = (new Element('div').setStyle({
			overflow: 'hidden',
			width: this.dimensions.small.width + 'px',
			height: this.dimensions.small.height + 'px'
		}));



//		alert(((parseInt($('box_width_magnific').getValue())/this.dimensions.big.width) * this.dimensions.small.width) + 'px');
		var areaBoxRatioWidth = parseInt($('box_width_magnific').getValue())/this.dimensions.big.width;
		var areaBoxRatioHeight = parseInt($('box_height_magnific').getValue())/this.dimensions.big.height;
		if(areaBoxRatioWidth > 1) {
			areaBoxRatioWidth = 1;
		}
		if(areaBoxRatioHeight > 1) {
			areaBoxRatioHeight = 1;
		}
		this.areaBoxWidth = areaBoxRatioWidth * this.dimensions.small.width;
		this.areaBoxHeight = areaBoxRatioHeight * this.dimensions.small.height;
		this.areaBox = (new Element('div').setStyle({
			width: this.areaBoxWidth + 'px',
			height: this.areaBoxHeight + 'px',
//			width: $('area_width_magnific').getValue() + 'px',
//			height: $('area_height_magnific').getValue() + 'px',
			position: 'fixed'
		}));
//		this.areaBox.update('areaBox');
		if($('enable_tint').getValue() == 0 && $('enable_soft_focus').getValue() == 0) {
			this.areaBox.setOpacity($('opacity_magnific').getValue()/100);
			this.areaBox.setStyle({backgroundColor:$('hover_image_color').getValue()});
		}
		this.areaBox.setStyle({left:this.position.left + 'px', top:this.position.top + 'px', zIndex:10});

		this.wrapper.appendChild(this.areaBox);
		this.scroller.wrap(this.wrapper);

		if($('enable_soft_focus').getValue() == 1) {
			if(typeof(this.softFocusBox) == 'undefined') {
				this.softFocusBox = new Image();
				Element.setStyle(this.softFocusBox, {
					width: this.wrapper.getStyle('width'),
					height: this.wrapper.getStyle('height'),
					left: this.position.left + 2 + 'px',
					top: this.position.top + 2 + 'px',
	//				display: 'none',
					position: 'absolute',
					zIndex: 10
				});
				this.softFocusBox.id     = 'softFocusBox';
				this.softFocusBox.src = this.image.src;
				this.softFocusBox.setOpacity(0.5);
				this.softFocusBox.hide();
				this.wrapper.appendChild(this.softFocusBox);
			}
			if(typeof(this.areaBoxScroller == 'undefined')) {
				this.areaBoxScroller = (new Element('div').setStyle({
					width: this.areaBoxWidth + 'px',
					height: this.areaBoxHeight + 'px',
					position: 'fixed',
					overflow: 'hidden',
					border: '2px solid red',
					zIndex: 0
				}));
				this.areaBoxScroller.setAttribute('id', 'areaBoxScroller');
				this.areaBoxScroller.setAttribute('href', '#zoomBox');
				this.image2        = new Image();
				this.image2.id     = 'image2';
				this.image2.src    = this.image.src;
	//				this.image2.setStyle();
				Element.setStyle(this.image2, {width: this.image.getStyle('width'), height: this.image.getStyle('height'), zIndex: 0});
				this.areaBoxScroller.appendChild(this.image2);
				document.body.appendChild(this.areaBoxScroller);
	/*
				this.areaBoxScrollerWrapper = (new Element('div').setStyle({
					width: parseInt($('area_width_magnific').getValue()) + 2 + 'px',
					height: parseInt($('area_height_magnific').getValue()) + 2 + 'px',
					position: 'fixed',
					overflow: 'hidden',
					border: '2px solid red',
					zIndex: 1
				}));
				document.body.appendChild(this.areaBoxScrollerWrapper);
	*/
				this.areaBoxScroller.wrap(this.areaBox);
	//			this.areaBoxScrollerWrapper.wrap(this.areaBox);
			}				
		}

		if($('enable_tint').getValue() == 1) {
			if(typeof(this.tintBox) == 'undefined') {
				this.tintBox = (new Element('div').setStyle({
					width: this.wrapper.getStyle('width'),
					height: this.wrapper.getStyle('height'),
					backgroundColor: $('tint_color').getValue(),
					left: this.position.left + 'px',
					top: this.position.top + 'px',
					display: 'none',
					position: 'absolute',
					zIndex: 10
				}));
				this.wrapper.appendChild(this.tintBox);
			}
			if(typeof(this.areaBoxScroller == 'undefined')) {
				this.areaBoxScroller = (new Element('div').setStyle({
					width: this.areaBoxWidth + 'px',
					height: this.areaBoxHeight + 'px',
					position: 'fixed',
					overflow: 'hidden',
					zIndex: 0
				}));
				this.areaBoxScroller.setAttribute('id', 'areaBoxScroller');
				this.areaBoxScroller.setAttribute('href', '#zoomBox');
				this.image2        = new Image();
				this.image2.id     = 'image2';
				this.image2.src    = this.image.src;
//				this.image2.setStyle();
				Element.setStyle(this.image2, {width: this.image.getStyle('width'), height: this.image.getStyle('height'), zIndex: 0});
				this.areaBoxScroller.appendChild(this.image2);
				document.body.appendChild(this.areaBoxScroller);
				this.areaBoxScroller.wrap(this.areaBox);
			}				
		}

//		this.areaBox.absolutize();
		this.areaBox.hide();
		this.areaBox.setAttribute('id', 'areaBox');
		this.areaBox.setAttribute('href', '#zoomBox');

//		alert(this.areaBox.getStyle('background-color'));
		this.bigScroller = (new Element('div')).setStyle({
			overflow: 'hidden',
			width: parseInt($('box_width_magnific').getValue()) + 15 + 'px',
			height: parseInt($('box_height_magnific').getValue()) + 12 + 'px',
//2px solid #000
			border: $('border_magnified').getValue(),
			backgroundColor:'white'
		});
		this.bigScroller.appendChild(this.preload);
		this.bigWrapper = (new Element('div').setStyle({
//            overflow: 'hidden',
		}));
		this.bigWrapper.absolutize();
		this.bigScroller.wrap(this.bigWrapper);
		this.bigWrapper.setStyle({left:this.position.left +  this.dimensions.small.width + 'px', top:this.position.top + 'px', zIndex:10, backgroundColor:'white', display: 'none', width: parseInt($('box_width_magnific').getValue()) + 15 + 'px', height: parseInt($('box_height_magnific').getValue()) + 12 + 'px', zIndex:10000});
//		alert($('hover_image_color').getValue());
//		this.bigWrapper.update('bigWrapper');
		this.bigWrapper.hide();
		this.bigWrapper.setAttribute('id', 'bigWrapper');
		this.areaBox.setAttribute('id', 'areaBox');

		if($('image_name_magnific').getValue() == 1) {
			this.imageName = (new Element('div')).setStyle({
				top: '0px',
				left: '0px',
				width: parseInt($('box_width_magnific').getValue()) + 15 + 'px',
				backgroundColor: $('image_bottom_color').getValue(),
				border: $('border_magnified').getValue(),
				borderTopWidth: '0px'
			});
			this.bigScroller.setStyle({borderBottomWidth: '0px'});
			this.imageName.id = 'imageName';
			var imgAlt = this.image.readAttribute('alt');
			this.imageName.update(imgAlt);
			this.bigWrapper.appendChild(this.imageName);
			$('zoomBoxImageName').update(imgAlt);
		}
		
		if($('display_default_image').getValue() === '1' && typeof($$('.more-views').first()) !== 'undefined') {
			var string = '';
			string = this.image.src;
			var splittedArray = string.split('/');
			var imgName = splittedArray[splittedArray.length-1];

			var main_image_thumbnail = new Element('div').setStyle({float: 'left'});
			var the_thumbnail_itself = new Element('img').setStyle({cursor: 'pointer'});
			the_thumbnail_itself.onclick = function(){popWin('/01/', '', '');}
			main_image_thumbnail.appendChild(the_thumbnail_itself);
			main_image_thumbnail.addClassName('more-views');
			$$('.more-views').first().childElements()[1].insert({before: main_image_thumbnail});
			var height = $$('.more-views').first().childElements()[2].childElements()[0].childElements()[0].childElements()[0].getHeight();
			var width = $$('.more-views').first().childElements()[2].childElements()[0].childElements()[0].childElements()[0].getWidth();
			the_thumbnail_itself.setStyle({width: width + 'px', height: height + 'px'});
//			var thumbnail_url = $$('.more-views').first().childElements()[2].childElements()[0].childElements()[0].childElements()[0].src;
//			alert(thumbnail_url)
//			var thumbnail_url_array = thumbnail_url.split('/');
//			thumbnail_url_array[thumbnail_url_array.length-1] = imgName;
//			the_thumbnail_itself.src = thumbnail_url_array.join('/');
			the_thumbnail_itself.src = this.image.src;
		}



		document.body.appendChild(this.bigWrapper);
		FancyZoomBox.directory = $('media_path').getValue(); // no need for trailing slash
		$('zoomBox').setStyle({width: $('zoomBoxImage').getStyle('width')});
		if($('enable_tint').getValue() == 1 || $('enable_soft_focus').getValue() == 1) {
			new FancyZoom('areaBoxScroller');
		} else {
			new FancyZoom('areaBox');
		}
		

		// Zoom onclick on additional trigger
		if (this.options.trigger) {
			$(this.options.trigger).observe('click', this.click.bindAsEventListener(this));
		}
		
		document.observe('click',       this.click.bindAsEventListener(this));
		document.observe('mousemove',   this.move.bindAsEventListener(this));

		var div = $('areaBox');
		div.onmouseover = function()   {
			mouseIsOver = true;
		};
		div.onmouseout = function()   {
			mouseIsOver = false;
		}

	},


	click: function (event) {
//		if((event.pointerX() > this.position.left) && (event.pointerX() < this.position.left + this.dimensions.small.width) && (event.pointerY() > this.position.top) && (event.pointerY() < this.position.top + this.dimensions.small.height)) {
//			alert('yo');
			this.bigWrapper.hide();
//			new FancyZoom($('image'));
//		}
/*
		event.stop();
		switch (this.selected) {
			case 'small':
				if (this.element.loaded) {
					this.image.setStyle({width: this.dimensions.big.width + 'px', height: this.dimensions.big.height + 'px'});
					this.element.setStyle({height: this.dimensions.big.height + 20 + 'px', width: this.dimensions.big.width + 20 + 'px', overflow: 'hidden'});
					this.element.show();
					this.move(event);
					if (this.options.afterZoomIn) {
						this.options.afterZoomIn();
					}
					this.selected = 'big';
				} else {                    
					this.element.hide();
					// Periodically check if target image has loaded
					this.click.bind(this).delay(0.5, event);
				}
			break;
			case 'big':
				this.image.setStyle({width: this.dimensions.small.width + 'px', height: this.dimensions.small.height + 'px'});
				this.element.setStyle({height: this.dimensions.small.height + 'px', width: this.dimensions.small.width + 'px', overflow: 'hidden'});
				if (this.options.afterZoomOut) {
					this.options.afterZoomOut();
				}
				this.selected = 'small';
				this.scroller.scrollLeft = 0;
				this.scroller.scrollTop  = 0;
			break;
		}
*/
	},


	controlLoop: function() {
		if($('image_name_magnific').getValue() == 1) {
			var imgAlt = this.image.readAttribute('alt');
			this.imageName.update(imgAlt);
			$('zoomBoxImageName').update(imgAlt);
		}


//		var x = this.mx - this.position.left;
//		var y = this.my - this.position.top;
//			$('track_hint').update(event.pointerY());
//			this.scroller.scrollLeft = x * this.scaleReport - x;
//			this.scroller.scrollTop  = y * this.scaleReport - y;

//			if(this.enableAreaBox == true) {
		var left = this.left;
		var top = this.top;
		if(this.mx <= this.position.left + (this.areaBoxWidth/2)) {
			left = this.position.left;
		} else if(this.mx >= (this.position.left + this.dimensions.small.width - (this.areaBoxWidth/2))) {
			left = this.position.left + this.dimensions.small.width - this.areaBoxWidth;
		} else if(this.mx < (this.position.left + this.dimensions.small.width - (this.areaBoxWidth/2))) {
			left = this.mx - (this.areaBoxWidth/2);
		}

		if(this.my <= this.position.top + (this.areaBoxHeight/2)) {
			top = this.position.top;
		} else if(this.my >= (this.position.top + this.dimensions.small.height - (this.areaBoxHeight/2))) {
			top = this.position.top + this.dimensions.small.height - this.areaBoxHeight;
		} else if(this.my < (this.position.top + this.dimensions.small.height - (this.areaBoxHeight/2))) {
			top = this.my - (this.areaBoxHeight/2);
		}

		this.left = left;
		this.top = top;

		this.areaBox.setStyle({left: left + 'px', top: top + 'px', position: 'absolute'});
		if(typeof(this.areaBoxScroller) != 'undefined') {
			this.areaBoxScroller.scrollLeft = left - this.position.left;
			this.areaBoxScroller.scrollTop = top - this.position.top;
		}
		var destPositionLeft = (left - this.position.left) * this.scaleReport;
		var destPositionTop = (top - this.position.top) * this.scaleReport;

		if($('enable_smooth').getValue() == 1) {

			this.currPositionLeft += (destPositionLeft - this.currPositionLeft) / this.smoothMove;
			this.currPositionTop += (destPositionTop - this.currPositionTop) / this.smoothMove;
			
			this.bigScroller.scrollLeft = this.currPositionLeft;
			this.bigScroller.scrollTop  = this.currPositionTop;

			var copyThis = this;
			this.controlTimer = setTimeout(function () {
				copyThis.controlLoop();
			}, 30);
		} else {
			this.bigScroller.scrollLeft = destPositionLeft;
			this.bigScroller.scrollTop  = destPositionTop;
		}
	},

	move: function (event) {
		if((event.pointerX() > this.position.left) && (event.pointerX() < this.position.left + this.dimensions.small.width) && (event.pointerY() > this.position.top) && (event.pointerY() < this.position.top + this.dimensions.small.height) && mouseIsOver) {
			this.mx = event.pointerX();
			this.my = event.pointerY();
			if(!this.timerStarted) {

				if(typeof(this.softFocusBox) != 'undefined') {
					this.softFocusBox.show();
				}
				this.areaBox.show();
				if($('zoom').getStyle('display') == 'none') {
					this.bigWrapper.appear({duration: 0.5});
				} else {
					this.bigWrapper.hide();
				}
				if(typeof(this.tintBox) != 'undefined') {
					this.tintBox.appear({duration: 0.5, from: 0, to:0.3});
				}
				this.timerStarted = true;
				var copyThis2 = this;
				copyThis2.controlLoop();
			} else if($('enable_smooth').getValue() == 0) {
				this.controlLoop();
			}


//				$('track_hint').update('left=' + left + ', this.position.left=' + this.position.left + ',this.scaleReport=' + this.scaleReport);


//				this.enableAreaBox = false;
//			}
/*
			if(areaBoxOffset.left >= this.position.left && (areaBoxOffset.left + 100) <= (this.position.left + this.dimensions.small.width) && areaBoxOffset.top >= this.position.top && (areaBoxOffset.top + 50) <= (this.position.top + this.dimensions.small.height)) {
				this.areaBox.setStyle({left: event.pointerX() - 50 + 'px', top: event.pointerY() - 25 + 'px'});
			}
*/
/*			
			else {
				if(areaBoxOffset.left < this.position.left || areaBoxOffset.left == this.position.left) {
					this.areaBox.setStyle({left: this.position.left + 'px'});
				}
			}
*/

		} else {
			if(this.timerStarted) {
				if(typeof(this.tintBox) != 'undefined') {
					this.tintBox.fade({duration: 0.5});
				}
				this.bigWrapper.fade({duration: 0.5});
				this.areaBox.hide();
				if(typeof(this.softFocusBox) != 'undefined') {
					this.softFocusBox.hide();
				}
			}
//			this.bigWrapper.hide();
			this.enableAreaBox = true;
			if($('enable_smooth').getValue() == 1) {
				clearTimeout(this.controlTimer);
			}
			this.timerStarted = false;
		}

	},

	loaded: function () {
		this.element.loaded = true;
		this.scaleReport = this.dimensions.big.width / this.dimensions.small.width;
	},

	testImg: function (self) {
		if($('bigImage').complete != null && $('bigImage').complete == true) { 
			this.element.loaded = true;
			this.scaleReport = this.dimensions.big.width / this.dimensions.small.width;
			return;
		}
		setTimeout(function(){testImg(self)}, 200);
	}
}
function popWin(url,win,para) {
	var splittedArray = url.split('/');
	var imgId = splittedArray[splittedArray.length-2];
	if($('image' + imgId).getValue()) {
		var preload    = new Image();
		preload.src    = $('image' + imgId).getValue();

		// IE > 6 workarond
		var IEVersion = parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5));
		if(IEVersion > 6) {
			setTimeout(loaded, 200);
		} else {
			preload.onload = loaded;
		}

		$('image').src = $('image' + imgId).getValue();
		if($('enable_tint').getValue() == 1 || $('enable_soft_focus').getValue() == 1) {
			$('image2').src = $('image').src;
		}
		if($('enable_soft_focus').getValue() == 1) {
			$('softFocusBox').src = $('image').src;
		}
		$('image').writeAttribute('alt', $('image_alt' + imgId).getValue());
		$('bigImage').src = $('image' + imgId).getValue();
		$('zoomBoxImage').src = $('image' + imgId).getValue();
		$('loading').show();
	} else {
		var win = window.open(url,win,para);
		win.focus();
	}
}

function loaded() {
	$('loading').hide();
	if($('zoomBoxImage').width > parseInt($('zoom_width_magnific').getValue())) {
		var scale = parseInt($('zoom_width_magnific').getValue()) / $('zoomBoxImage').width;
		$('zoomBoxImage').setStyle({width: $('zoomBoxImage').width * scale + 'px', height: $('zoomBoxImage').height * scale + 'px'});
	}
	if($('zoomBoxImage').height > parseInt($('zoom_height_magnific').getValue())) {
		var scale = parseInt($('zoom_height_magnific').getValue()) / $('zoomBoxImage').height;
		$('zoomBoxImage').setStyle({width: $('zoomBoxImage').width * scale + 'px', height: $('zoomBoxImage').height * scale + 'px'});
	}
	$('zoomBox').setStyle({width: $('zoomBoxImage').getStyle('width')});
}

Effect.SmoothScrollMagnific = Class.create();
Object.extend(Object.extend(Effect.SmoothScrollMagnific.prototype, Effect.Base.prototype), {
	initialize: function (element) {
		this.element = $(element);
		var options = Object.extend({ x: 0, y: 0, mode: 'absolute' } , arguments[1] || {});
		this.start(options);
    },

	setup: function () {
		this.originalLeft = this.element.scrollLeft;
		this.originalTop  = this.element.scrollTop;

		if (this.options.mode == 'absolute') {
			this.options.x -= this.originalLeft;
			this.options.y -= this.originalTop;
        }
    },

	update: function (position) {
		this.element.scrollLeft = this.options.x * position + this.originalLeft;
		this.element.scrollTop  = this.options.y * position + this.originalTop;
    }
});



window.onload = initDivMouseOver;
var mouseIsOver = false;
function initDivMouseOver()   {
	var div = $$('.product-image-zoom').first();
	if(div) {
		div.onmouseover = function()   {
			mouseIsOver = true;
		};
	}
}
