(function (c) {
	function D() { c("a[rel^=superbox],area[rel^=superbox]").each(function () { var b = c(this), a = b.attr("rel"), d = a.match(/^superbox\[([^#\.\]]+)/)[1], f = a.replace("superbox", "").match(/([#\.][^#\.\]]+)/g) || [], e = g.boxId, k = g.boxClasses; this._relSettings = a.replace("superbox[" + d + f.join("") + "]", ""); c.each(f, function (v, h) { if (h.substr(0, 1) == "#") e = h.substr(1); else if (h.substr(0, 1) == ".") k += " " + h.substr(1) }); d.search(/^image|gallery|iframe|content|ajax$/) != -1 && b.superbox(d, { boxId: e, boxClasses: k }) }) } function l(b) { return b._relSettings.match(/([^\[\]]+)/g) }
	function E(b, a) { m.show(); galleryMode = true; var d = b.get(0)._superboxGroupKey + 1, f = d - 2; galleryGroups[a][d] ? n.removeClass("disabled").unbind("click").bind("click", function () { galleryGroups[a][d].click() }) : n.addClass("disabled").unbind("click"); galleryGroups[a][f] ? o.removeClass("disabled").unbind("click").bind("click", function () { galleryGroups[a][f].click() }) : o.addClass("disabled").unbind("click") } function q(b) { $superbox.attr("id", b.boxId).attr("class", b.boxClasses) } function z() {
		c(document).unbind("keydown");
		r.hide(); m.hide(); i.hide().css({ position: "fixed", top: 0 }); $innerbox.empty(); p.fadeOut(300, function () { hideElts.show() }); galleryMode = false; w != undefined && w(A)
	} function s(b) { var a = function () { c.browser.msie && c.browser.version < 7 && i.css({ position: "absolute", top: "50%" }); hideElts.hide(); r.show(); b() }; if (galleryMode) { p.css("opacity", g.overlayOpacity).show(); a() } else p.css("opacity", 0).show().fadeTo(300, g.overlayOpacity, a) } function t() { i.show(); $innerbox.empty(); $superbox.css({ position: "absolute", top: "-99999px" }) }
	function u() {
		r.hide(); c(document).unbind("keydown").bind("keydown", function (b) { b.keyCode == 27 && z(); b.keyCode == 39 && n.is(":visible") && n.click(); b.keyCode == 37 && o.is(":visible") && o.click() }); $superbox.css({ position: "static", top: 0, opacity: 0 }); if (c.browser.msie && c.browser.version < 8) { $superbox.css({ position: "relative", top: "-50%" }); c.browser.msie && c.browser.version < 7 && i.css({ position: "absolute", top: "50%" }) } c(window).height() < i.height() && i.css({ position: "absolute", top: i.offset().top + 10 + "px" }); g.beforeShow();
		x != undefined && x(B); $superbox.fadeTo(300, 1)
	} function F() {
		if (!c.superbox.elementsReady) {
			p = c('<div id="superbox-overlay"></div>').appendTo("body").hide(); i = c('<div id="superbox-wrapper"></div>').appendTo("body").hide(); y = c('<div id="superbox-container"></div>').appendTo(i); $superbox = c('<div id="superbox"></div>').appendTo(y); $innerbox = c('<div id="superbox-innerbox"></div>').appendTo($superbox); m = c('<p class="nextprev"></p>').appendTo($superbox).hide(); o = c('<a class="prev"><strong><span>' + g.prevTxt + "</span></strong></a>").appendTo(m);
			n = c('<a class="next"><strong><span>' + g.nextTxt + "</span></strong></a>").appendTo(m); C = c('<p class="close"><a><strong><span>' + g.closeTxt + "</span></strong></a></p>").prependTo($superbox).find("a"); r = c('<p class="loading">' + g.loadTxt + "</p>").appendTo(y).hide(); p.add(i).add(C).click(function () { z() }); $superbox.click(function (b) { b.stopPropagation() }); c.superbox.elementsReady = true
		} 
	} var p, i, y, $superbox, C, r, m, n, o, g, w = undefined, A = undefined; c.superboxRegisterCloseCallback = function (b, a) { w = b; A = a }; var x = undefined,
B = undefined; c.superboxRegisterOpenCallback = function (b, a) { x = b; B = a }; defaultSettings = { boxId: "superbox", boxClasses: "", overlayOpacity: 0.8, boxWidth: "600", boxHeight: "400", loadTxt: "Loading...", closeTxt: "Fechar", prevTxt: "Previous", nextTxt: "Next", beforeShow: function () { } }; galleryGroups = {}; galleryMode = false; hideElts = c([]); c.superbox = function () { g = c.extend({}, defaultSettings, c.superbox.settings); if (c.browser.msie && c.browser.version < 7) hideElts = hideElts.add("select"); F(); D() }; c.fn.superbox = function (b, a) {
	a = c.extend({},
g, a); c.superbox[b](this, a)
}; c.extend(c.superbox, { image: function (b, a, d) {
	var f = l(b.get(0)), e = false; if (f && d == "gallery") e = f[1]; else if (f) e = f[0]; b.click(function (k) {
		k.preventDefault(); t(); d == "gallery" && E(b, f[0]); s(function () {
			var v = false, h; if (e) v = e.split("x"); h = c('<img src="' + b.attr("href") + '" title="' + (b.attr("title") || b.text()) + '" />'); h.load(function () {
				var j = v; $superbox.width(h.width() + ($innerbox.css("paddingLeft").slice(0, -2) - 0) + ($innerbox.css("paddingRight").slice(0, -2) - 0)); $innerbox.height(h.height());
				j && j[0] != "" && $superbox.width(j[0] + "px"); j && j[1] != "" && j[1] > h.height() && $innerbox.height(j[1] + "px"); q({ boxClasses: "image " + a.boxClasses, boxId: a.boxId }); u()
			}).appendTo($innerbox)
		})
	})
}, gallery: function (b, a) { var d = l(b.get(0)); galleryGroups[d[0]] || (galleryGroups[d[0]] = []); galleryGroups[d[0]].push(b); b.get(0)._superboxGroupKey = galleryGroups[d[0]].length - 1; c.superbox.image(b, a, "gallery") }, iframe: function (b, a) {
	var d = l(b.get(0)); b.click(function (f) {
		f.preventDefault(); t(); s(function () {
			var e = false; if (d) e = d[0].split("x");
			a = c.extend({}, a, { boxWidth: e[0] || a.boxWidth, boxHeight: e[1] || a.boxHeight }); c('<iframe src="' + b.attr("href") + '" name="' + b.attr("href") + '" frameborder="0" scrolling="auto" hspace="0" width="' + a.boxWidth + '" height="' + a.boxHeight + '"></iframe>').load(function () { $superbox.width(a.boxWidth + "px"); $innerbox.height(a.boxHeight + "px"); q({ boxClasses: "iframe " + a.boxClasses, boxId: a.boxId }); u() }).appendTo($innerbox)
		})
	})
}, content: function (b, a) {
	var d = l(b.get(0)); b.click(function (f) {
		f.preventDefault(); t(); s(function () {
			var e =
false; if (d) e = d[0].split("x"); a = c.extend({}, a, { boxWidth: e[0] || a.boxWidth, boxHeight: e[1] || a.boxHeight }); $superbox.width(a.boxWidth + "px"); $innerbox.height(a.boxHeight + "px"); c(b.attr("href")).clone().appendTo($innerbox).show(); q({ boxClasses: "content " + a.boxClasses, boxId: a.boxId }); u()
		})
	})
}, ajax: function (b, a) {
	var d = l(b.get(0)); b.click(function (f) {
		f.preventDefault(); t(); s(function () {
			var e = false; if (d && d[3]) e = d[3].split("x"); a = c.extend({}, a, { boxWidth: e[0] || a.boxWidth, boxHeight: e[1] || a.boxHeight }); $superbox.width(a.boxWidth +
"px"); $innerbox.height(a.boxHeight + "px"); c.get(d[2], function (k) { c(k).appendTo($innerbox) }); q({ boxClasses: "ajax " + a.boxClasses, boxId: a.boxId }); u()
		})
	})
} 
})
})(jQuery);
