﻿/*
*		Modified by Kayam for Suntra.ca for Banga Photography @09/09
*       Developed by Justin Mead
*       ©2009 MeadMiracle
*		www.meadmiracle.com / meadmiracle@gmail.com
*       Version 1.0
*       Testing: IE7/Windows XP
*                Firefox/Windows XP
*       Licensed under the Creative Commons GPL http://creativecommons.org/licenses/GPL/2.0/
*/
(function($) {
    $.galleryUtility = {};
    $.galleryUtility.centerImage = {};
    $.galleryUtility.rightImage = {};
    $.galleryUtility.leftImage = {};
    $.galleryUtility.rightImageStorage = {};
    $.galleryUtility.leftImageStorage = {};
    $.galleryUtility.zoomImage = {};
    $.galleryUtility.gallery = {};
    $.galleryUtility.Options = {
        Lheight: 400,
        Lwidth: 600,
        Lshrink:
                        function(dimension) {
                            return dimension * 0.70;
                        },
			
        Pheight: 450,
        Pwidth: 350,
        Pshrink:
                        function(dimension) {
                            return dimension * 0.70;
                        },
			
        defaultLayout: 'landscape',
        startClass: 'start',
        slideSpeed: 'slow',
        gutterWidth: 10
    };

    $.fn.slidingGallery = function(options) {
        //global settings
        $.extend($.galleryUtility.Options, options);
        $.galleryUtility.gallery = $(this).css('cursor', 'pointer');
        $.galleryUtility.definePositions();
      
        //eliminate overflow
        $('#gallery_content').css('overflow', 'hidden');

        //setup existing images
        var lastIndex = 0;
        var gallerySize = $.galleryUtility.gallery.each(function(i) {
	
            $(this).attr({'index': i, 'prev': (i - 1), 'next': (i + 1)}).css('position', 'absolute');
            if (($(this).attr('layout') !== 'portrait') && ($(this).attr('layout') !== 'landscape')) {
                $(this).attr('layout', $.galleryUtility.Options.defaultLayout);
            }
            lastIndex = i;
        }).hide().size();

		// update html with GalleryName
		var galleryName = $('.gallery').attr('id');
		$("#galery_name").html(galleryName);

		// update html with total images
		$("#gallery_info .total_pictures").html(gallerySize);
        
		//fill in gallery with duplicates until there are at least 7
        var currIndex = 0;
        while (gallerySize < 7) {
            var $clone = $.galleryUtility.gallery.filter('[index=' + currIndex + ']').clone().attr({
                'index': lastIndex + 1,
                'prev': lastIndex,
                'next': lastIndex + 2
            }).removeClass($.galleryUtility.Options.startClass);
            $.galleryUtility.gallery.filter('[index=' + (lastIndex) + ']').after($clone);
            $.galleryUtility.gallery = $.galleryUtility.gallery.add('img[index=' + (lastIndex + 1) + ']');
            lastIndex++;
            currIndex++;
            gallerySize++;
        }
        $.galleryUtility.gallery.filter('[index=' + lastIndex + ']').attr('next', 1);
        $.galleryUtility.gallery.filter('[index=0]').attr('prev', lastIndex);

		var startIndex = 0;
        //set images $.galleryUtility.gallery.filter('[index=' + startIndex + ']').attr('next', 2).show()
		var cimage = $.galleryUtility.gallery.filter('[index=' + startIndex + ']').show();
        $.galleryUtility.setCenter(cimage);
        $.galleryUtility.setLeft($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.centerImage.image.attr('prev') + ']').show());
        $.galleryUtility.setRight($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.centerImage.image.attr('next') + ']').show());
        $.galleryUtility.setLeftStorage($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.leftImage.image.attr('prev') + ']'));
        $.galleryUtility.setRightStorage($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.rightImage.image.attr('next') + ']'));
	
		var alreadydoingit = 0;
		//add mousewheel control
		$('.gallery')
			.mousewheel(function(event, delta) {
				if (delta > 0) {
					$.galleryUtility.slideRight();
				} else if (delta < 0) {
					$.galleryUtility.slideLeft();
				}
				return false; // prevent default
			});
        //bind events
		   $('#gallery_right').click(function(){
			$.galleryUtility.slideLeft();
		});
		   $('#gallery_left').click(function(){
			$.galleryUtility.slideRight();
		});
		$("#gallery_left").mouseover(function(){ $('#left_arrow').show(); }).mouseout(function(){ //$('#left_arrow').hide();
			
			});
		$("#gallery_right").mouseover(function(){ $('#right_arrow').show(); }).mouseout(function(){ // $('#right_arrow').hide(); 
		});

        $.galleryUtility.leftImage.image.one('click', $.galleryUtility.slideRight);
        $.galleryUtility.rightImage.image.one('click', $.galleryUtility.slideLeft);
	//	$.galleryUtility.centerImage.image.one('click', $.galleryUtility.zoomIn);
        return $(this);
    };

 $.galleryUtility.zoomIn = function() {
        $.galleryUtility.gallery.unbind();
		
    };



    $.galleryUtility.slideRight = function() {
		$("#loader").hide();
        var liLeft = $.galleryUtility.leftImage.left($.galleryUtility.leftImageStorage.image, $.galleryUtility.leftImage.image);
        var riLeft = $.galleryUtility.rightImage.left($.galleryUtility.leftImage.image);
        var risLeft = $.galleryUtility.rightImageStorage.left($.galleryUtility.centerImage.image);
        if ($.galleryUtility.leftImageStorage.image.attr('layout') === 'landscape') {
            $.galleryUtility.leftImageStorage.image.animate({
                'top': $.galleryUtility.leftImage.Ltop,
                'left': liLeft,
                'height': $.galleryUtility.leftImage.Lheight,
                'width': $.galleryUtility.leftImage.Lwidth,
                'opacity': 'show'
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideRight);
            });
        } else {
            $.galleryUtility.leftImageStorage.image.animate({
                'top': $.galleryUtility.leftImage.Ptop,
                'left': liLeft,
                'height': $.galleryUtility.leftImage.Pheight,
                'width': $.galleryUtility.leftImage.Pwidth,
                'opacity': 'show'
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideRight);
            });
        }
        if ($.galleryUtility.leftImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.leftImage.image.unbind().animate({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ltop,
                'left': $.galleryUtility.centerImage.Lleft,
                'height': $.galleryUtility.centerImage.Lheight,
                'width': $.galleryUtility.centerImage.Lwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
           //    $(this).one('click', $.galleryUtility.zoomIn);
            });
        } else {
            $.galleryUtility.leftImage.image.unbind().animate({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ptop,
                'left': $.galleryUtility.centerImage.Pleft,
                'height': $.galleryUtility.centerImage.Pheight,
                'width': $.galleryUtility.centerImage.Pwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
           //    $(this).one('click', $.galleryUtility.zoomIn);
            });
        }
        if ($.galleryUtility.centerImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.centerImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImage.Ltop,
                'left': riLeft,
                'height': $.galleryUtility.rightImage.Lheight,
                'width': $.galleryUtility.rightImage.Lwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideLeft);
            });
        } else {
            $.galleryUtility.centerImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImage.Ptop,
                'left': riLeft,
                'height': $.galleryUtility.rightImage.Pheight,
                'width': $.galleryUtility.rightImage.Pwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideLeft);
            });
        }
        if ($.galleryUtility.rightImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.rightImage.image.unbind().animate({
                'top': $.galleryUtility.rightImageStorage.Ltop,
                'left': risLeft,
                'height': $.galleryUtility.rightImageStorage.Lheight,
                'width': $.galleryUtility.rightImageStorage.Lwidth,
                'opacity': 'hide'
            },
            $.galleryUtility.Options.slideSpeed, 'linear');
        } else {
            $.galleryUtility.rightImage.image.unbind().animate({
                'top': $.galleryUtility.rightImageStorage.Ptop,
                'left': risLeft,
                'height': $.galleryUtility.rightImageStorage.Pheight,
                'width': $.galleryUtility.rightImageStorage.Pwidth,
                'opacity': 'hide'
            },
         	$.galleryUtility.Options.slideSpeed, 'linear');
        }
        $.galleryUtility.rightImageStorage.image = $.galleryUtility.rightImage.image;
        $.galleryUtility.rightImage.image = $.galleryUtility.centerImage.image;
        $.galleryUtility.centerImage.image = $.galleryUtility.leftImage.image;
        $.galleryUtility.leftImage.image = $.galleryUtility.leftImageStorage.image;
        $.galleryUtility.setLeftStorage($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.leftImageStorage.image.attr('prev') + ']'));
		var currentpic_num = $.galleryUtility.centerImage.image.attr('index');
			// update html with current center pic
			$("#gallery_info .picture_number").html(currentpic_num);		
 };

    $.galleryUtility.slideLeft = function() {
		$("#loader").hide();
        var riLeft = $.galleryUtility.rightImage.left($.galleryUtility.rightImage.image);
        var liLeft = $.galleryUtility.leftImage.left($.galleryUtility.centerImage.image, $.galleryUtility.rightImage.image);
        var lisLeft = $.galleryUtility.leftImageStorage.left($.galleryUtility.leftImage.image, $.galleryUtility.centerImage.image, $.galleryUtility.rightImage.image);
     
 		if ($.galleryUtility.rightImageStorage.image.attr('layout') === 'landscape') {
            $.galleryUtility.rightImageStorage.image.animate({
                'top': $.galleryUtility.rightImage.Ltop,
                'left': riLeft,
                'height': $.galleryUtility.rightImage.Lheight,
                'width': $.galleryUtility.rightImage.Lwidth,
                'opacity': 'show'
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideLeft);
            });
        } else {
            $.galleryUtility.rightImageStorage.image.animate({
                'top': $.galleryUtility.rightImage.Ptop,
                'left': riLeft,
                'height': $.galleryUtility.rightImage.Pheight,
                'width': $.galleryUtility.rightImage.Pwidth,
                'opacity': 'show'
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideLeft);
            });
        }
        if ($.galleryUtility.rightImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.rightImage.image.unbind().animate({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ltop,
                'left': $.galleryUtility.centerImage.Lleft,
                'height': $.galleryUtility.centerImage.Lheight,
                'width': $.galleryUtility.centerImage.Lwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
              //  $(this).one('click', $.galleryUtility.zoomIn);
            });
        } else {
            $.galleryUtility.rightImage.image.unbind().animate({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ptop,
                'left': $.galleryUtility.centerImage.Pleft,
                'height': $.galleryUtility.centerImage.Pheight,
                'width': $.galleryUtility.centerImage.Pwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
            //    $(this).one('click', $.galleryUtility.zoomIn);
            });

        }
        if ($.galleryUtility.centerImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.centerImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImage.Ltop,
                'left': liLeft,
                'height': $.galleryUtility.leftImage.Lheight,
                'width': $.galleryUtility.leftImage.Lwidth
            },	
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideRight);
            });
			} else {
            $.galleryUtility.centerImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImage.Ptop,
                'left': liLeft,
                'height': $.galleryUtility.leftImage.Pheight,
                'width': $.galleryUtility.leftImage.Pwidth
            },
            $.galleryUtility.Options.slideSpeed, 'linear', function() {
                $(this).one('click', $.galleryUtility.slideRight);
            });

        }
        if ($.galleryUtility.leftImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.leftImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImageStorage.Ltop,
                'left': lisLeft,
                'height': $.galleryUtility.leftImageStorage.Lheight,
                'width': $.galleryUtility.leftImageStorage.Lwidth, 'opacity': 'hide'
            },
            $.galleryUtility.Options.slideSpeed, 'linear');
        } else {
            $.galleryUtility.leftImage.image.unbind().animate({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImageStorage.Ptop,
                'left': lisLeft,
                'height': $.galleryUtility.leftImageStorage.Pheight,
                'width': $.galleryUtility.leftImageStorage.Pwidth,
                'opacity': 'hide'
            },
            $.galleryUtility.Options.slideSpeed, 'linear');
        }
 		$.galleryUtility.leftImageStorage.image = $.galleryUtility.leftImage.image;
        $.galleryUtility.leftImage.image = $.galleryUtility.centerImage.image;
        $.galleryUtility.centerImage.image = $.galleryUtility.rightImage.image;
        $.galleryUtility.rightImage.image = $.galleryUtility.rightImageStorage.image;
        $.galleryUtility.setRightStorage($.galleryUtility.gallery.filter('[index=' + $.galleryUtility.rightImageStorage.image.attr('next') + ']'));
 		var currentpic_num = $.galleryUtility.centerImage.image.attr('index');
			// update html with current center pic
			$("#gallery_info .picture_number").html(currentpic_num);
};


    $.galleryUtility.setRightStorage = function(image) {
        $.galleryUtility.rightImageStorage.image = image;
        if ($.galleryUtility.rightImageStorage.image.attr('layout') === 'landscape') {
            $.galleryUtility.rightImageStorage.image.hide().css({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImageStorage.Ltop,
                'height': $.galleryUtility.rightImageStorage.Lheight,
                'width': $.galleryUtility.rightImageStorage.Lwidth
            });
        } else {
            $.galleryUtility.rightImageStorage.image.hide().css({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImageStorage.Ptop,
                'height': $.galleryUtility.rightImageStorage.Pheight,
                'width': $.galleryUtility.rightImageStorage.Pwidth
            });
        }
        $.galleryUtility.rightImageStorage.image.css('left', $.galleryUtility.rightImageStorage.left($.galleryUtility.rightImage.image));
    };

    $.galleryUtility.setLeftStorage = function(image) {
        $.galleryUtility.leftImageStorage.image = image;
        if ($.galleryUtility.leftImageStorage.image.attr('layout') === 'landscape') {
            $.galleryUtility.leftImageStorage.image.hide().css({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImageStorage.Ltop,
                'height': $.galleryUtility.leftImageStorage.Lheight,
                'width': $.galleryUtility.leftImageStorage.Lwidth
            });
        } else {
            $.galleryUtility.leftImageStorage.image.hide().css({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImageStorage.Ptop,
                'height': $.galleryUtility.leftImageStorage.Pheight,
                'width': $.galleryUtility.leftImageStorage.Pwidth
            });
        }
        $.galleryUtility.leftImageStorage.image
             .css('left', $.galleryUtility.leftImageStorage.left($.galleryUtility.leftImageStorage.image, $.galleryUtility.leftImage.image, $.galleryUtility.centerImage.image));
 };

    $.galleryUtility.setCenter = function(image) {
        $.galleryUtility.centerImage.image = image;
        if ($.galleryUtility.centerImage.image.attr('layout') === 'landscape') {
 
      		$.galleryUtility.centerImage.image.css({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ltop,
                'left': $.galleryUtility.centerImage.Lleft,
                'height': $.galleryUtility.centerImage.Lheight,
                'width': $.galleryUtility.centerImage.Lwidth
            });
        } else {
            $.galleryUtility.centerImage.image.css({
				'opacity': '1.0',
                'top': $.galleryUtility.centerImage.Ptop,
                'left': $.galleryUtility.centerImage.Pleft,
                'height': $.galleryUtility.centerImage.Pheight,
                'width': $.galleryUtility.centerImage.Pwidth
            });
        }
				// update html with current center pic
				var currentpic_num = $.galleryUtility.centerImage.image.attr('index')
				$("#gallery_info .picture_number").html(currentpic_num);
    };

    $.galleryUtility.setRight = function(image) {
        $.galleryUtility.rightImage.image = image;
        if ($.galleryUtility.rightImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.rightImage.image.css({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImage.Ltop,
                'height': $.galleryUtility.rightImage.Lheight,
                'width': $.galleryUtility.rightImage.Lwidth
            });
        } else {
            $.galleryUtility.rightImage.image.css({
				'opacity': '0.2',
                'top': $.galleryUtility.rightImage.Ptop,
                'height': $.galleryUtility.rightImage.Pheight,
                'width': $.galleryUtility.rightImage.Pwidth
            });
        }
        $.galleryUtility.rightImage.image.css('left', $.galleryUtility.rightImage.left($.galleryUtility.centerImage.image));
  	};

    $.galleryUtility.setLeft = function(image) {
        $.galleryUtility.leftImage.image = image;
        if ($.galleryUtility.leftImage.image.attr('layout') === 'landscape') {
            $.galleryUtility.leftImage.image.css({
				'opacity': '0.2',
                'top': $.galleryUtility.leftImage.Ltop,
                'height': $.galleryUtility.leftImage.Lheight,
                'width': $.galleryUtility.leftImage.Lwidth
            });
        } else {
            $.galleryUtility.leftImage.image.css({
				'opacity': '0.3',
                'top': $.galleryUtility.leftImage.Ptop,
                'height': $.galleryUtility.leftImage.Pheight,
                'width': $.galleryUtility.leftImage.Pwidth
            });
        }
        $.galleryUtility.leftImage.image.css('left', $.galleryUtility.leftImage.left($.galleryUtility.leftImage.image, $.galleryUtility.centerImage.image));
  };
    $.galleryUtility.definePositions = function() {
	    $.galleryUtility.centerImage.Lheight = Math.round($.galleryUtility.Options.Lheight);
        $.galleryUtility.centerImage.Lwidth = Math.round($.galleryUtility.Options.Lwidth);
        $.galleryUtility.centerImage.Ltop = 10 ;
        $.galleryUtility.centerImage.Lleft = 200 ;
        $.galleryUtility.centerImage.Pheight = Math.round($.galleryUtility.Options.Pheight);
        $.galleryUtility.centerImage.Pwidth = Math.round($.galleryUtility.Options.Pwidth);
        $.galleryUtility.centerImage.Ptop = 10 ; 
        $.galleryUtility.centerImage.Pleft = 300 ;
     


        $.galleryUtility.leftImage.Lheight = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.centerImage.Lheight));
        $.galleryUtility.leftImage.Lwidth = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.centerImage.Lwidth));
       $.galleryUtility.leftImage.Ltop = Math.round($.galleryUtility.centerImage.Ltop + (($.galleryUtility.centerImage.Lheight - $.galleryUtility.leftImage.Lheight) / 2));
      
  		$.galleryUtility.leftImage.left = function(left, center) {
            if (center.attr('layout') === 'landscape') {
                if (left.attr('layout') === 'landscape') {
                    return Math.round($.galleryUtility.centerImage.Lleft - ($.galleryUtility.leftImage.Lwidth + $.galleryUtility.Options.gutterWidth));
                } else {
                    return Math.round($.galleryUtility.centerImage.Lleft - ($.galleryUtility.leftImage.Pwidth + $.galleryUtility.Options.gutterWidth));
                }
            } else {
                if (left.attr('layout') === 'landscape') {
                    return Math.round($.galleryUtility.centerImage.Pleft - ($.galleryUtility.leftImage.Lwidth + $.galleryUtility.Options.gutterWidth));
                } else {
                    return Math.round($.galleryUtility.centerImage.Pleft - ($.galleryUtility.leftImage.Pwidth + $.galleryUtility.Options.gutterWidth));
                }
            }
        };

        $.galleryUtility.leftImage.Pheight = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.centerImage.Pheight));
        $.galleryUtility.leftImage.Pwidth = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.centerImage.Pwidth));
        $.galleryUtility.leftImage.Ptop = Math.round($.galleryUtility.centerImage.Ptop + (($.galleryUtility.centerImage.Pheight - $.galleryUtility.leftImage.Pheight) / 2));
        $.galleryUtility.rightImage.Lheight = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.centerImage.Lheight));
        $.galleryUtility.rightImage.Lwidth = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.centerImage.Lwidth));
        $.galleryUtility.rightImage.Ltop = Math.round($.galleryUtility.centerImage.Ltop + (($.galleryUtility.centerImage.Lheight - $.galleryUtility.rightImage.Lheight) / 2));
        $.galleryUtility.rightImage.left = function(center) {
            if (center.attr('layout') === 'landscape') {
                return Math.round($.galleryUtility.centerImage.Lleft + ($.galleryUtility.centerImage.Lwidth + $.galleryUtility.Options.gutterWidth));
            } else {
                return Math.round($.galleryUtility.centerImage.Pleft + ($.galleryUtility.centerImage.Pwidth + $.galleryUtility.Options.gutterWidth));
            }
        };

        $.galleryUtility.rightImage.Pheight = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.centerImage.Pheight));
        $.galleryUtility.rightImage.Pwidth = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.centerImage.Pwidth)) ;
        $.galleryUtility.rightImage.Ptop = Math.round($.galleryUtility.centerImage.Ptop + (($.galleryUtility.centerImage.Pheight - $.galleryUtility.leftImage.Pheight) / 2));
        $.galleryUtility.leftImageStorage.Lheight = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.leftImage.Lheight));
        $.galleryUtility.leftImageStorage.Lwidth = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.leftImage.Lwidth));
        $.galleryUtility.leftImageStorage.Ltop = Math.round($.galleryUtility.leftImage.Ltop + (($.galleryUtility.leftImage.Lheight - $.galleryUtility.leftImageStorage.Lheight) / 2));
        $.galleryUtility.leftImageStorage.left = function(leftStorage, left, center) {
            if (leftStorage.attr('layout') === 'landscape') {
                return Math.round($.galleryUtility.leftImage.left(left, center) - ($.galleryUtility.leftImageStorage.Lwidth + $.galleryUtility.Options.gutterWidth));
            } else {
                return Math.round($.galleryUtility.leftImage.left(left, center) - ($.galleryUtility.leftImageStorage.Pwidth + $.galleryUtility.Options.gutterWidth));
            }
        };

        $.galleryUtility.leftImageStorage.Pheight = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.leftImage.Pheight));
        $.galleryUtility.leftImageStorage.Pwidth = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.leftImage.Pwidth));
        $.galleryUtility.leftImageStorage.Ptop = Math.round($.galleryUtility.leftImage.Ptop + (($.galleryUtility.leftImage.Pheight - $.galleryUtility.leftImageStorage.Pheight) / 2));
        $.galleryUtility.rightImageStorage.Lheight = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.rightImage.Lheight));
        $.galleryUtility.rightImageStorage.Lwidth = Math.round($.galleryUtility.Options.Lshrink($.galleryUtility.rightImage.Lwidth));
        $.galleryUtility.rightImageStorage.Ltop = Math.round($.galleryUtility.rightImage.Ltop + (($.galleryUtility.rightImage.Lheight - $.galleryUtility.rightImageStorage.Lheight) / 2));
        $.galleryUtility.rightImageStorage.left = function(right) {
            if (right.attr('layout') === 'landscape') {
                return Math.round($.galleryUtility.rightImage.left(right) + ($.galleryUtility.rightImage.Lwidth + $.galleryUtility.Options.gutterWidth));
            } else {
                return Math.round($.galleryUtility.rightImage.left(right) + ($.galleryUtility.rightImage.Pwidth + $.galleryUtility.Options.gutterWidth));
            }
        };

        $.galleryUtility.rightImageStorage.Pheight = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.rightImage.Pheight));
        $.galleryUtility.rightImageStorage.Pwidth = Math.round($.galleryUtility.Options.Pshrink($.galleryUtility.rightImage.Pwidth));
        $.galleryUtility.rightImageStorage.Ptop = Math.round($.galleryUtility.rightImage.Ptop + (($.galleryUtility.rightImage.Pheight - $.galleryUtility.rightImageStorage.Pheight) / 2));
    };
})(jQuery);
