
function ThumbnailGallery()
{
    var PrototypesObject = new Prototypes();
    var Class = this;

    // ID
    this.ID = '';

    // Container
    this.Container = '';

    // Settings
    this.Width = '100%';
    this.Height = '100%';
    this.BgColor = 'css';
    this.BgImage = 'none';
    this.BgAlpha = '100';

    this.ThumbnailsPosition = 'bottom';
    this.ThumbnailsOverImage = 'false';
    this.ThumbnailsBgColor = 'css';
    this.ThumbnailsBgAlpha = '100';
    this.ThumbnailsSpacing = 0;
    this.ThumbnailsPaddingTop = 0;
    this.ThumbnailsPaddingRight = 0;
    this.ThumbnailsPaddingBottom = 0;
    this.ThumbnailsPaddingLeft = 0;
    this.ThumbnailWidth = 50;
    this.ThumbnailHeight = 50;
    this.ThumbnailSize = 'fixed';
    this.ThumbnailAlpha = '50';
    this.ThumbnailAlphaHover = '100';
    this.ThumbnailAlphaSelected = '100';
    this.ThumbnailBgColor = 'ffffff';
    this.ThumbnailBgColorHover = 'ffffff';
    this.ThumbnailBgColorSelected = 'ffffff';
    this.ThumbnailBorderSize = 0;
    this.ThumbnailBorderColor = '000000';
    this.ThumbnailBorderColorHover = '000000';
    this.ThumbnailBorderColorSelected = '000000';
    this.ThumbnailPaddingTop = 0;
    this.ThumbnailPaddingRight = 0;
    this.ThumbnailPaddingBottom = 0;
    this.ThumbnailPaddingLeft = 0;

    this.ImageBgColor = 'css';
    this.ImageBgAlpha = '100';
    this.ImageDisplayType = 'fit';
    this.ImageDisplayTime = '1000';
    this.ImageMarginTop = 0;
    this.ImageMarginRight = 0;
    this.ImageMarginBottom = 0;
    this.ImageMarginLeft = 0;
    this.ImagePaddingTop = 0;
    this.ImagePaddingRight = 0;
    this.ImagePaddingBottom = 0;
    this.ImagePaddingLeft = 0;

    this.Buttons = 'true';
    this.ButtonsColor = 'ffffff';
    this.ButtonsColorHover = 'ffffff';
    this.ButtonsIconColor = '000000';
    this.ButtonsIconColorHover = '000000';
    this.ButtonsAlpha = '50';
    this.ButtonsAlphaHover = '100';

    this.CaptionWidth = 'auto';
    this.CaptionHeight = '50';
    this.CaptionTitleColor = 'css';
    this.CaptionTextColor = 'css';
    this.CaptionBgColor = 'css';
    this.CaptionBgAlpha = '50';
    this.CaptionPosition = 'bottom';
    this.CaptionScrollSize = 10;
    this.CaptionScrollScrubColor = 'css';
    this.CaptionScrollBgColor = 'css';
    this.CaptionMarginTop = 0;
    this.CaptionMarginRight = 0;
    this.CaptionMarginBottom = 0;
    this.CaptionMarginLeft = 0;
    this.CaptionPaddingTop = 0;
    this.CaptionPaddingRight = 0;
    this.CaptionPaddingBottom = 0;
    this.CaptionPaddingLeft = 0;

    this.TooltipBgColor = 'css';
    this.TooltipStrokeColor = 'css';
    this.TooltipTextColor = 'css';

    this.Slideshow = 'false';
    this.SlideshowTime = '5000';
    this.SlideshowLoop = 'true';
    
    this.AutoHide = 'false';
    this.AutoHideTime = '2000';

    // Content
    this.Images = new Array();
    this.Thumbs = new Array();
    this.CaptionTitle = new Array();
    this.CaptionText = new Array();
    this.noImages = 0;

    // Background
    this.BgImageLoaded = false;
    this.BgImageWidth = 0;
    this.BgImageHeight = 0;

    // Thumbnails
    this.thumbnailsMove = false;

    // Image
    this.currentImage = 0;
    this.imageLoaded = false;
    this.ImageWidth = 0;
    this.ImageHeight = 0;

    // Slideshow
    this.SlideshowID;
    this.stopSlideshow = false;

    // Auto Hide
    this.HideID;
    this.ItemsHidden = false;
    
    //
    this.agent = navigator.userAgent.toLowerCase();

    this.init = function(id, container, data)
    {
        this.ID = id;
        this.Container = container;
        this.parseData(data);
    }

    this.parseData = function(data)
    {
        var settingsData;
        var imagesData;
        var settingsSplit = new Array();
        var imagesSplit = new Array();
        var i;
        var settingName;
        var settingValue;

        settingsData = data.split(';;;;;')[0];
        imagesData = data.split(';;;;;')[1];

        settingsSplit = settingsData.split(';;');
        imagesSplit = imagesData.split(';;;');

        for (i=0; i<settingsSplit.length; i++)
        {
            settingName = settingsSplit[i].split('::')[0];
            settingValue = settingsSplit[i].split('::')[1];

            if (settingName == 'Width' && settingValue != '' && settingValue != 'css') this.Width = settingValue;
            if (settingName == 'Height' && settingValue != '' && settingValue != 'css') this.Height = settingValue;
            if (settingName == 'BgColor' && settingValue != '' && settingValue != 'css') this.BgColor = settingValue;
            if (settingName == 'BgImage' && settingValue != '') this.BgImage = settingValue;
            if (settingName == 'BgAlpha' && settingValue != '') this.BgAlpha = settingValue;

            if (settingName == 'ThumbnailsPosition' && settingValue != '') this.ThumbnailsPosition = settingValue;
            if (settingName == 'ThumbnailsOverImage' && settingValue != '') this.ThumbnailsOverImage = settingValue;
            if (settingName == 'ThumbnailsBgColor' && settingValue != '' && settingValue != 'css') this.ThumbnailsBgColor = settingValue;
            if (settingName == 'ThumbnailsBgAlpha' && settingValue != '') this.ThumbnailsBgAlpha = settingValue;
            if (settingName == 'ThumbnailsSpacing' && settingValue != '') this.ThumbnailsSpacing = parseInt(settingValue);
            if (settingName == 'ThumbnailsPaddingTop' && settingValue != '') this.ThumbnailsPaddingTop = parseInt(settingValue);
            if (settingName == 'ThumbnailsPaddingRight' && settingValue != '') this.ThumbnailsPaddingRight = parseInt(settingValue);
            if (settingName == 'ThumbnailsPaddingBottom' && settingValue != '') this.ThumbnailsPaddingBottom = parseInt(settingValue);
            if (settingName == 'ThumbnailsPaddingLeft' && settingValue != '') this.ThumbnailsPaddingLeft = parseInt(settingValue);
            if (settingName == 'ThumbnailWidth' && settingValue != '' && settingValue != 'css') this.ThumbnailWidth = parseInt(settingValue);
            if (settingName == 'ThumbnailHeight' && settingValue != '' && settingValue != 'css') this.ThumbnailHeight = parseInt(settingValue);
            if (settingName == 'ThumbnailSize' && settingValue != '') this.ThumbnailSize = settingValue;
            if (settingName == 'ThumbnailAlpha' && settingValue != '') this.ThumbnailAlpha = settingValue;
            if (settingName == 'ThumbnailAlphaHover' && settingValue != '') this.ThumbnailAlphaHover = settingValue;
            if (settingName == 'ThumbnailAlphaSelected' && settingValue != '') this.ThumbnailAlphaSelected = settingValue;
            if (settingName == 'ThumbnailBgColor' && settingValue != '') this.ThumbnailBgColor = settingValue;
            if (settingName == 'ThumbnailBgColorHover' && settingValue != '') this.ThumbnailBgColorHover = settingValue;
            if (settingName == 'ThumbnailBgColorSelected' && settingValue != '') this.ThumbnailBgColorSelected = settingValue;
            if (settingName == 'ThumbnailBorderSize' && settingValue != '') this.ThumbnailBorderSize = parseInt(settingValue);
            if (settingName == 'ThumbnailBorderColor' && settingValue != '') this.ThumbnailBorderColor = settingValue;
            if (settingName == 'ThumbnailBorderColorHover' && settingValue != '') this.ThumbnailBorderColorHover = settingValue;
            if (settingName == 'ThumbnailBorderColorSelected' && settingValue != '') this.ThumbnailBorderColorSelected = settingValue;
            if (settingName == 'ThumbnailPaddingTop' && settingValue != '') this.ThumbnailPaddingTop = parseInt(settingValue);
            if (settingName == 'ThumbnailPaddingRight' && settingValue != '') this.ThumbnailPaddingRight = parseInt(settingValue);
            if (settingName == 'ThumbnailPaddingBottom' && settingValue != '') this.ThumbnailPaddingBottom = parseInt(settingValue);
            if (settingName == 'ThumbnailPaddingLeft' && settingValue != '') this.ThumbnailPaddingLeft = parseInt(settingValue);

            if (settingName == 'ImageBgColor' && settingValue != '' && settingValue != 'css') this.ImageBgColor = settingValue;
            if (settingName == 'ImageBgAlpha' && settingValue != '') this.ImageBgAlpha = settingValue;
            if (settingName == 'ImageDisplayType' && settingValue != '') this.ImageDisplayType = settingValue;
            if (settingName == 'ImageDisplayTime' && settingValue != '') this.ImageDisplayTime = settingValue;
            if (settingName == 'ImageMarginTop' && settingValue != '') this.ImageMarginTop = parseInt(settingValue);
            if (settingName == 'ImageMarginRight' && settingValue != '') this.ImageMarginRight = parseInt(settingValue);
            if (settingName == 'ImageMarginBottom' && settingValue != '') this.ImageMarginBottom = parseInt(settingValue);
            if (settingName == 'ImageMarginLeft' && settingValue != '') this.ImageMarginLeft = parseInt(settingValue);
            if (settingName == 'ImagePaddingTop' && settingValue != '') this.ImagePaddingTop = parseInt(settingValue);
            if (settingName == 'ImagePaddingRight' && settingValue != '') this.ImagePaddingRight = parseInt(settingValue);
            if (settingName == 'ImagePaddingBottom' && settingValue != '') this.ImagePaddingBottom = parseInt(settingValue);
            if (settingName == 'ImagePaddingLeft' && settingValue != '') this.ImagePaddingLeft = parseInt(settingValue);

            if (settingName == 'Buttons' && settingValue != '') this.ButtonsColorHover = settingValue;
            if (settingName == 'ButtonsColor' && settingValue != '') this.ButtonsColor = settingValue;
            if (settingName == 'ButtonsColorHover' && settingValue != '') this.ButtonsColorHover = settingValue;
            if (settingName == 'ButtonsIconColor' && settingValue != '') this.ButtonsIconColor = settingValue;
            if (settingName == 'ButtonsIconColorHover' && settingValue != '') this.ButtonsIconColorHover = settingValue;
            if (settingName == 'ButtonsAlpha' && settingValue != '') this.ButtonsAlpha = settingValue;
            if (settingName == 'ButtonsAlphaHover' && settingValue != '') this.ButtonsAlphaHover = settingValue;

            if (settingName == 'CaptionWidth' && settingValue != '') this.CaptionWidth = settingValue;
            if (settingName == 'CaptionHeight' && settingValue != '') this.CaptionHeight = settingValue;
            if (settingName == 'CaptionTitleColor' && settingValue != '' && settingValue != 'css') this.CaptionTitleColor = settingValue;
            if (settingName == 'CaptionTextColor' && settingValue != '' && settingValue != 'css') this.CaptionTextColor = settingValue;
            if (settingName == 'CaptionBgColor' && settingValue != '' && settingValue != 'css') this.CaptionBgColor = settingValue;
            if (settingName == 'CaptionBgAlpha' && settingValue != '') this.CaptionBgAlpha = settingValue;
            if (settingName == 'CaptionPosition' && settingValue != '') this.CaptionPosition = settingValue;
            if (settingName == 'CaptionScrollSize' && settingValue != '') this.CaptionScrollSize = parseInt(settingValue);
            if (settingName == 'CaptionScrollScrubColor' && settingValue != '' && settingValue != 'css') this.CaptionScrollScrubColor = settingValue;
            if (settingName == 'CaptionScrollBgColor' && settingValue != '' && settingValue != 'css') this.CaptionScrollBgColor = settingValue;
            if (settingName == 'CaptionMarginTop' && settingValue != '') this.CaptionMarginTop = parseInt(settingValue);
            if (settingName == 'CaptionMarginRight' && settingValue != '') this.CaptionMarginRight = parseInt(settingValue);
            if (settingName == 'CaptionMarginBottom' && settingValue != '') this.CaptionMarginBottom = parseInt(settingValue);
            if (settingName == 'CaptionMarginLeft' && settingValue != '') this.CaptionMarginLeft = parseInt(settingValue);
            if (settingName == 'CaptionPaddingTop' && settingValue != '') this.CaptionPaddingTop = parseInt(settingValue);
            if (settingName == 'CaptionPaddingRight' && settingValue != '') this.CaptionPaddingRight = parseInt(settingValue);
            if (settingName == 'CaptionPaddingBottom' && settingValue != '') this.CaptionPaddingBottom = parseInt(settingValue);
            if (settingName == 'CaptionPaddingLeft' && settingValue != '') this.CaptionPaddingLeft = parseInt(settingValue);

            if (settingName == 'TooltipBgColor' && settingValue != '' && settingValue != 'css') this.TooltipBgColor = settingValue;
            if (settingName == 'TooltipStrokeColor' && settingValue != '' && settingValue != 'css') this.TooltipStrokeColor = settingValue;
            if (settingName == 'TooltipTextColor' && settingValue != '' && settingValue != 'css') this.TooltipTextColor = settingValue;

            if (settingName == 'Slideshow' && settingValue != '') this.Slideshow = settingValue;
            if (settingName == 'SlideshowTime' && settingValue != '') this.SlideshowTime = settingValue;
            if (settingName == 'SlideshowLoop' && settingValue != '') this.SlideshowLoop = settingValue;

            if (settingName == 'AutoHide' && settingValue != '') this.AutoHide = settingValue;
            if (settingName == 'AutoHideTime' && settingValue != '') this.AutoHideTime = settingValue;
        }

        this.noImages = imagesSplit.length;
        
        for (i=0; i<this.noImages; i++)
        {
            this.Images[i] = imagesSplit[i].split(';;')[0];
            this.Thumbs[i] = imagesSplit[i].split(';;')[1];
            this.CaptionTitle[i] = imagesSplit[i].split(';;')[2];
            this.CaptionText[i] = imagesSplit[i].split(';;')[3];
        }

        this.initGallery();
    }

    this.initGallery = function()
    {
        var HTML = '';

        HTML += '<div class="DOP_ThumbnailGallery_Container" id="DOP_ThumbnailGallery_Container_'+this.ID+'">';

        HTML += '   <div class="DOP_ThumbnailGallery_Background" id="DOP_ThumbnailGallery_Background_'+this.ID+'"></div>';
        
        HTML += '   <div class="DOP_ThumbnailGallery_ThumbnailsContainer" id="DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID+'">';
        HTML += '       <div class="DOP_ThumbnailGallery_ThumbnailsBg" id="DOP_ThumbnailGallery_ThumbnailsBg_'+this.ID+'"></div>';
        HTML += '       <div class="DOP_ThumbnailGallery_ThumbnailsWrapper" id="DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID+'">';
        HTML += '           <div class="DOP_ThumbnailGallery_Thumbnails" id="DOP_ThumbnailGallery_Thumbnails_'+this.ID+'">';
        HTML += '           </div>';
        HTML += '       </div>';
        HTML += '   </div>';

        HTML += '   <div class="DOP_ThumbnailGallery_Image" id="DOP_ThumbnailGallery_Image_'+this.ID+'"></div>';
        HTML += '   <div class="DOP_ThumbnailGallery_ImageBackup" id="DOP_ThumbnailGallery_ImageBackup_'+this.ID+'"></div>';

        if (this.Buttons == 'true')
        {
            HTML += '   <div class="DOP_ThumbnailGallery_Button" id="DOP_ThumbnailGallery_ButtonLeft_'+this.ID+'">';
            HTML += '       <div class="DOP_ThumbnailGallery_Button_LeftIcon" id="DOP_ThumbnailGallery_Button_LeftIcon_'+this.ID+'"></div>';
            HTML += '   </div>';
            HTML += '   <div class="DOP_ThumbnailGallery_Button" id="DOP_ThumbnailGallery_ButtonRight_'+this.ID+'">';
            HTML += '       <div class="DOP_ThumbnailGallery_Button_RightIcon" id="DOP_ThumbnailGallery_Button_RightIcon_'+this.ID+'"></div>';
            HTML += '   </div>';
        }
        
        HTML += '   <div class="DOP_ThumbnailGallery_Caption" id="DOP_ThumbnailGallery_Caption_'+this.ID+'">';
        HTML += '       <div class="DOP_ThumbnailGallery_CaptionTitle" id="DOP_ThumbnailGallery_CaptionTitle_'+this.ID+'">';
        HTML += '           <div class="DOP_ThumbnailGallery_CaptionTextContainer" id="DOP_ThumbnailGallery_CaptionTextContainer_'+this.ID+'">';
        HTML += '               <div class="DOP_ThumbnailGallery_CaptionText" id="DOP_ThumbnailGallery_CaptionText_'+this.ID+'">';
        HTML += '               </div>';
        HTML += '           </div>';
        HTML += '       </div>';
        HTML += '   </div>';

        HTML += '   <div class="DOP_ThumbnailGallery_Tooltip" id="DOP_ThumbnailGallery_Tooltip_'+this.ID+'"></div>';

        HTML += '</div>';

        $(this.Container).html(HTML);

        this.initSettings();    
    }

    this.initSettings= function()
    {
        this.initContainer();
        this.initBackground();
        this.initThumbnails();
        this.initImage();
        if (this.Buttons == 'true') this.initButtons();
        if (this.AutoHide == 'true') this.initAutoHide();
    }

    this.initResize = function()
    {
        this.RPContainer();
        this.RPBackground();
        this.RPThumbnails();
        this.RPImage();
        if (this.Buttons == 'true') this.RPButtons();
    }

// ***** Begin Container *****

    this.initContainer = function()
    {
        $('#DOP_ThumbnailGallery_Container_'+this.ID).css('display', 'block');
        this.RPContainer();
    }
    
    this.RPContainer = function()
    {
        if (this.Width != 'css')
        {
            if (this.Width == '100%') $('#DOP_ThumbnailGallery_Container_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).parent().width());
            else $('#DOP_ThumbnailGallery_Container_'+this.ID).width(this.Width);
        }
        if (this.Height != 'css')
        {
            if (this.Height == '100%') $('#DOP_ThumbnailGallery_Container_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).parent().height());
            else $('#DOP_ThumbnailGallery_Container_'+this.ID).height(this.Height);
        }
    }

// ***** End Container *****

// ***** Begin Background *****

    this.initBackground = function()
    {
        if (this.BgColor != 'css') $('#DOP_ThumbnailGallery_Background_'+this.ID).css('background-color', '#'+this.BgColor);
        $('#DOP_ThumbnailGallery_Background_'+this.ID).stop(true, true).animate({'opacity':parseInt(Class.BgAlpha)/100}, 0);
        
        if (this.BgImage != 'none')
        {
            var img = new Image();
            $(img).load(function()
            {
                Class.BgImageLoaded = true;
                $('#DOP_ThumbnailGallery_Background_'+Class.ID).html(this);
                Class.BgImageWidth = $('img', '#DOP_ThumbnailGallery_Background_'+Class.ID).width();
                Class.BgImageHeight = $('img', '#DOP_ThumbnailGallery_Background_'+Class.ID).height();
                Class.RPBackground();
                $('img', '#DOP_ThumbnailGallery_Background_'+Class.ID).stop(true, true).animate({'opacity':'0'}, 0, function()
                {
                    $('img', '#DOP_ThumbnailGallery_Background_'+Class.ID).stop(true, true).animate({'opacity':'1'}, 600);
                });
            }).attr('src', this.BgImage);
        }
        
        this.RPBackground();
    }

    this.RPBackground = function()
    {
        if (this.Width != 'css')
        {
            if (this.Width == '100%') $('#DOP_ThumbnailGallery_Background_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).parent().width());
            else $('#DOP_ThumbnailGallery_Background_'+this.ID).width(this.Width);
        }
        if (this.Height != 'css')
        {
            if (this.Height == '100%') $('#DOP_ThumbnailGallery_Background_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).parent().height());
            else $('#DOP_ThumbnailGallery_Background_'+this.ID).height(this.Height);
        }
        
        if (this.BgImage != 'none' && this.BgImageLoaded) PrototypesObject.ResizeItem2('#DOP_ThumbnailGallery_Background_'+this.ID, $('#DOP_ThumbnailGallery_Background_'+this.ID).width(), $('#DOP_ThumbnailGallery_Background_'+this.ID).height(), this.BgImageWidth, this.BgImageHeight, 'center');
    }

// ***** End Background *****

// ***** Begin Thumbnails *****

    this.initThumbnails = function()
    {
        if (this.ThumbnailsBgColor != 'css') $('#DOP_ThumbnailGallery_ThumbnailsBg_'+this.ID).css('background-color', '#'+this.ThumbnailsBgColor);
        $('#DOP_ThumbnailGallery_ThumbnailsBg_'+this.ID).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailsBgAlpha)/100}, 0);

        $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).css('margin-top', this.ThumbnailsPaddingTop);
        $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).css('margin-left', this.ThumbnailsPaddingLeft);

        this.RPThumbnails();

        if (this.ThumbnailsPosition == 'top')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).css('margin-top', 0-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).height());
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).stop(true, true).animate({'margin-top':0}, 600);
        }
        if (this.ThumbnailsPosition == 'right')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).css('margin-left', $('#DOP_ThumbnailGallery_Container_'+this.ID).width());
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).stop(true, true).animate({'margin-left': $('#DOP_ThumbnailGallery_Container_'+this.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).width()}, 600);
        }
        if (this.ThumbnailsPosition == 'bottom')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).css('margin-top', $('#DOP_ThumbnailGallery_Container_'+this.ID).height());
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).stop(true, true).animate({'margin-top':$('#DOP_ThumbnailGallery_Container_'+this.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).height()}, 600);
        }
        if (this.ThumbnailsPosition == 'left')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).css('margin-left', 0-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).width());
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).stop(true, true).animate({'margin-left':0}, 600);
        }
        $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).hover(function(){Class.thumbnailsMove = true;});

        this.moveThumbnails();
        this.loadThumb(1);
    }

    this.loadThumb = function(no)
    {
        this.initThumb(no);        
        var img = new Image();

        $(img).load(function()
        {
            $('#DOP_ThumbnailGallery_Thumb_'+no).html(this);
            Class.loadCompleteThumb(no);
            if (no < Class.noImages) Class.loadThumb(no+1);
        }).attr('src', this.Thumbs[no-1]);
    }

    this.initThumb = function(no)
    {
        var ThumbHTML = '';
        ThumbHTML += '<div class="DOP_ThumbnailGallery_ThumbContainer" id="DOP_ThumbnailGallery_ThumbContainer_'+no+'">';
        ThumbHTML += '   <div class="DOP_ThumbnailGallery_Thumb" id="DOP_ThumbnailGallery_Thumb_'+no+'">';
        ThumbHTML += '   </div>';
        ThumbHTML += '</div>';

        if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom')
        {
            if (no == 1) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()+Class.ThumbnailWidth+(2*Class.ThumbnailBorderSize)+Class.ThumbnailPaddingRight+Class.ThumbnailPaddingLeft);
            else $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()+Class.ThumbnailWidth+(2*Class.ThumbnailBorderSize)+Class.ThumbnailPaddingRight+Class.ThumbnailPaddingLeft+Class.ThumbnailsSpacing);
        }

        $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).append(ThumbHTML);

        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailAlpha)/100}, 0);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).width(this.ThumbnailWidth+this.ThumbnailPaddingRight+this.ThumbnailPaddingLeft);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).height(this.ThumbnailHeight+this.ThumbnailPaddingTop+this.ThumbnailPaddingBottom);
        $('#DOP_ThumbnailGallery_Thumb_'+no).css('margin-top', this.ThumbnailPaddingTop);
        $('#DOP_ThumbnailGallery_Thumb_'+no).css('margin-left', this.ThumbnailPaddingLeft);
        $('#DOP_ThumbnailGallery_Thumb_'+no).css('margin-bottom', this.ThumbnailPaddingBottom);
        $('#DOP_ThumbnailGallery_Thumb_'+no).css('margin-right', this.ThumbnailPaddingRight);
        
        if (this.ThumbnailSize == 'fixed')
        {
            $('#DOP_ThumbnailGallery_Thumb_'+no).css('overflow', 'hidden');
            $('#DOP_ThumbnailGallery_Thumb_'+no).width(this.ThumbnailWidth);
            $('#DOP_ThumbnailGallery_Thumb_'+no).height(this.ThumbnailHeight);
        }
        else
        {
            if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom') $('#DOP_ThumbnailGallery_ThumbContainer_'+no).height(this.ThumbnailHeight+this.ThumbnailPaddingTop+this.ThumbnailPaddingBottom);
            else  $('#DOP_ThumbnailGallery_ThumbContainer_'+no).width(this.ThumbnailWidth+this.ThumbnailPaddingRight+this.ThumbnailPaddingLeft);
        }

        if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom') $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('float', 'left');
        
        if (no != '1')
        {
            if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom') $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('margin-left', this.ThumbnailsSpacing);
            else $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('margin-top', this.ThumbnailsSpacing);
        }

        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('background-color', '#'+this.ThumbnailBgColor);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('border-width', this.ThumbnailBorderSize);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('border-color', '#'+this.ThumbnailBorderColor);

        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).addClass('DOP_ThumbnailGallery_SmallLoader');

        if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom')
        {
            if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width()) PrototypesObject.HCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width());
            else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left', 0);
        }
        else
        {
            if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).height() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height()) PrototypesObject.VCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height());
            else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top', 0);
        }
    }

    this.loadCompleteThumb = function(no)
    {
        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).removeClass('DOP_ThumbnailGallery_SmallLoader');

        if (this.ThumbnailSize == 'fixed') PrototypesObject.ResizeItem2('#DOP_ThumbnailGallery_Thumb_'+no, this.ThumbnailWidth, this.ThumbnailHeight, $('img', '#DOP_ThumbnailGallery_Thumb_'+no).width(), $('img', '#DOP_ThumbnailGallery_Thumb_'+no).height(), 'center');
        else
        {            
            if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom')
            {
                $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('width', 'auto');
                $('img', '#DOP_ThumbnailGallery_Thumb_'+no).height(this.ThumbnailHeight);
                $('img', '#DOP_ThumbnailGallery_Thumb_'+no).css('width', 'auto');
                
                $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()-Class.ThumbnailWidth-Class.ThumbnailPaddingRight-Class.ThumbnailPaddingLeft);
                $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()+$('#DOP_ThumbnailGallery_ThumbContainer_'+no).width());
                
                if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width()) PrototypesObject.HCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width());
                else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left', 0);
            }
            else
            {
                $('#DOP_ThumbnailGallery_ThumbContainer_'+no).css('height', 'auto');
                $('img', '#DOP_ThumbnailGallery_Thumb_'+no).width(this.ThumbnailWidth);
                $('img', '#DOP_ThumbnailGallery_Thumb_'+no).css('height', 'auto');

                if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).height() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height()) PrototypesObject.VCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height());
                else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top', 0);
            }
        }

        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).hover(function()
        {
            if (Class.currentImage != no)
            {
                $(this).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailAlphaHover)/100}, 300);
                $(this).css('background-color', '#'+Class.ThumbnailBgColorHover);
                $(this).css('border-color', '#'+Class.ThumbnailBorderColorHover);
            }
        },
        function()
        {
            if (Class.currentImage != no)
            {
                $(this).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailAlpha)/100}, 300);
                $(this).css('background-color', '#'+Class.ThumbnailBgColor);
                $(this).css('border-color', '#'+Class.ThumbnailBorderColor);
            }
        });

        $('#DOP_ThumbnailGallery_ThumbContainer_'+no).click(function()
        {
            if (Class.imageLoaded) Class.loadImage(no);
        });
    }

    this.RPThumbnails = function()
    {
        if (this.ThumbnailsPosition == 'top' || this.ThumbnailsPosition == 'bottom')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).width()-this.ThumbnailsPaddingRight-this.ThumbnailsPaddingLeft);
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height(this.ThumbnailHeight+(2*this.ThumbnailBorderSize)+this.ThumbnailPaddingTop+this.ThumbnailPaddingBottom);

            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).width());
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).height($('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height()+this.ThumbnailsPaddingTop+this.ThumbnailsPaddingBottom);

            if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).width() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width()) PrototypesObject.HCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width());
            else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-left', 0);
        }
        else if (this.ThumbnailsPosition == 'right' || this.ThumbnailsPosition == 'left')
        {
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width(this.ThumbnailWidth+(2*this.ThumbnailBorderSize)+this.ThumbnailPaddingRight+this.ThumbnailPaddingLeft);
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).height()-this.ThumbnailsPaddingTop-this.ThumbnailsPaddingBottom);
            
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).width($('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).width()+this.ThumbnailsPaddingRight+this.ThumbnailsPaddingLeft);
            $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).height());

            if ($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).height() <= $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height()) PrototypesObject.VCenterItem('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID, $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).height());
            else if (parseInt($('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top')) >= 0) $('#DOP_ThumbnailGallery_Thumbnails_'+this.ID).css('margin-top', 0);
        }
        
        $('#DOP_ThumbnailGallery_ThumbnailsBg_'+this.ID).width($('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).width());
        $('#DOP_ThumbnailGallery_ThumbnailsBg_'+this.ID).height($('#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID).height());

        if (this.ThumbnailsPosition == 'bottom') PrototypesObject.OnBottomItem('#DOP_ThumbnailGallery_Container_'+this.ID, '#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID, $('#DOP_ThumbnailGallery_Container_'+this.ID).height());
        if (this.ThumbnailsPosition == 'right') PrototypesObject.OnRightItem('#DOP_ThumbnailGallery_Container_'+this.ID, '#DOP_ThumbnailGallery_ThumbnailsContainer_'+this.ID, $('#DOP_ThumbnailGallery_Container_'+this.ID).width());
    }

    this.moveThumbnails = function()
    {
        if (this.agent.indexOf('iphone') != -1 || this.agent.indexOf('ipad') != -1)
        {
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).css('overflow', 'scroll');
        }
        else
        {
            $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+this.ID).mousemove(function(e)
            {
                var thumbnailWidth;
                var thumbnailHeight;
                var mousePosition;
                var thumbnailsPosition;

                if ((Class.ThumbnailsPosition == 'top' || Class.ThumbnailsPosition == 'bottom') && $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width() > $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width())
                {
                    thumbnailWidth = Class.ThumbnailWidth+Class.ThumbnailPaddingRight+Class.ThumbnailPaddingLeft+2*Class.ThumbnailBorderSize;
                    mousePosition = e.clientX-$(this).offset().left;
                    thumbnailsPosition = 0-($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width())*mousePosition/$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width();

                    if (thumbnailsPosition > (-1)*thumbnailWidth && thumbnailsPosition != 0)
                    {
                        Class.thumbnailsMove = true;
                        thumbnailsPosition = 0;
                    }

                    if (thumbnailsPosition < (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width()-thumbnailWidth) && thumbnailsPosition != (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width()))
                    {
                        Class.thumbnailsMove = true;
                        thumbnailsPosition = (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).width());
                    }

                    if (Class.thumbnailsMove)
                    {
                        $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).stop(true, false).animate({'margin-left':thumbnailsPosition}, 300, function()
                        {
                            Class.thumbnailsMove = false;
                        });
                    }
                    else $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).stop(false, true).animate({'margin-left':thumbnailsPosition}, 300);
                }

                if ((Class.ThumbnailsPosition == 'right' || Class.ThumbnailsPosition == 'left') && $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).height() > $('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height())
                {
                    thumbnailHeight = Class.ThumbnailHeight+Class.ThumbnailPaddingTop+Class.ThumbnailPaddingBottom+2*Class.ThumbnailBorderSize;
                    mousePosition = e.clientY-$(this).offset().top;
                    thumbnailsPosition = 0-($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height())*mousePosition/$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height();

                    if (thumbnailsPosition > (-1)*thumbnailHeight && thumbnailsPosition != 0)
                    {
                        Class.thumbnailsMove = true;
                        thumbnailsPosition = 0;
                    }

                    if (thumbnailsPosition < (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height()-thumbnailHeight) && thumbnailsPosition != (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height()))
                    {
                        Class.thumbnailsMove = true;
                        thumbnailsPosition = (-1)*($('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsWrapper_'+Class.ID).height());
                    }

                    if (Class.thumbnailsMove)
                    {
                        $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).stop(true, false).animate({'margin-top':thumbnailsPosition}, 300, function()
                        {
                            Class.thumbnailsMove = false;
                        });
                    }
                    else $('#DOP_ThumbnailGallery_Thumbnails_'+Class.ID).stop(false, true).animate({'margin-top':thumbnailsPosition}, 300);
                }
            });
        }
    }

// ***** End Thumbnails *****

// ***** Begin Image *****

    this.initImage = function()
    {
        $('#DOP_ThumbnailGallery_Image_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).width());
        $('#DOP_ThumbnailGallery_Image_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).height());
        $('#DOP_ThumbnailGallery_ImageBackup_'+this.ID).width($('#DOP_ThumbnailGallery_Container_'+this.ID).width());
        $('#DOP_ThumbnailGallery_ImageBackup_'+this.ID).height($('#DOP_ThumbnailGallery_Container_'+this.ID).height());

        this.loadImage(1);
    }

    this.loadImage = function(no)
    {
        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailAlpha)/100}, 300);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).css('background-color', '#'+Class.ThumbnailBgColor);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).css('border-color', '#'+Class.ThumbnailBorderColor);

        this.currentImage = no;
        this.imageLoaded = false;

        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).stop(true, true).animate({'opacity':parseInt(Class.ThumbnailAlphaHover)/100}, 300);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).css('background-color', '#'+Class.ThumbnailBgColorHover);
        $('#DOP_ThumbnailGallery_ThumbContainer_'+this.currentImage).css('border-color', '#'+Class.ThumbnailBorderColorHover);
        
        $('#DOP_ThumbnailGallery_Image_'+this.ID).html('');
        $('#DOP_ThumbnailGallery_Image_'+this.ID).addClass('DOP_ThumbnailGallery_BigLoader');
        $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('display', 'none');
        $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('display', 'none');
        
        clearInterval(Class.SlideshowID);

        var img = new Image();

        $(img).load(function()
        {
            Class.imageLoaded = true;
            $('#DOP_ThumbnailGallery_Image_'+Class.ID).removeClass('DOP_ThumbnailGallery_BigLoader');
            $('#DOP_ThumbnailGallery_Image_'+Class.ID).html(this);
            Class.ImageWidth = $(this).width();
            Class.ImageHeight = $(this).height();
            Class.RPImage();
            $('#DOP_ThumbnailGallery_Image_'+Class.ID).stop(true, true).animate({'opacity':'0'}, 0, function()
            {                
                $('#DOP_ThumbnailGallery_Image_'+Class.ID).stop(true, true).animate({'opacity':'1'}, 600, function()
                {
                    $('#DOP_ThumbnailGallery_ImageBackup_'+Class.ID).html(img);
                    Class.RPImage();
                    if (!Class.ItemsHidden)
                    {
                        $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('display', 'block');
                        $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('display', 'block');
                    }
                     
                    if (Class.Slideshow == 'true')
                    {
                        if (Class.stopSlideshow && !Class.imageLoaded){
                            clearInterval(Class.SlideshowID);
                            Class.stopSlideshow = false;
                        }
                        else{
                            if  ((Class.SlideshowLoop == 'true' && Class.currentImage == Class.noImages) || Class.currentImage < Class.noImages) Class.SlideshowID = setInterval(Class.nextImage, parseInt(Class.SlideshowTime));
                        }
                    }
                });
            });
        }).attr('src', this.Images[no-1]);
    }

    this.RPImage = function()
    {
        PrototypesObject.ResizeItem2('#DOP_ThumbnailGallery_Image_'+this.ID, $('#DOP_ThumbnailGallery_Container_'+this.ID).width(), $('#DOP_ThumbnailGallery_Container_'+this.ID).height(), this.ImageWidth, this.ImageHeight, 'center');
        PrototypesObject.ResizeItem2('#DOP_ThumbnailGallery_ImageBackup_'+this.ID, $('#DOP_ThumbnailGallery_Container_'+this.ID).width(), $('#DOP_ThumbnailGallery_Container_'+this.ID).height(), this.ImageWidth, this.ImageHeight, 'center');
        this.RPButtons();
    }

// ***** End Image *****

// ***** Begin Buttons *****

    this.initButtons = function()
    {
        $('.DOP_ThumbnailGallery_Button').css('background-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_LeftIcon_'+this.ID).css('border-top-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_LeftIcon_'+this.ID).css('border-bottom-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_LeftIcon_'+this.ID).css('border-left-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_RightIcon_'+this.ID).css('border-top-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_RightIcon_'+this.ID).css('border-bottom-color', '#'+this.ButtonsColor);
        $('#DOP_ThumbnailGallery_Button_RightIcon_'+this.ID).css('border-right-color', '#'+this.ButtonsColor);

        $('#DOP_ThumbnailGallery_Button_LeftIcon_'+this.ID).css('border-right-color', '#'+this.ButtonsIconColor);
        $('#DOP_ThumbnailGallery_Button_RightIcon_'+this.ID).css('border-left-color', '#'+this.ButtonsIconColor);
        
        $('.DOP_ThumbnailGallery_Button').stop(true, true).animate({'opacity':parseInt(Class.ButtonsAlpha)/100}, 0);

        $('#DOP_ThumbnailGallery_ButtonLeft_'+this.ID).corner('right');
        $('#DOP_ThumbnailGallery_ButtonRight_'+this.ID).corner('left');

        $('#DOP_ThumbnailGallery_ButtonLeft_'+this.ID).hover(function()
        {
            $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('background-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-top-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-bottom-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-left-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).stop(true, true).animate({'opacity':parseInt(Class.ButtonsAlphaHover)/100}, 0);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-right-color', '#'+Class.ButtonsIconColorHover);
        }, function()
        {
            $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('background-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-top-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-bottom-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-left-color', '#'+Class.ButtonsColor);
            $('.DOP_ThumbnailGallery_Button').stop(true, true).animate({'opacity':parseInt(Class.ButtonsAlpha)/100}, 0);
            $('#DOP_ThumbnailGallery_Button_LeftIcon_'+Class.ID).css('border-right-color', '#'+Class.ButtonsIconColor);
        });

        $('#DOP_ThumbnailGallery_ButtonRight_'+this.ID).hover(function()
        {
            $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('background-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-top-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-bottom-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-right-color', '#'+Class.ButtonsColorHover);
            $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).stop(true, true).animate({'opacity':parseInt(Class.ButtonsAlphaHover)/100}, 0);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-left-color', '#'+Class.ButtonsIconColorHover);
        }, function()
        {
            $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('background-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-top-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-bottom-color', '#'+Class.ButtonsColor);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-right-color', '#'+Class.ButtonsColor);
            $('.DOP_ThumbnailGallery_Button').stop(true, true).animate({'opacity':parseInt(Class.ButtonsAlpha)/100}, 0);
            $('#DOP_ThumbnailGallery_Button_RightIcon_'+Class.ID).css('border-left-color', '#'+Class.ButtonsIconColor);
        });

        $('#DOP_ThumbnailGallery_ButtonLeft_'+this.ID).click(function()
        {
            if (Class.imageLoaded) Class.previousImage();
        });

        $('#DOP_ThumbnailGallery_ButtonRight_'+this.ID).click(function()
        {
            if (Class.imageLoaded) Class.nextImage();
        });
    }

    this.RPButtons = function()
    {
        $('#DOP_ThumbnailGallery_ButtonLeft_'+this.ID).css('margin-left', parseInt($('#DOP_ThumbnailGallery_Image_'+this.ID).css('margin-left')));
        $('#DOP_ThumbnailGallery_ButtonRight_'+this.ID).css('margin-left', parseInt($('#DOP_ThumbnailGallery_Image_'+this.ID).css('margin-left'))+($('#DOP_ThumbnailGallery_Image_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).width()));
        $('#DOP_ThumbnailGallery_ButtonLeft_'+this.ID).css('margin-top', parseInt($('#DOP_ThumbnailGallery_Image_'+Class.ID).css('margin-top'))+($('#DOP_ThumbnailGallery_Image_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).height())/2);
        $('#DOP_ThumbnailGallery_ButtonRight_'+this.ID).css('margin-top', parseInt($('#DOP_ThumbnailGallery_Image_'+Class.ID).css('margin-top'))+($('#DOP_ThumbnailGallery_Image_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).height())/2);
    }

    this.nextImage = function()
    {
        if (Class.currentImage == Class.noImages) Class.loadImage(1);
        else Class.loadImage(Class.currentImage+1);
    }

    this.previousImage = function()
    {
        if (this.currentImage == 1) this.loadImage(this.noImages);
        else this.loadImage(this.currentImage-1);
    }

// ***** End Buttons *****

// ***** End Auto Hide *****

    this.initAutoHide = function()
    {
        Class.HideID = setInterval(Class.hideItems, parseInt(Class.AutoHideTime));

        $('#DOP_ThumbnailGallery_Container_'+this.ID).hover(function()
        {
            Class.showItems();
        }, function()
        {
            Class.HideID = setInterval(Class.hideItems, parseInt(Class.AutoHideTime));
        });
    }

    this.showItems = function()
    {
        clearInterval(Class.HideID);
        Class.ItemsHidden = false;

        if (Class.imageLoaded)
        {
            $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('display', 'block');
            $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('display', 'block');
        }

        if (Class.ThumbnailsPosition == 'top') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-top':0}, 600);
        if (Class.ThumbnailsPosition == 'right') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-left': $('#DOP_ThumbnailGallery_Container_'+Class.ID).width()-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).width()}, 600);
        if (Class.ThumbnailsPosition == 'bottom') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-top':$('#DOP_ThumbnailGallery_Container_'+Class.ID).height()-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).height()}, 600);
        if (Class.ThumbnailsPosition == 'left') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-left':0}, 600);
    }

    this.hideItems = function()
    {
        clearInterval(Class.HideID);
        Class.ItemsHidden = true;

        $('#DOP_ThumbnailGallery_ButtonLeft_'+Class.ID).css('display', 'none');
        $('#DOP_ThumbnailGallery_ButtonRight_'+Class.ID).css('display', 'none');

        if (Class.ThumbnailsPosition == 'top') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-top': 0-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).height()}, 600);
        if (Class.ThumbnailsPosition == 'right') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-left': $('#DOP_ThumbnailGallery_Container_'+Class.ID).width()}, 600);
        if (Class.ThumbnailsPosition == 'bottom') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-top': $('#DOP_ThumbnailGallery_Container_'+Class.ID).height()}, 600);
        if (Class.ThumbnailsPosition == 'left') $('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).stop(true, true).animate({'margin-left': 0-$('#DOP_ThumbnailGallery_ThumbnailsContainer_'+Class.ID).width()}, 600);
    }

// ***** End Auto Hide *****

// ***** Begin Reset *****

    this.reset = function()
    {
        var i = 0;

        //
        //$(this.Container).html('');

        // ID
        this.ID = '';

        // Container
        this.Container = '';
        
        // Content
        for (i=0; i<this.noImages; i++)
        {
            this.Images[i] = '';
            this.Thumbs[i] = '';
            this.CaptionTitle[i] = '';
            this.CaptionText[i] = '';
        }

        this.noImages = 0;

        // Background
        this.BgImageLoaded = false;
        this.BgImageWidth = 0;
        this.BgImageHeight = 0;

        // Thumbnails
        this.thumbnailsMove = false;

        // Image
        this.currentImage = 0;
        this.imageLoaded = false;
        this.ImageWidth = 0;
        this.ImageHeight = 0;

        // Slideshow
        clearInterval(Class.SlideshowID);
        this.stopSlideshow = true;

        // Auto Hide
        clearInterval(Class.HideID);
        this.ItemsHidden = false;
    }

// ***** End Reset *****

}
