(function (I) {
	var T = "colorbox",
	m = "hover",
	Q = true,
	K = false,
	J, p = !I.support.opacity,
	B = p && !window.XMLHttpRequest,
	C = "click.colorbox",
	g = "cbox_open",
	x = "cbox_load",
	D = "cbox_complete",
	E = "cbox_cleanup",
	j = "cbox_closed",
	F = "resize.cbox_resize",
	U, M, a, R, W, X, Y, Z, L, S, P, y, z, G, aa, c, r, s, A, n, o, e, k, O, N, H, u, v, ab, ac = {
		transition: "elastic",
		speed: 350,
		width: 300,
		height: 420,
		innerWidth: K,
		innerHeight: K,
		initialWidth: 300,
		initialHeight: 420,
		maxWidth: K,
		maxHeight: K,
		scalePhotos: Q,
		scrolling: Q,
		inline: K,
		html: K,
		iframe: K,
		photo: K,
		href: K,
		title: K,
		rel: K,
		opacity: 0.05,
		preloading: Q,
		current: "image {current} of {total}",
		previous: "previous",
		next: "next",
		close: "close",
		open: K,
		overlayClose: Q,
		slideshow: K,
		slideshowAuto: Q,
		slideshowSpeed: 1750,
		slideshowStart: "start slideshow",
		slideshowStop: "stop slideshow",
		preloadIMG: Q
	};
	function V(b, d) {
		d = d === "x" ? document.documentElement.clientWidth: document.documentElement.clientHeight;
		return typeof b === "string" ? Math.round(b.match(/%/) ? d / 100 * parseInt(b, 10) : parseInt(b, 10)) : b
	}
	function ad(b) {
		return H.photo || b.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i)
	}
	function h() {
		for (var b in H) {
			if (typeof H[b] === "function") {
				H[b] = H[b].call(O)
			}
		}
	}
	J = I.fn.colorbox = function (b, d) {
		this.length ? this.each(function () {
			var f = I(this).data(T) ? I.extend({},
			I(this).data(T), b) : I.extend({},
			ac, b);
			I(this).data(T, f).addClass("cboxelement")
		}) : I(this).data(T, I.extend({},
		ac, b));
		I(this).unbind(C).bind(C, function (f) {
			O = this;
			H = I(O).data(T);
			h();
			ab = d || K;
			var i = H.rel || O.rel;
			if (i && i !== "nofollow") {
				L = I(".cboxelement").filter(function () {
					var l = I(this).data(T).rel || this.rel;
					return l === i
				});
				N = L.index(O);
				if (N < 0) {
					L = L.add(O);
					N = L.length - 1
				}
			} else {
				L = I(O);
				N = 0
			}
			if (!u) {
				v = u = Q;
				I().bind("keydown.cbox_close", function (l) {
					if (l.keyCode === 27) {
						l.preventDefault();
						J.close()
					}
				}).bind("keydown.cbox_arrows", function (l) {
					if (l.keyCode === 37) {
						l.preventDefault();
						s.click()
					} else {
						if (l.keyCode === 39) {
							l.preventDefault();
							r.click()
						}
					}
				});
				H.overlayClose && U.css({
					cursor: "pointer"
				}).one("click", J.close);
				O.blur();
				I.event.trigger(g);
				A.html(H.close);
				U.css({
					opacity: H.opacity
				}).show();
				H.w = V(H.initialWidth, "x");
				H.h = V(H.initialHeight, "y");
				J.position(0);
				B && S.bind("resize.cboxie6 scroll.cboxie6", function () {
					U.css({
						width: S.width(),
						height: S.height(),
						top: S.scrollTop(),
						left: S.scrollLeft()
					})
				}).trigger("scroll.cboxie6")
			}
			J.slideshow();
			J.load();
			f.preventDefault()
		});
		b && b.open && I(this).triggerHandler(C);
		return this
	};
	J.init = function () {
		function b(d) {
			return I('<div id="cbox' + d + '"/>')
		}
		S = I("#content-main");
		M = I('<div id="colorbox"/>');
		U = b("Overlay").hide();
		a = b("Wrapper");
		R = b("Content").append(P = b("LoadedContent").css({
			width: 0,
			height: 0
		}), y = b("LoadingOverlay"), z = b("LoadingGraphic"), G = b("Title"), aa = b("Current"), c = b("Slideshow"), r = b("Next"), s = b("Previous"), A = b("Close"));
		a.append(I("<div/>").append(b("TopLeft"), W = b("TopCenter"), b("TopRight")), I("<div/>").append(X = b("MiddleLeft"), R, Y = b("MiddleRight")), I("<div/>").append(b("BottomLeft"), Z = b("BottomCenter"), b("BottomRight"))).children().children().css({
			"float": "left"
		});
		I("#content-main").prepend(U, M.append(a));
		if (p) {
			M.addClass("cboxIE");
			B && U.css("position", "absolute")
		}
		R.children().addClass(m).mouseover(function () {
			I(this).addClass(m)
		}).mouseout(function () {
			I(this).removeClass(m)
		}).hide();
		n = W.height() + Z.height() + R.outerHeight(Q) - R.height();
		o = X.width() + Y.width() + R.outerWidth(Q) - R.width();
		e = P.outerHeight(Q);
		k = P.outerWidth(Q);
		M.css({
			"padding-bottom": n,
			"padding-right": o
		}).hide();
		r.click(J.next);
		s.click(J.prev);
		A.click(J.close);
		R.children().removeClass(m)
	};
	J.position = function (b, d) {
		var i = document.documentElement.clientHeight;
		i = Math.max(i - H.h - e - n, 0) / 2 + S.scrollTop();
		var l = Math.max(document.documentElement.clientWidth - H.w - k - o, 0) / 2 + S.scrollLeft();
		b = M.width() === H.w + k && M.height() === H.h + e ? 0 : b;
		a[0].style.width = a[0].style.height = "9999px";
		function f(q) {
			W[0].style.width = Z[0].style.width = R[0].style.width = q.style.width;
			z[0].style.height = y[0].style.height = R[0].style.height = X[0].style.height = Y[0].style.height = q.style.height
		}
		M.dequeue().animate({
			width: H.w + k,
			height: H.h + e,
			top: i,
			left: l
		},
		{
			duration: b,
			complete: function () {
				f(this);
				v = K;
				a[0].style.width = H.w + k + o + "px";
				a[0].style.height = H.h + e + n + "px";
				d && d()
			},
			step: function () {
				f(this)
			}
		})
	};
	J.resize = function (b) {
		if (u) {
			function d(w) {
				J.position(w, function () {
					if (u) {
						if (p) {
							i && P.fadeIn(100);
							M[0].style.removeAttribute("filter")
						}
						R.children().show();
						if (H.iframe) {
							P.append("<iframe id='cboxIframe'" + (H.scrolling ? " ": "scrolling='no'") + " name='iframe_" + (new Date).getTime() + "' frameborder=0 src='" + (H.href || O.href) + "' />")
						}
						y.hide();
						z.hide();
						c.hide();
						if (L.length > 1) {
							aa.html(H.current.replace(/\{current\}/, N + 1).replace(/\{total\}/, L.length));
							r.html(H.next);
							s.html(H.previous);
							H.slideshow && c.show()
						} else {
							aa.hide();
							r.hide();
							s.hide()
						}
						G.html(H.title || O.title);
						I.event.trigger(D);
						ab && ab.call(O);
						H.transition === "fade" && M.fadeTo(q, 1, function () {
							p && M[0].style.removeAttribute("filter")
						});
						S.bind(F, function () {
							J.position(0)
						})
					}
				})
			}
			function l() {
				H.h = H.h || P.height();
				return H.h
			}
			function t() {
				H.w = H.w || P.width();
				return H.w
			}
			var f, i, q = H.transition === "none" ? 0 : H.speed;
			S.unbind(F);
			if (b) {
				P.remove();
				P = I('<div id="cboxLoadedContent"/>').html(b);
				P.hide().appendTo(U).css({
					width: t(),
					overflow: H.scrolling ? "auto": "hidden"
				}).css({
					height: l()
				}).prependTo(R);
				I("#cboxPhoto").css({
					cssFloat: "none"
				});
				B && I("select:not(#colorbox select)").filter(function () {
					return this.style.visibility !== "hidden"
				}).css({
					visibility: "hidden"
				}).one(E, function () {
					this.style.visibility = "inherit"
				});
				H.transition === "fade" && M.fadeTo(q, 0, function () {
					d(0)
				}) || d(q);
				if (H.preloading && L.length > 1) {
					b = N > 0 ? L[N - 1] : L[L.length - 1];
					f = N < L.length - 1 ? L[N + 1] : L[0];
					f = I(f).data(T).href || f.href;
					b = I(b).data(T).href || b.href;
					ad(f) && I("<img />").attr("src", f);
					ad(b) && I("<img />").attr("src", b)
				}
			} else {
				b = setTimeout(function () {
					var w = P.wrapInner("<div style='overflow:auto'></div>").children();
					H.h = w.height();
					P.css({
						height: H.h
					});
					w.replaceWith(w.children());
					J.position(q)
				},
				1)
			}
		}
	};
	J.load = function () {
		var b, d, i, l = J.resize;
		v = Q;
		function f(ae) {
			var q = I(ae),
			w = q.find("img"),
			af = w.length;
			function t() {
				var ag = new Image;
				af -= 1;
				if (af >= 0 && H.preloadIMG) {
					ag.onload = t;
					ag.src = w[af].src
				} else {
					l(q)
				}
			}
			t()
		}
		O = L[N];
		H = I(O).data(T);
		h();
		I.event.trigger(x);
		H.h = H.height ? V(H.height, "y") - e - n: H.innerHeight ? V(H.innerHeight, "y") : K;
		H.w = H.width ? V(H.width, "x") - k - o: H.innerWidth ? V(H.innerWidth, "x") : K;
		H.mw = H.w;
		H.mh = H.h;
		if (H.maxWidth) {
			H.mw = V(H.maxWidth, "x") - k - o;
			H.mw = H.w && H.w < H.mw ? H.w: H.mw
		}
		if (H.maxHeight) {
			H.mh = V(H.maxHeight, "y") - e - n;
			H.mh = H.h && H.h < H.mh ? H.h: H.mh
		}
		b = H.href || I(O).attr("href");
		y.show();
		z.show();
		A.show();
		if (H.inline) {
			I('<div id="cboxInlineTemp" />').hide().insertBefore(I(b)[0]).bind(x + " " + E, function () {
				I(this).replaceWith(P.children())
			});
			l(I(b))
		} else {
			if (H.iframe) {
				l(" ")
			} else {
				if (H.html) {
					f(H.html)
				} else {
					if (ad(b)) {
						d = new Image;
						d.onload = function () {
							var q;
							d.onload = null;
							d.id = "cboxPhoto";
							I(d).css({
								margin: "auto",
								border: "none",
								display: "block",
								cssFloat: "left"
							});
							if (H.scalePhotos) {
								i = function () {
									d.height -= d.height * q;
									d.width -= d.width * q
								};
								if (H.mw && d.width > H.mw) {
									q = (d.width - H.mw) / d.width;
									i()
								}
								if (H.mh && d.height > H.mh) {
									q = (d.height - H.mh) / d.height;
									i()
								}
							}
							if (H.h) {
								d.style.marginTop = Math.max(H.h - d.height, 0) / 2 + "px"
							}
							l(d);
							L.length > 1 && I(d).css({
								cursor: "pointer"
							}).click(J.next);
							if (p) {
								d.style.msInterpolationMode = "bicubic"
							}
						};
						d.src = b
					} else {
						I("<div />").load(b, function (q, t) {
							t === "success" ? f(this) : l(I("<p>Request unsuccessful.</p>"))
						})
					}
				}
			}
		}
	};
	J.next = function () {
		if (!v) {
			N = N < L.length - 1 ? N + 1 : 0;
			J.load()
		}
	};
	J.prev = function () {
		if (!v) {
			N = N > 0 ? N - 1 : L.length - 1;
			J.load()
		}
	};
	J.slideshow = function () {
		var b, d, f = "cboxSlideshow_";
		c.bind(j, function () {
			c.unbind();
			clearTimeout(d);
			M.removeClass(f + "off " + f + "on")
		});
		function i() {
			c.text(H.slideshowStop).bind(D, function () {
				d = setTimeout(J.next, H.slideshowSpeed)
			}).bind(x, function () {
				clearTimeout(d)
			}).one("click", function () {
				b();
				I(this).removeClass(m)
			});
			M.removeClass(f + "off").addClass(f + "on")
		}
		b = function () {
			clearTimeout(d);
			c.text(H.slideshowStart).unbind(D + " " + x).one("click", function () {
				i();
				d = setTimeout(J.next, H.slideshowSpeed);
				I(this).removeClass(m)
			});
			M.removeClass(f + "on").addClass(f + "off")
		};
		if (H.slideshow && L.length > 1) {
			H.slideshowAuto ? i() : b()
		}
	};
	J.close = function () {
		I.event.trigger(E);
		u = K;
		I().unbind("keydown.cbox_close keydown.cbox_arrows");
		S.unbind(F + " resize.cboxie6 scroll.cboxie6");
		U.css({
			cursor: "auto"
		}).fadeOut("fast");
		M.stop(Q, K).fadeOut("fast", function () {
			P.remove();
			M.css({
				opacity: 1
			});
			R.children().hide();
			I.event.trigger(j)
		})
	};
	J.element = function () {
		return I(O)
	};
	J.settings = ac;
	I(J.init)
})(jQuery);
jQuery(function (b) {
	b("a[rel^='lightbox']").colorbox({
		photo: true,
		slideshow: false,
		open: true,
		preloading: true,
		slideshowSpeed: 3250,
		slideshowStart: 'start',
		slideshowStop: 'stop',
		current: "<p>image {current}<\/p>"
	});
	
});


