﻿document.writeln('<div id="WPA_ADWrap" style="margin: 0; padding: 0; position: absolute; left: 0; top: 0; z-index: 901; width: 100%; display: none;">');
document.writeln('  <div id="WPA_ADHolder_Face" style="margin: 0; padding: 0; position: absolute; left: 0; top: 0; z-index: 904; width: 100%;">');
document.writeln('      <div class="WPA_ContentWrap" style="margin: 0 auto;">');
document.writeln('          <div class="WPA_ToolBar" style="height: 20px;"><span class="WPA_TipTxt" style="height: 20px; float: left;"></span><a class="WPA_CloseBtn" href="javascript:void(0);" style="float: right; text-decoration: none; color: #000;">[关闭]</a></div>');
document.writeln('          <div class="WPA_Content"></div>');
document.writeln('      </div>');
document.writeln('  </div>');
document.writeln('  <div id="WPA_ADHolder_T" style="margin: 0; padding: 0; position: absolute; left: 0; top: 0; z-index: 903; width: 100%; background-color: #fff; filter: alpha(opacity=95); opacity: 0.95;">');
document.writeln('  </div>');
document.writeln('  <div id="WPA_ADHolder_B" style="margin: 0; padding: 0; position: absolute; left: 0; top: 0; z-index: 902; width: 100%; background-color: #fff; filter: alpha(opacity=95); opacity: 0.95;">');
document.writeln('  </div>');
document.writeln('</div>');
(function() {
    var id = 'WPA_Hide';
    var self = this;
    var timeoutID = null;
    var countTime = 10;
    var w = 0;
    var h = 0;
    var obj = '';

    var tempheight = document.documentElement.clientHeight;

    var init = function() {
        if ($('#' + id).children().length < 1) {
            $('#' + id).css('display', 'none');
            return;
        }

        if ($('#' + id + ' img').length > 0) {
            w = $('#' + id + ' img').width();
            h = $('#' + id + ' img').height();
        }
        else {
            w = parseInt($('#' + id).children().not('script').attr('width').replace('px', ''));
            h = parseInt($('#' + id).children().not('script').attr('height').replace('px', ''));
        }

        obj = $('#' + id).children().not('script');

        var viewWidth = $(window).width();
        var viewHeight = $(window).height();
        var mainHeight = $("body").height();
        $('#WPA_ADWrap').css({
            height: '2750px',
            display: 'block'
        });

        $('#WPA_ADHolder_Face').css({
            height: '2750px'
        });
        $('.WPA_ContentWrap').css({
            width: w + 'px',
            height: h + 20 + 'px',
            'margin-top': parseInt((viewHeight - (h + 20)) / 2) + 'px'
        });

        $('.WPA_TipTxt').html('正在加载网站内容，请稍等...' + countTime + '秒');
        $('.WPA_CloseBtn').click(function() {
            self.close();
        });

        $('.WPA_Content').html(obj);

        $('#WPA_ADHolder_T').css({
            height: parseInt(viewHeight / 2) + 'px'
        });

        $('#WPA_ADHolder_B').css({
            // height: viewHeight - parseInt(viewHeight / 2) + 'px',
            height: 2250 + 'px',
            top: parseInt(viewHeight / 2) + 'px'
        });

        timeoutID = window.setInterval(function() {
            countTime--;
            if (countTime <= 0) {
                 self.close();
            }
            else {
                $('.WPA_TipTxt').html('正在加载网站内容，请稍等...' + countTime + '秒');
            }
        }, 1000);
    };

    this.close = function() {
        window.clearInterval(timeoutID);
        timeoutID = null;
        countTime = 999;

        $('.WPA_ToolBar').css('visibility', 'hidden');
        $("#WPA_ADHolder_T").append($('#WPA_ADHolder_Face .WPA_ContentWrap').clone());

        $("#WPA_ADHolder_B").append($('#WPA_ADHolder_Face .WPA_ContentWrap').clone());
        var wrapHeight = parseInt($("#WPA_ADHolder_B .WPA_ContentWrap").height() / 2) * (-1);
        $("#WPA_ADHolder_B .WPA_ContentWrap").css('margin-top', wrapHeight + 'px');

        $('#WPA_ADHolder_Face').css('display', 'none');

        $("#WPA_ADHolder_T").animate({
            top: $('#WPA_ADHolder_T').height() * (-1) + 'px'
        },
        1000,
        function() {
            $("#WPA_ADHolder_T").css('display', 'none');
        });

        $("#WPA_ADHolder_B").animate({
            top: $(window).height() + 'px'
        },
        1000,
        function() {
            $("#WPA_ADHolder_B").css('display', 'none');
            $("#WPA_ADWrap").css('display', 'none');
        });
    };

    init();
})();
