// ColorBox v1.3.15 - a full featured, light-weight, customizable lightbox based on jQuery 1.3+
// Copyright (c) 2010 Jack Moore - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function(b,ib){var t="none",M="LoadedContent",c=false,v="resize.",o="y",q="auto",e=true,L="nofollow",m="x";function f(a,c){a=a?' id="'+i+a+'"':"";c=c?' style="'+c+'"':"";return b("<div"+a+c+"/>")}function p(a,b){b=b===m?n.width():n.height();return typeof a==="string"?Math.round(/%/.test(a)?b/100*parseInt(a,10):parseInt(a,10)):a}function U(b){return a.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(b)}function cb(a){for(var c in a)if(b.isFunction(a[c])&&c.substring(0,2)!=="on")a[c]=a[c].call(l);a.rel=a.rel||l.rel||L;a.href=a.href||b(l).attr("href");a.title=a.title||l.title;return a}function w(c,a){a&&a.call(l);b.event.trigger(c)}function jb(){var b,e=i+"Slideshow_",c="click."+i,f,k;if(a.slideshow&&h[1]){f=function(){F.text(a.slideshowStop).unbind(c).bind(V,function(){if(g<h.length-1||a.loop)b=setTimeout(d.next,a.slideshowSpeed)}).bind(W,function(){clearTimeout(b)}).one(c+" "+N,k);j.removeClass(e+"off").addClass(e+"on");b=setTimeout(d.next,a.slideshowSpeed)};k=function(){clearTimeout(b);F.text(a.slideshowStart).unbind([V,W,N,c].join(" ")).one(c,f);j.removeClass(e+"on").addClass(e+"off")};a.slideshowAuto?f():k()}}function db(c){if(!O){l=c;a=cb(b.extend({},b.data(l,r)));h=b(l);g=0;if(a.rel!==L){h=b("."+G).filter(function(){return (b.data(this,r).rel||this.rel)===a.rel});g=h.index(l);if(g===-1){h=h.add(l);g=h.length-1}}if(!u){u=D=e;j.show();if(a.returnFocus)try{l.blur();b(l).one(eb,function(){try{this.focus()}catch(a){}})}catch(f){}x.css({opacity:+a.opacity,cursor:a.overlayClose?"pointer":q}).show();a.w=p(a.initialWidth,m);a.h=p(a.initialHeight,o);d.position(0);X&&n.bind(v+P+" scroll."+P,function(){x.css({width:n.width(),height:n.height(),top:n.scrollTop(),left:n.scrollLeft()})}).trigger("scroll."+P);w(fb,a.onOpen);Y.add(H).add(I).add(F).add(Z).hide();ab.html(a.close).show()}d.load(e)}}var gb={transition:"elastic",speed:300,width:c,initialWidth:"600",innerWidth:c,maxWidth:c,height:c,initialHeight:"450",innerHeight:c,maxHeight:c,scalePhotos:e,scrolling:e,inline:c,html:c,iframe:c,photo:c,href:c,title:c,rel:c,opacity:.9,preloading:e,current:"image {current} of {total}",previous:"previous",next:"next",close:"close",open:c,returnFocus:e,loop:e,slideshow:c,slideshowAuto:e,slideshowSpeed:2500,slideshowStart:"start slideshow",slideshowStop:"stop slideshow",onOpen:c,onLoad:c,onComplete:c,onCleanup:c,onClosed:c,overlayClose:e,escKey:e,arrowKey:e},r="colorbox",i="cbox",fb=i+"_open",W=i+"_load",V=i+"_complete",N=i+"_cleanup",eb=i+"_closed",Q=i+"_purge",hb=i+"_loaded",E=b.browser.msie&&!b.support.opacity,X=E&&b.browser.version<7,P=i+"_IE6",x,j,A,s,bb,T,R,S,h,n,k,J,K,Z,Y,F,I,H,ab,B,C,y,z,l,g,a,u,D,O=c,d,G=i+"Element";d=b.fn[r]=b[r]=function(c,f){var a=this,d;if(!a[0]&&a.selector)return a;c=c||{};if(f)c.onComplete=f;if(!a[0]||a.selector===undefined){a=b("<a/>");c.open=e}a.each(function(){b.data(this,r,b.extend({},b.data(this,r)||gb,c));b(this).addClass(G)});d=c.open;if(b.isFunction(d))d=d.call(a);d&&db(a[0]);return a};d.init=function(){var l="hover",m="clear:left";n=b(ib);j=f().attr({id:r,"class":E?i+"IE":""});x=f("Overlay",X?"position:absolute":"").hide();A=f("Wrapper");s=f("Content").append(k=f(M,"width:0; height:0; overflow:hidden"),K=f("LoadingOverlay").add(f("LoadingGraphic")),Z=f("Title"),Y=f("Current"),I=f("Next"),H=f("Previous"),F=f("Slideshow").bind(fb,jb),ab=f("Close"));A.append(f().append(f("TopLeft"),bb=f("TopCenter"),f("TopRight")),f(c,m).append(T=f("MiddleLeft"),s,R=f("MiddleRight")),f(c,m).append(f("BottomLeft"),S=f("BottomCenter"),f("BottomRight"))).children().children().css({"float":"left"});J=f(c,"position:absolute; width:9999px; visibility:hidden; display:none");b("body").prepend(x,j.append(A,J));s.children().hover(function(){b(this).addClass(l)},function(){b(this).removeClass(l)}).addClass(l);B=bb.height()+S.height()+s.outerHeight(e)-s.height();C=T.width()+R.width()+s.outerWidth(e)-s.width();y=k.outerHeight(e);z=k.outerWidth(e);j.css({"padding-bottom":B,"padding-right":C}).hide();I.click(d.next);H.click(d.prev);ab.click(d.close);s.children().removeClass(l);b("."+G).live("click",function(a){if(!(a.button!==0&&typeof a.button!=="undefined"||a.ctrlKey||a.shiftKey||a.altKey)){a.preventDefault();db(this)}});x.click(function(){a.overlayClose&&d.close()});b(document).bind("keydown",function(b){if(u&&a.escKey&&b.keyCode===27){b.preventDefault();d.close()}if(u&&a.arrowKey&&!D&&h[1])if(b.keyCode===37&&(g||a.loop)){b.preventDefault();H.click()}else if(b.keyCode===39&&(g<h.length-1||a.loop)){b.preventDefault();I.click()}})};d.remove=function(){j.add(x).remove();b("."+G).die("click").removeData(r).removeClass(G)};d.position=function(f,d){function b(a){bb[0].style.width=S[0].style.width=s[0].style.width=a.style.width;K[0].style.height=K[1].style.height=s[0].style.height=T[0].style.height=R[0].style.height=a.style.height}var e,h=Math.max(document.documentElement.clientHeight-a.h-y-B,0)/2+n.scrollTop(),g=Math.max(n.width()-a.w-z-C,0)/2+n.scrollLeft();e=j.width()===a.w+z&&j.height()===a.h+y?0:f;A[0].style.width=A[0].style.height="9999px";j.dequeue().animate({width:a.w+z,height:a.h+y,top:h,left:g},{duration:e,complete:function(){b(this);D=c;A[0].style.width=a.w+z+C+"px";A[0].style.height=a.h+y+B+"px";d&&d()},step:function(){b(this)}})};d.resize=function(b){if(u){b=b||{};if(b.width)a.w=p(b.width,m)-z-C;if(b.innerWidth)a.w=p(b.innerWidth,m);k.css({width:a.w});if(b.height)a.h=p(b.height,o)-y-B;if(b.innerHeight)a.h=p(b.innerHeight,o);if(!b.innerHeight&&!b.height){b=k.wrapInner("<div style='overflow:auto'></div>").children();a.h=b.height();b.replaceWith(b.children())}k.css({height:a.h});d.position(a.transition===t?0:a.speed)}};d.prep=function(m){var c="hidden";function l(s){var p,f,m,c,l=h.length,q=a.loop;d.position(s,function(){function s(){E&&j[0].style.removeAttribute("filter")}if(u){E&&o&&k.fadeIn(100);k.show();w(hb);Z.show().html(a.title);if(l>1){typeof a.current==="string"&&Y.html(a.current.replace(/\{current\}/,g+1).replace(/\{total\}/,l)).show();I[q||g<l-1?"show":"hide"]().html(a.next);H[q||g?"show":"hide"]().html(a.previous);p=g?h[g-1]:h[l-1];m=g<l-1?h[g+1]:h[0];a.slideshow&&F.show();if(a.preloading){c=b.data(m,r).href||m.href;f=b.data(p,r).href||p.href;c=b.isFunction(c)?c.call(m):c;f=b.isFunction(f)?f.call(p):f;if(U(c))b("<img/>")[0].src=c;if(U(f))b("<img/>")[0].src=f}}K.hide();a.transition==="fade"?j.fadeTo(e,1,function(){s()}):s();n.bind(v+i,function(){d.position(0)});w(V,a.onComplete)}})}if(u){var o,e=a.transition===t?0:a.speed;n.unbind(v+i);k.remove();k=f(M).html(m);k.hide().appendTo(J.show()).css({width:function(){a.w=a.w||k.width();a.w=a.mw&&a.mw<a.w?a.mw:a.w;return a.w}(),overflow:a.scrolling?q:c}).css({height:function(){a.h=a.h||k.height();a.h=a.mh&&a.mh<a.h?a.mh:a.h;return a.h}()}).prependTo(s);J.hide();b("#"+i+"Photo").css({cssFloat:t,marginLeft:q,marginRight:q});X&&b("select").not(j.find("select")).filter(function(){return this.style.visibility!==c}).css({visibility:c}).one(N,function(){this.style.visibility="inherit"});a.transition==="fade"?j.fadeTo(e,0,function(){l(0)}):l(e)}};d.load=function(u){var n,c,s,q=d.prep;D=e;l=h[g];u||(a=cb(b.extend({},b.data(l,r))));w(Q);w(W,a.onLoad);a.h=a.height?p(a.height,o)-y-B:a.innerHeight&&p(a.innerHeight,o);a.w=a.width?p(a.width,m)-z-C:a.innerWidth&&p(a.innerWidth,m);a.mw=a.w;a.mh=a.h;if(a.maxWidth){a.mw=p(a.maxWidth,m)-z-C;a.mw=a.w&&a.w<a.mw?a.w:a.mw}if(a.maxHeight){a.mh=p(a.maxHeight,o)-y-B;a.mh=a.h&&a.h<a.mh?a.h:a.mh}n=a.href;K.show();if(a.inline){f().hide().insertBefore(b(n)[0]).one(Q,function(){b(this).replaceWith(k.children())});q(b(n))}else if(a.iframe){j.one(hb,function(){var c=b("<iframe frameborder='0' style='width:100%; height:100%; border:0; display:block'/>")[0];c.name=i+ +new Date;c.src=a.href;if(!a.scrolling)c.scrolling="no";if(E)c.allowtransparency="true";b(c).appendTo(k).one(Q,function(){c.src="//about:blank"})});q(" ")}else if(a.html)q(a.html);else if(U(n)){c=new Image;c.onload=function(){var e;c.onload=null;c.id=i+"Photo";b(c).css({border:t,display:"block",cssFloat:"left"});if(a.scalePhotos){s=function(){c.height-=c.height*e;c.width-=c.width*e};if(a.mw&&c.width>a.mw){e=(c.width-a.mw)/c.width;s()}if(a.mh&&c.height>a.mh){e=(c.height-a.mh)/c.height;s()}}if(a.h)c.style.marginTop=Math.max(a.h-c.height,0)/2+"px";h[1]&&(g<h.length-1||a.loop)&&b(c).css({cursor:"pointer"}).click(d.next);if(E)c.style.msInterpolationMode="bicubic";setTimeout(function(){q(c)},1)};setTimeout(function(){c.src=n},1)}else n&&J.load(n,function(d,c,a){q(c==="error"?"Request unsuccessful: "+a.statusText:b(this).children())})};d.next=function(){if(!D){g=g<h.length-1?g+1:0;d.load()}};d.prev=function(){if(!D){g=g?g-1:h.length-1;d.load()}};d.close=function(){if(u&&!O){O=e;u=c;w(N,a.onCleanup);n.unbind("."+i+" ."+P);x.fadeTo("fast",0);j.stop().fadeTo("fast",0,function(){w(Q);k.remove();j.add(x).css({opacity:1,cursor:q}).hide();setTimeout(function(){O=c;w(eb,a.onClosed)},1)})}};d.element=function(){return b(l)};d.settings=gb;b(d.init)})(jQuery,this);

/*	
 *	jQuery carouFredSel 4.2.3
 *	Demo's and documentation:
 *	caroufredsel.frebsite.nl
 *	
 *	Copyright (c) 2010 Fred Heusschen
 *	www.frebsite.nl
 *
 *	Dual licensed under the MIT and GPL licenses.
 *	http://en.wikipedia.org/wiki/MIT_License
 *	http://en.wikipedia.org/wiki/GNU_General_Public_License
 */


(function($) {
	if ($.fn.carouFredSel) return;

	$.fn.carouFredSel = function(o) {
		if (this.length == 0) return log('No element selected.');
		if (this.length > 1) {
			return this.each(function() {
				$(this).carouFredSel(o);
			});
		}
		var $ttt = this,
			$tt0 = $ttt[0],
			$cfs = $(this);

		$ttt.init = function(o, setOrig) {
			var obs = ['items', 'scroll', 'auto', 'prev', 'next', 'pagination'];
			o = getObject(o);
			for (var a = 0; a < obs.length; a++) {
				o[obs[a]] = getObject(o[obs[a]]);
			}
			if (typeof o.scroll == 'number') {
				if (o.scroll <= 50)					o.scroll	= { items		: o.scroll 	};
				else								o.scroll	= { duration	: o.scroll 	};
			} else {
				if (typeof o.scroll == 'string')	o.scroll	= { easing		: o.scroll 	};
			}
				 if (typeof o.items == 'number')	o.items		= { visible		: o.items 	};
			else if (typeof o.items == 'string')	o.items		= { visible		: o.items,
																	width		: o.items, 
																	height		: o.items	};

			if (setOrig) {
				opts_orig = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
			}

			opts = $.extend(true, {}, $.fn.carouFredSel.defaults, o);
			opts.variableVisible = false;

			direction = (opts.direction == 'up' || opts.direction == 'left') ? 'next' : 'prev';

			if (opts.direction == 'right' || opts.direction == 'left') {
				opts.dimensions = ['width', 'innerWidth', 'outerWidth', 'height', 'innerHeight', 'outerHeight', 'left', 'top', 'marginRight', 0, 1, 2, 3];
			} else {
				opts.dimensions = ['height', 'innerHeight', 'outerHeight', 'width', 'innerWidth', 'outerWidth', 'top', 'left', 'marginBottom', 3, 2, 1, 0];
			}

			var all_itm = getItems($cfs);
			var lrgst_b = getTrueLargestSize(all_itm, opts, 5, false);


			//	secondairy size set to auto -> measure largest size and set it
			if (opts[opts.dimensions[3]] == 'auto') {
				opts[opts.dimensions[3]] = lrgst_b;
				opts.items[opts.dimensions[3]] = lrgst_b;
			}

			//	primairy item-size not set -> measure it or set to "variable"
			if (!opts.items[opts.dimensions[0]]) {
				opts.items[opts.dimensions[0]] = (hasVariableSizes(all_itm, opts, 2)) 
					? 'variable' 
					: all_itm[opts.dimensions[2]](true);
			}

			//	secondairy item-size not set -> measure it or set to "variable"
			if (!opts.items[opts.dimensions[3]]) {
				opts.items[opts.dimensions[3]] = (hasVariableSizes(all_itm, opts, 5)) 
					? 'variable' 
					: all_itm[opts.dimensions[5]](true);
			}

			//	secondairy size not set -> set to secondairy item-size
			if (!opts[opts.dimensions[3]]) {
				opts[opts.dimensions[3]] = opts.items[opts.dimensions[3]];
			}

			//	visible-items not set
			if (!opts.items.visible) {
				//	primairy item-size variable -> set visible items variable
				if (opts.items[opts.dimensions[0]] == 'variable') {
					opts.items.visible = 'variable';
				} else {
					//	primairy size is number -> calculate visible-items
					if (typeof opts[opts.dimensions[0]] == 'number') {
						opts.items.visible = Math.floor(opts[opts.dimensions[0]] / opts.items[opts.dimensions[0]]);
					} else {
						//	measure and calculate primairy size and visible-items
						var maxS = getTrueInnerSize($wrp.parent(), opts, 1);
						opts.items.visible = Math.floor(maxS / opts.items[opts.dimensions[0]]);
						opts[opts.dimensions[0]] = opts.items.visible * opts.items[opts.dimensions[0]];
						if (typeof opts.padding == 'undefined') {
							opts.padding = 0;
						}
					}
				}
			}

			//	primairy size not set -> calculate it or set to "variable"
			if (!opts[opts.dimensions[0]]) {
				if (opts.items.visible != 'variable' && opts.items[opts.dimensions[0]] != 'variable') {
					opts[opts.dimensions[0]] = opts.items.visible * opts.items[opts.dimensions[0]];
					if (typeof opts.padding == 'undefined') {
						opts.padding = 0;
					}
				} else {
					opts[opts.dimensions[0]] = 'variable';
				}
			}

			//	variable primairy item-sizes with variabe visible-items
			if (opts.items.visible == 'variable') {
				opts.variableVisible = true;
				opts.maxDimention = (opts[opts.dimensions[0]] == 'variable')
					? getTrueInnerSize($wrp.parent(), opts, 1)
					: opts[opts.dimensions[0]];
				if (opts.padding === false || opts.padding === 0) {
					opts[opts.dimensions[0]] = 'variable';
				}
				opts.items.visible = getVisibleItemsNext($cfs, opts, 0);
			} else {
				if (opts.padding === false) {
					opts.padding = 0;
				}
			}

			//	padding not set -> set to auto if primairy size is number
			if (typeof opts.padding == 'undefined') {
				opts.padding = (opts[opts.dimensions[0]] == 'variable')
					? 0
					: 'auto';
			}

			opts.items.oldVisible = opts.items.visible;
			opts.usePadding = false;

			//	auto-padding, only on fixed sizes
			if (opts.padding == 'auto') {
				opts.padding = [0,0,0,0];
				//	 for primairy size
				if (opts[opts.dimensions[0]] != 'variable') {
					opts.usePadding = 'auto';
					var p = getAutoPadding(getCurrentItems($cfs, opts), opts);
					opts.padding[opts.dimensions[10]] = p[0];
					opts.padding[opts.dimensions[12]] = p[0];
				}
				//	for secondairy size
				if (opts[opts.dimensions[3]] != 'variable') {
					var p = (opts[opts.dimensions[3]] - lrgst_b) / 2;
					if ( p < 0 ) p = 0;
					opts.padding[opts.dimensions[9]]  = p;
					opts.padding[opts.dimensions[11]] = p;
				}
			//	default-padding
			} else {
				opts.padding = getPadding(opts.padding);
				opts.usePadding = (
					opts.padding[0] == 0 && 
					opts.padding[1] == 0 && 
					opts.padding[2] == 0 && 
					opts.padding[3] == 0
				) ? false : true;
			}

			if (typeof opts.items.minimum	!= 'number')	opts.items.minimum		= (opts.variableVisible) ? 1 : opts.items.visible;
			if (typeof opts.scroll.items	!= 'number')	opts.scroll.items		= (opts.variableVisible) ? 'variable' : opts.items.visible;
			if (typeof opts.scroll.duration	!= 'number')	opts.scroll.duration	= 500;

			opts.auto		= getNaviObject(opts.auto, false, true);
			opts.prev		= getNaviObject(opts.prev);
			opts.next		= getNaviObject(opts.next);
			opts.pagination	= getNaviObject(opts.pagination, true);

			opts.auto		= $.extend(true, {}, opts.scroll, opts.auto);
			opts.prev		= $.extend(true, {}, opts.scroll, opts.prev);
			opts.next		= $.extend(true, {}, opts.scroll, opts.next);
			opts.pagination	= $.extend(true, {}, opts.scroll, opts.pagination);

			if (typeof opts.pagination.keys				!= 'boolean')	opts.pagination.keys 			= false;
			if (typeof opts.pagination.anchorBuilder	!= 'function')	opts.pagination.anchorBuilder	= $.fn.carouFredSel.pageAnchorBuilder;
			if (typeof opts.auto.play					!= 'boolean')	opts.auto.play					= true;
			if (typeof opts.auto.nap					!= 'boolean')	opts.auto.nap					= true;
			if (typeof opts.auto.delay					!= 'number')	opts.auto.delay					= 0;
			if (typeof opts.auto.pauseDuration			!= 'number')	opts.auto.pauseDuration			= (opts.auto.duration < 10) ? 2500 : opts.auto.duration * 5;

		};	//	/init

		$ttt.build = function() {
			if ($cfs.css('position') == 'absolute' || $cfs.css('position') == 'fixed') {
				log('Carousels CSS-attribute "position" should be "static" or "relative".');
			}
			$wrp.css({
				position	: 'relative',
				overflow	: 'hidden',
				marginTop	: $cfs.css('marginTop'),
				marginRight	: $cfs.css('marginRight'),
				marginBottom: $cfs.css('marginBottom'),
				marginLeft	: $cfs.css('marginLeft')
			});
			$cfs.data('cfs_origCss', {
				width		: $cfs.css('width'),
				height		: $cfs.css('height'),
				marginTop	: $cfs.css('marginTop'),
				marginRight	: $cfs.css('marginRight'),
				marginBottom: $cfs.css('marginBottom'),
				marginLeft	: $cfs.css('marginLeft'),
				'float'		: $cfs.css('float'),
				position	: $cfs.css('position'),
				top			: $cfs.css('top'),
				left		: $cfs.css('left')
			}).css({
				marginTop	: 0,
				marginRight	: 0,
				marginBottom: 0,
				marginLeft	: 0,
				'float'		: 'none',
				position	: 'absolute'
			});
			if (opts.usePadding) {
				getItems($cfs).each(function() {
					var m = parseInt($(this).css(opts.dimensions[8]));
					if (isNaN(m)) m = 0;
					$(this).data('cfs_origCssMargin', m);
				});
			}
		};	//	/build

		$ttt.bind_events = function() {
			$ttt.unbind_events();
			$cfs.bind('pause', function(e, g) {
				if (typeof g != 'boolean') g = false;
				if (g) pausedGlobal = true;
				if (autoTimeout != null)	clearTimeout(autoTimeout);
				if (autoInterval != null)	clearInterval(autoInterval);
				if (timerInterval != null)	clearInterval(timerInterval);
				
				var dur1 = opts.auto.pauseDuration - pauseTimePassed,
					perc = 100 - Math.ceil( dur1 * 100 / opts.auto.pauseDuration );

				if (perc != 0) {
					if (opts.auto.onPausePause) opts.auto.onPausePause.call($tt0, perc, dur1);
				}
			});

			$cfs.bind('play', function(e, d, f, g) {
				$cfs.trigger('pause');
				if (!opts.auto.play) return;

				if (typeof g != 'boolean') {
					if (typeof f == 'boolean') 		g = f;
					else if (typeof d == 'boolean')	g = d;
					else 							g = false;
				}
				if (typeof f != 'number') {
					if (typeof d == 'number')		f = d;
					else							f = 0;
				}
				if (d != 'prev' && d != 'next')		d = direction;

				if (g) pausedGlobal = false;
				if (pausedGlobal) return;

				var dur1 = opts.auto.pauseDuration - pauseTimePassed,
					dur2 = dur1 + f;
					perc = 100 - Math.ceil(dur1 * 100 / opts.auto.pauseDuration);

				autoTimeout = setTimeout(function() {
					if ($cfs.is(':animated')) {
						$cfs.trigger('play', d);
					} else {
						pauseTimePassed = 0;
						$cfs.trigger(d, opts.auto);
					}
				}, dur2);

				if (opts.auto.pauseOnHover === 'resume') {
					autoInterval = setInterval(function() {
						pauseTimePassed += 50;
					}, 50);
				}
				if (opts.auto.onPauseEnd && perc == 0) {
					opts.auto.onPauseEnd.call($tt0, perc, dur1);
				}
				if (opts.auto.onPauseStart) {
					timerInterval = setTimeout(function() {
						opts.auto.onPauseStart.call($tt0, perc, dur1);
					}, f);
				}
			});

			$cfs.bind('prev next', function(e) {
				if (pausedGlobal || $cfs.is(':animated') || $cfs.is(':hidden')) {
					e.stopImmediatePropagation();
					return;
				}
				if (opts.items.minimum >= totalItems) {
					log('Not enough items: not scrolling');
					e.stopImmediatePropagation();
					return;
				}
				pauseTimePassed = 0;
			});

			if (opts.variableVisible) {
				$cfs.bind('prev', function(e, sO, nI) {
					if (typeof sO == 'number') nI = sO;
					if (typeof sO != 'object') sO = opts.prev;
					if (typeof nI != 'number') nI = (typeof sO.items == 'number') ? sO.items : opts.items.visible;

					oI = nI;
					opts.items.oldVisible = opts.items.visible;

					var itm = getItems($cfs);
					if (opts.usePadding) {
						resetMargin(itm, opts);
					}
					opts.items.visible = getVisibleItemsPrev($cfs, opts, oI);
					nI = opts.items.visible - opts.items.oldVisible + oI;

					if (nI <= 0) {
						opts.items.visible = getVisibleItemsNext($cfs, opts, totalItems-oI);
						nI = oI;
					}
					if (opts.usePadding) {
						resetMargin(itm, opts, true);
					}

					$cfs.trigger('slidePrev', [sO, nI]);
				});
				$cfs.bind('next', function(e, sO, nI) {
					if (typeof sO == 'number') nI = sO;
					if (typeof sO != 'object') sO = opts.next;
					if (typeof nI != 'number') nI = (typeof sO.items == 'number') ? sO.items : opts.items.visible;

					opts.items.oldVisible = opts.items.visible;

					var itm = getItems($cfs);
					if (opts.usePadding) {
						resetMargin(itm, opts);
					}
					opts.items.visible = getVisibleItemsNext($cfs, opts, nI);

					if (opts.items.oldVisible - nI >= opts.items.visible) {
						opts.items.visible = getVisibleItemsNext($cfs, opts, ++nI);
					}
					if (opts.usePadding) {
						resetMargin(itm, opts, true);
					}
					$cfs.trigger('slideNext', [sO, nI]);
				});
			} else {
				$cfs.bind('prev', function(e, sO, nI) {
					$cfs.trigger('slidePrev', [sO, nI]);
				});
				$cfs.bind('next', function(e, sO, nI) {
					$cfs.trigger('slideNext', [sO, nI]);
				});
			}

			$cfs.bind('slidePrev', function(e, sO, nI) {
				if (typeof sO == 'number') nI = sO;
				if (typeof sO != 'object') sO = opts.prev;
				if (typeof nI != 'number') nI = (typeof sO.items == 'number') ? sO.items : opts.items.visible;
				if (typeof nI != 'number') return log('Not a valid number: not scrolling');

				if (sO.conditions && !sO.conditions.call($tt0)) return;

				if (!opts.circular) {
					var nulItem = totalItems - firstItem;
					if (nulItem - nI < 0) {
						nI = nulItem;
					}
					if (firstItem == 0) {
						nI = 0;
					}
				}

				firstItem += nI;
				if (firstItem >= totalItems) firstItem -= totalItems;

				if (!opts.circular) {
					if (firstItem == 0 && nI != 0 && sO.onEnd) sO.onEnd.call($tt0);
					if (opts.infinite) {
						if (nI == 0) {
							$cfs.trigger('next', totalItems-opts.items.visible);
							return;
						}
					} else enableNavi(opts, firstItem);
				}

				if (nI == 0) return;

				getItems($cfs, ':gt('+(totalItems-nI-1)+')').prependTo($cfs);

				if (totalItems < opts.items.visible + nI) {
					getItems($cfs, ':lt('+((opts.items.visible+nI)-totalItems)+')').clone(true).appendTo($cfs);
				}

				var c_old = getOldItemsPrev($cfs, opts, nI),
					c_new = getNewItemsPrev($cfs, opts),
					l_cur = getItems($cfs, ':eq('+(nI-1)+')'),
					l_old = c_old.filter(':last'),
					l_new = c_new.filter(':last');

				if (opts.usePadding) {
					resetMargin(l_old, opts);
					resetMargin(c_new, opts);
				}
				if (opts.usePadding == 'auto') {
					var p = getAutoPadding(getNewItemsPrev($cfs, opts, nI), opts);
				}

				var i_siz = getTotalSize(getItems($cfs, ':lt('+nI+')'), opts, 0),
					w_siz = mapWrapperSizes(getSizes(c_new, opts, true), opts, !opts.usePadding);

				if (opts.usePadding) {
					resetMargin(l_old, opts, opts.padding[opts.dimensions[10]]);
					resetMargin(l_cur, opts, opts.padding[opts.dimensions[12]]);
				}

				if (opts.usePadding == 'auto') {
					opts.padding[opts.dimensions[9]]  = p[1];
					opts.padding[opts.dimensions[10]] = p[0];
					opts.padding[opts.dimensions[11]] = p[1];
					opts.padding[opts.dimensions[12]] = p[0];
				}

				var a_cfs = {},
					a_new = {},
					a_cur = {},
					a_old = {},
					a_dur = sO.duration;

					 if (sO.fx == 'none')	a_dur = 0;
				else if (a_dur == 'auto')	a_dur = opts.scroll.duration / opts.scroll.items * nI;
				else if (a_dur <= 0)		a_dur = 0;
				else if (a_dur < 10)		a_dur = i_siz / a_dur;

				var a_conf = {
					duration: a_dur,
					easing	: sO.easing
				};
				if (sO.onBefore) sO.onBefore.call($tt0, c_old, c_new, w_siz, a_dur);
				if (opts.usePadding) {
					var new_m = opts.padding[opts.dimensions[12]];
					a_cur[opts.dimensions[8]] = l_cur.data('cfs_origCssMargin');
					a_new[opts.dimensions[8]] = l_new.data('cfs_origCssMargin') + opts.padding[opts.dimensions[10]];
					a_old[opts.dimensions[8]] = l_old.data('cfs_origCssMargin');

					l_cur.stop().animate(a_cur, a_conf);
					l_new.stop().animate(a_new, a_conf);
					l_old.stop().animate(a_old, a_conf);

				} else {
					var new_m = 0;
				}
				a_cfs[opts.dimensions[6]] = new_m;

				if (opts[opts.dimensions[0]] == 'variable' || opts[opts.dimensions[3]] == 'variable') {
					$wrp.stop().animate(w_siz, a_conf);
				}

				//	alternative effects
				switch(sO.fx) {
					case 'crossfade':
					case 'cover':
					case 'uncover':
						var $cf2 = $cfs.clone().appendTo($wrp);
						break;
				}
				switch(sO.fx) {
					case 'uncover':
						getItems($cf2, ':lt('+nI+')').remove();
					case 'crossfade':
					case 'cover':
						getItems($cf2, ':gt('+(opts.items.oldVisible-1)+')').remove();
						break;
				}
				switch(sO.fx) {
					case 'fade':
						fx_fade(sO, $cfs, 0, a_dur);
						break;
					case 'crossfade':
						$cf2.css({ opacity: 0 });
						fx_fade(sO, $cf2, 1, a_dur);
						fx_fade(sO, $cfs, 1, a_dur, function() { $cf2.remove(); });
						break;
					case 'cover':
						fx_cover(sO, $cfs, $cf2, opts, a_dur, true);
						break;
					case 'uncover':
						fx_uncover(sO, $cf2, opts, a_dur, true);
						break;
				}
				switch(sO.fx) {
					case 'fade':
					case 'crossfade':
					case 'cover':
					case 'uncover':
						f_dur = a_dur;
						a_dur = 0;
						break;
				}
				//	/alternative effects

				var c_nI = nI;
				$cfs.css(opts.dimensions[6], -i_siz);
				$cfs.animate(a_cfs, {
					duration: a_dur,
					easing	: sO.easing,
					complete: function() {
						var overFill = opts.items.visible+c_nI-totalItems;
						if (overFill > 0) {
							getItems($cfs, ':gt('+(totalItems-1)+')').remove();
							c_old = getItems($cfs, ':gt('+(totalItems-(c_nI-overFill)-1)+')').get().concat( getItems($cfs, ':lt('+overFill+')').get() );
						}
						if (opts.usePadding) {
							var l_itm = getItems($cfs, ':eq('+(opts.items.visible+nI-1)+')');
							l_itm.css(opts.dimensions[8], l_itm.data('cfs_origCssMargin'));
						}

						var fn = (sO.onAfter) ? function() { sO.onAfter.call($tt0, c_old, c_new, w_siz); } : false;
						switch(sO.fx) {
							case 'fade':
								fx_fade(sO, $cfs, 1, f_dur, fn);
								break;
							case 'uncover':
								$cfs.animate({ opacity: '+=0' }, {
									duration: f_dur,
									complete: fn
								});
								break;
							default:
								if (fn) fn();
								break;
						}
					}
				});
				$cfs.trigger('updatePageStatus').trigger('play', a_dur);
			});

			$cfs.bind('slideNext', function(e, sO, nI) {
				if (typeof sO == 'number') nI = sO;
				if (typeof sO != 'object') sO = opts.next;
				if (typeof nI != 'number') nI = (typeof sO.items == 'number') ? sO.items : opts.items.visible;
				if (typeof nI != 'number') return log('Not a valid number: not scrolling');

				if (sO.conditions && !sO.conditions.call($tt0)) return;

				if (!opts.circular) {
					if (firstItem == 0) {
						if (nI > totalItems - opts.items.visible) {
							nI = totalItems - opts.items.visible;
						}
					} else {
						if (firstItem - nI < opts.items.visible) {
							nI = firstItem - opts.items.visible;
						}
					}
				}

				firstItem -= nI;
				if (firstItem < 0) firstItem += totalItems;

				if (!opts.circular) {
					if (firstItem == opts.items.visible && nI != 0 && sO.onEnd) sO.onEnd.call($tt0);
					if (opts.infinite) {
						if (nI == 0) {
							$cfs.trigger('prev', totalItems-opts.items.visible);
							return;
						}
					} else enableNavi(opts, firstItem);
				}

				if (nI == 0) return;					
				if (totalItems < opts.items.visible + nI) getItems($cfs, ':lt('+((opts.items.visible+nI)-totalItems)+')').clone(true).appendTo($cfs);

				var c_old = getOldItemsNext($cfs, opts),
					c_new = getNewItemsNext($cfs, opts, nI),
					l_cur = c_old.filter(':eq('+(nI-1)+')'),
					l_old = c_old.filter(':last'),
					l_new = c_new.filter(':last');

				if (opts.usePadding) {
					resetMargin(l_old, opts);
					resetMargin(l_new, opts);
				}

				if (opts.usePadding == 'auto') {
					var p = getAutoPadding(getNewItemsNext($cfs, opts, nI), opts);
				}

				var i_siz = getTotalSize(getItems($cfs, ':lt('+nI+')'), opts, 0),
					w_siz = mapWrapperSizes(getSizes(c_new, opts, true), opts, !opts.usePadding);

				if (opts.usePadding) {
					resetMargin(l_old, opts, opts.padding[opts.dimensions[10]]);
					resetMargin(l_new, opts, opts.padding[opts.dimensions[10]]);
				}
				if (opts.usePadding == 'auto') {
					opts.padding[opts.dimensions[9]]  = p[1];
					opts.padding[opts.dimensions[10]] = p[0];
					opts.padding[opts.dimensions[11]] = p[1];
					opts.padding[opts.dimensions[12]] = p[0];
				}

				var a_cfs = {},
					a_old = {},
					a_cur = {},
					a_dur = sO.duration;

					 if (sO.fx == 'none')	a_dur = 0;
				else if (a_dur == 'auto')	a_dur = opts.scroll.duration / opts.scroll.items * nI;
				else if (a_dur <= 0)		a_dur = 0;
				else if (a_dur < 10)		a_dur = i_siz / a_dur;

				var a_conf = {
					duration: a_dur,
					easing	: sO.easing
				};
				if (sO.onBefore) sO.onBefore.call($tt0, c_old, c_new, w_siz, a_dur);
				if (opts.usePadding) {
					a_old[opts.dimensions[8]] = l_old.data('cfs_origCssMargin');
					a_cur[opts.dimensions[8]] = l_cur.data('cfs_origCssMargin') + opts.padding[opts.dimensions[12]];
					l_new.css(opts.dimensions[8], l_new.data('cfs_origCssMargin') + opts.padding[opts.dimensions[10]]);
					l_old.stop().animate(a_old, a_conf);
					l_cur.stop().animate(a_cur, a_conf);
				}
				a_cfs[opts.dimensions[6]] = -i_siz;

				if (opts[opts.dimensions[0]] == 'variable' || opts[opts.dimensions[3]] == 'variable') {
					$wrp.stop().animate(w_siz, a_conf);
				}

				//	alternative effects
				switch(sO.fx) {
					case 'crossfade':
					case 'cover':
					case 'uncover':
						var $cf2 = $cfs.clone().appendTo($wrp);
						break;
				}
				switch(sO.fx) {
					case 'crossfade':
					case 'cover':
						getItems($cf2, ':lt('+nI+')').remove();
					case 'uncover':
						getItems($cf2, ':gt('+(opts.items.visible-1)+')').remove();
						break;
				}
				switch(sO.fx) {
					case 'fade':
						fx_fade(sO, $cfs, 0, a_dur);
						break;
					case 'crossfade':
						$cf2.css({ opacity: 0 });
						fx_fade(sO, $cf2, 1, a_dur);
						fx_fade(sO, $cfs, 1, a_dur, function() { $cf2.remove(); });
						break;
					case 'cover':
						fx_cover(sO, $cfs, $cf2, opts, a_dur, false);
						break;
					case 'uncover':
						fx_uncover(sO, $cf2, opts, a_dur, false);
						break;
				}
				switch(sO.fx) {
					case 'fade':
					case 'crossfade':
					case 'cover':
					case 'uncover':
						f_dur = a_dur;
						a_dur = 0;
						break;
				}
				//	/alternative effects

				var c_nI = nI;
				$cfs.animate(a_cfs, {
					duration: a_dur,
					easing	: sO.easing,
					complete: function() {
						var overFill = opts.items.visible+c_nI-totalItems;
						$cfs.css(opts.dimensions[6], opts.padding[opts.dimensions[12]]);
						if (overFill > 0) {
							getItems($cfs, ':gt('+(totalItems-1)+')').remove();
						}
						var l_itm = getItems($cfs, ':lt('+c_nI+')').appendTo($cfs).filter(':last');
						if (overFill > 0) {
							c_new = getCurrentItems($cfs, opts);
						}
						if (opts.usePadding) {
							if (totalItems < opts.items.visible+c_nI) {
								var l_cur = getItems($cfs, ':eq('+(opts.items.visible-1)+')');
								l_cur.css(opts.dimensions[8], l_cur.data('cfs_origCssMargin') + opts.padding[opts.dimensions[12]]);
							}
							l_itm.css(opts.dimensions[8], l_itm.data('cfs_origCssMargin'));
						}

						var fn = (sO.onAfter) ? function() { sO.onAfter.call($tt0, c_old, c_new, w_siz); } : false;
						switch(sO.fx) {
							case 'fade':
								fx_fade(sO, $cfs, 1, f_dur, fn);
								break;
							case 'uncover':
								$cfs.animate({ opacity: '+=0' }, {
									duration: f_dur,
									complete: fn
								});
								break;
							default:
								if (fn) fn();
								break;
						}
					}
				});
				$cfs.trigger('updatePageStatus').trigger('play', a_dur);
			});

			$cfs.bind('slideTo', function(e, num, dev, org, obj) {
				if ($cfs.is(':animated')) return;

				num = getItemIndex(num, dev, org, firstItem, totalItems, $cfs);
				if (num == 0) return;
				if (typeof obj != 'object') obj = false;

				if (opts.circular) {
					if (num < totalItems / 2) 	$cfs.trigger('next', [obj, num]);
					else 						$cfs.trigger('prev', [obj, totalItems-num]);
				} else {
					if (firstItem == 0 ||
						firstItem > num)		$cfs.trigger('next', [obj, num]);
					else						$cfs.trigger('prev', [obj, totalItems-num]);
				}
			});

			$cfs.bind('insertItem', function(e, itm, num, org, dev) {
				if (typeof itm == 'object' && 
					typeof itm.jquery == 'undefined')	itm = $(itm);
				if (typeof itm == 'string') 			itm = $(itm);
				if (typeof itm != 'object' || 
					typeof itm.jquery == 'undefined' || 
					itm.length == 0) return log('Not a valid object.');

				if (typeof num == 'undefined' || num == 'end') {
					$cfs.append(itm);
				} else {
					num = getItemIndex(num, dev, org, firstItem, totalItems, $cfs);
					var $cit = getItems($cfs, ':eq('+num+')');
					if (opts.usePadding) {
						itm.each(function() {
							var m = parseInt($(this).css(opts.dimensions[8]));
							if (isNaN(m)) m = 0;
							$(this).data('cfs_origCssMargin', m);
						});
					}
					if ($cit.length) {
						if (num < firstItem) firstItem += itm.length;
						if (firstItem >= totalItems) firstItem -= totalItems;
						$cit.before(itm);
					} else {
						$cfs.append(itm);
					}
				}
				totalItems = getItems($cfs).length;
				$cfs.trigger('linkAnchors');
				setSizes($cfs, opts);
				showNavi(opts, totalItems);
				enableNavi(opts, firstItem);
				$cfs.trigger('updatePageStatus', true);
			});

			$cfs.bind('removeItem', function(e, num, org, dev) {
				if (typeof num == 'undefined' || num == 'end') {
					getItems($cfs, ':last').remove();
				} else {
					num = getItemIndex(num, dev, org, firstItem, totalItems, $cfs);
					var $cit = getItems($cfs, ':eq('+num+')');
					if ($cit.length){
						if (num < firstItem) firstItem -= $cit.length;
						$cit.remove();
					}
				}
				totalItems = getItems($cfs).length;
				setSizes($cfs, opts);
				showNavi(opts, totalItems);
				enableNavi(opts, firstItem);
				$cfs.trigger('updatePageStatus', true);
			});
			
			$cfs.bind('linkAnchors', function(e, $con, sel) {
				if (typeof $con == 'undefined' || $con.length == 0) $con = $('body');
				else if (typeof $con == 'string') $con = $($con);
				if (typeof $con != 'object') return log('Not a valid object.');
				if (typeof sel != 'string' || sel.length == 0) sel = 'a.caroufredsel';
				$con.find(sel).each(function() {
					var h = this.hash || '';
					if (h.length > 0 && getItems($cfs).index($(h)) != -1) {
						$(this).unbind('click').click(function(e) {
							e.preventDefault();
							$cfs.trigger('slideTo', h);
						});
					}
				});
			});

			$cfs.bind('currentPosition', function(e, fn) {
				if (firstItem == 0) var val = 0;
				else var val = totalItems - firstItem;
				if (typeof fn == 'function') fn.call($tt0, val);
			});

			$cfs.bind('configuration', function(e, a, b, reInit) {
				if ($cfs.is(':animated')) {
					var configTimer = setInterval(function() {
						$cfs.trigger('configuration', [a, b, reInit]);
						clearInterval(configTimer);
					}, 100);
					return;
				}
				if (typeof reInit != 'boolean') reInit = true;
				if (typeof a == 'function') {
					a.call($tt0, opts);
				} else if (typeof b == 'function') {
					var val = eval('opts.'+a);
					if (typeof val == 'undefined') val = '';
					b.call($tt0, val);
				} else if (typeof a != 'undefined' && typeof b != 'undefined') {
					eval('opts_orig.'+a+' = b');
					if (reInit) {
						resetMargin(getItems($cfs), opts);
						$ttt.init(opts_orig);
						setSizes($cfs, opts);
					} else {
						eval('opts.'+a+' = b');
					}
				}
			});

			$cfs.bind('destroy', function(e, orgOrder) {
				if (orgOrder) {
					$cfs.trigger('slideTo', [0, 0, true, { duration: 0 }]);
				}
				if (opts.usePadding) {
					resetMargin(getItems($cfs), opts);
				}
				$cfs.trigger('pause').css($cfs.data('cfs_origCss'));
				$ttt.unbind_events();
				$ttt.unbind_buttons();
				$wrp.replaceWith($cfs);
			});

			$cfs.bind('updatePageStatus', function(e, build) {
				if (!opts.pagination.container) return;
				if (typeof build == 'boolean' && build) {
					getItems(opts.pagination.container).remove();
					for (var a = 0; a < Math.ceil(totalItems/opts.items.visible); a++) {
						var i = getItems($cfs, ':eq(' + getItemIndex(a*opts.items.visible, 0, true, firstItem, totalItems, $cfs) + ')');
						opts.pagination.container.append(opts.pagination.anchorBuilder(a+1, i));
					}
					getItems(opts.pagination.container).unbind('click').each(function(a) {
						$(this).click(function(e) {
							e.preventDefault();
							$cfs.trigger('slideTo', [a * opts.items.visible, 0, true, opts.pagination]);
						});
					});
				}
				var max = Math.ceil(totalItems/opts.items.visible-1);
				if (firstItem == 0) var nr = 0;
				else if (firstItem < totalItems % opts.items.visible) var nr = 0;
				else if (firstItem == opts.items.visible && !opts.circular) var nr = max;
				else var nr = Math.round((totalItems-firstItem)/opts.items.visible);
				if (nr < 0) nr = 0;
				if (nr > max) nr = max;
				getItems(opts.pagination.container).removeClass('selected').filter(':eq('+nr+')').addClass('selected');
			});
		};	//	/bind_events

		$ttt.unbind_events = function() {
			$cfs.unbind('pause')
				.unbind('play')
				.unbind('prev')
				.unbind('next')
				.unbind('slidePrev')
				.unbind('slideNext')
				.unbind('slideTo')
				.unbind('insertItem')
				.unbind('removeItem')
				.unbind('linkAnchors')
				.unbind('destroy')
				.unbind('updatePageStatus')
				.unbind('currentPosition')
				.unbind('configuration');
		};	//	/unbind_events

		$ttt.bind_buttons = function() {
			showNavi(opts, 'show');
			enableNavi(opts, firstItem);
			if (opts.auto.pauseOnHover && opts.auto.play) {
				$wrp.hover(
					function() { $cfs.trigger('pause'); },
					function() { $cfs.trigger('play');	}
				);
			}
			if (opts.prev.button) {
				opts.prev.button.click(function(e) {
					e.preventDefault();
					$cfs.trigger('prev');
				});
				if (opts.prev.pauseOnHover && opts.auto.play) {
					opts.prev.button.hover(
						function() { $cfs.trigger('pause');	},
						function() { $cfs.trigger('play');	}
					);
				}
			}
			if (opts.next.button) {
				opts.next.button.click(function(e) {
					e.preventDefault();
					$cfs.trigger('next');
				});
				if (opts.next.pauseOnHover && opts.auto.play) {
					opts.next.button.hover(
						function() { $cfs.trigger('pause');	},
						function() { $cfs.trigger('play');	}
					)
				}
			}
			if ($.fn.mousewheel) {
				if (opts.prev.mousewheel) {
					$wrp.mousewheel(function(e, delta) { 
						if (delta > 0) {
							e.preventDefault();
							num = (typeof opts.prev.mousewheel == 'number') ? opts.prev.mousewheel : '';
							$cfs.trigger('prev', num);
						}
					});
				}
				if (opts.next.mousewheel) {
					$wrp.mousewheel(function(e, delta) { 
						if (delta < 0) {
							e.preventDefault();
							num = (typeof opts.next.mousewheel == 'number') ? opts.next.mousewheel : '';
							$cfs.trigger('next', num);
						}
					});
				}
			}
			if (opts.pagination.container) {
				$cfs.trigger('updatePageStatus', true);
				if (opts.pagination.pauseOnHover && opts.auto.play) {
					opts.pagination.container.hover(
						function() { $cfs.trigger('pause');	},
						function() { $cfs.trigger('play');	}
					);
				}
			}
			if (opts.next.key || opts.prev.key) {
				$(document).keyup(function(e) {
					var k = e.keyCode;
					if (k == opts.next.key)	{
						e.preventDefault();
						$cfs.trigger('next');
					}
					if (k == opts.prev.key) {
						e.preventDefault();
						$cfs.trigger('prev');
					}
				});
			}
			if (opts.pagination.keys) {
				$(document).keyup(function(e) {
					var k = e.keyCode;
					if (k >= 49 && k < 58) {
						k = (k-49) * opts.items.visible;
						if (k <= totalItems) {
							e.preventDefault();
							$cfs.trigger('slideTo', [k, 0, true, opts.pagination]);
						}
					}
				});
			}
			if (opts.auto.play) {
				$cfs.trigger('play', opts.auto.delay);
				if ($.fn.nap && opts.auto.nap) {
					$cfs.nap('pause', 'play');
				}
			}
		};	//	/bind_buttons

		$ttt.unbind_buttons = function() {
			showNavi(opts, 'hide');
			enableNavi(opts, 'removeClass');
			if (opts.pagination.container) {
				getItems(opts.pagination.container).remove();
			}
		};



		//	DEPRECATED
		$ttt.configuration = function(a, b) {
			log('The "configuration" public method is deprecated, use the "configuration" custom event.');
			var cr = false;
			var fn = function(val) { cr = val; };
			if (!a) a = fn;
			if (!b) b = fn;
			$cfs.trigger('configuration', [a, b]);
			return cr;
		};
		$ttt.current_position = function() {
			log('The "current_position" public method is deprecated, use the "currentPosition" custom event.');
			var cp = false;
			$cfs.trigger('currentPosition', function(val) { cp = val; });
			return cp;
		};
		$ttt.destroy = function() {
			log('The "destroy" public method is deprecated, use the "destroy" custom event.');
			$cfs.trigger('destroy');
			return $ttt;
		};
		$ttt.link_anchors = function($c, se) {
			log('The "link_anchors" public method is deprecated, use the "linkAnchors" custom event.');
			$cfs.trigger('linkAnchors', [$c, se]);
			return $ttt;
		};
		//	/DEPRECATED




		if ($cfs.parent().is('.caroufredsel_wrapper')) {
			var $wrp = $cfs.parent();
			$cfs.trigger('destroy');
		}
		var $wrp			= $cfs.wrap('<div class="caroufredsel_wrapper" />').parent(),
			opts 			= {},
			opts_orig		= o,
			totalItems		= getItems($cfs).length,
			firstItem 		= 0,
			autoTimeout		= null,
			autoInterval	= null,
			timerInterval	= null,
			pauseTimePassed	= 0,
			pausedGlobal	= false,
			direction		= 'next';

		$ttt.init(opts_orig, true);
		$ttt.build();
		$ttt.bind_events();
		$ttt.bind_buttons();

		$cfs.trigger('linkAnchors');
		setSizes($cfs, opts, false);

		if (opts.items.start !== 0 && opts.items.start !== false) {
			var s = opts.items.start;
			if (s === true) {
				s = window.location.hash;
				if (!s.length) s = 0;
			}
			if (s === 'random') {
				s = Math.floor(Math.random() * totalItems);
			}
			$cfs.trigger('slideTo', [s, 0, true, { duration: 0 }]);
		}
		return this;
	};


	//	public
	$.fn.carouFredSel.defaults = {
		infinite: true,
		circular: true,
		direction: 'left',
		items: {
			start: 0
		},
		scroll: {
			easing: 'swing',
			pauseOnHover: false,
			mousewheel: false
		}
	};

	$.fn.carouFredSel.pageAnchorBuilder = function(nr, itm) {
		return '<a href="#"><span>'+nr+'</span></a>';
	};


	//	private
	function fx_fade(sO, c, x, d, f) {
		var o = {
			duration: d,
			easing: sO.easing
		};
		if (typeof f == 'function') o.complete = f;
		c.animate({
			opacity: x
		}, o);
	}
	function fx_cover(sO, c1, c2, o, d, prev) {
		var cur_w = getSizes(getItems(c2), o, true)[0],
			cur_p = (prev) ? -cur_w : cur_w,
			css_o = {},
			ani_o = {};
		css_o[o.dimensions[0]] = cur_w;
		css_o[o.dimensions[6]] = cur_p;
		ani_o[o.dimensions[6]] = 0;
		c1.animate({ opacity: '+=0' }, d);
		c2.css(css_o).animate(ani_o, {
			duration: d,
			easing: sO.easing,
			complete: function() {
				$(this).remove();
			}
		});
	}
	function fx_uncover(sO, c, o, d, prev) {
		var cur_w = getSizes(getItems(c), o, true)[0],
			cur_p = (prev) ? cur_w : -cur_w,
			css_o = {},
			ani_o = {};
		css_o[o.dimensions[0]] = cur_w;
		ani_o[o.dimensions[6]] = cur_p;
		c.css(css_o).animate(ani_o, {
			duration: d,
			easing: sO.easing,
			complete: function() {
				$(this).remove();
			}
		});
	}

	function showNavi(o, t) {
		if (t == 'show' || t == 'hide') {
			var f = t;
		} else if (o.items.minimum >= t) {
			log('Not enough items: not scrolling');
			var f = 'hide';
		} else {
			var f = 'show';
		}
		if (o.prev.button) o.prev.button[f]();
		if (o.next.button) o.next.button[f]();
		if (o.pagination.container) o.pagination.container[f]();
	}
	function enableNavi(o, f) {
		if (o.circular || o.infinite) return;
		var fx = (f == 'removeClass' || f == 'addClass') ? f : false;
		if (o.next.button) {
			var fn = fx || (f == o.items.visible) ? 'addClass' : 'removeClass';
			o.next.button[fn]('disabled');
		}
		if (o.prev.button) {
			var fn = fx || (f == 0) ? 'addClass' : 'removeClass';
			o.prev.button[fn]('disabled');
		}
	}
	function getKeyCode(k) {
		if (k == 'right')	return 39;
		if (k == 'left')	return 37;
		if (k == 'up')		return 38;
		if (k == 'down')	return 40;
		return -1;
	}
	function getObject(obj) {
		if (typeof obj == 'undefined') obj = {};
		return obj;
	}
	function getNaviObject(obj, pagi, auto) {
		if (typeof pagi != 'boolean') pagi = false;
		if (typeof auto != 'boolean') auto = false;

		obj = getObject(obj);
		if (typeof obj == 'string') {
			var temp = getKeyCode(obj);
			if (temp == -1) obj = $(obj);
			else 			obj = temp;
		}

		//	pagination
		if (pagi) {
			if (typeof obj 				== 'boolean')	obj = { keys: obj };
			if (typeof obj.jquery 		!= 'undefined')	obj = { container: obj };
			if (typeof obj.container	== 'string')	obj.container = $(obj.container);

		//	auto
		} else if (auto) {
			if (typeof obj == 'boolean')				obj = { play: obj };
			if (typeof obj == 'number')					obj = { pauseDuration: obj };
			if (typeof obj.timer != 'object')			obj.timer = {};


		//	prev + next
		} else {
			if (typeof obj.jquery	!= 'undefined')		obj = { button: obj };
			if (typeof obj 			== 'number')		obj = { key: obj };
			if (typeof obj.button	== 'string')		obj.button = $(obj.button);
			if (typeof obj.key		== 'string')		obj.key = getKeyCode(obj.key);
		}
		return obj;
	}
	function getItemIndex(num, dev, org, firstItem, totalItems, $cfs) {
		if (typeof num == 'string') {
			if (isNaN(num)) num = $(num);
			else 			num = parseInt(num);
		}
		if (typeof num == 'object') {
			if (typeof num.jquery == 'undefined') num = $(num);
			num = getItems($cfs).index(num);
			if (num == -1) num = 0;
			if (typeof org != 'boolean') org = false;
		} else {
			if (typeof org != 'boolean') org = true;
		}
		if (isNaN(num))	num = 0;
		else 			num = parseInt(num);
		if (isNaN(dev))	dev = 0;
		else 			dev = parseInt(dev);

		if (org) {
			num += firstItem;
		}
		num += dev;
		if (totalItems > 0) {
			while (num >= totalItems)	{	num -= totalItems; }
			while (num < 0)				{	num += totalItems; }
		}
		return num;
	}

	function getItems(c, f) {
		if (typeof f != 'string') f = '';
		return $('> *'+f, c);
	}
	function getCurrentItems(c, o) {
		return getItems(c, ':lt('+o.items.visible+')');
	}
	function getOldItemsPrev(c, o, n) {
		return getItems(c, ':lt('+(o.items.oldVisible+n)+'):gt('+(n-1)+')');
	}
	function getNewItemsPrev(c, o) {
		return getItems(c, ':lt('+o.items.visible+')');
	}
	function getOldItemsNext(c, o) {
		return getItems(c, ':lt('+o.items.oldVisible+')');
	}
	function getNewItemsNext(c, o, n) {
		return getItems(c, ':lt('+(o.items.visible+n)+'):gt('+(n-1)+')');
	}

	function resetMargin(i, o, m) {
		var x = (typeof m == 'boolean') ? m : false;
		if (typeof m != 'number') m = 0;
		i.each(function() {
			var t = parseInt($(this).css(o.dimensions[8]));
			if (isNaN(t)) t = 0;
			$(this).data('cfs_tempCssMargin', t);
			$(this).css(o.dimensions[8], ((x) ? $(this).data('cfs_tempCssMargin') : m + $(this).data('cfs_origCssMargin')));
		});
	}
	function getSizes(i, o, wrapper) {
		s1 = getTotalSize(i, o, 0, wrapper);
		s2 = getLargestSize(i, o, 3, wrapper);
		return [s1, s2];
	}
	function getLargestSize(i, o, dim, wrapper) {
		if (typeof wrapper != 'boolean') wrapper = false;
		if (typeof o[o.dimensions[dim]] == 'number' && wrapper) return o[o.dimensions[dim]];
		if (typeof o.items[o.dimensions[dim]] == 'number') return o.items[o.dimensions[dim]];
		return getTrueLargestSize(i, o, dim+2);
	}
	function getTrueLargestSize(i, o, dim) {
		var s = 0;
		i.each(function() {
			var m = $(this)[o.dimensions[dim]](true);
			if (s < m) s = m;
		});
		return s;
	}
	function getTrueInnerSize($el, o, dim) {
		var siz = $el[o.dimensions[dim]](),
			arr = (o.dimensions[dim].toLowerCase().indexOf('width') > -1) ? ['paddingLeft', 'paddingRight'] : ['paddingTop', 'paddingBottom'];
		for (a = 0; a < arr.length; a++) {
			var m = parseInt($el.css(arr[a]));
			if (isNaN(m)) m = 0;
			siz -= m;
		}
		return siz;
	}
	function getTotalSize(i, o, dim, wrapper) {
		if (typeof wrapper != 'boolean') wrapper = false;
		if (typeof o[o.dimensions[dim]] == 'number' && wrapper) return o[o.dimensions[dim]];
		if (typeof o.items[o.dimensions[dim]] == 'number') return o.items[o.dimensions[dim]] * i.length;
		return getTotalSizeVariable(i, o, dim+2);
	}
	function getTotalSizeVariable(i, o, dim) {
		var s = 0;
		i.each(function() { 
			s += $(this)[o.dimensions[dim]](true);
		});
		return s;
	}

	function hasVariableSizes(i, o, dim) {
		var s = false,
			v = false;
		i.each(function() { 
			c = $(this)[o.dimensions[dim]]();
			if (s === false) s = c;
			else if (s != c) v = true;
		});
		return v;
	}

	function mapWrapperSizes(ws, o, p) {
		if (typeof p != 'boolean') p = true;
		var pad = (o.usePadding && p) ? o.padding : [0, 0, 0, 0];
		var wra = {};
			wra[o.dimensions[0]] = ws[0] + pad[1] + pad[3];
			wra[o.dimensions[3]] = ws[1] + pad[0] + pad[2];

		return wra;
	}
	function setSizes($c, o, p) {
		var $w = $c.parent(),
			$i = getItems($c),
			$l = $i.filter(':eq('+(o.items.visible-1)+')');

		$w.css(mapWrapperSizes(getSizes($i.filter(':lt('+o.items.visible+')'), o, true), o, p));

		if (o.usePadding) {
			$l.css(o.dimensions[8], $l.data('cfs_origCssMargin') + o.padding[o.dimensions[10]]);
			$c.css(o.dimensions[7], o.padding[o.dimensions[9]]);
			$c.css(o.dimensions[6], o.padding[o.dimensions[12]]);
		}
		$c.css(o.dimensions[0], getTotalSize($i, o, 0)*2);
		$c.css(o.dimensions[3], getLargestSize($i, o, 3));
	}

	function getPadding(p) {
		if (typeof p == 'undefined') return [0, 0, 0, 0];
		
		if (typeof p == 'number') return [p, p, p, p];
		else if (typeof p == 'string') p = p.split('px').join('').split(' ');

		if (typeof p != 'object') {
			return [0, 0, 0, 0];
		}
		for (i in p) {
			p[i] = parseInt(p[i]);
		}
		switch (p.length) {
			case 0: return [0, 0, 0, 0];
			case 1: return [p[0], p[0], p[0], p[0]];
			case 2: return [p[0], p[1], p[0], p[1]];
			case 3: return [p[0], p[1], p[2], p[1]];
			default: return [p[0], p[1], p[2], p[3]];
		}
	}
	function getAutoPadding(itm, o) {
		var	wiz = (typeof o[o.dimensions[3]] == 'number') ? o[o.dimensions[3]] : getLargestSize(itm, o, 3);
		return [(o[o.dimensions[0]] - getTotalSize(itm, o, 0)) / 2, (wiz - getLargestSize(itm, o, 3)) / 2];
	}

	function getVisibleItemsPrev($c, o, nI) {
		var items = getItems($c),
			total = 0,
			start = o.items.visible - nI - 1,
			x = 0;

		if (start < 0) start = items.length-1;
		for (var a = start; a >= 0; a--) {
			total += items.filter(':eq('+ a +')')[o.dimensions[2]](true);
			if (total > o.maxDimention) return x;
			if (a == 0) a = items.length;
			x++;
		}
	}
	function getVisibleItemsNext($c, o, nI) {
		var items = getItems($c),
			total = 0,
			x = 0;

		for (var a = nI; a <= items.length-1; a++) {
			total += items.filter(':eq('+ a +')')[o.dimensions[2]](true);
			if (total > o.maxDimention) return x;
			if (a == items.length-1) a = -1;
			x++;
		}
	}

	function log(m) {
		if (typeof m == 'string') m = 'carouFredSel: ' + m;
		if (window.console && window.console.log) window.console.log(m);
		else try { console.log(m); } catch(err) { }
		return false;
	}



	$.fn.caroufredsel = function(o) {
		return this.carouFredSel(o);
	};

})(jQuery);

/* idTabs ~ Sean Catchpole - Version 2.2 - MIT/GPL */
(function(){var dep={"jQuery":"http://code.jquery.com/jquery-latest.min.js"};var init=function(){(function($){$.fn.idTabs=function(){var s={};for(var i=0;i<arguments.length;++i){var a=arguments[i];switch(a.constructor){case Object:$.extend(s,a);break;case Boolean:s.change=a;break;case Number:s.start=a;break;case Function:s.click=a;break;case String:if(a.charAt(0)=='.')s.selected=a;else if(a.charAt(0)=='!')s.event=a;else s.start=a;break;}}
if(typeof s['return']=="function")
s.change=s['return'];return this.each(function(){$.idTabs(this,s);});}
$.idTabs=function(tabs,options){var meta=($.metadata)?$(tabs).metadata():{};var s=$.extend({},$.idTabs.settings,meta,options);if(s.selected.charAt(0)=='.')s.selected=s.selected.substr(1);if(s.event.charAt(0)=='!')s.event=s.event.substr(1);if(s.start==null)s.start=-1;var showId=function(){if($(this).is('.'+s.selected))
return s.change;var id="#"+this.href.split('#')[1];var aList=[];var idList=[];$("a",tabs).each(function(){if(this.href.match(/#/)){aList.push(this);idList.push("#"+this.href.split('#')[1]);}});if(s.click&&!s.click.apply(this,[id,idList,tabs,s]))return s.change;for(i in aList)$(aList[i]).removeClass(s.selected);for(i in idList)$(idList[i]).hide();$(this).addClass(s.selected);$(id).show();return s.change;}
var list=$("a[href*='#']",tabs).unbind(s.event,showId).bind(s.event,showId);list.each(function(){$("#"+this.href.split('#')[1]).hide();});var test=false;if((test=list.filter('.'+s.selected)).length);else if(typeof s.start=="number"&&(test=list.eq(s.start)).length);else if(typeof s.start=="string"&&(test=list.filter("[href*='#"+s.start+"']")).length);if(test){test.removeClass(s.selected);test.trigger(s.event);}
return s;}
$.idTabs.settings={start:0,change:false,click:null,selected:".selected",event:"!click"};$.idTabs.version="2.2";$(function(){$(".idTabs").idTabs();});})(jQuery);}
var check=function(o,s){s=s.split('.');while(o&&s.length)o=o[s.shift()];return o;}
var head=document.getElementsByTagName("head")[0];var add=function(url){var s=document.createElement("script");s.type="text/javascript";s.src=url;head.appendChild(s);}
var s=document.getElementsByTagName('script');var src=s[s.length-1].src;var ok=true;for(d in dep){if(check(this,d))continue;ok=false;add(dep[d]);}if(ok)return init();add(src);})();

/*
 Galleria v 1.2.4 2011-06-07
 http://galleria.aino.se

 Copyright (c) 2011, Aino
 Licensed under the MIT license.
*/
(function(e){var l=this,n=l.document,F=e(n),u=e(l),A=!0,y=navigator.userAgent.toLowerCase(),G=l.location.hash.replace(/#\//,""),o=function(){var a=3,b=n.createElement("div"),c=b.getElementsByTagName("i");do b.innerHTML="<\!--[if gt IE "+ ++a+"]><i></i><![endif]--\>";while(c[0]);return a>4?a:void 0}(),v=function(){return{html:n.documentElement,body:n.body,head:n.getElementsByTagName("head")[0],title:n.title}},H=function(){var a=[];e.each("data ready thumbnail loadstart loadfinish image play pause progress fullscreen_enter fullscreen_exit idle_enter idle_exit rescale lightbox_open lightbox_close lightbox_image".split(" "),
function(b,c){a.push(c);/_/.test(c)&&a.push(c.replace(/_/g,""))});return a}(),I=function(a){var b;if(typeof a!=="object")return a;e.each(a,function(c,d){/^[a-z]+_/.test(c)&&(b="",e.each(c.split("_"),function(a,c){b+=a>0?c.substr(0,1).toUpperCase()+c.substr(1):c}),a[b]=d,delete a[c])});return a},B=function(a){if(e.inArray(a,H)>-1)return g[a.toUpperCase()];return a},w={trunk:{},add:function(a,b,c,d){d=d||!1;this.clear(a);if(d)var e=b,b=function(){e();w.add(a,b,c)};this.trunk[a]=l.setTimeout(b,c)},clear:function(a){var b=
function(a){l.clearTimeout(this.trunk[a]);delete this.trunk[a]},c;if(a&&a in this.trunk)b.call(w,a);else if(typeof a==="undefined")for(c in this.trunk)this.trunk.hasOwnProperty(c)&&b.call(w,c)}},C=[],z=[],J=!1,t=!1,f=function(){return{array:function(a){return Array.prototype.slice.call(a)},create:function(a,b){var c=n.createElement(b||"div");c.className=a;return c},animate:function(){var a=function(a){var b="transition WebkitTransition MozTransition OTransition".split(" "),c;for(c=0;b[c];c++)if(typeof a[b[c]]!==
"undefined")return b[c];return!1}((document.body||document.documentElement).style),b={MozTransition:"transitionend",OTransition:"oTransitionEnd",WebkitTransition:"webkitTransitionEnd",transition:"transitionend"}[a],c={_default:[0.25,0.1,0.25,1],galleria:[0.645,0.045,0.355,1],galleriaIn:[0.55,0.085,0.68,0.53],galleriaOut:[0.25,0.46,0.45,0.94],ease:[0.25,0,0.25,1],linear:[0.25,0.25,0.75,0.75],"ease-in":[0.42,0,1,1],"ease-out":[0,0,0.58,1],"ease-in-out":[0.42,0,0.58,1]},d=function(a,b,c){var d={},c=
c||"transition";e.each("webkit moz ms o".split(" "),function(){d["-"+this+"-"+c]=b});a.css(d)},j=function(a){d(a,"none","transition");g.WEBKIT&&(d(a,"translate3d(0,0,0)","transform"),a.data("revert")&&(a.css(a.data("revert")),a.data("revert",null)))},k,i,h,m,q,x,D;return function(p,r,s){s=e.extend({duration:400,complete:function(){},stop:!1},s);p=e(p);s.duration?a?(s.stop&&(p.unbind(b),j(p)),k=!1,e.each(r,function(a,b){D=p.css(a);f.parseValue(D)!=f.parseValue(b)&&(k=!0);p.css(a,D)}),k?(i=[],h=s.easing in
c?c[s.easing]:c._default,m=" "+s.duration+"ms cubic-bezier("+h.join(",")+")",l.setTimeout(function(){p.one(b,function(a){return function(){j(a);s.complete.call(a[0])}}(p));if(g.WEBKIT&&g.TOUCH&&(q={},x=[0,0,0],e.each(["left","top"],function(a,b){b in r&&(x[a]=f.parseValue(r[b])-f.parseValue(p.css(b))+"px",q[b]=r[b],delete r[b])}),x[0]||x[1]))p.data("revert",q),i.push("-webkit-transform"+m),d(p,"translate3d("+x.join(",")+")","transform");e.each(r,function(a){i.push(a+m)});d(p,i.join(","));p.css(r)},
1)):l.setTimeout(function(){s.complete.call(p[0])},s.duration)):p.animate(r,s):(p.css(r),s.complete.call(p[0]))}}(),forceStyles:function(a,b){a=e(a);a.attr("style")&&a.data("styles",a.attr("style")).removeAttr("style");a.css(b)},revertStyles:function(){e.each(f.array(arguments),function(a,b){b=e(b);b.removeAttr("style");b.attr("style","");b.data("styles")&&b.attr("style",b.data("styles")).data("styles",null)})},moveOut:function(a){f.forceStyles(a,{position:"absolute",left:-1E4})},moveIn:function(){f.revertStyles.apply(f,
f.array(arguments))},hide:function(a,b,c){a=e(a);a.data("opacity")||a.data("opacity",a.css("opacity"));var d={opacity:0};b?f.animate(a,d,{duration:b,complete:c,stop:!0}):a.css(d)},show:function(a,b,c){var a=e(a),d={opacity:parseFloat(a.data("opacity"))||1};b?f.animate(a,d,{duration:b,complete:c,stop:!0}):a.css(d)},optimizeTouch:function(){var a,b,c,d,f={},g=function(a){a.preventDefault();f=e.extend({},a,!0)},i=function(){this.evt=f},h=function(){this.handler.call(a,this.evt)};return function(m){e(m).bind("touchstart",
function(m){a=m.target;for(d=!0;a.parentNode&&a!=m.currentTarget&&d;)b=e(a).data("events"),c=e(a).data("fakes"),b&&"click"in b?(d=!1,m.preventDefault(),e(a).click(g).click(),b.click.pop(),e.each(b.click,i),e(a).data("fakes",b.click),delete b.click):c&&(d=!1,m.preventDefault(),e.each(c,h)),a=a.parentNode})}}(),addTimer:function(){w.add.apply(w,f.array(arguments));return this},clearTimer:function(){w.clear.apply(w,f.array(arguments));return this},wait:function(a){var a=e.extend({until:function(){return!1},
success:function(){},error:function(){g.raise("Could not complete wait function.")},timeout:3E3},a),b=f.timestamp(),c,d,j=function(){d=f.timestamp();c=d-b;if(a.until(c))return a.success(),!1;if(d>=b+a.timeout)return a.error(),!1;l.setTimeout(j,2)};l.setTimeout(j,2)},toggleQuality:function(a,b){if(!(o!==7&&o!==8)&&a)typeof b==="undefined"&&(b=a.style.msInterpolationMode==="nearest-neighbor"),a.style.msInterpolationMode=b?"bicubic":"nearest-neighbor"},insertStyleTag:function(a){var b=n.createElement("style");
v().head.appendChild(b);b.styleSheet?b.styleSheet.cssText=a:(a=n.createTextNode(a),b.appendChild(a))},loadScript:function(a,b){var c=!1,d=e("<script>").attr({src:a,async:!0}).get(0);d.onload=d.onreadystatechange=function(){if(!c&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete"))c=!0,d.onload=d.onreadystatechange=null,typeof b==="function"&&b.call(this,this)};v().head.appendChild(d)},parseValue:function(a){return typeof a==="number"?a:typeof a==="string"?(a=a.match(/\-?\d|\./g))&&
a.constructor===Array?a.join("")*1:0:0},timestamp:function(){return(new Date).getTime()},loadCSS:function(a,b,c){var d,j=!1,k;e("link[rel=stylesheet]").each(function(){if(RegExp(a).test(this.href))return d=this,!1});typeof b==="function"&&(c=b,b=void 0);c=c||function(){};if(d)return c.call(d,d),d;k=n.styleSheets.length;A&&(a+="?"+f.timestamp());e("#"+b).length?(e("#"+b).attr("href",a),k--,j=!0):(d=e("<link>").attr({rel:"stylesheet",href:a,id:b}).get(0),l.setTimeout(function(){var b=e('link[rel="stylesheet"], style');
b.length?b.get(0).parentNode.insertBefore(d,b[0]):v().head.appendChild(d);o?k>=31?g.raise("You have reached the browser stylesheet limit (31)",!0):d.onreadystatechange=function(){if(!j&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete"))j=!0}:/file:\/\//i.test(a)?j=!0:e.ajax({url:a,success:function(){j=!0},error:function(a){a.isRejected()&&g.WEBKIT&&(j=!0)}})},10));typeof c==="function"&&f.wait({until:function(){return j&&n.styleSheets.length>k},success:function(){l.setTimeout(function(){c.call(d,
d)},100)},error:function(){g.raise("Theme CSS could not load",!0)},timeout:1E4});return d}}}(),E=function(){var a=function(a,c,d,g){var k=this.getOptions("easing"),i=this.getStageWidth(),h={left:i*(a.rewind?-1:1)},m={left:0};if(d)h.opacity=0,m.opacity=1;e(a.next).css(h);f.animate(a.next,m,{duration:a.speed,complete:function(a){return function(){c();a.css({left:0})}}(e(a.next).add(a.prev)),queue:!1,easing:k});if(g)a.rewind=!a.rewind;if(a.prev){h={left:0};m={left:i*(a.rewind?1:-1)};if(d)h.opacity=1,
m.opacity=0;e(a.prev).css(h);f.animate(a.prev,m,{duration:a.speed,queue:!1,easing:k,complete:function(){e(this).css("opacity",0)}})}};return{fade:function(a,c){e(a.next).css("opacity",0).show();f.animate(a.next,{opacity:1},{duration:a.speed,complete:c});a.prev&&(e(a.prev).css("opacity",1).show(),f.animate(a.prev,{opacity:0},{duration:a.speed}))},flash:function(a,c){e(a.next).css("opacity",0);a.prev?f.animate(a.prev,{opacity:0},{duration:a.speed/2,complete:function(){f.animate(a.next,{opacity:1},{duration:a.speed,
complete:c})}}):f.animate(a.next,{opacity:1},{duration:a.speed,complete:c})},pulse:function(a,c){a.prev&&e(a.prev).hide();e(a.next).css("opacity",0).show();f.animate(a.next,{opacity:1},{duration:a.speed,complete:c})},slide:function(){a.apply(this,f.array(arguments))},fadeslide:function(){a.apply(this,f.array(arguments).concat([!0]))},doorslide:function(){a.apply(this,f.array(arguments).concat([!1,!0]))}}}(),g=function(){var a=this;this._theme=void 0;this._options={};this._playing=!1;this._playtime=
5E3;this._active=null;this._queue={length:0};this._data=[];this._dom={};this._thumbnails=[];this._firstrun=this._initialized=!1;this._stageHeight=this._stageWidth=0;this._target=void 0;this._id=Math.random();e.each("container stage images image-nav image-nav-left image-nav-right info info-text info-title info-description thumbnails thumbnails-list thumbnails-container thumb-nav-left thumb-nav-right loader counter tooltip".split(" "),function(b,c){a._dom[c]=f.create("galleria-"+c)});e.each("current total".split(" "),
function(b,c){a._dom[c]=f.create("galleria-"+c,"span")});var b=this._keyboard={keys:{UP:38,DOWN:40,LEFT:37,RIGHT:39,RETURN:13,ESCAPE:27,BACKSPACE:8,SPACE:32},map:{},bound:!1,press:function(c){var d=c.keyCode||c.which;d in b.map&&typeof b.map[d]==="function"&&b.map[d].call(a,c)},attach:function(a){var c,d;for(c in a)a.hasOwnProperty(c)&&(d=c.toUpperCase(),d in b.keys?b.map[b.keys[d]]=a[c]:b.map[d]=a[c]);if(!b.bound)b.bound=!0,F.bind("keydown",b.press)},detach:function(){b.bound=!1;b.map={};F.unbind("keydown",
b.press)}},c=this._controls={0:void 0,1:void 0,active:0,swap:function(){c.active=c.active?0:1},getActive:function(){return c[c.active]},getNext:function(){return c[1-c.active]}},d=this._carousel={next:a.$("thumb-nav-right"),prev:a.$("thumb-nav-left"),width:0,current:0,max:0,hooks:[],update:function(){var b=0,c=0,f=[0];e.each(a._thumbnails,function(a,d){d.ready&&(b+=d.outerWidth||e(d.container).outerWidth(!0),f[a+1]=b,c=Math.max(c,d.outerHeight||e(d.container).outerHeight(!0)))});a.$("thumbnails").css({width:b,
height:c});d.max=b;d.hooks=f;d.width=a.$("thumbnails-list").width();d.setClasses();a.$("thumbnails-container").toggleClass("galleria-carousel",b>d.width);d.width=a.$("thumbnails-list").width()},bindControls:function(){var b;d.next.bind("click",function(c){c.preventDefault();if(a._options.carouselSteps==="auto")for(b=d.current;b<d.hooks.length;b++){if(d.hooks[b]-d.hooks[d.current]>d.width){d.set(b-2);break}}else d.set(d.current+a._options.carouselSteps)});d.prev.bind("click",function(c){c.preventDefault();
if(a._options.carouselSteps==="auto")for(b=d.current;b>=0;b--)if(d.hooks[d.current]-d.hooks[b]>d.width){d.set(b+2);break}else{if(b===0){d.set(0);break}}else d.set(d.current-a._options.carouselSteps)})},set:function(a){for(a=Math.max(a,0);d.hooks[a-1]+d.width>=d.max&&a>=0;)a--;d.current=a;d.animate()},getLast:function(a){return(a||d.current)-1},follow:function(a){if(a===0||a===d.hooks.length-2)d.set(a);else{for(var b=d.current;d.hooks[b]-d.hooks[d.current]<d.width&&b<=d.hooks.length;)b++;a-1<d.current?
d.set(a-1):a+2>b&&d.set(a-b+d.current+2)}},setClasses:function(){d.prev.toggleClass("disabled",!d.current);d.next.toggleClass("disabled",d.hooks[d.current]+d.width>=d.max)},animate:function(){d.setClasses();var b=d.hooks[d.current]*-1;isNaN(b)||f.animate(a.get("thumbnails"),{left:b},{duration:a._options.carouselSpeed,easing:a._options.easing,queue:!1})}},j=this._tooltip={initialized:!1,open:!1,init:function(){j.initialized=!0;f.insertStyleTag(".galleria-tooltip{padding:3px 8px;max-width:50%;background:#ffe;color:#000;z-index:3;position:absolute;font-size:11px;line-height:1.3opacity:0;box-shadow:0 0 2px rgba(0,0,0,.4);-moz-box-shadow:0 0 2px rgba(0,0,0,.4);-webkit-box-shadow:0 0 2px rgba(0,0,0,.4);}");
a.$("tooltip").css("opacity",0.8);f.hide(a.get("tooltip"))},move:function(b){var c=a.getMousePosition(b).x,b=a.getMousePosition(b).y,d=a.$("tooltip"),e=b,f=d.outerHeight(!0)+1,g=d.outerWidth(!0),h=f+15,g=a.$("container").width()-g-2,f=a.$("container").height()-f-2;!isNaN(c)&&!isNaN(e)&&(c+=10,e-=30,c=Math.max(0,Math.min(g,c)),e=Math.max(0,Math.min(f,e)),b<h&&(e=h),d.css({left:c,top:e}))},bind:function(b,c){if(!g.TOUCH){j.initialized||j.init();var d=function(b,c){j.define(b,c);e(b).hover(function(){f.clearTimer("switch_tooltip");
a.$("container").unbind("mousemove",j.move).bind("mousemove",j.move).trigger("mousemove");j.show(b);g.utils.addTimer("tooltip",function(){a.$("tooltip").stop().show().animate({opacity:1});j.open=!0},j.open?0:500)},function(){a.$("container").unbind("mousemove",j.move);f.clearTimer("tooltip");a.$("tooltip").stop().animate({opacity:0},200,function(){a.$("tooltip").hide();f.addTimer("switch_tooltip",function(){j.open=!1},1E3)})})};typeof c==="string"?d(b in a._dom?a.get(b):b,c):e.each(b,function(b,c){d(a.get(b),
c)})}},show:function(b){var b=e(b in a._dom?a.get(b):b),c=b.data("tt"),d=function(a){l.setTimeout(function(a){return function(){j.move(a)}}(a),10);b.unbind("mouseup",d)};if(c=typeof c==="function"?c():c)a.$("tooltip").html(c.replace(/\s/,"&nbsp;")),b.bind("mouseup",d)},define:function(b,c){if(typeof c!=="function")var d=c,c=function(){return d};b=e(b in a._dom?a.get(b):b).data("tt",c);j.show(b)}},k=this._fullscreen={scrolled:0,active:!1,keymap:a._keyboard.map,enter:function(b){k.active=!0;f.hide(a.getActiveImage());
a.$("container").addClass("fullscreen");k.scrolled=u.scrollTop();f.forceStyles(a.get("container"),{position:"fixed",top:0,left:0,width:"100%",height:"100%",zIndex:1E4});var c={height:"100%",overflow:"hidden",margin:0,padding:0},d=a.getData();f.forceStyles(v().html,c);f.forceStyles(v().body,c);k.keymap=e.extend({},a._keyboard.map);a.attachKeyboard({escape:a.exitFullscreen,right:a.next,left:a.prev});if(d&&d.big&&d.image!==d.big){var c=new g.Picture,h=c.isCached(d.big),j=a.getIndex(),i=a._thumbnails[j];
a.trigger({type:g.LOADSTART,cached:h,index:j,imageTarget:a.getActiveImage(),thumbTarget:i});c.load(d.big,function(b){a._scaleImage(b,{complete:function(b){a.trigger({type:g.LOADFINISH,cached:h,index:j,imageTarget:b.image,thumbTarget:i});var c=a._controls.getActive().image;c&&e(c).width(b.image.width).height(b.image.height).attr("style",e(b.image).attr("style")).attr("src",b.image.src)}})})}a.rescale(function(){f.addTimer("fullscreen_enter",function(){f.show(a.getActiveImage());typeof b==="function"&&
b.call(a)},100);a.trigger(g.FULLSCREEN_ENTER)});u.resize(function(){k.scale()})},scale:function(){a.rescale()},exit:function(b){k.active=!1;f.hide(a.getActiveImage());a.$("container").removeClass("fullscreen");f.revertStyles(a.get("container"),v().html,v().body);l.scrollTo(0,k.scrolled);a.detachKeyboard();a.attachKeyboard(k.keymap);a.rescale(function(){f.addTimer("fullscreen_exit",function(){f.show(a.getActiveImage());typeof b==="function"&&b.call(a)},50);a.trigger(g.FULLSCREEN_EXIT)});u.unbind("resize",
k.scale)}},i=this._idle={trunk:[],bound:!1,add:function(a,b){if(a){i.bound||i.addEvent();var a=e(a),c={},d;for(d in b)b.hasOwnProperty(d)&&(c[d]=a.css(d));a.data("idle",{from:c,to:b,complete:!0,busy:!1});i.addTimer();i.trunk.push(a)}},remove:function(b){b=jQuery(b);e.each(i.trunk,function(c,d){d.length&&!d.not(b).length&&(a._idle.show(b),a._idle.trunk.splice(c,1))});i.trunk.length||(i.removeEvent(),f.clearTimer("idle"))},addEvent:function(){i.bound=!0;a.$("container").bind("mousemove click",i.showAll)},
removeEvent:function(){i.bound=!1;a.$("container").unbind("mousemove click",i.showAll)},addTimer:function(){f.addTimer("idle",function(){a._idle.hide()},a._options.idleTime)},hide:function(){a._options.idleMode&&(a.trigger(g.IDLE_ENTER),e.each(i.trunk,function(b,c){var d=c.data("idle");if(d)c.data("idle").complete=!1,f.animate(c,d.to,{duration:a._options.idleSpeed})}))},showAll:function(){f.clearTimer("idle");e.each(a._idle.trunk,function(b,c){a._idle.show(c)})},show:function(b){var c=b.data("idle");
if(!c.busy&&!c.complete)c.busy=!0,a.trigger(g.IDLE_EXIT),f.clearTimer("idle"),f.animate(b,c.from,{duration:a._options.idleSpeed/2,complete:function(){e(this).data("idle").busy=!1;e(this).data("idle").complete=!0}});i.addTimer()}},h=this._lightbox={width:0,height:0,initialized:!1,active:null,image:null,elems:{},keymap:!1,init:function(){a.trigger(g.LIGHTBOX_OPEN);if(!h.initialized){h.initialized=!0;var b={},c=a._options,d="",c={overlay:"position:fixed;display:none;opacity:"+c.overlayOpacity+";filter:alpha(opacity="+
c.overlayOpacity*100+");top:0;left:0;width:100%;height:100%;background:"+c.overlayBackground+";z-index:99990",box:"position:fixed;display:none;width:400px;height:400px;top:50%;left:50%;margin-top:-200px;margin-left:-200px;z-index:99991",shadow:"position:absolute;background:#000;width:100%;height:100%;",content:"position:absolute;background-color:#fff;top:10px;left:10px;right:10px;bottom:10px;overflow:hidden",info:"position:absolute;bottom:10px;left:10px;right:10px;color:#444;font:11px/13px arial,sans-serif;height:13px",
close:"position:absolute;top:10px;right:10px;height:20px;width:20px;background:#fff;text-align:center;cursor:pointer;color:#444;font:16px/22px arial,sans-serif;z-index:99999",image:"position:absolute;top:10px;left:10px;right:10px;bottom:30px;overflow:hidden;display:block;",prevholder:"position:absolute;width:50%;top:0;bottom:40px;cursor:pointer;",nextholder:"position:absolute;width:50%;top:0;bottom:40px;right:-1px;cursor:pointer;",prev:"position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;left:20px;display:none;text-align:center;color:#000;font:bold 16px/36px arial,sans-serif",
next:"position:absolute;top:50%;margin-top:-20px;height:40px;width:30px;background:#fff;right:20px;left:auto;display:none;font:bold 16px/36px arial,sans-serif;text-align:center;color:#000",title:"float:left",counter:"float:right;margin-left:8px;"},j={};o===8&&(c.nextholder+="background:#000;filter:alpha(opacity=0);",c.prevholder+="background:#000;filter:alpha(opacity=0);");e.each(c,function(a,b){d+=".galleria-lightbox-"+a+"{"+b+"}"});f.insertStyleTag(d);e.each("overlay box content shadow title info close prevholder prev nextholder next counter image".split(" "),
function(c,d){a.addElement("lightbox-"+d);b[d]=h.elems[d]=a.get("lightbox-"+d)});h.image=new g.Picture;e.each({box:"shadow content close prevholder nextholder",info:"title counter",content:"info image",prevholder:"prev",nextholder:"next"},function(a,b){var c=[];e.each(b.split(" "),function(a,b){c.push("lightbox-"+b)});j["lightbox-"+a]=c});a.append(j);e(b.image).append(h.image.container);e(v().body).append(b.overlay,b.box);f.optimizeTouch(b.box);(function(a){return a.hover(function(){e(this).css("color",
"#bbb")},function(){e(this).css("color","#444")})})(e(b.close).bind("click",h.hide).html("&#215;"));e.each(["Prev","Next"],function(a,c){var d=e(b[c.toLowerCase()]).html(/v/.test(c)?"&#8249;&nbsp;":"&nbsp;&#8250;"),f=e(b[c.toLowerCase()+"holder"]);f.bind("click",function(){h["show"+c]()});o<8||g.TOUCH?d.show():f.hover(function(){d.show()},function(){d.stop().fadeOut(200)})});e(b.overlay).bind("click",h.hide);if(g.IPAD)a._options.lightboxTransitionSpeed=0}},rescale:function(b){var c=Math.min(u.width()-
40,h.width),d=Math.min(u.height()-60,h.height),d=Math.min(c/h.width,d/h.height),c=Math.round(h.width*d)+40,d=Math.round(h.height*d)+60,c={width:c,height:d,"margin-top":Math.ceil(d/2)*-1,"margin-left":Math.ceil(c/2)*-1};b?e(h.elems.box).css(c):e(h.elems.box).animate(c,{duration:a._options.lightboxTransitionSpeed,easing:a._options.easing,complete:function(){var b=h.image,c=a._options.lightboxFadeSpeed;a.trigger({type:g.LIGHTBOX_IMAGE,imageTarget:b.image});e(b.container).show();f.show(b.image,c);f.show(h.elems.info,
c)}})},hide:function(){h.image.image=null;u.unbind("resize",h.rescale);e(h.elems.box).hide();f.hide(h.elems.info);a.detachKeyboard();a.attachKeyboard(h.keymap);h.keymap=!1;f.hide(h.elems.overlay,200,function(){e(this).hide().css("opacity",a._options.overlayOpacity);a.trigger(g.LIGHTBOX_CLOSE)})},showNext:function(){h.show(a.getNext(h.active))},showPrev:function(){h.show(a.getPrev(h.active))},show:function(b){h.active=b=typeof b==="number"?b:a.getIndex();h.initialized||h.init();if(!h.keymap)h.keymap=
e.extend({},a._keyboard.map),a.attachKeyboard({escape:h.hide,right:h.showNext,left:h.showPrev});u.unbind("resize",h.rescale);var c=a.getData(b),d=a.getDataLength();f.hide(h.elems.info);h.image.load(c.big||c.image,function(a){h.width=a.original.width;h.height=a.original.height;e(a.image).css({width:"100.5%",height:"100.5%",top:0,zIndex:99998});f.hide(a.image);h.elems.title.innerHTML=c.title||"";h.elems.counter.innerHTML=b+1+" / "+d;u.resize(h.rescale);h.rescale()});e(h.elems.overlay).show();e(h.elems.box).show()}};
return this};g.prototype={constructor:g,init:function(a,b){var c=this,b=I(b);this._original={target:a,options:b,data:null};this._target=this._dom.target=a.nodeName?a:e(a).get(0);z.push(this);this._target?(this._options={autoplay:!1,carousel:!0,carouselFollow:!0,carouselSpeed:400,carouselSteps:"auto",clicknext:!1,dataConfig:function(){return{}},dataSelector:"img",dataSource:this._target,debug:void 0,easing:"galleria",extend:function(){},fullscreenDoubleTap:!0,height:"auto",idleMode:!0,idleTime:3E3,
idleSpeed:200,imageCrop:!1,imageMargin:0,imagePan:!1,imagePanSmoothness:12,imagePosition:"50%",initialTransition:void 0,keepSource:!1,lightbox:!1,lightboxFadeSpeed:200,lightboxTransitionSpeed:200,linkSourceTmages:!0,maxScaleRatio:void 0,minScaleRatio:void 0,overlayOpacity:0.85,overlayBackground:"#0b0b0b",pauseOnInteraction:!0,popupLinks:!1,preload:2,protect:!1,queue:!0,show:0,showInfo:!0,showCounter:!0,showImagenav:!0,swipe:!0,thumbCrop:!0,thumbEventType:"click",thumbFit:!0,thumbMargin:0,thumbQuality:"auto",
thumbnails:!0,transition:"fade",transitionInitial:void 0,transitionSpeed:400,useCanvas:!1,width:"auto"},this._options.initialTransition=this._options.initialTransition||this._options.transitionInitial,b&&b.debug===!1&&(A=!1),e(this._target).children().hide(),typeof g.theme==="object"?this._init():f.wait({until:function(){return typeof g.theme==="object"},success:function(){c._init.call(c)},error:function(){g.raise("No theme found.",!0)},timeout:5E3})):g.raise("Target not found.",!0)},_init:function(){var a=
this;if(this._initialized)return g.raise("Init failed: Gallery instance already initialized."),this;this._initialized=!0;if(!g.theme)return g.raise("Init failed: No theme found."),this;e.extend(!0,this._options,g.theme.defaults,this._original.options);(function(a){"getContext"in a&&(t=t||{elem:a,context:a.getContext("2d"),cache:{},length:0})})(n.createElement("canvas"));this.bind(g.DATA,function(){this._original.data=this._data;this.get("total").innerHTML=this.getDataLength();var b=this.$("container"),
c={width:0,height:0},d=function(){return a.$("stage").height()};f.wait({until:function(){e.each(["width","height"],function(d,e){c[e]=a._options[e]&&typeof a._options[e]==="number"?a._options[e]:Math.max(f.parseValue(b.css(e)),f.parseValue(a.$("target").css(e)),b[e](),a.$("target")[e]());b[e](c[e])});return d()&&c.width&&c.height>10},success:function(){g.WEBKIT?l.setTimeout(function(){a._run()},1):a._run()},error:function(){d()?g.raise("Could not extract sufficient width/height of the gallery container. Traced measures: width:"+
c.width+"px, height: "+c.height+"px.",!0):g.raise("Could not extract a stage height from the CSS. Traced height: "+d()+"px.",!0)},timeout:2E3})});this.append({"info-text":["info-title","info-description"],info:["info-text"],"image-nav":["image-nav-right","image-nav-left"],stage:["images","loader","counter","image-nav"],"thumbnails-list":["thumbnails"],"thumbnails-container":["thumb-nav-left","thumbnails-list","thumb-nav-right"],container:["stage","thumbnails-container","info","tooltip"]});f.hide(this.$("counter").append(this.get("current"),
" / ",this.get("total")));this.setCounter("&#8211;");f.hide(a.get("tooltip"));this.$("container").addClass(g.TOUCH?"touch":"notouch");e.each(Array(2),function(b){var c=new g.Picture;e(c.container).css({position:"absolute",top:0,left:0});a.$("images").append(c.container);a._controls[b]=c});this.$("images").css({position:"relative",top:0,left:0,width:"100%",height:"100%"});this.$("thumbnails, thumbnails-list").css({overflow:"hidden",position:"relative"});this.$("image-nav-right, image-nav-left").bind("click",
function(b){a._options.clicknext&&b.stopPropagation();a._options.pauseOnInteraction&&a.pause();b=/right/.test(this.className)?"next":"prev";a[b]()});e.each(["info","counter","image-nav"],function(b,c){a._options["show"+c.substr(0,1).toUpperCase()+c.substr(1).replace(/-/,"")]===!1&&f.moveOut(a.get(c.toLowerCase()))});this.load();if(!this._options.keep_source&&!o)this._target.innerHTML="";this.$("target").append(this.get("container"));this._options.carousel&&this.bind(g.THUMBNAIL,function(){this.updateCarousel()});
this._options.swipe&&(function(b){var c=[0,0],d=[0,0],e=!1,g=0,i,h={start:"touchstart",move:"touchmove",stop:"touchend"},m=function(a){a.originalEvent.touches&&a.originalEvent.touches.length>1||(i=a.originalEvent.touches?a.originalEvent.touches[0]:a,d=[i.pageX,i.pageY],c[0]||(c=d),Math.abs(c[0]-d[0])>10&&a.preventDefault())},q=function(i){b.unbind(h.move,m);i.originalEvent.touches&&i.originalEvent.touches.length||e?e=!e:(f.timestamp()-g<1E3&&Math.abs(c[0]-d[0])>30&&Math.abs(c[1]-d[1])<100&&(i.preventDefault(),
a[c[0]>d[0]?"next":"prev"]()),c=d=[0,0])};b.bind(h.start,function(a){a.originalEvent.touches&&a.originalEvent.touches.length>1||(i=a.originalEvent.touches?a.originalEvent.touches[0]:a,g=f.timestamp(),c=d=[i.pageX,i.pageY],b.bind(h.move,m).one(h.stop,q))})}(a.$("images")),this._options.fullscreenDoubleTap&&this.$("stage").bind("touchstart",function(){var b,c,d,e,f,i;return function(h){i=g.utils.timestamp();c=(h.originalEvent.touches?h.originalEvent.touches[0]:h).pageX;d=(h.originalEvent.touches?h.originalEvent.touches[0]:
h).pageY;i-b<500&&c-e<20&&d-f<20?(a.toggleFullscreen(),h.preventDefault(),a.$("stage").unbind("touchend",arguments.callee)):(b=i,e=c,f=d)}}()));f.optimizeTouch(this.get("container"));return this},_createThumbnails:function(){this.get("total").innerHTML=this.getDataLength();var a,b,c,d,j,k=this,i=this._options,h=function(){var a=k.$("thumbnails").find(".active");if(!a.length)return!1;return a.find("img").attr("src")}(),m=typeof i.thumbnails==="string"?i.thumbnails.toLowerCase():null,q=function(a){return n.defaultView&&
n.defaultView.getComputedStyle?n.defaultView.getComputedStyle(c.container,null)[a]:j.css(a)},x=function(a,b,c){return function(){e(c).append(a);k.trigger({type:g.THUMBNAIL,thumbTarget:a,index:b})}},o=function(a){i.pauseOnInteraction&&k.pause();var b=e(a.currentTarget).data("index");k.getIndex()!==b&&k.show(b);a.preventDefault()},p=function(a){a.scale({width:a.data.width,height:a.data.height,crop:i.thumbCrop,margin:i.thumbMargin,canvas:i.useCanvas,complete:function(a){var b=["left","top"],c,d;e.each(["Width",
"Height"],function(f,g){c=g.toLowerCase();if((i.thumbCrop!==!0||i.thumbCrop===c)&&i.thumbFit)d={},d[c]=a[c],e(a.container).css(d),d={},d[b[f]]=0,e(a.image).css(d);a["outer"+g]=e(a.container)["outer"+g](!0)});f.toggleQuality(a.image,i.thumbQuality===!0||i.thumbQuality==="auto"&&a.original.width<a.width*3);k.trigger({type:g.THUMBNAIL,thumbTarget:a.image,index:a.data.order})}})};this._thumbnails=[];this.$("thumbnails").empty();for(a=0;this._data[a];a++)d=this._data[a],i.thumbnails===!0?(c=new g.Picture(a),
b=d.thumb||d.image,this.$("thumbnails").append(c.container),j=e(c.container),c.data={width:f.parseValue(q("width")),height:f.parseValue(q("height")),order:a},i.thumbFit&&i.thumbCrop!==!0?j.css({width:0,height:0}):j.css({width:c.data.width,height:c.data.height}),c.load(b,p),i.preload==="all"&&c.add(d.image)):m==="empty"||m==="numbers"?(c={container:f.create("galleria-image"),image:f.create("img","span"),ready:!0},m==="numbers"&&e(c.image).text(a+1),this.$("thumbnails").append(c.container),l.setTimeout(x(c.image,
a,c.container),50+a*20)):c={container:null,image:null},e(c.container).add(i.keepSource&&i.linkSourceImages?d.original:null).data("index",a).bind(i.thumbEventType,o),h===b&&e(c.container).addClass("active"),this._thumbnails.push(c)},_run:function(){var a=this;a._createThumbnails();f.wait({until:function(){g.OPERA&&a.$("stage").css("display","inline-block");a._stageWidth=a.$("stage").width();a._stageHeight=a.$("stage").height();return a._stageWidth&&a._stageHeight>50},success:function(){C.push(a);f.show(a.get("counter"));
a._options.carousel&&a._carousel.bindControls();if(a._options.autoplay){a.pause();if(typeof a._options.autoplay==="number")a._playtime=a._options.autoplay;a.trigger(g.PLAY);a._playing=!0}a._firstrun?typeof a._options.show==="number"&&a.show(a._options.show):(a._firstrun=!0,a._options.clicknext&&!g.TOUCH&&(e.each(a._data,function(a,c){delete c.link}),a.$("stage").css({cursor:"pointer"}).bind("click",function(){a._options.pauseOnInteraction&&a.pause();a.next()})),g.History&&g.History.change(function(b){b=
parseInt(b.value.replace(/\//,""),10);isNaN(b)?l.history.go(-1):a.show(b,void 0,!0)}),e.each(g.ready.callbacks,function(){this.call(a,a._options)}),a.trigger(g.READY),g.theme.init.call(a,a._options),a._options.extend.call(a,a._options),/^[0-9]{1,4}$/.test(G)&&g.History?a.show(G,void 0,!0):a._data[a._options.show]&&a.show(a._options.show))},error:function(){g.raise("Stage width or height is too small to show the gallery. Traced measures: width:"+a._stageWidth+"px, height: "+a._stageHeight+"px.",!0)}})},
load:function(a,b,c){var d=this;this._data=[];this._thumbnails=[];this.$("thumbnails").empty();typeof b==="function"&&(c=b,b=null);a=a||this._options.dataSource;b=b||this._options.dataSelector;c=c||this._options.dataConfig;/^function Object/.test(a.constructor)&&(a=[a]);if(a.constructor===Array)return this.validate(a)?(this._data=a,this._parseData().trigger(g.DATA)):g.raise("Load failed: JSON Array not valid."),this;e(a).find(b).each(function(a,b){var b=e(b),f={},g=b.parent(),m=g.attr("href"),g=g.attr("rel"),
q=/\.(png|gif|jpg|jpeg)(\?.*)?$/i;if(q.test(m))f.image=m,f.big=q.test(g)?g:m;else if(m)f.link=m;d._data.push(e.extend({title:b.attr("title")||"",thumb:b.attr("src"),image:b.attr("src"),big:b.attr("src"),description:b.attr("alt")||"",link:b.attr("longdesc"),original:b.get(0)},f,c(b)))});this.getDataLength()?this.trigger(g.DATA):g.raise("Load failed: no data found.");return this},_parseData:function(){var a=this;e.each(this._data,function(b,c){if("thumb"in c===!1)a._data[b].thumb=c.image;if(!1 in c)a._data[b].big=
c.image});return this},splice:function(){Array.prototype.splice.apply(this._data,f.array(arguments));return this._parseData()._createThumbnails()},push:function(){Array.prototype.push.apply(this._data,f.array(arguments));return this._parseData()._createThumbnails()},_getActive:function(){return this._controls.getActive()},validate:function(){return!0},bind:function(a,b){a=B(a);this.$("container").bind(a,this.proxy(b));return this},unbind:function(a){a=B(a);this.$("container").unbind(a);return this},
trigger:function(a){a=typeof a==="object"?e.extend(a,{scope:this}):{type:B(a),scope:this};this.$("container").trigger(a);return this},addIdleState:function(){this._idle.add.apply(this._idle,f.array(arguments));return this},removeIdleState:function(){this._idle.remove.apply(this._idle,f.array(arguments));return this},enterIdleMode:function(){this._idle.hide();return this},exitIdleMode:function(){this._idle.showAll();return this},enterFullscreen:function(){this._fullscreen.enter.apply(this,f.array(arguments));
return this},exitFullscreen:function(){this._fullscreen.exit.apply(this,f.array(arguments));return this},toggleFullscreen:function(){this._fullscreen[this.isFullscreen()?"exit":"enter"].apply(this,f.array(arguments));return this},bindTooltip:function(){this._tooltip.bind.apply(this._tooltip,f.array(arguments));return this},defineTooltip:function(){this._tooltip.define.apply(this._tooltip,f.array(arguments));return this},refreshTooltip:function(){this._tooltip.show.apply(this._tooltip,f.array(arguments));
return this},openLightbox:function(){this._lightbox.show.apply(this._lightbox,f.array(arguments));return this},closeLightbox:function(){this._lightbox.hide.apply(this._lightbox,f.array(arguments));return this},getActiveImage:function(){return this._getActive().image||void 0},getActiveThumb:function(){return this._thumbnails[this._active].image||void 0},getMousePosition:function(a){return{x:a.pageX-this.$("container").offset().left,y:a.pageY-this.$("container").offset().top}},addPan:function(a){if(this._options.imageCrop!==
!1){var a=e(a||this.getActiveImage()),b=this,c=a.width()/2,d=a.height()/2,g=parseInt(a.css("left"),10),k=parseInt(a.css("top"),10),i=g||0,h=k||0,m=0,q=0,l=!1,n=f.timestamp(),p=0,r=0,s=function(b,c,d){if(b>0&&(r=Math.round(Math.max(b*-1,Math.min(0,c))),p!==r))if(p=r,o===8)a.parent()["scroll"+d](r*-1);else b={},b[d.toLowerCase()]=r,a.css(b)},K=function(a){if(!(f.timestamp()-n<50))l=!0,c=b.getMousePosition(a).x,d=b.getMousePosition(a).y};o===8&&(a.parent().scrollTop(h*-1).scrollLeft(i*-1),a.css({top:0,
left:0}));this.$("stage").unbind("mousemove",K).bind("mousemove",K);f.addTimer("pan",function(){l&&(m=a.width()-b._stageWidth,q=a.height()-b._stageHeight,g=c/b._stageWidth*m*-1,k=d/b._stageHeight*q*-1,i+=(g-i)/b._options.imagePanSmoothness,h+=(k-h)/b._options.imagePanSmoothness,s(q,h,"Top"),s(m,i,"Left"))},50,!0);return this}},proxy:function(a,b){if(typeof a!=="function")return function(){};b=b||this;return function(){return a.apply(b,f.array(arguments))}},removePan:function(){this.$("stage").unbind("mousemove");
f.clearTimer("pan");return this},addElement:function(){var a=this._dom;e.each(f.array(arguments),function(b,c){a[c]=f.create("galleria-"+c)});return this},attachKeyboard:function(){this._keyboard.attach.apply(this._keyboard,f.array(arguments));return this},detachKeyboard:function(){this._keyboard.detach.apply(this._keyboard,f.array(arguments));return this},appendChild:function(a,b){this.$(a).append(this.get(b)||b);return this},prependChild:function(a,b){this.$(a).prepend(this.get(b)||b);return this},
remove:function(){this.$(f.array(arguments).join(",")).remove();return this},append:function(a){var b,c;for(b in a)if(a.hasOwnProperty(b))if(a[b].constructor===Array)for(c=0;a[b][c];c++)this.appendChild(b,a[b][c]);else this.appendChild(b,a[b]);return this},_scaleImage:function(a,b){b=e.extend({width:this._stageWidth,height:this._stageHeight,crop:this._options.imageCrop,max:this._options.maxScaleRatio,min:this._options.minScaleRatio,margin:this._options.imageMargin,position:this._options.imagePosition},
b);(a||this._controls.getActive()).scale(b);return this},updateCarousel:function(){this._carousel.update();return this},rescale:function(a,b,c){var d=this;typeof a==="function"&&(c=a,a=void 0);var e=function(){d._stageWidth=a||d.$("stage").width();d._stageHeight=b||d.$("stage").height();d._scaleImage();d._options.carousel&&d.updateCarousel();d.trigger(g.RESCALE);typeof c==="function"&&c.call(d)};g.WEBKIT&&!a&&!b?f.addTimer("scale",e,10):e.call(d);return this},refreshImage:function(){this._scaleImage();
this._options.imagePan&&this.addPan();return this},show:function(a,b,c){if(!(a===!1||!this._options.queue&&this._queue.stalled))if(a=Math.max(0,Math.min(parseInt(a,10),this.getDataLength()-1)),b=typeof b!=="undefined"?!!b:a<this.getIndex(),!c&&g.History)g.History.value(a.toString());else return this._active=a,Array.prototype.push.call(this._queue,{index:a,rewind:b}),this._queue.stalled||this._show(),this},_show:function(){var a=this,b=this._queue[0],c=this.getData(b.index);if(c){var d=this.isFullscreen()&&
"big"in c?c.big:c.image,j=this._controls.getActive(),k=this._controls.getNext(),i=k.isCached(d),h=this._thumbnails[b.index],m=function(b,c,d,h,i){return function(){a._queue.stalled=!1;f.toggleQuality(c.image,a._options.imageQuality);e(d.container).css({zIndex:0,opacity:0}).show();e(c.container).css({zIndex:1,opacity:1}).show();a._controls.swap();a._options.imagePan&&a.addPan(c.image);(b.link||a._options.lightbox)&&e(c.image).css({cursor:"pointer"}).bind("mouseup",function(){b.link?a._options.popupLinks?
l.open(b.link,"_blank"):l.location.href=b.link:a.openLightbox()});Array.prototype.shift.call(a._queue);a._queue.length&&a._show();a._playCheck();a.trigger({type:g.IMAGE,index:h.index,imageTarget:c.image,thumbTarget:i.image})}}(c,k,j,b,h);this._options.carousel&&this._options.carouselFollow&&this._carousel.follow(b.index);if(this._options.preload){var q,n,c=this.getNext(),o;try{for(n=this._options.preload;n>0;n--)q=new g.Picture,o=a.getData(c),q.add(this.isFullscreen()&&"big"in o?o.big:o.image),c=
a.getNext(c)}catch(p){}}f.show(k.container);e(a._thumbnails[b.index].container).addClass("active").siblings(".active").removeClass("active");a.trigger({type:g.LOADSTART,cached:i,index:b.index,imageTarget:k.image,thumbTarget:h.image});k.load(d,function(c){a._scaleImage(c,{complete:function(c){"image"in j&&f.toggleQuality(j.image,!1);f.toggleQuality(c.image,!1);a._queue.stalled=!0;a.removePan();a.setInfo(b.index);a.setCounter(b.index);a.trigger({type:g.LOADFINISH,cached:i,index:b.index,imageTarget:c.image,
thumbTarget:a._thumbnails[b.index].image});var d=j.image===null&&a._options.initialTransition!==void 0?a._options.initialTransition:a._options.transition;d in E===!1?m():E[d].call(a,{prev:j.container,next:c.container,rewind:b.rewind,speed:a._options.transitionSpeed||400},m)}})})}},getNext:function(a){a=typeof a==="number"?a:this.getIndex();return a===this.getDataLength()-1?0:a+1},getPrev:function(a){a=typeof a==="number"?a:this.getIndex();return a===0?this.getDataLength()-1:a-1},next:function(){this.getDataLength()>
1&&this.show(this.getNext(),!1);return this},prev:function(){this.getDataLength()>1&&this.show(this.getPrev(),!0);return this},get:function(a){return a in this._dom?this._dom[a]:null},getData:function(a){return a in this._data?this._data[a]:this._data[this._active]},getDataLength:function(){return this._data.length},getIndex:function(){return typeof this._active==="number"?this._active:!1},getStageHeight:function(){return this._stageHeight},getStageWidth:function(){return this._stageWidth},getOptions:function(a){return typeof a===
"undefined"?this._options:this._options[a]},setOptions:function(a,b){typeof a==="object"?e.extend(this._options,a):this._options[a]=b;return this},play:function(a){this._playing=!0;this._playtime=a||this._playtime;this._playCheck();this.trigger(g.PLAY);return this},pause:function(){this._playing=!1;this.trigger(g.PAUSE);return this},playToggle:function(a){return this._playing?this.pause():this.play(a)},isPlaying:function(){return this._playing},isFullscreen:function(){return this._fullscreen.active},
_playCheck:function(){var a=this,b=0,c=f.timestamp(),d="play"+this._id;if(this._playing){f.clearTimer(d);var e=function(){b=f.timestamp()-c;b>=a._playtime&&a._playing?(f.clearTimer(d),a.next()):a._playing&&(a.trigger({type:g.PROGRESS,percent:Math.ceil(b/a._playtime*100),seconds:Math.floor(b/1E3),milliseconds:b}),f.addTimer(d,e,20))};f.addTimer(d,e,20)}},setIndex:function(a){this._active=a;return this},setCounter:function(a){typeof a==="number"?a++:typeof a==="undefined"&&(a=this.getIndex()+1);this.get("current").innerHTML=
a;if(o){var a=this.$("counter"),b=a.css("opacity"),c=a.attr("style");c&&parseInt(b,10)===1?a.attr("style",c.replace(/filter[^\;]+\;/i,"")):this.$("counter").css("opacity",b)}return this},setInfo:function(a){var b=this,c=this.getData(a);e.each(["title","description"],function(a,e){var f=b.$("info-"+e);c[e]?f[c[e].length?"show":"hide"]().html(c[e]):f.empty().hide()});return this},hasInfo:function(a){var b="title description".split(" "),c;for(c=0;b[c];c++)if(this.getData(a)[b[c]])return!0;return!1},
jQuery:function(a){var b=this,c=[];e.each(a.split(","),function(a,d){d=e.trim(d);b.get(d)&&c.push(d)});var d=e(b.get(c.shift()));e.each(c,function(a,c){d=d.add(b.get(c))});return d},$:function(){return this.jQuery.apply(this,f.array(arguments))}};e.each(H,function(a,b){var c=/_/.test(b)?b.replace(/_/g,""):b;g[b.toUpperCase()]="galleria."+c});e.extend(g,{IE9:o===9,IE8:o===8,IE7:o===7,IE6:o===6,IE:!!o,WEBKIT:/webkit/.test(y),SAFARI:/safari/.test(y),CHROME:/chrome/.test(y),QUIRK:o&&n.compatMode&&n.compatMode===
"BackCompat",MAC:/mac/.test(navigator.platform.toLowerCase()),OPERA:!!l.opera,IPHONE:/iphone/.test(y),IPAD:/ipad/.test(y),ANDROID:/android/.test(y),TOUCH:"ontouchstart"in document});g.addTheme=function(a){a.name||g.raise("No theme name specified");a.defaults=typeof a.defaults!=="object"?{}:I(a.defaults);var b=!1,c;typeof a.css==="string"?(e("link").each(function(d,e){c=RegExp(a.css);if(c.test(e.href))return b=!0,g.theme=a,!1}),b||e("script").each(function(d,e){c=RegExp("galleria\\."+a.name.toLowerCase()+
"\\.");c.test(e.src)&&(b=e.src.replace(/[^\/]*$/,"")+a.css,f.addTimer("css",function(){f.loadCSS(b,"galleria-theme",function(){g.theme=a})},1))}),b||g.raise("No theme CSS loaded")):g.theme=a;return a};g.loadTheme=function(a,b){var c=!1,d=C.length;g.theme=void 0;f.loadScript(a,function(){c=!0});f.wait({until:function(){return c},error:function(){g.raise("Theme at "+a+" could not load, check theme path.",!0)},success:function(){if(d){var a=[];e.each(g.get(),function(c,d){var f=e.extend(d._original.options,
{data_source:d._data},b);d.$("container").remove();var m=new g;m._id=d._id;m.init(d._original.target,f);a.push(m)});C=a}},timeout:2E3})};g.get=function(a){if(z[a])return z[a];else if(typeof a!=="number")return z;else g.raise("Gallery index "+a+" not found")};g.addTransition=function(a,b){E[a]=b};g.utils=f;g.log=function(){try{l.console.log.apply(l.console,f.array(arguments))}catch(a){try{l.opera.postError.apply(l.opera,arguments)}catch(b){l.alert(f.array(arguments).split(", "))}}};g.ready=function(a){g.ready.callbacks.push(a)};
g.ready.callbacks=[];g.raise=function(a,b){var c=b?"Fatal error":"Error",d=function(a){var d='<div style="padding:4px;margin:0 0 2px;background:#'+(b?"811":"222")+'";>'+(b?"<strong>"+c+": </strong>":"")+a+"</div>";e.each(z,function(){var a=this.$("errors"),b=this.$("target");a.length||(b.css("position","relative"),a=this.addElement("errors").appendChild("target","errors").$("errors").css({color:"#fff",position:"absolute",top:0,left:0,zIndex:1E5}));a.append(d)})};if(A){if(d(a),b)throw Error(c+": "+
a);}else b&&!J&&(J=!0,b=!1,d("Image gallery could not load."))};g.Picture=function(a){this.id=a||null;this.image=null;this.container=f.create("galleria-image");e(this.container).css({overflow:"hidden",position:"relative"});this.original={width:0,height:0};this.loaded=this.ready=!1};g.Picture.prototype={cache:{},add:function(a){var b=0,c=this,d=new Image,f=function(){if((!this.width||!this.height)&&b<1E3)b++,e(d).load(f).attr("src",a+"?"+(new Date).getTime());c.original={height:this.height,width:this.width};
c.cache[a]=a;c.loaded=!0};e(d).css("display","block");if(c.cache[a])return d.src=a,f.call(d),d;e(d).load(f).error(function(){g.raise("image could not load: "+a)}).attr("src",a);return d},show:function(){f.show(this.image)},hide:function(){f.moveOut(this.image)},clear:function(){this.image=null},isCached:function(a){return!!this.cache[a]},load:function(a,b){var c=this;e(this.container).empty(!0);this.image=this.add(a);f.hide(this.image);e(this.container).append(this.image);f.wait({until:function(){return c.loaded&&
c.image.complete&&c.original.width&&c.image.width},success:function(){l.setTimeout(function(){b.call(c,c)},1)},error:function(){l.setTimeout(function(){b.call(c,c)},1);g.raise("image not loaded in 30 seconds: "+a)},timeout:3E4});return this.container},scale:function(a){a=e.extend({width:0,height:0,min:void 0,max:void 0,margin:0,complete:function(){},position:"center",crop:!1,canvas:!1},a);if(!this.image)return this.container;var b,c,d=this,j=e(d.container),k;f.wait({until:function(){b=a.width||j.width()||
f.parseValue(j.css("width"));c=a.height||j.height()||f.parseValue(j.css("height"));return b&&c},success:function(){var g=(b-a.margin*2)/d.original.width,h=(c-a.margin*2)/d.original.height,j={"true":Math.max(g,h),width:g,height:h,"false":Math.min(g,h)}[a.crop.toString()],g="";a.max&&(j=Math.min(a.max,j));a.min&&(j=Math.max(a.min,j));e.each(["width","height"],function(a,b){e(d.image)[b](d[b]=d.image[b]=Math.round(d.original[b]*j))});e(d.container).width(b).height(c);if(a.canvas&&t)t.elem.width=d.width,
t.elem.height=d.height,g=d.image.src+":"+d.width+"x"+d.height,d.image.src=t.cache[g]||function(a){t.context.drawImage(d.image,0,0,d.original.width*j,d.original.height*j);try{return k=t.elem.toDataURL(),t.length+=k.length,t.cache[a]=k}catch(b){return d.image.src}}(g);var l={},n={},g=function(a,b,c){var g=0;/\%/.test(a)?(a=parseInt(a,10)/100,b=d.image[b]||e(d.image)[b](),g=Math.ceil(b*-1*a+c*a)):g=f.parseValue(a);return g},o={top:{top:0},left:{left:0},right:{left:"100%"},bottom:{top:"100%"}};e.each(a.position.toLowerCase().split(" "),
function(a,b){b==="center"&&(b="50%");l[a?"top":"left"]=b});e.each(l,function(a,b){o.hasOwnProperty(b)&&e.extend(n,o[b])});l=l.top?e.extend(l,n):n;l=e.extend({top:"50%",left:"50%"},l);e(d.image).css({position:"relative",top:g(l.top,"height",c),left:g(l.left,"width",b)});d.show();d.ready=!0;a.complete.call(d,d)},error:function(){g.raise("Could not scale image: "+d.image.src)},timeout:1E3});return this}};e.extend(e.easing,{galleria:function(a,b,c,d,e){if((b/=e/2)<1)return d/2*b*b*b+c;return d/2*((b-=
2)*b*b+2)+c},galleriaIn:function(a,b,c,d,e){return d*(b/=e)*b+c},galleriaOut:function(a,b,c,d,e){return-d*(b/=e)*(b-2)+c}});e.fn.galleria=function(a){return this.each(function(){(new g).init(this,a)})};l.Galleria=g})(jQuery);

