﻿///图片切换
Advertisement = function() {
    var container = $('#ad-container');  //滚动广告的ID
    var close;
    function showAd(time) {
        setTimeout(function() {
            $(container).show();
        }, time);
    }

    function hideAd(time) {
        setTimeout(function() {
            $(container).hide();
        }, time);
    }

    function scrollAd() {
        var offset = $(window).height() - $(container).height() + $(document).scrollTop();
        $(container).animate({ top: offset }, { duration: 800, queue: false });
    }




    return {
        Show: function(containerId, closeId) {
            container = $('#' + containerId);
            close = $('#' + closeId);
    
            $(close).click(function() {
                $(container).hide();
            });

            showAd(1000); //页面加载完毕多久后显示广告

            scrollAd();

            $(window).scroll(scrollAd);
        }
    }
} ();        
        
