﻿/// <reference path="jquery-1[1].3.2-vsdoc2.js" />

jQuery.loading = function(title)
{
    var html = [
                 "<div class=\"popBoxBg\" id=\"popBoxBg_loading\">",
                     "<iframe style='backgroundColor:transparent;width:100%;height:100%;filter:alpha(opacity=0);'></iframe>", //IE6下遮挡select,同时遮挡未设通明属性的flash
                 "</div>",
                 "<div class=\"popBoxContainer\" id=\"popBoxContainer_loading\">",
                    "<div class=\"popBox\">",
	                    "<table width=\"500\" cellspacing=\"0\" cellpadding=\"0\">",
		                    "<tbody>",
		                        "<tr>",
			                        "<td class=\"pbCtl\"/>",
			                        "<td class=\"pbCt\"/>",
			                        "<td class=\"pbCtr\"/>",
		                        "</tr>",
		                        "<tr>",
			                        "<td class=\"pbL\"/>",
			                        "<td>",
				                        "<div class=\"pbInsideContent\">",
					                        "<div class=\"content\">",
						                        "<div class=\"popBody\">",
                                                    "<img src=\"http://sns.qidian.com/images/new/ajax-loader-32x32.gif\"/>",
                                                    "&nbsp;&nbsp;&nbsp;<h2 style=\"display: inline;\">{0}</h2>".format(title || "处理中..."),
						                        "</div>",
					                        "</div>",
				                        "</div>",
			                        "</td>",
			                        "<td class=\"pbR\"/>",
		                        "</tr>",
		                        "<tr>",
			                        "<td class=\"pbCbl\"/>",
			                        "<td class=\"pbBt\"/>",
			                        "<td class=\"pbCbr\"/>",
		                        "</tr>",
	                        "</tbody>",
	                    "</table>",
                    "</div>",
                 "</div>"
               ].join("");

    jQuery(document.body).append(html);
    ///关闭滚轮事件，隐藏滚动条
    if (!jQuery.browser.msie || document.all[0].nodeValue)
    {
        jQuery(document.documentElement).css("overflow-y", "hidden");
    }
    else
    {
        jQuery(document.body).css("overflow-y", "hidden");
    }
    if (!jQuery.browser.msie && !jQuery.browser.mozilla)
    {
        jQuery(document).bind("mousewheel", stopScroll);
    }

    ///设置IE6遮罩层高度, 拉动窗口时改变遮罩的尺寸, 处理无文档头的问题（主站章节阅读页）
    if (jQuery.browser.msie && (!jQuery.browser.msie < 7 || !document.all[0].nodeValue))
    {
        ///修补IE6无法遮挡select的bug 和设置IE6遮罩层高度, 拉动窗口时改变遮罩的尺寸, 处理无文档头的问题（主站章节阅读页）
        ///设置对话框的top;
        jQuery("#popBoxContainer_loading").css({ top: jQuery(window).scrollTop() + 100 });
        jQuery(window).resize(
                                function()
                                {
                                    jQuery("#popBoxBg_loading").css(
                                                                {
                                                                    height: jQuery(window).height(),
                                                                    width: jQuery(window).width(),
                                                                    top: jQuery(window).scrollTop()
                                                                }
                                                            );
                                }
                            );
        jQuery("#popBoxBg_loading").css(
                                        {
                                            height: jQuery(window).height(),
                                            width: jQuery(window).width(),
                                            top: jQuery(window).scrollTop()
                                        }
                                      );
        if (!document.all[0].nodeValue)
        {
            jQuery("#popBoxContainer_loading table:first").css({ marginLeft: (jQuery(window).width() - jQuery("#popBoxContainer_loading table:first").width()) / 2 });
            jQuery(window).resize(
                                    function()
                                    {
                                        jQuery("#popBoxContainer_loading table:first").css({ marginLeft: (jQuery(window).width() - jQuery("#popBoxContainer_loading table:first").width()) / 2 });
                                    }
                                );
        }
    }
}
jQuery.loadingClose = function()
{
    ///恢复滚轮事件，滚动条
    if (!jQuery.browser.msie || document.all[0].nodeValue)
    {
        jQuery(document.documentElement).css("overflow-y", "scroll");
    }
    else
    {
        jQuery(document.body).css("overflow-y", "scroll");
    } 
    if (!jQuery.browser.msie && !jQuery.browser.mozilla)
    {
        jQuery(document).unbind("mousewheel", stopScroll);
    }
    jQuery("#popBoxBg_loading,#popBoxContainer_loading".format(this.uniqueId)).remove();
}