﻿/*
* jqDnR - Minimalistic Drag'n'Resize for jQuery.
*
* Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
* 
* $Version: 2007.08.19 +r2
*/

(function($) {
    $.fn.jqDrag = function(h) { return i(this, h, 'd'); };
    $.fn.jqResize = function(h) { return i(this, h, 'r'); };
    $.jqDnR = { dnr: {}, e: 0,
        drag: function(v) {
            if (M.k == 'd') E.css({ left: M.X + v.pageX - M.pX, top: M.Y + v.pageY - M.pY });
            else E.css({ width: Math.max(v.pageX - M.pX + M.W, 0), height: Math.max(v.pageY - M.pY + M.H, 0) });
            return false;
        },
        stop: function() { E.css('opacity', M.o); $().unbind('mousemove', J.drag).unbind('mouseup', J.stop); }
    };
    var J = $.jqDnR, M = J.dnr, E = J.e,
i = function(e, h, k) {
    return e.each(function() {
        h = (h) ? $(h, e) : e;
        h.bind('mousedown', { e: e, k: k }, function(v) {
            var d = v.data, p = {}; E = d.e;
            // attempt utilization of dimensions plugin to fix IE issues
            if (E.css('position') != 'relative') { try { E.position(p); } catch (e) { } }
            M = { X: p.left || f('left') || 0, Y: p.top || f('top') || 0, W: f('width') || E[0].scrollWidth || 0, H: f('height') || E[0].scrollHeight || 0, pX: v.pageX, pY: v.pageY, k: d.k };
            $().mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
            return false;
        });
    });
},
f = function(k) { return parseInt(E.css(k)) || false; };
})(jQuery);

/*
* jqModal - Minimalist Modaling with jQuery
*   (http://dev.iceburg.net/jquery/jqmodal/)
*
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
* Dual licensed under the MIT and GPL licenses:
*   http://www.opensource.org/licenses/mit-license.php
*   http://www.gnu.org/licenses/gpl.html
* 
* $Version: 07/06/2008 +r13
*/
(function($) {
    $.fn.jqm = function(o) {
        var p = {
            overlay: 50,
            overlayClass: 'jqmOverlay',
            closeClass: 'spacemsgClose',
            trigger: '.jqModal',
            ajax: F,
            ajaxText: '',
            target: F,
            modal: F,
            toTop: F,
            onShow: F,
            onHide: F,
            onLoad: F
        };
        return this.each(function() {
            if (this._jqm) return H[this._jqm].c = $.extend({}, H[this._jqm].c, o); s++; this._jqm = s;
            H[s] = { c: $.extend(p, $.jqm.params, o), a: F, w: $(this).addClass('jqmID' + s), s: s };
            if (p.trigger) $(this).jqmAddTrigger(p.trigger);
        });
    };

    $.fn.jqmAddClose = function(e) { return hs(this, e, 'jqmHide'); };
    $.fn.jqmAddTrigger = function(e) { return hs(this, e, 'jqmShow'); };
    $.fn.jqmShow = function(t) { return this.each(function() { $.jqm.open(this._jqm, t); }); };
    $.fn.jqmHide = function(t) { return this.each(function() { $.jqm.close(this._jqm, t) }); };

    $.jqm = {
        hash: {},
        open: function(s, t) {
            var h = H[s],
            c = h.c,
            cc = '.' + c.closeClass,
            z = (parseInt(h.w.css('z-index'))),
            z = (z > 0) ? z : 3000,
            o = $('<div></div>').css({ height: '100%', width: '100%', position: ie6 ? 'absolute' : 'fixed', left: 0, top: 0, 'z-index': z - 1, opacity: c.overlay / 100 });
            if (h.a) return F; h.t = t; h.a = true; h.w.css('z-index', z);
            if (c.modal) { if (!A[0]) L('bind'); A.push(s); }
            else if (c.overlay > 0) h.w.jqmAddClose(o);
            else o = F;
            h.o = (o) ? o.addClass(c.overlayClass).prependTo('body') : F;
            if (ie6) { $('html,body').css({ height: '100%', width: '100%' }); if (o) { o = o.css({ position: 'absolute' })[0]; for (var y in { Top: 1, Left: 1 }) o.style.setExpression(y.toLowerCase(), "(_=(document.documentElement.scroll" + y + " || document.body.scroll" + y + "))+'px'"); } }
            if (c.ajax) {
                var r = c.target || h.w, u = c.ajax, r = (typeof r == 'string') ? $(r, h.w) : $(r), u = (u.substr(0, 1) == '@') ? $(t).attr(u.substring(1)) : u;
                r.html(c.ajaxText).load(u, function() { if (c.onLoad) c.onLoad.call(this, h); if (cc) h.w.jqmAddClose($(cc, h.w)); e(h); });
            }
            else if (cc) h.w.jqmAddClose($(cc, h.w));
            else if (cc) h.w.jqmAddClose($(cc, h.w));
            else if (cc) h.w.jqmAddClose($(cc, h.w));

            if (c.toTop && h.o) h.w.before('<span id="jqmP' + h.w[0]._jqm + '"></span>').insertAfter(h.o);
            (c.onShow) ? c.onShow(h) : h.w.show(); e(h); return F;
        },
        close: function(s) {
            var h = H[s]; if (!h.a) return F; h.a = F;
            if (A[0]) { A.pop(); if (!A[0]) L('unbind'); }
            if (h.c.toTop && h.o) $('#jqmP' + h.w[0]._jqm).after(h.w).remove();
            if (h.c.onHide) h.c.onHide(h); else { h.w.hide(); if (h.o) h.o.remove(); } return F;
        },
        params: {}
    };
    var s = 0, H = $.jqm.hash, A = [], ie6 = $.browser.msie && ($.browser.version == "6.0"), F = false,
i = $('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({ opacity: 0 }),
e = function(h) { if (ie6) if (h.o) h.o.html('<p style="width:100%;height:100%"/>').prepend(i); else if (!$('iframe.jqm', h.w)[0]) h.w.prepend(i); f(h); },
f = function(h) { try { $(':input:visible', h.w)[0].focus(); } catch (_) { } },
L = function(t) { $()[t]("keypress", m)[t]("keydown", m)[t]("mousedown", m); },
m = function(e) { var h = H[A[A.length - 1]], r = (!$(e.target).parents('.jqmID' + h.s)[0]); if (r) f(h); return !r; },
hs = function(w, t, c) {
    return w.each(function() {
        var s = this._jqm; $(t).each(function() {
            if (!this[c]) { this[c] = []; $(this).click(function() { for (var i in { jqmShow: 1, jqmHide: 1 }) for (var s in this[i]) if (H[this[i][s]]) H[this[i][s]].w[i](this); return F; }); } this[c].push(s);
        });
    });
};
})(jQuery);

function spacePopTool() {
    /*新增的方法*/
    this.isESC_jqm = 27;
    this.isEnter_jqm = 13;
    this.isSpace_jqm = 32;
    this.pubIsSlide = false;
    this.setTimeOut_jqm = null;
    this.initTop = null;
    this.initialize();
}
spacePopTool.prototype.initialize = function() {
    var toolTmp = this;
    $(document).bind("keydown", function(e) { toolTmp.spaceKeyDown(e); });
    //处理IE6下滚动时的定位
    if ($.browser.version == "6.0") {
        $(window).bind("scroll", function() {
            if (toolTmp.initTop == null) toolTmp.initTop = 150;
            var topscroll = parseInt(document.documentElement.scrollTop || document.body.scrollTop, 10);
            $("#spaceWindow").css("top", parseInt(toolTmp.initTop, 10) + topscroll);
            $("#spaceConfirm").css("top", parseInt(toolTmp.initTop, 10) + topscroll);
            $("#spaceAlert").css("top", parseInt(toolTmp.initTop, 10) + topscroll);
        });
    }
    // document.onkeydown=this.spaceKeyDown;   
}
///键盘控制
spacePopTool.prototype.spaceKeyDown = function(keyEvent) {
    //debugger;
    if (!keyEvent) keyEvent = window.event;
    var kc = keyEvent.which || keyEvent.keyCode;
    if (kc == this.isESC_jqm) {
        var isKey = true;
        this.closeSpaceAlert(isKey);
        this.closeSpaceWindow(isKey);
        this.closeSpaceConfirm(isKey);
        $(".jqmOverlay").remove();
        this.pubIsSlide = false;
    }

}
/* alert
msg:显示消息
title:标题
mode:[0:可操作 1：不可操作]
overlayParam:透明度 0----100;
isClose:true自动关闭
isSlide:true启用下滑效果
closeTime:自动关闭的时间
isObjPosition:在对象位置弹出
positionNumX:偏离对象X
positionNumY:偏离对象Y
w:宽
h:高
x:弹出框的位置X
y:弹出框的位置Y
onShowFn:显示CALLBACK

onHideFn:关闭CALLBACK
*/
spacePopTool.prototype.spaceAlert = function(param) {
    //debugger;
    if (typeof param == "string") {
        param = eval('(' + param + ')');
    }
    this.pubIsSlide = false;
    var toolTmp = this;
    param = param || {};
    if (undefined == param.onShowFn || typeof (param.onShowFn) != "function") param.onShowFn = function() { };
    if (undefined == param.onLoadFn || typeof (param.onLoadFn) != "function") param.onLoadFn = function() { };
    if (undefined == param.onHideFn || typeof (param.onHideFn) != "function") param.onHideFn = function() { };
    if (undefined == param.isSlide) param.isSlide = false;
    if (undefined == param.w) param.w = 350;
    if (undefined == param.h) param.h = 0;
    if (undefined == param.mode) param.mode = 1;
    if (undefined == param.overlayParam) param.overlayParam = 10;
    if (undefined == param.isClose) param.isClose = true;
    if (undefined == param.isSureBtn) param.isSureBtn = false;
    if (undefined == param.closeTime) param.closeTime = 3500;
    if (undefined == param.positionNumY) param.positionNumY = 0;
    if (undefined == param.positionNumX) param.positionNumX = 0;
    if (undefined == param.isObjPosition) param.isObjPosition = false;
    if (undefined == param.title) param.title = "提示";
    if (undefined == param.msg) param.msg = "无任何提示信息";
    if (undefined == param.x) {
        param.x = document.body.offsetWidth / 2 - param.w / 2;
    }
    else {
        param.x = param.x;
    }
    var scrollTop = document.documentElement.scrollTop;

    if (undefined == param.y) {
        param.y = 150;
    }
    else {
        param.y = param.y;
    }

    if (param.isObjPosition) {
        param.x = this.jqnGetElementLeft(param.isObjPosition, param.positionNumX);
        param.y = this.jqnGetElementTop(param.isObjPosition, param.positionNumY);
    }
    var alertHtml = "";
    this.initTop = param.y;
    if (param.isSlide) {
        alertHtml += "<div class='spaceMsg' style='left:0px;top:" + param.y + "px;width:" + param.w + "px' id='spaceAlert'>";
    }
    else {

        alertHtml += "<div class='spaceMsg' style='left:" + param.x + "px;top:" + param.y + "px;width:" + param.w + "px' id='spaceAlert'>";

    }
    alertHtml += "    <div class='spaceMsgbox' >";
    alertHtml += "       <table class='spacecontent' style='width:" + param.w + "px; ' >";
    alertHtml += "               <tbody>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgTl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgTr' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgMain'>";
    alertHtml += "                        <div class='hd alertHd' style='cursor: move;'>";
    alertHtml += "                            <h4>";
    alertHtml += "                                <span class='spacemsgClose' title='按ESC关闭'>关闭</span>" + param.title + "</h4>";
    alertHtml += "                        </div>";
    if (param.h != 0) {
        alertHtml += "                    <div class='bd alertBd'  style='height:" + param.h + "px;'>";
    }
    else {
        alertHtml += "                     <div class='bd alertBd'>";
    }
    alertHtml += "                        </div>";
    alertHtml += "                        <div class='ft'>";
    alertHtml += "                               <input type='button' class='btnNormal' id='spaceAlert_Sure' value='确定' />";
    alertHtml += "                         </div>";
    alertHtml += "                    </td>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgBr' />";
    alertHtml += "                </tr>";
    alertHtml += "            </tbody>";
    alertHtml += "        </table>";
    alertHtml += "    </div>";
    if ($.browser.msie) {
        if ($.browser.version == "6.0")
        //alertHtml += "    <iframe id='ifr_ie6' style=\"position: relative; visibility: inherit; width: " + param.w + " px;height: 600px; top: 0px; left: 0px; z-index: -1; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)'\" frameborder='0' scrolling='no' src=''></iframe>";
            alertHtml += "    <iframe id='ifr_ie6' style=\"position: absolute;width:100%;height:100%; top: 0px; left: 0px; z-index:0; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)' \" frameborder='0' scrolling='no' src=''></iframe>";

    }
    alertHtml += "</div>";


    if ($("#spaceAlert").length > 0) {
        $("#spaceAlert").remove();
    }
    $(alertHtml).appendTo(document.body);
    $("#spaceAlert").jqDrag('.alertHd');

    var slideShowFn;
    var slideHideFn;
    var showFn;
    var hideFn;
    var overlayParam = param.overlayParam;
    if (param.mode == 0) {
        overlayParam = 0;
        showFn = function(h) { $(".jqmOverlay").css("width", "0").css("height", "0"); };
        slideShowFn = function(h) { h.w.animate({ left: param.x + "px" }, 500, function() { showFn(); }); };
    }
    else {
        showFn = function(h) { };
        slideShowFn = function(h) { h.w.animate({ left: param.x + "px" }, 500); };
    }
    hideFn = function(h) { if (h.o) h.o.remove(); };
    var defaultFn = function() {
        if (this.setTimeOut_jqm != null) {
            window.clearTimeout(this.setTimeOut_jqm);
        }
        $("#spaceAlert").remove();

    };
    slideHideFn = function(h) { $('.jqmOverlay').remove(); h.w.animate({ left: "0px" }, 500, function() { defaultFn(); }); };
    if (param.isSlide) {
        this.pubIsSlide = true;
        $('#spaceAlert').jqm({ overlay: overlayParam, modal: true, trigger: false, onShow: function(h) { slideShowFn(h); param.onShowFn(); }, onHide: function(h) { slideHideFn(h); param.onHideFn(); }, onLoad: function() { param.onLoadFn(); } });
    }
    else {
        $('#spaceAlert').jqm({ overlay: overlayParam, modal: true, trigger: false, onShow: function(h) { showFn(h); param.onShowFn(); }, onHide: function(h) { defaultFn(); hideFn(h); param.onHideFn(); }, onLoad: function() { param.onLoadFn(); } });
    }
    $('#spaceAlert')
        .jqmShow()
        .find('div.alertBd')
          .html(param.msg);
    $("#spaceAlert_Sure").bind("click", function() { toolTmp.closeSpaceAlert(); });
    if (param.isClose) {
        this.setTimeOut_jqm = window.setTimeout("mySpacePopTool.closeSpaceAlert();", param.closeTime);
    }
}
spacePopTool.prototype.closeSpaceAlert = function(isKey) {
    if (this.setTimeOut_jqm != null) {
        window.clearTimeout(this.setTimeOut_jqm);
    }
    if (this.pubIsSlide) {
        $('.jqmOverlay').remove();
        $('#spaceAlert').animate({ left: "0px" }, 500, function() { $('#spaceAlert').remove(); });
    }
    else {
        $('#spaceAlert').jqmHide();
        $('.jqmOverlay').remove();
        $('#spaceAlert').remove();
    }
    $("#ifr_ie6").remove();
}
/* Window
type:"div","iframe"
divContent:显示内容
title:标题
isSlide:true启用效果
mode:[0:可操作 1：不可操作]
overlayParam:透明度 0----100;
isObjPosition:在对象位置弹出
positionNumX:偏离对象X
positionNumY:偏离对象Y
w:宽
h:高
x:弹出框的位置X
y:弹出框的位置Y
onShowFn:显示CALLBACK
onLoadFn:显示完CALLBACK
onHideFn:关闭CALLBACK
*/
spacePopTool.prototype.spaceWindow = function(param) {
    if (typeof param == "string") {
        param = eval('(' + param + ')');
    }
    this.pubIsSlide = false;
    param = param || {};
    if (undefined == param.onShowFn || typeof (param.onShowFn) != "function") param.onShowFn = function() { };
    if (undefined == param.onLoadFn || typeof (param.onLoadFn) != "function") param.onLoadFn = function() { };
    if (undefined == param.onHideFn || typeof (param.onHideFn) != "function") param.onHideFn = function() { };
    if (undefined == param.mode) param.mode = 1;
    if (undefined == param.overlayParam) param.overlayParam = 10;
    if (undefined == param.positionNumY) param.positionNumY = 0;
    if (undefined == param.positionNumX) param.positionNumX = 0;
    if (undefined == param.isObjPosition) param.isObjPosition = false;
    if (undefined == param.w) param.w = 400;
    if (undefined == param.x) {

        param.x = document.body.offsetWidth / 2 - param.w / 2;
    }
    else {
        param.x = param.x;
    }
    var scrollTop = document.documentElement.scrollTop;

    if (undefined == param.y) {
        param.y = 150;
    }
    else {
        param.y = param.y;
    }
    if (param.isObjPosition) {
        //alert(1);
        param.x = this.jqnGetElementLeft(param.isObjPosition, param.positionNumX);
        param.y = this.jqnGetElementTop(param.isObjPosition, param.positionNumY);
    }
    if (undefined == param.isSlide) param.isSlide = false;
    if (undefined == param.type) param.type = "div";
    if (undefined == param.divContent) param.divContent = "";
    if (undefined == param.h) param.h = 0;
    if (undefined == param.title) param.title = "提示";
    var alertHtml = "";
    this.initTop = param.y;
    if (param.isSlide) {
        alertHtml += "<div class='spaceMsg' style='left:0px;top:" + param.y + "px;width:" + param.w + "px' id='spaceWindow'>";
    }
    else {

        alertHtml += "<div class='spaceMsg' style='left:" + param.x + "px;top:" + param.y + "px;width:" + param.w + "px' id='spaceWindow'>";

    }
    alertHtml += "    <div class='spaceMsgbox' >";
    alertHtml += "       <table class='spacecontent' style='width:" + param.w + "px; ' >";
    alertHtml += "               <tbody>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgTl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgTr' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgMain'>";
    alertHtml += "                        <div class='hd windowHd' style='cursor: move;'>";
    alertHtml += "                            <h4>";
    alertHtml += "                                <span class='spacemsgClose'  title='按ESC关闭'>关闭</span>" + param.title + "</h4>";
    alertHtml += "                        </div>";
    if (param.h != 0) {
        alertHtml += "                    <div class='bd windowBd'  style='height:" + param.h + "px;'>";
    }
    else {
        alertHtml += "                     <div class='bd windowBd'>";
    }
    alertHtml += "                        </div>";
    alertHtml += "                        <div class='ft'>";
    //alertHtml += "                               <input type='button' value='' style='position:absolute;left:10000px;top:10000px;width:0px;height:0px;' />";
    alertHtml += "                         </div>";
    alertHtml += "                    </td>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgBr' />";
    alertHtml += "                </tr>";
    alertHtml += "            </tbody>";
    alertHtml += "        </table>";

    alertHtml += "    </div>";
    //alert(1);

    alertHtml += "</div>";
    if ($.browser.msie) {
        if ($.browser.version == "6.0") {
            //alertHtml += "    <iframe id='ifr_ie6' style=\"position: absolute; width:100%;height: 100%; top: 0px; left: 0px; z-index: 0;\" frameborder='0' scrolling='no' src=''></iframe>";
            alertHtml += "    <iframe id='ifr_ie6' style=\"position: absolute;width:100%;height:100%; top: 0px; left: 0px; z-index:0; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)' \" frameborder='0' scrolling='no' src=''></iframe>";

        }
    }
    if ($("#spaceWindow").length > 0) {
        $("#spaceWindow").remove();
    }
    $(alertHtml).appendTo(document.body);
    $("#spaceWindow").jqDrag('.windowHd');
    var slideShowFn;
    var slideHideFn;
    var showFn;
    var hideFn;
    var overlayParam = param.overlayParam;
    if (param.mode == 0) {
        overlayParam = 0;
        showFn = function(h) { $(".jqmOverlay").css("width", "0").css("height", "0"); };
        slideShowFn = function(h) { h.w.animate({ left: param.x + "px" }, 500, function() { showFn(); }); };
    }
    else {
        showFn = function(h) { };
        slideShowFn = function(h) { h.w.animate({ left: param.x + "px" }, 500); };
    }
    hideFn = function(h) { if (h.o) h.o.remove(); };
    var defaultFn = function() { $("#spaceWindow").remove(); };
    slideHideFn = function(h) { $('.jqmOverlay').remove(); h.w.animate({ left: "0px" }, 500, function() { defaultFn(); }); };
    if (param.isSlide && param.type == "div") {
        this.pubIsSlide = true;
        // alert(pubIsSlide); 
        $('#spaceWindow').jqm({ overlay: overlayParam, modal: true, trigger: true, onShow: function(h) { slideShowFn(h); }, onHide: function(h) { slideHideFn(h); param.onHideFn(); } });
    }
    else {
        $('#spaceWindow').jqm({ overlay: overlayParam, modal: true, trigger: true, onShow: function(h) { showFn(h); }, onHide: function(h) { defaultFn(); hideFn(h); param.onHideFn(); }, onLoad: function() { param.onLoadFn(); } });
    }
    if (param.type == "div") {
        $('#spaceWindow')
            .jqmShow()
            .find('div.windowBd')
              .html(param.divContent);
    }
    else {
        $('#spaceWindow')
                .jqmShow()
                .find('div.windowBd')
                  .html("<iframe  style='margin: 0pt; padding: 0pt; width: 100%; height: 100%;' id=\"spaceWindowIframe\" scrolling='no' frameborder='0' src=''></iframe>");
        $('#spaceWindowIframe').attr("src", param.divContent);
    }
    param.onShowFn();
}
spacePopTool.prototype.closeSpaceWindow = function(isKey) {
    if (this.pubIsSlide) {
        $('.jqmOverlay').remove();
        $('#spaceWindow').animate({ left: "0px" }, 500, function() { $('#spaceWindow').remove(); });
    }
    else {
        $('#spaceWindow').jqmHide();
        $('#spaceWindow').remove();
        $('.jqmOverlay').remove();
    }
    $("#ifr_ie6").remove();
}

/* alert
msg:显示消息
title:标题
isObjPosition:在对象位置弹出
positionNumX:偏离对象X
positionNumY:偏离对象Y
w:宽
h:高
x:弹出框的位置X
y:弹出框的位置Y
onYesFn:确定后运行的函数
onN0Fn:取消后运行的函数
*/
spacePopTool.prototype.spaceConfirm = function(param) {
    //debugger;
    if (typeof param == "string") {
        param = eval('(' + param + ')');
    }
    param = param || {};
    this.pubIsSlide = false;
    if (undefined == param.onYesFn || typeof (param.onYesFn) != "function") param.onYesFn = function() { };
    if (undefined == param.onNoFn || typeof (param.onNoFn) != "function") param.onNoFn = function() { };
    if (undefined == param.onShowFn || typeof (param.onShowFn) != "function") param.onShowFn = function() { };
    if (undefined == param.onLoadFn || typeof (param.onLoadFn) != "function") param.onLoadFn = function() { };
    if (undefined == param.onHideFn || typeof (param.onHideFn) != "function") param.onHideFn = function() { };
    if (undefined == param.isSlide) param.isSlide = false;
    if (undefined == param.w) param.w = 400;
    if (undefined == param.h) param.h = 0;
    if (undefined == param.overlayParam) param.overlayParam = 10;
    if (undefined == param.positionNumX) param.positionNumX = 0;
    if (undefined == param.positionNumY) param.positionNumY = 0;
    if (undefined == param.isObjPosition) param.isObjPosition = false;
    if (undefined == param.title) param.title = "提示";
    if (undefined == param.msg) param.msg = "无任何提示信息";
    if (undefined == param.x) {

        param.x = document.body.offsetWidth / 2 - param.w / 2;
    }
    else {
        param.x = param.x;
    }
    var scrollTop = document.documentElement.scrollTop;

    if (undefined == param.y) {
        param.y = 150;
    }
    else {
        param.y = param.y;
    }
    if (param.isObjPosition) {
        param.x = this.jqnGetElementLeft(param.isObjPosition, param.positionNumX);
        param.y = this.jqnGetElementTop(param.isObjPosition, param.positionNumY);
    }

    var alertHtml = "";
    this.initTop = param.y;
    if (param.isSlide) {
        alertHtml += "<div class='spaceMsg' style='left:0px;top:" + param.y + "px;width:" + param.w + "px' id='spaceConfirm'>";
    }
    else {

        alertHtml += "<div class='spaceMsg' style='left:" + param.x + "px;top:" + param.y + "px;width:" + param.w + "px' id='spaceConfirm'>";

    }
    alertHtml += "    <div class='spaceMsgbox' >";
    alertHtml += "       <table class='spacecontent' style='width:" + param.w + "px; ' >";
    alertHtml += "               <tbody>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgTl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgTr' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgMain'>";
    alertHtml += "                        <div class='hd confirmHd' style='cursor: move;'>";
    alertHtml += "                            <h4>";
    alertHtml += "                                <span class='spacemsgClose'  title='按ESC关闭'>关闭</span>" + param.title + "</h4>";
    alertHtml += "                        </div>";
    if (param.h != 0) {
        alertHtml += "                    <div class='bd confirmBd'  style='height:" + param.h + "px;'>";
    }
    else {
        alertHtml += "                     <div class='bd confirmBd'>";
    }
    alertHtml += "                        </div>";
    alertHtml += "                        <div class='ft'>";
    alertHtml += "                               <input type='button' class='btnNormal confirmBtn' id='spaceConfirm_Sure' value='确定' />&nbsp;<input type='button' class='btnCancel confirmBtn' id='spaceConfirm_Cancle' value='取消' />";
    alertHtml += "                         </div>";
    alertHtml += "                    </td>";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                </tr>";
    alertHtml += "                <tr>";
    alertHtml += "                    <td class='spacemsgBl' />";
    alertHtml += "                    <td class='spacemsgBorder' />";
    alertHtml += "                    <td class='spacemsgBr' />";
    alertHtml += "                </tr>";
    alertHtml += "            </tbody>";
    alertHtml += "        </table>";
    alertHtml += "    </div>";

    alertHtml += "</div>";
    if ($.browser.msie) {
        if ($.browser.version == "6.0") {
            alertHtml += "    <iframe id='ifr_ie6' style=\"position: absolute;width:100%;height:100%; top: 0px; left: 0px; z-index:0; filter='progid:dximagetransform.microsoft.alpha(style=0,opacity=0)' \" frameborder='0' scrolling='no' src=''></iframe>";
        }
    }
    if ($("#spaceConfirm").length > 0) {
        $("#spaceConfirm").remove();
    }
    $(alertHtml).appendTo(document.body);
    $("#spaceConfirm").jqDrag('.confirmHd');
    $("#spaceConfirm_Sure").bind("click", function() { param.onYesFn(); closeSpaceConfirm(); });
    $("#spaceConfirm_Cancle").bind("click", function() { param.onNoFn(); closeSpaceConfirm(); });
    $("#spaceConfirm_Sure").bind("keydown", function(e) { if (e.keyCode == 39 || e.keyCode == 37) $("#spaceConfirm_Cancle").focus(); });
    $("#spaceConfirm_Cancle").bind("keydown", function(e) { if (e.keyCode == 39 || e.keyCode == 37) $("#spaceConfirm_Sure").focus(); });
    var defaultFn = function() { $("#spaceConfirm").remove(); $('.jqmOverlay').remove(); };
    var slideShowFn = function(h) { h.w.animate({ left: param.x + "px" }, 500); };
    var slideHideFn = function(h) { $('.jqmOverlay').remove(); h.w.animate({ left: "0px" }, 500, function() { defaultFn(); }); };
    var showFn = function(h) { };
    var hideFn = function(h) { if (h.o) h.o.remove(); };

    var overlayParam = param.overlayParam;
    if (param.isSlide) {
        this.pubIsSlide = true;
        $('#spaceConfirm').jqm({ overlay: overlayParam, modal: true, trigger: false, onShow: function(h) { slideShowFn(h); param.onShowFn(); }, onHide: function(h) { slideHideFn(h); param.onHideFn(); }, onLoad: function() { param.onLoadFn(); } });
    }
    else {
        $('#spaceConfirm').jqm({ overlay: overlayParam, modal: true, trigger: false, onShow: function(h) { showFn(h); param.onShowFn(); }, onHide: function(h) { defaultFn(); hideFn(h); param.onHideFn(); }, onLoad: function() { param.onLoadFn(); } });
    }
    $('#spaceConfirm')
        .jqmShow()
        .find('div.confirmBd')
          .html(param.msg);

}
spacePopTool.prototype.closeSpaceConfirm = function(isKey) {
    if (this.pubIsSlide) {
        $('.jqmOverlay').remove();
        $('#spaceConfirm').animate({ left: "0px" }, 500, function() { $('#spaceConfirm').remove(); });
    }
    else {
        $('#spaceConfirm').jqmHide();
        $('#spaceConfirm').remove();
        $('.jqmOverlay').remove();
    }
    $("#ifr_ie6").remove();
}
/*辅助方法*/
spacePopTool.prototype.jqnGetElementTop = function(obj, positionNum) {
    var y = obj.offsetTop;
    var theight = obj.offsetHeight / 3;
    var divScrollTop = 0; //处理有滚动条的时候
    if ($(".DIVscroll").length > 0) {
        divScrollTop = $(".DIVscroll")[0].scrollTop;
    }
    while (obj = obj.offsetParent) y += obj.offsetTop;
    if (document.all) {
        if (typeof (positionNum) != 'undefined') {
            return y + positionNum + theight - divScrollTop;
        } else {
            return y + theight - divScrollTop;
        }
    }
    else {
        if (typeof (positionNum) != 'undefined') {
            return (y + positionNum + theight - divScrollTop) + "px";
        } else {
            return (y + theight - divScrollTop) + "px";
        }
    }
}
spacePopTool.prototype.jqnGetElementLeft = function(obj, positionNum) {
    var x = obj.offsetLeft;
    var twidth = obj.offsetWidth;
    while (obj = obj.offsetParent) x += obj.offsetLeft;
    if (document.all) {
        return x - positionNum;
    } else {
        return (x - positionNum) + "px";
    }
}
$(document).ready(function() {
    mySpacePopTool = new spacePopTool();
    spaceAlert = function(param) {
        mySpacePopTool.spaceAlert(param);
    };
    spaceConfirm = function(param) {
        mySpacePopTool.spaceConfirm(param);
    };
    spaceWindow = function(param) {
        mySpacePopTool.spaceWindow(param);
    };
    colseSpaceAlert = function(param) {
        mySpacePopTool.colseSpaceAlert(param);
    }
    closeSpaceConfirm = function(param) {
        mySpacePopTool.closeSpaceConfirm(param);
    }
    closeSpaceWindow = function(param) {
        mySpacePopTool.closeSpaceWindow(param);
    }
    spaceDeleteConfirm = function(param) {
        mySpacePopTool.spaceDeleteConfirm(param);
    }
    closeSpaceDeleteConfirm = function(param) {
        mySpacePopTool.closeSpaceDeleteConfirm(param);
    }

});