(function (a) { a.fn.wbox = function (o) { var f = { wboxurl: "wbox/", opacity: 0.5, callback: null, notitle: false, show: false, timeout: 0, target: null, requesttype: null, title: "wbox title", drag: true, iframewh: { width: 400, height: 300 }, html: "" }, j = this; this.yq = a.extend(f, o); var n = '
 
' + (j.yq.notitle ? "" : '
' + j.yq.title + '
') + '
 
', c = null, b = null, d = a(window), g = a(this); this.showbox = function () { a("#wbox_overlay").remove(); a("#wbox").remove(); c = a("
").hide().addclass("wbox_overlaybg").css("opacity", j.yq.opacity).dblclick(function () { j.close() }).appendto("body").fadein(300); b = a(n).appendto("body"); i() }; function i() { var p = b.find("#wboxcontent"); if (j.yq.requesttype && a.inarray(j.yq.requesttype, ["iframe", "ajax", "img"]) != -1) { p.html("
"); if (j.yq.requesttype === "img") { var q = a(""); q.attr("src", j.yq.target); q.load(function () { q.appendto(p.empty()); m() }) } else { if (j.yq.requesttype === "ajax") { a.get(j.yq.target, function (r) { p.html(r); b.find(".wbox_close").click(j.close); m() }) } else { ifr = a(""); ifr.appendto(p.empty()); ifr.load(function () { try { $it = a(this).contents(); $it.find(".wbox_close").click(j.close); fh = $it.height(); fw = $it.width(); w = d; neww = math.min(w.width() - 40, fw); newh = w.height() - 25 - (j.yq.notitle ? 0 : 30); newh = math.min(newh, fh); if (!newh) { return } var r = k(neww); b.css({ left: r[0], top: r[1] }); a(this).css({ height: newh, width: neww }) } catch (s) { } }) } } } else { if (j.yq.target) { a(j.yq.target).clone(true).show().appendto(p.empty()) } else { if (j.yq.html) { p.html(j.yq.html) } else { g.clone(true).show().appendto(p.empty()) } } } e() } function e() { m(); b.show().find(".wbox_close").click(j.close).hover(function () { a(this).addclass("on") }, function () { a(this).removeclass("on") }); a(document).unbind("keydown.wbox").bind("keydown.wbox", function (p) { if (p.keycode === 27) { j.close() } return true }); typeof j.yq.callback === "function" ? j.yq.callback() : null; !j.yq.notitle && j.yq.drag ? h() : null; if (j.yq.timeout) { settimeout(j.close, j.yq.timeout) } } function m() { if (!b) { return false } var u = b.width(), r = k(u); b.css({ left: r[0], top: r[1] }); var q = a("body").height(), p = d.height(), s = a("html").height(); q = math.max(q, p); c.height(q).width(d.width()) } function k(p) { l = (d.width() - p) / 2; t = d.scrolltop() + d.height() / 9; return [l, t] } function h() { var u, r, s; var x = b.find(".wbox_dragtitle").css("cursor", "move"); x.bind("selectstart", function () { return false }); x.mousedown(function (y) { u = y.clientx - parseint(b.css("left")); r = y.clienty - parseint(b.css("top")); b.mousemove(q).mouseout(v).css("opacity", 0.8); x.mouseup(p) }); function q(y) { s = false; if (y.clientx - u < 0) { l = 0 } else { if (y.clientx - u > d.width() - b.width()) { l = d.width() - b.width() } else { l = y.clientx - u } } b.css({ left: l, top: y.clienty - r }) } function v(y) { s = true; settimeout(function () { s && p(y) }, 10) } function p(y) { b.unbind("mousemove", q).unbind("mouseout", v).css("opacity", 1); x.unbind("mouseup", p) } } this.close = function () { if (b) { c.remove(); b.stop().fadeout(300, function () { b.remove() }) } }; d.resize(function () { m() }); j.yq.show ? j.showbox() : g.click(function () { j.showbox(); return false }); return this } })(jquery);