
    $(document).ready(function()
    {
        var PrototypesObject = new Prototypes();
        var noImages = images.length;
        var imageLoaded = new Array();
        var HTML = '';
        var i;
        var TransitionDelay = 2000;
        var TransitionDuration = 300;
        var currentImage = 0;
        var AnimationID;
        
        for (i=1; i<=(noImages); i++)
        {
            HTML += '<div class="splash-image" id="splash-image'+i+'"></div>';
            imageLoaded[i] = false;
        }
        HTML += '<div class="splash-image" id="splash-logo"></div>';
        $('#splash-slideshow').html(HTML);

        $('#splash-slideshow').click(function()
        {
            window.location = mainURL;
        });

        RPSplashSlideshow();

        var img = new Image();

        $(img).load(function()
        {
            $('#splash-logo').html(this);
            PrototypesObject.ResizeItem2('#splash-logo', $(window).width(), $(window).height(), 1920, 1200, 'center');

            $('#splash-logo').fadeIn(TransitionDuration);

            loadImage(1);
            animation();
        }).attr('src', logoURL);


        $(window).resize(function()
        {
            RPSplashSlideshow()
        });

        function RPSplashSlideshow()
        {
            $('#splash-slideshow').width($(window).width());
            $('#splash-slideshow').height($(window).height())
            $('.splash-link').width($(window).width());
            $('.splash-link').height($(window).height())
            $('.splash-image').width($(window).width());
            $('.splash-image').height($(window).height());
            PrototypesObject.ResizeItem2('#splash-logo', $(window).width(), $(window).height(), 1920, 1200, 'center');

            for (i=1; i<=(noImages); i++)
            {
                if (imageLoaded[i]) PrototypesObject.ResizeItem2('#splash-image'+i, $(window).width(), $(window).height(), 2920, 1200, 'center');
            }
        }

        function loadImage(no)
        {
            var img = new Image();

            $(img).load(function()
            {
                imageLoaded[no] = true;
                $('#splash-image'+no).html(this);
                $('#splash-link').css('z-index', 1000);
                PrototypesObject.ResizeItem2('#splash-image'+no, $(window).width(), $(window).height(), 2920, 1200, 'center');

                if (no < noImages) loadImage(no+1);
            }).attr('src', images[no-1]);
        }

        function animation()
        {
            clearInterval(AnimationID);
            var previousImage = currentImage;
            var nextImage = currentImage+1;
            if (currentImage == noImages) nextImage = 1;
            
            if (imageLoaded[nextImage] == true)
            {
                currentImage = nextImage;

                if (previousImage > 0)
                {
                    $('#splash-image'+previousImage).fadeOut(TransitionDuration, function()
                    {
                        $('#splash-image'+currentImage).fadeIn(TransitionDuration, function()
                        {
                            AnimationID = setInterval(animation, TransitionDelay);
                        });
                    });
                }
                else
                {
                    $('#splash-image'+currentImage).fadeIn(TransitionDuration, function()
                    {
                        AnimationID = setInterval(animation, TransitionDelay);
                    });
                }
            }
            else AnimationID = setInterval(animation, 300);
        }
    });
