//
// imageDetail r1 // 2009.03.27 // jQuery 1.1.2
// <http://exertionist.com/ImageDetail/>
//
/* Copyright (c) 2009 Justin Robert Wehrman (jwehrman@exertionist.com)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
// Tested on Windows Firefox 2+, IE 6+, Opera 9+, Safari 3+ and Google Chrome 1+
//

(function ($) {
    $.fn.imageDetail = function (thumbnailID, fullID, thumbWidth, thumbHeight, fullWidth, fullHeight, pth) {
        return this.each(function() {

            // Create vars for Thumbnail and Full Containers
            var IDthumb = $('#' + thumbnailID);
            var IDfull = $('#' + fullID);

            // mid width/height of thumbnail container
            var MidDisplayWidth = thumbWidth / 2;
            var MidDisplayHeight = thumbHeight / 2;

            // get full / thumb difference
            var widthDiff = fullWidth / thumbWidth;
            var heightDiff = fullHeight / thumbHeight;

            // Get Thumbnail Image path // Create Full Image path from Thumbnail
            var ImageFullPath = pth+"hazardeg600.png";

            // Set Thumbnail Container cursor to crosshair
            $("#CubeMap").css('cursor','crosshair');
		
		// alert("hi");
            // Thumbnail Mouseover Event
            $("#CubeMap").find('.gid18').mouseover(function(event) {

                // Set Full Image as Full Container background-image
                $("#zoomer").css({
                    backgroundImage: 'url(' + ImageFullPath + ')',
                    backgroundRepeat: 'no-repeat',
                    backgroundPosition: '50% 50%'
                });

                // Thumbnail Mousemove Event
                $("#CubeMap").mousemove(function(thumb) {

                    // get Mouse Position over Thumbnail Container
                    var pos = $("#map2").offset();
                    pos.left = parseInt(pos.left);
                    pos.top = parseInt(pos.top);

                    // set Full Image background-position
                    var bgx = (((thumb.pageX - pos.left ) * -1) * widthDiff) +95//+ MidDisplayWidth;
                    var bgy = (((thumb.pageY - pos.top ) * -1) * heightDiff)+95 //+ MidDisplayHeight;
                    $("#zoomer").css('backgroundPosition', bgx + 'px' + ' ' + bgy + 'px');
                });
            });
        });
    };
})(jQuery);