﻿$(document).ready(function(){
    CreateProductZoom();
});

function CreateProductZoom()
{
    var imageControls = $('div#product div.productImages p.imageControls');
    imageControls.prepend($('<span class="zoom">Hover to zoom</span>'));
    
	$("a.zoom").jqzoom({
        xOffset: 8,
        yOffset: 0,
        zoomWidth: 290,
        zoomHeight: 290,
        zoomType: 'reverse',
        title: false,
        showEffect: 'fadein',
        hideEffect: 'fadeout',
        fadeinSpeed: 'medium',
        fadeoutSpeed: 'medium'
    })
    .mouseover(
        function()
        {
            var img = $(this).find('img');
            var alt = img.attr('alt');
            if (alt != null)
            {
                img.data('alt', alt);
                img.attr('alt', '');
            }
            var title = img.attr('title');
            if (title != null)
            {
                img.data('title', title);
                img.removeAttr('title');
            }
        }
    )
    .mouseout(
        function()
        {
            var img = $(this).find('img');
            var alt = img.data('alt');
            if (alt != null)
            {
                img.attr('alt', alt);
                img.removeData('alt');
            }
            var title = img.data('title');
            if (title != null)
            {
                img.attr('title', title);
                img.removeData('title');
            }
        }
    );
}
