(function (o) { var ap, aC, aH, ad, R, ah, aL, d, r, av = 0, aa = {}, ax = [], ar = 0, t = {}, aj = [], ab = null, az = new Image, ae = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, aA = /[^\.]\.(swf)\s*$/i, ag, ai = 1, al, an, af = false, aJ = o.extend(o("<div/>")[0], { prop: 0 }), aE = 0, au = !o.support.opacity && !window.XMLHttpRequest, ak = function () { aC.hide(); az.onerror = az.onload = null; ab && ab.abort(); ap.empty() }, aw = function () { o.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', { scrolling: "no", padding: 20, transitionIn: "none", transitionOut: "none" }) }, am = function () { return [o(window).width(), o(window).height(), o(document).scrollLeft(), o(document).scrollTop()] }, aB = function () { var b = am(), c = {}, e = t.margin, g = t.autoScale, i = (20 + e) * 2, j = (20 + e) * 2, h = t.padding * 2; if (t.width.toString().indexOf("%") > -1) { c.width = b[0] * parseFloat(t.width) / 100 - 40; g = false } else { c.width = t.width + h } if (t.height.toString().indexOf("%") > -1) { c.height = b[1] * parseFloat(t.height) / 100 - 40; g = false } else { c.height = t.height + h } if (g && (c.width > b[0] - i || c.height > b[1] - j)) { if (aa.type == "image" || aa.type == "swf") { i += h; j += h; g = Math.min(Math.min(b[0] - i, t.width) / t.width, Math.min(b[1] - j, t.height) / t.height); c.width = Math.round(g * (c.width - h)) + h; c.height = Math.round(g * (c.height - h)) + h } else { c.width = Math.min(c.width, b[0] - i); c.height = Math.min(c.height, b[1] - j) } } c.top = b[3] + (b[1] - (c.height + 40)) * 0.5; c.left = b[2] + (b[0] - (c.width + 40)) * 0.5; if (t.autoScale === false) { c.top = Math.max(b[3] + e, c.top); c.left = Math.max(b[2] + e, c.left) } return c }, aD = function (b) { if (b && b.length) { switch (t.titlePosition) { case "inside": return b; case "over": return '<span id="fancybox-title-over">' + b + "</span>"; default: return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + b + '</span><span id="fancybox-title-right"></span></span>' } } return false }, aF = function () { var b = t.title, c = an.width - t.padding * 2, e = "fancybox-title-" + t.titlePosition; o("#fancybox-title").remove(); aE = 0; if (t.titleShow !== false) { b = o.isFunction(t.titleFormat) ? t.titleFormat(b, aj, ar, t) : aD(b); if (!(!b || b === "")) { o('<div id="fancybox-title" class="' + e + '" />').css({ width: c, paddingLeft: t.padding, paddingRight: t.padding }).html(b).appendTo("body"); switch (t.titlePosition) { case "inside": aE = o("#fancybox-title").outerHeight(true) - t.padding; an.height += aE; break; case "over": o("#fancybox-title").css("bottom", t.padding); break; default: o("#fancybox-title").css("bottom", o("#fancybox-title").outerHeight(true) * -1); break } o("#fancybox-title").appendTo(R).hide() } } }, aG = function () { o(document).unbind("keydown.fb").bind("keydown.fb", function (b) { if (b.keyCode == 27 && t.enableEscapeButton) { b.preventDefault(); o.fancybox.close() } else { if (b.keyCode == 37) { b.preventDefault(); o.fancybox.prev() } else { if (b.keyCode == 39) { b.preventDefault(); o.fancybox.next() } } } }); if (o.fn.mousewheel) { ad.unbind("mousewheel.fb"); aj.length > 1 && ad.bind("mousewheel.fb", function (b, c) { b.preventDefault(); af || c === 0 || (c > 0 ? o.fancybox.prev() : o.fancybox.next()) }) } if (t.showNavArrows) { if (t.cyclic && aj.length > 1 || ar !== 0) { d.show() } if (t.cyclic && aj.length > 1 || ar != aj.length - 1) { r.show() } } }, aI = function () { var b, c; if (aj.length - 1 > ar) { b = aj[ar + 1].href; if (typeof b !== "undefined" && b.match(ae)) { c = new Image; c.src = b } } if (ar > 0) { b = aj[ar - 1].href; if (typeof b !== "undefined" && b.match(ae)) { c = new Image; c.src = b } } }, ao = function () { ah.css("overflow", t.scrolling == "auto" ? t.type == "image" || t.type == "iframe" || t.type == "swf" ? "hidden" : "auto" : t.scrolling == "yes" ? "auto" : "visible"); if (!o.support.opacity) { ah.get(0).style.removeAttribute("filter"); ad.get(0).style.removeAttribute("filter") } o("#fancybox-title").show(); t.hideOnContentClick && ah.one("click", o.fancybox.close); t.hideOnOverlayClick && aH.one("click", o.fancybox.close); t.showCloseButton && aL.show(); aG(); o(window).bind("resize.fb", o.fancybox.center); t.centerOnScroll ? o(window).bind("scroll.fb", o.fancybox.center) : o(window).unbind("scroll.fb"); o.isFunction(t.onComplete) && t.onComplete(aj, ar, t); af = false; aI() }, aq = function (b) { var c = Math.round(al.width + (an.width - al.width) * b), e = Math.round(al.height + (an.height - al.height) * b), g = Math.round(al.top + (an.top - al.top) * b), h = Math.round(al.left + (an.left - al.left) * b); ad.css({ width: c + "px", height: e + "px", top: g + "px", left: h + "px" }); c = Math.max(c - t.padding * 2, 0); e = Math.max(e - (t.padding * 2 + aE * b), 0); ah.css({ width: c + "px", height: e + "px" }); if (typeof an.opacity !== "undefined") { ad.css("opacity", b < 0.5 ? 0.5 : b) } }, aK = function (b) { var c = b.offset(); c.top += parseFloat(b.css("paddingTop")) || 0; c.left += parseFloat(b.css("paddingLeft")) || 0; c.top += parseFloat(b.css("border-top-width")) || 0; c.left += parseFloat(b.css("border-left-width")) || 0; c.width = b.width(); c.height = b.height(); return c }, ay = function () { var b = aa.orig ? o(aa.orig) : false, c = {}; if (b && b.length) { b = aK(b); c = { width: b.width + t.padding * 2, height: b.height + t.padding * 2, top: b.top - t.padding - 20, left: b.left - t.padding - 20} } else { b = am(); c = { width: 1, height: 1, top: b[3] + b[1] * 0.5, left: b[2] + b[0] * 0.5} } return c }, at = function () { aC.hide(); if (ad.is(":visible") && o.isFunction(t.onCleanup)) { if (t.onCleanup(aj, ar, t) === false) { o.event.trigger("fancybox-cancel"); af = false; return } } aj = ax; ar = av; t = aa; ah.get(0).scrollTop = 0; ah.get(0).scrollLeft = 0; if (t.overlayShow) { au && o("select:not(#fancybox-tmp select)").filter(function () { return this.style.visibility !== "hidden" }).css({ visibility: "hidden" }).one("fancybox-cleanup", function () { this.style.visibility = "inherit" }); aH.css({ "background-color": t.overlayColor, opacity: t.overlayOpacity }).unbind().show() } an = aB(); aF(); if (ad.is(":visible")) { o(aL.add(d).add(r)).hide(); var b = ad.position(), c; al = { top: b.top, left: b.left, width: ad.width(), height: ad.height() }; c = al.width == an.width && al.height == an.height; ah.fadeOut(t.changeFade, function () { var e = function () { ah.html(ap.contents()).fadeIn(t.changeFade, ao) }; o.event.trigger("fancybox-change"); ah.empty().css("overflow", "hidden"); if (c) { ah.css({ top: t.padding, left: t.padding, width: Math.max(an.width - t.padding * 2, 1), height: Math.max(an.height - t.padding * 2 - aE, 1) }); e() } else { ah.css({ top: t.padding, left: t.padding, width: Math.max(al.width - t.padding * 2, 1), height: Math.max(al.height - t.padding * 2, 1) }); aJ.prop = 0; o(aJ).animate({ prop: 1 }, { duration: t.changeSpeed, easing: t.easingChange, step: aq, complete: e }) } }) } else { ad.css("opacity", 1); if (t.transitionIn == "elastic") { al = ay(); ah.css({ top: t.padding, left: t.padding, width: Math.max(al.width - t.padding * 2, 1), height: Math.max(al.height - t.padding * 2, 1) }).html(ap.contents()); ad.css(al).show(); if (t.opacity) { an.opacity = 0 } aJ.prop = 0; o(aJ).animate({ prop: 1 }, { duration: t.speedIn, easing: t.easingIn, step: aq, complete: ao }) } else { ah.css({ top: t.padding, left: t.padding, width: Math.max(an.width - t.padding * 2, 1), height: Math.max(an.height - t.padding * 2 - aE, 1) }).html(ap.contents()); ad.css(an).fadeIn(t.transitionIn == "none" ? 0 : t.speedIn, ao) } } }, ac = function () { ap.width(aa.width); ap.height(aa.height); if (aa.width == "auto") { aa.width = ap.width() } if (aa.height == "auto") { aa.height = ap.height() } at() }, aM = function () { af = true; aa.width = az.width; aa.height = az.height; o("<img />").attr({ id: "fancybox-img", src: az.src, alt: aa.title }).appendTo(ap); at() }, w = function () { ak(); var b = ax[av], c, e, g, h, i; aa = o.extend({}, o.fn.fancybox.defaults, typeof o(b).data("fancybox") == "undefined" ? aa : o(b).data("fancybox")); g = b.title || o(b).title || aa.title || ""; if (b.nodeName && !aa.orig) { aa.orig = o(b).children("img:first").length ? o(b).children("img:first") : o(b) } if (g === "" && aa.orig) { g = aa.orig.attr("alt") } c = b.nodeName && /^(?:javascript|#)/i.test(b.href) ? aa.href || null : aa.href || b.href || null; if (aa.type) { e = aa.type; if (!c) { c = aa.content } } else { if (aa.content) { e = "html" } else { if (c) { if (c.match(ae)) { e = "image" } else { if (c.match(aA)) { e = "swf" } else { if (o(b).hasClass("iframe")) { e = "iframe" } else { if (c.match(/#/)) { b = c.substr(c.indexOf("#")); e = o(b).length > 0 ? "inline" : "ajax" } else { e = "ajax" } } } } } else { e = "inline" } } } aa.type = e; aa.href = c; aa.title = g; if (aa.autoDimensions && aa.type !== "iframe" && aa.type !== "swf") { aa.width = "auto"; aa.height = "auto" } if (aa.modal) { aa.overlayShow = true; aa.hideOnOverlayClick = false; aa.hideOnContentClick = false; aa.enableEscapeButton = false; aa.showCloseButton = false } if (o.isFunction(aa.onStart)) { if (aa.onStart(ax, av, aa) === false) { af = false; return } } ap.css("padding", 20 + aa.padding + aa.margin); o(".fancybox-inline-tmp").unbind("fancybox-cancel").bind("fancybox-change", function () { o(this).replaceWith(ah.children()) }); switch (e) { case "html": ap.html(aa.content); ac(); break; case "inline": o('<div class="fancybox-inline-tmp" />').hide().insertBefore(o(b)).bind("fancybox-cleanup", function () { o(this).replaceWith(ah.children()) }).bind("fancybox-cancel", function () { o(this).replaceWith(ap.children()) }); o(b).appendTo(ap); ac(); break; case "image": af = false; o.fancybox.showActivity(); az = new Image; az.onerror = function () { aw() }; az.onload = function () { az.onerror = null; az.onload = null; aM() }; az.src = c; break; case "swf": h = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + aa.width + '" height="' + aa.height + '"><param name="movie" value="' + c + '"></param>'; i = ""; o.each(aa.swf, function (j, k) { h += '<param name="' + j + '" value="' + k + '"></param>'; i += " " + j + '="' + k + '"' }); h += '<embed src="' + c + '" type="application/x-shockwave-flash" width="' + aa.width + '" height="' + aa.height + '"' + i + "></embed></object>"; ap.html(h); ac(); break; case "ajax": b = c.split("#", 2); e = aa.ajax.data || {}; if (b.length > 1) { c = b[0]; if (typeof e == "string") { e += "&selector=" + b[1] } else { e.selector = b[1] } } af = false; o.fancybox.showActivity(); ab = o.ajax(o.extend(aa.ajax, { url: c, data: e, error: aw, success: function (j) { if (ab.status == 200) { ap.html(j); ac() } } })); break; case "iframe": o('<iframe id="fancybox-frame" name="fancybox-frame' + (new Date).getTime() + '" frameborder="0" hspace="0" scrolling="' + aa.scrolling + '" src="' + aa.href + '" title="' + aa.title + '"></iframe>').appendTo(ap); at(); break } }, a = function () { if (aC.is(":visible")) { o("div", aC).css("top", ai * -40 + "px"); ai = (ai + 1) % 12 } else { clearInterval(ag) } }, f = function () { if (!o("#fancybox-wrap").length) { o("body").append(ap = o('<div id="fancybox-tmp"></div>'), aC = o('<div id="fancybox-loading"><div></div></div>'), aH = o('<div id="fancybox-overlay"></div>'), ad = o('<div id="fancybox-wrap"></div>')); if (!o.support.opacity) { ad.addClass("fancybox-ie"); aC.addClass("fancybox-ie") } R = o('<div id="fancybox-outer"></div>').append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>').appendTo(ad); R.append(ah = o('<div id="fancybox-inner"></div>'), aL = o('<a id="fancybox-close"></a>'), d = o('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), r = o('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')); aL.click(o.fancybox.close); aC.click(o.fancybox.cancel); d.click(function (b) { b.preventDefault(); o.fancybox.prev() }); r.click(function (b) { b.preventDefault(); o.fancybox.next() }); if (au) { aH.get(0).style.setExpression("height", "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'"); aC.get(0).style.setExpression("top", "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'"); R.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>') } } }; o.fn.fancybox = function (b) { o(this).data("fancybox", o.extend({}, b, o.metadata ? o(this).metadata() : {})).unbind("click.fb").bind("click.fb", function (c) { c.preventDefault(); if (!af) { af = true; o(this).blur(); ax = []; av = 0; c = o(this).attr("rel") || ""; if (!c || c == "" || c === "nofollow") { ax.push(this) } else { ax = o("a[rel=" + c + "], area[rel=" + c + "]"); av = ax.index(this) } w(); return false } }); return this }; o.fancybox = function (b, c) { if (!af) { af = true; c = typeof c !== "undefined" ? c : {}; ax = []; av = c.index || 0; if (o.isArray(b)) { for (var e = 0, g = b.length; e < g; e++) { if (typeof b[e] == "object") { o(b[e]).data("fancybox", o.extend({}, c, b[e])) } else { b[e] = o({}).data("fancybox", o.extend({ content: b[e] }, c)) } } ax = jQuery.merge(ax, b) } else { if (typeof b == "object") { o(b).data("fancybox", o.extend({}, c, b)) } else { b = o({}).data("fancybox", o.extend({ content: b }, c)) } ax.push(b) } if (av > ax.length || av < 0) { av = 0 } w() } }; o.fancybox.showActivity = function () { clearInterval(ag); aC.show(); ag = setInterval(a, 66) }; o.fancybox.hideActivity = function () { aC.hide() }; o.fancybox.next = function () { return o.fancybox.pos(ar + 1) }; o.fancybox.prev = function () { return o.fancybox.pos(ar - 1) }; o.fancybox.pos = function (b) { if (!af) { b = parseInt(b, 10); if (b > -1 && aj.length > b) { av = b; w() } if (t.cyclic && aj.length > 1 && b < 0) { av = aj.length - 1; w() } if (t.cyclic && aj.length > 1 && b >= aj.length) { av = 0; w() } } }; o.fancybox.cancel = function () { if (!af) { af = true; o.event.trigger("fancybox-cancel"); ak(); aa && o.isFunction(aa.onCancel) && aa.onCancel(ax, av, aa); af = false } }; o.fancybox.close = function () { function b() { aH.fadeOut("fast"); ad.hide(); o.event.trigger("fancybox-cleanup"); ah.empty(); o.isFunction(t.onClosed) && t.onClosed(aj, ar, t); aj = aa = []; ar = av = 0; t = aa = {}; af = false } if (!(af || ad.is(":hidden"))) { af = true; if (t && o.isFunction(t.onCleanup)) { if (t.onCleanup(aj, ar, t) === false) { af = false; return } } ak(); o(aL.add(d).add(r)).hide(); o("#fancybox-title").remove(); ad.add(ah).add(aH).unbind(); o(window).unbind("resize.fb scroll.fb"); o(document).unbind("keydown.fb"); ah.css("overflow", "hidden"); if (t.transitionOut == "elastic") { al = ay(); var c = ad.position(); an = { top: c.top, left: c.left, width: ad.width(), height: ad.height() }; if (t.opacity) { an.opacity = 1 } aJ.prop = 1; o(aJ).animate({ prop: 0 }, { duration: t.speedOut, easing: t.easingOut, step: aq, complete: b }) } else { ad.fadeOut(t.transitionOut == "none" ? 0 : t.speedOut, b) } } }; o.fancybox.resize = function () { var b, c; if (!(af || ad.is(":hidden"))) { af = true; b = ah.wrapInner("<div style='overflow:auto'></div>").children(); c = b.height(); ad.css({ height: c + t.padding * 2 + aE }); ah.css({ height: c }); b.replaceWith(b.children()); o.fancybox.center() } }; o.fancybox.center = function () { af = true; var b = am(), c = t.margin, e = {}; e.top = b[3] + (b[1] - (ad.height() - aE + 40)) * 0.5; e.left = b[2] + (b[0] - (ad.width() + 40)) * 0.5; e.top = Math.max(b[3] + c, e.top); e.left = Math.max(b[2] + c, e.left); ad.css(e); af = false }; o.fn.fancybox.defaults = { padding: 10, margin: 20, opacity: false, modal: false, cyclic: false, scrolling: "auto", width: 560, height: 340, autoScale: true, autoDimensions: true, centerOnScroll: false, ajax: {}, swf: { wmode: "transparent" }, hideOnOverlayClick: true, hideOnContentClick: false, overlayShow: true, overlayOpacity: 0.3, overlayColor: "#666", titleShow: true, titlePosition: "outside", titleFormat: null, transitionIn: "fade", transitionOut: "fade", speedIn: 300, speedOut: 300, changeSpeed: 300, changeFade: "fast", easingIn: "swing", easingOut: "swing", showCloseButton: true, showNavArrows: true, enableEscapeButton: true, onStart: null, onCancel: null, onComplete: null, onCleanup: null, onClosed: null }; o(document).ready(function () { f() }) })(jQuery);
