﻿/* This script is used to show the splash page */
;(function($) {

    $.splash = function(mode) { splash(mode); };
    $.resetSplash = function() { resetSplash(); };

    function splash(mode) {
        var showSplash = $.cookie('showSplash'); // 'true'; set to true to play every time;
        if (mode == 'replay') {
            showSplash = 'true';
        }
        var dtSplashEx = new Date();
        dtSplashEx.setDate(dtSplashEx.getDate() + 1);
        if (showSplash == null || showSplash == 'true') {
            $('html,body').animate({ scrollTop: 0 }, 2000);
            $.blockUI({ message: $('#splash'), centerY: false,
                overlayCSS: { backgroundColor: '#182e42', opacity: '1', margin: '0px' },
                css: { position: 'absolute', top: '0px', left: '0px', height: '100%',
                    width: '100%', margin: '0px auto', cursor: 'auto', padding: '0px'
                }, fadeIn: 2000
            });
            $("#splash_img_1").fadeIn({
                duration: 2000,
                queue: "splashQ",
                preDelay: 2000
            });
            $("#splash_img_2").fadeIn({
                duration: 2000,
                queue: "splashQ"
            });
            $("#splash_img_3_bg").fadeIn({
                duration: 4000,
                queue: "splashQ",
                wait: 2000
            });
            $("#splash_img_3").fadeIn({
                duration: 18000,
                queue: "splashQ",
                scope: "01"
            });
            $("#splash_img_3").animate({
                left: "0px"
            },
            { duration: 10000,
                queue: "splashQ",
                easing: "linear",
                scope: "01"
            });
            $("#splash_img_4").fadeIn({
                duration: 18000,
                queue: "splashQ",
                scope: "02"
            });
            $("#splash_img_4").animate({
                top: "505px"
            },
            { duration: 10000,
                queue: "splashQ",
                easing: "linear",
                scope: "02"
            });
            $.cookie('showSplash', 'false', { expires: dtSplashEx });
            //setTimeout(function() { $.unblockUI({ fadeOut: 2000 }); }, 30000);
            resetSplash();
        }
        else {
            dtSplashEx.setDate(dtSplashEx.getDate() + 1);
            $.cookie('showSplash', 'false', { expires: dtSplashEx });
        }
    }
    function resetSplash() {
        $('#splash_container img').each(function() {
            $(this).stop();
            $(this).css({ left: "", display: "" });
        });
    }

})(jQuery);
