/*
 * FancyBox - jQuery Plugin
 * Simple and fancy lightbox alternative
 *
 * Examples and documentation at: http://fancybox.net
 *
 * Copyright (c) 2008 - 2010 Janis Skarnelis
 * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
 *
 * Version: 1.3.4 (11/11/2010)
 * Requires: jQuery v1.3+
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

;(function($) {
	var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,

		selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],

		ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,

		loadingTimer, loadingFrame = 1,

		titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),

		isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,

		/*
		 * Private methods 
		 */

		_abort = function() {
			loading.hide();

			imgPreloader.onerror = imgPreloader.onload = null;

			if (ajaxLoader) {
				ajaxLoader.abort();
			}

			tmp.empty();
		},

		_error = function() {
			if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
				loading.hide();
				busy = false;
				return;
			}

			selectedOpts.titleShow = false;

			selectedOpts.width = 'auto';
			selectedOpts.height = 'auto';

			tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );

			_process_inline();
		},

		_start = function() {
			var obj = selectedArray[ selectedIndex ],
				href, 
				type, 
				title,
				str,
				emb,
				ret;

			_abort();

			selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

			ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);

			if (ret === false) {
				busy = false;
				return;
			} else if (typeof ret == 'object') {
				selectedOpts = $.extend(selectedOpts, ret);
			}

			title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';

			if (obj.nodeName && !selectedOpts.orig) {
				selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
			}

			if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
				title = selectedOpts.orig.attr('alt');
			}

			href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;

			if ((/^(?:javascript)/i).test(href) || href == '#') {
				href = null;
			}

			if (selectedOpts.type) {
				type = selectedOpts.type;

				if (!href) {
					href = selectedOpts.content;
				}

			} else if (selectedOpts.content) {
				type = 'html';

			} else if (href) {
				if (href.match(imgRegExp)) {
					type = 'image';

				} else if (href.match(swfRegExp)) {
					type = 'swf';

				} else if ($(obj).hasClass("iframe")) {
					type = 'iframe';

				} else if (href.indexOf("#") === 0) {
					type = 'inline';

				} else {
					type = 'ajax';
				}
			}

			if (!type) {
				_error();
				return;
			}

			if (type == 'inline') {
				obj	= href.substr(href.indexOf("#"));
				type = $(obj).length > 0 ? 'inline' : 'ajax';
			}

			selectedOpts.type = type;
			selectedOpts.href = href;
			selectedOpts.title = title;

			if (selectedOpts.autoDimensions) {
				if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
					selectedOpts.width = 'auto';
					selectedOpts.height = 'auto';
				} else {
					selectedOpts.autoDimensions = false;	
				}
			}

			if (selectedOpts.modal) {
				selectedOpts.overlayShow = true;
				selectedOpts.hideOnOverlayClick = false;
				selectedOpts.hideOnContentClick = false;
				selectedOpts.enableEscapeButton = false;
				selectedOpts.showCloseButton = false;
			}

			selectedOpts.padding = parseInt(selectedOpts.padding, 10);
			selectedOpts.margin = parseInt(selectedOpts.margin, 10);

			tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));

			$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
				$(this).replaceWith(content.children());				
			});

			switch (type) {
				case 'html' :
					tmp.html( selectedOpts.content );
					_process_inline();
				break;

				case 'inline' :
					if ( $(obj).parent().is('#fancybox-content') === true) {
						busy = false;
						return;
					}

					$('<div class="fancybox-inline-tmp" />')
						.hide()
						.insertBefore( $(obj) )
						.bind('fancybox-cleanup', function() {
							$(this).replaceWith(content.children());
						}).bind('fancybox-cancel', function() {
							$(this).replaceWith(tmp.children());
						});

					$(obj).appendTo(tmp);

					_process_inline();
				break;

				case 'image':
					busy = false;

					$.fancybox.showActivity();

					imgPreloader = new Image();

					imgPreloader.onerror = function() {
						_error();
					};

					imgPreloader.onload = function() {
						busy = true;

						imgPreloader.onerror = imgPreloader.onload = null;

						_process_image();
					};

					imgPreloader.src = href;
				break;

				case 'swf':
					selectedOpts.scrolling = 'no';

					str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
					emb = '';

					$.each(selectedOpts.swf, function(name, val) {
						str += '<param name="' + name + '" value="' + val + '"></param>';
						emb += ' ' + name + '="' + val + '"';
					});

					str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';

					tmp.html(str);

					_process_inline();
				break;

				case 'ajax':
					busy = false;

					$.fancybox.showActivity();

					selectedOpts.ajax.win = selectedOpts.ajax.success;

					ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
						url	: href,
						data : selectedOpts.ajax.data || {},
						error : function(XMLHttpRequest, textStatus, errorThrown) {
							if ( XMLHttpRequest.status > 0 ) {
								_error();
							}
						},
						success : function(data, textStatus, XMLHttpRequest) {
							var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
							if (o.status == 200) {
								if ( typeof selectedOpts.ajax.win == 'function' ) {
									ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);

									if (ret === false) {
										loading.hide();
										return;
									} else if (typeof ret == 'string' || typeof ret == 'object') {
										data = ret;
									}
								}

								tmp.html( data );
								_process_inline();
							}
						}
					}));

				break;

				case 'iframe':
					_show();
				break;
			}
		},

		_process_inline = function() {
			var
				w = selectedOpts.width,
				h = selectedOpts.height;

			if (w.toString().indexOf('%') > -1) {
				w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';

			} else {
				w = w == 'auto' ? 'auto' : w + 'px';	
			}

			if (h.toString().indexOf('%') > -1) {
				h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';

			} else {
				h = h == 'auto' ? 'auto' : h + 'px';	
			}

			tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');

			selectedOpts.width = tmp.width();
			selectedOpts.height = tmp.height();

			_show();
		},

		_process_image = function() {
			selectedOpts.width = imgPreloader.width;
			selectedOpts.height = imgPreloader.height;

			$("<img />").attr({
				'id' : 'fancybox-img',
				'src' : imgPreloader.src,
				'alt' : selectedOpts.title
			}).appendTo( tmp );

			_show();
		},

		_show = function() {
			var pos, equal;

			loading.hide();

			if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
				$.event.trigger('fancybox-cancel');

				busy = false;
				return;
			}

			busy = true;

			$(content.add( overlay )).unbind();

			$(window).unbind("resize.fb scroll.fb");
			$(document).unbind('keydown.fb');

			if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
				wrap.css('height', wrap.height());
			}

			currentArray = selectedArray;
			currentIndex = selectedIndex;
			currentOpts = selectedOpts;

			if (currentOpts.overlayShow) {
				overlay.css({
					'background-color' : currentOpts.overlayColor,
					'opacity' : currentOpts.overlayOpacity,
					'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
					'height' : $(document).height()
				});

				if (!overlay.is(':visible')) {
					if (isIE6) {
						$('select:not(#fancybox-tmp select)').filter(function() {
							return this.style.visibility !== 'hidden';
						}).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
							this.style.visibility = 'inherit';
						});
					}

					overlay.show();
				}
			} else {
				overlay.hide();
			}

			final_pos = _get_zoom_to();

			_process_title();

			if (wrap.is(":visible")) {
				$( close.add( nav_left ).add( nav_right ) ).hide();

				pos = wrap.position(),

				start_pos = {
					top	 : pos.top,
					left : pos.left,
					width : wrap.width(),
					height : wrap.height()
				};

				equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);

				content.fadeTo(currentOpts.changeFade, 0.3, function() {
					var finish_resizing = function() {
						content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
					};

					$.event.trigger('fancybox-change');

					content
						.empty()
						.removeAttr('filter')
						.css({
							'border-width' : currentOpts.padding,
							'width'	: final_pos.width - currentOpts.padding * 2,
							'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
						});

					if (equal) {
						finish_resizing();

					} else {
						fx.prop = 0;

						$(fx).animate({prop: 1}, {
							 duration : currentOpts.changeSpeed,
							 easing : currentOpts.easingChange,
							 step : _draw,
							 complete : finish_resizing
						});
					}
				});

				return;
			}

			wrap.removeAttr("style");

			content.css('border-width', currentOpts.padding);

			if (currentOpts.transitionIn == 'elastic') {
				start_pos = _get_zoom_from();

				content.html( tmp.contents() );

				wrap.show();

				if (currentOpts.opacity) {
					final_pos.opacity = 0;
				}

				fx.prop = 0;

				$(fx).animate({prop: 1}, {
					 duration : currentOpts.speedIn,
					 easing : currentOpts.easingIn,
					 step : _draw,
					 complete : _finish
				});

				return;
			}

			if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {	
				title.show();	
			}

			content
				.css({
					'width' : final_pos.width - currentOpts.padding * 2,
					'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
				})
				.html( tmp.contents() );

			wrap
				.css(final_pos)
				.fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
		},

		_format_title = function(title) {
			if (title && title.length) {
				if (currentOpts.titlePosition == 'float') {
					return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
				}

				return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
			}

			return false;
		},

		_process_title = function() {
			titleStr = currentOpts.title || '';
			titleHeight = 0;

			title
				.empty()
				.removeAttr('style')
				.removeClass();

			if (currentOpts.titleShow === false) {
				title.hide();
				return;
			}

			titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);

			if (!titleStr || titleStr === '') {
				title.hide();
				return;
			}

			title
				.addClass('fancybox-title-' + currentOpts.titlePosition)
				.html( titleStr )
				.appendTo( 'body' )
				.show();

			switch (currentOpts.titlePosition) {
				case 'inside':
					title
						.css({
							'width' : final_pos.width - (currentOpts.padding * 2),
							'marginLeft' : currentOpts.padding,
							'marginRight' : currentOpts.padding
						});

					titleHeight = title.outerHeight(true);

					title.appendTo( outer );

					final_pos.height += titleHeight;
				break;

				case 'over':
					title
						.css({
							'marginLeft' : currentOpts.padding,
							'width'	: final_pos.width - (currentOpts.padding * 2),
							'bottom' : currentOpts.padding
						})
						.appendTo( outer );
				break;

				case 'float':
					title
						.css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
						.appendTo( wrap );
				break;

				default:
					title
						.css({
							'width' : final_pos.width - (currentOpts.padding * 2),
							'paddingLeft' : currentOpts.padding,
							'paddingRight' : currentOpts.padding
						})
						.appendTo( wrap );
				break;
			}

			title.hide();
		},

		_set_navigation = function() {
			if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
				$(document).bind('keydown.fb', function(e) {
					if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
						e.preventDefault();
						$.fancybox.close();

					} else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
						e.preventDefault();
						$.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
					}
				});
			}

			if (!currentOpts.showNavArrows) { 
				nav_left.hide();
				nav_right.hide();
				return;
			}

			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
				nav_left.show();
			}

			if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
				nav_right.show();
			}
		},

		_finish = function () {
			if (!$.support.opacity) {
				content.get(0).style.removeAttribute('filter');
				wrap.get(0).style.removeAttribute('filter');
			}

			if (selectedOpts.autoDimensions) {
				content.css('height', 'auto');
			}

			wrap.css('height', 'auto');

			if (titleStr && titleStr.length) {
				title.show();
			}

			if (currentOpts.showCloseButton) {
				close.show();
			}

			_set_navigation();
	
			if (currentOpts.hideOnContentClick)	{
				content.bind('click', $.fancybox.close);
			}

			if (currentOpts.hideOnOverlayClick)	{
				overlay.bind('click', $.fancybox.close);
			}

			$(window).bind("resize.fb", $.fancybox.resize);

			if (currentOpts.centerOnScroll) {
				$(window).bind("scroll.fb", $.fancybox.center);
			}

			if (currentOpts.type == 'iframe') {
				$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
			}

			wrap.show();

			busy = false;

			$.fancybox.center();

			currentOpts.onComplete(currentArray, currentIndex, currentOpts);

			_preload_images();
		},

		_preload_images = function() {
			var href, 
				objNext;

			if ((currentArray.length -1) > currentIndex) {
				href = currentArray[ currentIndex + 1 ].href;

				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}

			if (currentIndex > 0) {
				href = currentArray[ currentIndex - 1 ].href;

				if (typeof href !== 'undefined' && href.match(imgRegExp)) {
					objNext = new Image();
					objNext.src = href;
				}
			}
		},

		_draw = function(pos) {
			var dim = {
				width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
				height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),

				top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
				left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
			};

			if (typeof final_pos.opacity !== 'undefined') {
				dim.opacity = pos < 0.5 ? 0.5 : pos;
			}

			wrap.css(dim);

			content.css({
				'width' : dim.width - currentOpts.padding * 2,
				'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
			});
		},

		_get_viewport = function() {
			return [
				$(window).width() - (currentOpts.margin * 2),
				$(window).height() - (currentOpts.margin * 2),
				$(document).scrollLeft() + currentOpts.margin,
				$(document).scrollTop() + currentOpts.margin
			];
		},

		_get_zoom_to = function () {
			var view = _get_viewport(),
				to = {},
				resize = currentOpts.autoScale,
				double_padding = currentOpts.padding * 2,
				ratio;

			if (currentOpts.width.toString().indexOf('%') > -1) {
				to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
			} else {
				to.width = currentOpts.width + double_padding;
			}

			if (currentOpts.height.toString().indexOf('%') > -1) {
				to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
			} else {
				to.height = currentOpts.height + double_padding;
			}

			if (resize && (to.width > view[0] || to.height > view[1])) {
				if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
					ratio = (currentOpts.width ) / (currentOpts.height );

					if ((to.width ) > view[0]) {
						to.width = view[0];
						to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
					}

					if ((to.height) > view[1]) {
						to.height = view[1];
						to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
					}

				} else {
					to.width = Math.min(to.width, view[0]);
					to.height = Math.min(to.height, view[1]);
				}
			}

			to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
			to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);

			return to;
		},

		_get_obj_pos = function(obj) {
			var pos = obj.offset();

			pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
			pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;

			pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
			pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;

			pos.width = obj.width();
			pos.height = obj.height();

			return pos;
		},

		_get_zoom_from = function() {
			var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
				from = {},
				pos,
				view;

			if (orig && orig.length) {
				pos = _get_obj_pos(orig);

				from = {
					width : pos.width + (currentOpts.padding * 2),
					height : pos.height + (currentOpts.padding * 2),
					top	: pos.top - currentOpts.padding - 20,
					left : pos.left - currentOpts.padding - 20
				};

			} else {
				view = _get_viewport();

				from = {
					width : currentOpts.padding * 2,
					height : currentOpts.padding * 2,
					top	: parseInt(view[3] + view[1] * 0.5, 10),
					left : parseInt(view[2] + view[0] * 0.5, 10)
				};
			}

			return from;
		},

		_animate_loading = function() {
			if (!loading.is(':visible')){
				clearInterval(loadingTimer);
				return;
			}

			$('div', loading).css('top', (loadingFrame * -40) + 'px');

			loadingFrame = (loadingFrame + 1) % 12;
		};

	/*
	 * Public methods 
	 */

	$.fn.fancybox = function(options) {
		if (!$(this).length) {
			return this;
		}

		$(this)
			.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
			.unbind('click.fb')
			.bind('click.fb', function(e) {
				e.preventDefault();

				if (busy) {
					return;
				}

				busy = true;

				$(this).blur();

				selectedArray = [];
				selectedIndex = 0;

				var rel = $(this).attr('rel') || '';

				if (!rel || rel == '' || rel === 'nofollow') {
					selectedArray.push(this);

				} else {
					selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
					selectedIndex = selectedArray.index( this );
				}

				_start();

				return;
			});

		return this;
	};

	$.fancybox = function(obj) {
		var opts;

		if (busy) {
			return;
		}

		busy = true;
		opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};

		selectedArray = [];
		selectedIndex = parseInt(opts.index, 10) || 0;

		if ($.isArray(obj)) {
			for (var i = 0, j = obj.length; i < j; i++) {
				if (typeof obj[i] == 'object') {
					$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
				} else {
					obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
				}
			}

			selectedArray = jQuery.merge(selectedArray, obj);

		} else {
			if (typeof obj == 'object') {
				$(obj).data('fancybox', $.extend({}, opts, obj));
			} else {
				obj = $({}).data('fancybox', $.extend({content : obj}, opts));
			}

			selectedArray.push(obj);
		}

		if (selectedIndex > selectedArray.length || selectedIndex < 0) {
			selectedIndex = 0;
		}

		_start();
	};

	$.fancybox.showActivity = function() {
		clearInterval(loadingTimer);

		loading.show();
		loadingTimer = setInterval(_animate_loading, 66);
	};

	$.fancybox.hideActivity = function() {
		loading.hide();
	};

	$.fancybox.next = function() {
		return $.fancybox.pos( currentIndex + 1);
	};

	$.fancybox.prev = function() {
		return $.fancybox.pos( currentIndex - 1);
	};

	$.fancybox.pos = function(pos) {
		if (busy) {
			return;
		}

		pos = parseInt(pos);

		selectedArray = currentArray;

		if (pos > -1 && pos < currentArray.length) {
			selectedIndex = pos;
			_start();

		} else if (currentOpts.cyclic && currentArray.length > 1) {
			selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
			_start();
		}

		return;
	};

	$.fancybox.cancel = function() {
		if (busy) {
			return;
		}

		busy = true;

		$.event.trigger('fancybox-cancel');

		_abort();

		selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);

		busy = false;
	};

	// Note: within an iframe use - parent.$.fancybox.close();
	$.fancybox.close = function() {
		if (busy || wrap.is(':hidden')) {
			return;
		}

		busy = true;

		if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
			busy = false;
			return;
		}

		_abort();

		$(close.add( nav_left ).add( nav_right )).hide();

		$(content.add( overlay )).unbind();

		$(window).unbind("resize.fb scroll.fb");
		$(document).unbind('keydown.fb');

		content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');

		if (currentOpts.titlePosition !== 'inside') {
			title.empty();
		}

		wrap.stop();

		function _cleanup() {
			overlay.fadeOut('fast');

			title.empty().hide();
			wrap.hide();

			$.event.trigger('fancybox-cleanup');

			content.empty();

			currentOpts.onClosed(currentArray, currentIndex, currentOpts);

			currentArray = selectedOpts	= [];
			currentIndex = selectedIndex = 0;
			currentOpts = selectedOpts	= {};

			busy = false;
		}

		if (currentOpts.transitionOut == 'elastic') {
			start_pos = _get_zoom_from();

			var pos = wrap.position();

			final_pos = {
				top	 : pos.top ,
				left : pos.left,
				width :	wrap.width(),
				height : wrap.height()
			};

			if (currentOpts.opacity) {
				final_pos.opacity = 1;
			}

			title.empty().hide();

			fx.prop = 1;

			$(fx).animate({ prop: 0 }, {
				 duration : currentOpts.speedOut,
				 easing : currentOpts.easingOut,
				 step : _draw,
				 complete : _cleanup
			});

		} else {
			wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
		}
	};

	$.fancybox.resize = function() {
		if (overlay.is(':visible')) {
			overlay.css('height', $(document).height());
		}

		$.fancybox.center(true);
	};

	$.fancybox.center = function() {
		var view, align;

		if (busy) {
			return;	
		}

		align = arguments[0] === true ? 1 : 0;
		view = _get_viewport();

		if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
			return;	
		}

		wrap
			.stop()
			.animate({
				'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
				'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
			}, typeof arguments[0] == 'number' ? arguments[0] : 200);
	};

	$.fancybox.init = function() {
		if ($("#fancybox-wrap").length) {
			return;
		}

		$('body').append(
			tmp	= $('<div id="fancybox-tmp"></div>'),
			loading	= $('<div id="fancybox-loading"><div></div></div>'),
			overlay	= $('<div id="fancybox-overlay"></div>'),
			wrap = $('<div id="fancybox-wrap"></div>')
		);

		outer = $('<div id="fancybox-outer"></div>')
			.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
			.appendTo( wrap );

		outer.append(
			content = $('<div id="fancybox-content"></div>'),
			close = $('<a id="fancybox-close"></a>'),
			title = $('<div id="fancybox-title"></div>'),

			nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
			nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
		);

		close.click($.fancybox.close);
		loading.click($.fancybox.cancel);

		nav_left.click(function(e) {
			e.preventDefault();
			$.fancybox.prev();
		});

		nav_right.click(function(e) {
			e.preventDefault();
			$.fancybox.next();
		});

		if ($.fn.mousewheel) {
			wrap.bind('mousewheel.fb', function(e, delta) {
				if (busy) {
					e.preventDefault();

				} else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
					e.preventDefault();
					$.fancybox[ delta > 0 ? 'prev' : 'next']();
				}
			});
		}

		if (!$.support.opacity) {
			wrap.addClass('fancybox-ie');
		}

		if (isIE6) {
			loading.addClass('fancybox-ie6');
			wrap.addClass('fancybox-ie6');

			$('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
		}
	};

	$.fn.fancybox.defaults = {
		padding : 10,
		margin : 40,
		opacity : false,
		modal : false,
		cyclic : false,
		scrolling : 'auto',	// 'auto', 'yes' or 'no'

		width : 560,
		height : 340,

		autoScale : true,
		autoDimensions : true,
		centerOnScroll : false,

		ajax : {},
		swf : { wmode: 'transparent' },

		hideOnOverlayClick : true,
		hideOnContentClick : false,

		overlayShow : true,
		overlayOpacity : 0.7,
		overlayColor : '#777',

		titleShow : true,
		titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
		titleFormat : null,
		titleFromAlt : false,

		transitionIn : 'fade', // 'elastic', 'fade' or 'none'
		transitionOut : 'fade', // 'elastic', 'fade' or 'none'

		speedIn : 300,
		speedOut : 300,

		changeSpeed : 300,
		changeFade : 'fast',

		easingIn : 'swing',
		easingOut : 'swing',

		showCloseButton	 : true,
		showNavArrows : true,
		enableEscapeButton : true,
		enableKeyboardNav : true,

		onStart : function(){},
		onCancel : function(){},
		onComplete : function(){},
		onCleanup : function(){},
		onClosed : function(){},
		onError : function(){}
	};

	$(document).ready(function() {
		$.fancybox.init();
	});

})(jQuery);;
/*
	Slimbox v2.04 - The ultimate lightweight Lightbox clone for jQuery
	(c) 2007-2010 Christophe Beyls <http://www.digitalia.be>
	MIT-style license.
*/
(function(w){var E=w(window),u,f,F=-1,n,x,D,v,y,L,r,m=!window.XMLHttpRequest,s=[],l=document.documentElement,k={},t=new Image(),J=new Image(),H,a,g,p,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));g=w('<div id="lbImage" />').appendTo(a).append(p=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(e)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+(E.height()/2);L=u.initialWidth;r=u.initialHeight;w(a).css({top:Math.max(0,y-(r/2)),width:L,height:r,marginLeft:-L/2}).show();v=m||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();j(1);f=O;u.loop=u.loop&&(f.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function j(M){if(M){w("object").add(m?"select":"embed").each(function(O,P){s[O]=[P,P.style.visibility];P.style.visibility="hidden"})}else{w.each(s,function(O,P){P[0].style.visibility=P[1]});s=[]}var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",o)}function o(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?e():(M(N,u.previousKeys)>=0)?B():false}function B(){return b(x)}function e(){return b(D)}function b(M){if(M>=0){F=M;n=f[F][0];x=(F||(u.loop?f.length:0))-1;D=((F+1)%f.length)||(u.loop?0:-1);q();a.className="lbLoading";k=new Image();k.onload=i;k.src=n}return false}function i(){a.className="";w(g).css({backgroundImage:"url("+n+")",visibility:"hidden",display:""});w(p).width(k.width);w([p,I,d]).height(k.height);w(A).html(f[F][1]||"");w(K).html((((f.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,f.length));if(x>=0){t.src=f[x][0]}if(D>=0){J.src=f[D][0]}L=g.offsetWidth;r=g.offsetHeight;var M=Math.max(0,y-(r/2));if(a.offsetHeight!=r){w(a).animate({height:r,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+r,marginLeft:-L/2,visibility:"hidden",display:""});w(g).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,h)})}function h(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function q(){k.onload=null;k.src=t.src=J.src=n;w([a,g,c]).stop(true);w([I,d,g,G]).hide()}function C(){if(F>=0){q();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,j)}return false}})(jQuery);

// AUTOLOAD CODE BLOCK (MAY BE CHANGED OR REMOVED)
if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)) {
	jQuery(function($) {
		$("a[rel^='lightbox']").slimbox({/* Put custom options here */}, null, function(el) {
			return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
		});
	});
};
/**
 * Picasa Webalbum Integration jQuery plugin
 * This library was inspired aon pwa by Dieter Raber
 * @name jquery.pwi.js
 * @author Jeroen Diderik - http://www.jdee.nl/
 * @author Johan Borkhuis - http://www.borkhuis.com/
 * @revision 1.5.0
 * @date September 18, 2011
 * @copyright (c) 2010-2011 Jeroen Diderik(www.jdee.nl)
 * @license Creative Commons Attribution-Share Alike 3.0 Netherlands License - http://creativecommons.org/licenses/by-sa/3.0/nl/
 * @Visit http://pwi.googlecode.com/ for more informations, duscussions etc about this library
 */
function formatTitle(a,b,c,d){var e='<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+a+'</td><td id="fancybox-title-float-right"></td></tr></table>';if(d.orig.context.parentNode.childElementCount>1){var f=d.orig.context.parentNode.getElementsByClassName("downloadlink");if(f.length>0){var g='<a style="color: #FFF;" href="'+f[0].href+'">Download</a>';e='<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">'+a+"  "+g+'</td><td id="fancybox-title-float-right"></td></tr></table>'}}return e}(function(a){var b,c={};a.fn.pwi=function(c){function t(b,c){if(b){if(e.loadingImage.length>0){var f=document.getElementById(e.loadingImage);if(f){f.style.display="block"}}document.body.style.cursor="wait";if(a.blockUI){d.block(e.blockUIConfig)}}else{if(e.loadingImage.length>0){var f=document.getElementById(e.loadingImage);if(f){f.style.display="none"}}document.body.style.cursor="default";if(a.blockUI){d.unblock()}d.html(c)}}function s(){t(true,"");var b="http://picasaweb.google.com/data/feed/api/user/"+e.username+(e.album!==""?"/album/"+e.album:"")+"?kind=photo&max-results="+e.maxResults+"&alt=json&q="+(e.authKey!==""?"&authkey="+e.authKey:"")+(e.keyword!==""?"&tag="+e.keyword:"")+"&imgmax=d&thumbsize="+e.thumbSize+(e.thumbCrop==1?"c":"u")+","+e.photoSize;a.getJSON(b,"callback=?",n);return d}function r(){if(e.photostore[e.album]){m(e.photostore[e.album])}else{var b="http://picasaweb.google.com/data/feed/api/user/"+e.username+(e.album!==""?"/album/"+e.album:"")+"?kind=photo&alt=json"+(e.authKey!==""?"&authkey="+e.authKey:"")+(e.keyword!==""?"&tag="+e.keyword:"")+"&imgmax=d&thumbsize="+e.thumbSize+(e.thumbCrop==1?"c":"u")+","+e.photoSize;t(true,"");a.getJSON(b,"callback=?",m)}return d}function q(){if(e.albumstore.feed){l(e.albumstore)}else{t(true,"");var b="http://picasaweb.google.com/data/feed/api/user/"+e.username+"?kind=album&access="+e.albumTypes+"&alt=json&thumbsize="+e.albumThumbSize+(e.albumCrop==1?"c":"u");a.getJSON(b,"callback=?",l)}return d}function p(a){a.stopPropagation();a.preventDefault();e.onclickThumb(a)}function o(a){a.stopPropagation();a.preventDefault();e.onclickAlbumThumb(a)}function n(b){var c=a("<div/>"),d=b.feed?b.feed.entry.length:0,f=0;var g=e.username.replace(/\./g,"_");while(f<e.maxResults&&f<d){var h=k(b.feed.entry[f],false,g);c.append(h);f++}c.append("<div style='clear: both;height:0px;'> </div>");var i=a("div.pwi_photo",c).css(e.thumbCss);if(typeof e.popupExt==="function"){e.popupExt(i.find("a[rel='lb-"+g+"']"))}else if(typeof e.onclickThumb!="function"&&a.slimbox){i.find("a[rel='lb-"+g+"']").slimbox(e.slimbox_config,function(a){var b=a.title;if(a.parentNode.childElementCount>1){var c=a.parentNode.getElementsByClassName("downloadlink");if(c.length>0){var d='<a href="'+c[0].href+'">Download</a>';b=a.title+"  "+d}}return[a.href,b]})}t(false,c)}function m(b){var c,d,f="",g=b.feed.openSearch$totalResults.$t,i="",j="",l=b.feed.gphoto$location===undefined?"":b.feed.gphoto$location.$t,m,n=h(b.feed.gphoto$timestamp===undefined?"":b.feed.gphoto$timestamp.$t),o=g=="1"?false:true;if(b.feed.subtitle===undefined){m=""}else{var p=b.feed.subtitle.$t.match(/\[keywords\s*:\s*.*\s*\](.*)/);if(p){m=p[1]}else{m=b.feed.subtitle.$t}}i=b.feed.title==="undefined"||e.albumTitle.length>0?e.albumTitle:b.feed.title.$t;c=a("<div/>");if(e.mode!="album"&&e.mode!="keyword"){f=a("<div class='pwi_album_backlink'>"+e.labels.albums+"</div>").bind("click.pwi",function(a){a.stopPropagation();q();return false});c.append(f)}if(e.showAlbumDescription){d=a("<div class='pwi_album_description'/>");d.append("<div class='title'>"+i+"</div>");d.append("<div class='details'>"+g+" "+(o?e.labels.photos:e.labels.photo)+(e.showAlbumdate?", "+n:"")+(e.showAlbumLocation&&l?", "+l:"")+"</div>");d.append("<div class='description'>"+m+"</div>");if(e.showSlideshowLink){if(e.mode==="keyword"||e.keyword!==""){}else{d.append("<div><a href='http://picasaweb.google.com/"+e.username+"/"+b.feed.gphoto$name.$t+""+(e.authKey!==""?"?authkey="+e.authKey:"")+"#slideshow/"+b.feed.entry[0].gphoto$id.$t+"' rel='gb_page_fs[]' target='_new' class='sslink'>"+e.labels.slideshow+"</a></div>")}}c.append(d)}if(e.showSlideshow&&typeof e.popupExt==="function"){var s=!a.support.opacity&&!window.XMLHttpRequest;var u=a("<div class='pwi_photo'/>");if(s||navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i)!=null){for(var v=0;v<b.feed.link.length;v++){if(b.feed.link[v].type=="text/html"&&b.feed.link[v].rel=="alternate"){u.append("<a class='iframe' href='"+b.feed.link[v].href+"#slideshow/' rel='sl-"+e.username+"' title='"+n+"'>"+e.labels.slideshow+"</a><br>");break}}}else{for(var v=0;v<b.feed.link.length;v++){if(b.feed.link[v].type=="application/x-shockwave-flash"){u.append("<a class='iframe' href='"+b.feed.link[v].href+"' rel='sl-"+e.username+"' title='"+n+"'>"+e.labels.slideshow+"</a><br>");break}}}c.append(u);c.append("<div style='clear: both;height:0px;'/>")}if(g>e.maxResults){$pageCount=g/e.maxResults;var w=a("<div class='pwi_prevpage'/>").text(e.labels.prev),x=a("<div class='pwi_nextpage'/>").text(e.labels.next);j=a("<div class='pwi_pager'/>");if(e.page>1){w.addClass("link").bind("click.pwi",function(a){a.stopPropagation();e.page=parseInt(e.page,10)-1;r();return false})}j.append(w);for(var y=1;y<$pageCount+1;y++){if(y==e.page){f="<div class='pwi_pager_current'>"+y+"</div> "}else{f=a("<div class='pwi_pager_page'>"+y+"</div>").bind("click.pwi",y,function(a){a.stopPropagation();e.page=a.data;r();return false})}j.append(f)}if(e.page<$pageCount){x.addClass("link").bind("click.pwi",function(a){a.stopPropagation();e.page=parseInt(e.page,10)+1;r();return false})}j.append(x);j.append("<div style='clear: both;height:0px;'/>")}if(j.length>0&&(e.showPager==="both"||e.showPager==="top")){c.append(j)}var z=(e.page-1)*e.maxResults;var A=e.maxResults*e.page;var B=e.username.replace(/\./g,"_");for(var v=0;v<g;v++){var C=k(b.feed.entry[v],!(v>=z&&v<A),B);c.append(C)}if(j.length>0&&(e.showPager==="both"||e.showPager==="bottom")){c.append(j.clone(true))}if(e.showPermaLink){c.append("<div style='clear: both;height:0px;'/>");var D=a("<div id='permalinkenable' class='pwi_nextpage'/>").text(e.labels.showPermaLink).bind("click.pwi",y,function(a){a.stopPropagation();var b=document.getElementById("permalinkbox");if(b){b.style.display="block"}b=document.getElementById("permalinkenable");if(b){b.style.display="none"}return false});var E=document.URL.split("?",2);var F=E[0]+"?pwi_album_selected="+b.feed.gphoto$name.$t+"&pwi_albumpage="+e.page;c.append(D);var G=a("<div style='display:none;' id='permalinkbox' />");var H=a("<form />");var I=a("<input type='text' size='40' name='PermaLink' readonly />").val(F);H.append(I);G.append(H);c.append(G)}e.photostore[e.album]=b;var J=a(".pwi_photo",c).css(e.thumbCss);if(typeof e.popupExt==="function"){e.popupExt(J.find("a[rel='lb-"+B+"']"));e.popupExt(J.find("a[rel='sl-"+B+"']"))}else if(typeof e.onclickThumb!="function"&&a.slimbox){J.find("a[rel='lb-"+B+"']").slimbox(e.slimbox_config,function(a){var b=a.title;if(a.parentNode.childElementCount>1){var c=a.parentNode.getElementsByClassName("downloadlink");if(c.length>0){var d='<a href="'+c[0].href+'">Download</a>';b=a.title+"  "+d}}return[a.href,b]})}c.append("<div style='clear: both;height:0px;'/>");t(false,c)}function l(b){var c=a("<div/>"),d=0;var f=0,g="",i=0;var j,k;if(navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i)==null){j=new Date(e.albumStartDateTime);if(isNaN(j)){var m=e.albumStartDateTime.replace(/-/g,"/");j=new Date(m)}k=new Date(e.albumEndDateTime);if(isNaN(k)){var m=e.albumEndDateTime.replace(/-/g,"/");k=new Date(m)}}else{var m=e.albumStartDateTime.replace(/-/g,"/");j=new Date(m);m=e.albumEndDateTime.replace(/-/g,"/");k=new Date(m)}d=e.albumsPerPage*(e.albumPage-1);f=b.feed.entry.length;while(d<e.albumMaxResults&&d<f&&d<e.albumsPerPage*e.albumPage){var n=new Date(Number(b.feed.entry[d].gphoto$timestamp.$t)),o=b.feed.entry[d].media$group.media$thumbnail[0].url;if((a.inArray(b.feed.entry[d].gphoto$name.$t,e.albums)>-1||e.albums.length===0)&&(b.feed.entry[d].gphoto$albumType===undefined||a.inArray(b.feed.entry[d].gphoto$albumType.$t,e.removeAlbumTypes)==-1)&&(e.albumStartDateTime==""||n>=j)&&(e.albumEndDateTime==""||n<=k)){var p=true;if(e.albumKeywords.length>0){p=false;var q=b.feed.entry[d].summary.$t.match(/\[keywords\s*:\s*(.*)\s*\]/);if(q){var s=new Array;var u=q[1].split(/,/);for(var v in u){$newmatch=u[v].match(/\s*['"](.*)['"]\s*/);if($newmatch){s.push($newmatch[1])}}if(s.length>0){p=true;for(var v in e.albumKeywords){if(a.inArray(e.albumKeywords[v],s)<0){p=false;break}}}}}if(p==true){i++;if(e.showAlbumThumbs){$scAlbum=a("<div class='pwi_album' style='height:180px;"+(e.albumThumbAlign==1?"width:"+(e.albumThumbSize+1)+"px;":"")+"cursor: pointer;'/>")}else{$scAlbum=a("<div class='pwi_album' style='cursor: pointer;'/>")}var w=b.feed.entry[d];$scAlbum.bind("click.pwi",w,function(a){a.stopPropagation();e.page=1;e.album=a.data.gphoto$name.$t;if(typeof e.onclickAlbumThumb==="function"){e.onclickAlbumThumb(a);return false}else{r();return false}});if(e.showAlbumThumbs){$scAlbum.append("<img src='"+o+"'/>")}if(e.showAlbumTitles){$item_plural=b.feed.entry[d].gphoto$numphotos.$t=="1"?false:true;$scAlbum.append("<br/>"+(b.feed.entry[d].title.$t.length>e.showAlbumTitlesLength?b.feed.entry[d].title.$t.substring(0,e.showCaptionLength):b.feed.entry[d].title.$t)+"<br/>"+(e.showAlbumdate?h(b.feed.entry[d].gphoto$timestamp.$t):"")+(e.showAlbumPhotoCount?"    "+b.feed.entry[d].gphoto$numphotos.$t+" "+($item_plural?e.labels.photos:e.labels.photo):""))}c.append($scAlbum)}}d++}c.append("<div style='clear: both;height:0px;'/>");if(i==0){c=a("<div class='pwi_album_description'/>");c.append("<div class='title'>"+e.labels.noalbums+"</div>");t(false,c);return}if(f>e.albumsPerPage){var x=f/e.albumsPerPage;var y=a("<div class='pwi_prevpage'/>").text(e.labels.prev),z=a("<div class='pwi_nextpage'/>").text(e.labels.next);$navRow=a("<div class='pwi_pager'/>");if(e.albumPage>1){y.addClass("link").bind("click.pwi",function(a){a.stopPropagation();e.albumPage=parseInt(e.albumPage,10)-1;l(b);return false})}$navRow.append(y);for(var v=1;v<x+1;v++){if(v==e.albumPage){tmp="<div class='pwi_pager_current'>"+v+"</div> "}else{tmp=a("<div class='pwi_pager_page'>"+v+"</div>").bind("click.pwi",v,function(a){a.stopPropagation();e.albumPage=a.data;l(b);return false})}$navRow.append(tmp)}if(e.albumPage<x){z.addClass("link").bind("click.pwi",function(a){a.stopPropagation();e.albumPage=parseInt(e.albumPage,10)+1;l(b);return false})}$navRow.append(z);$navRow.append("<div style='clear: both;height:0px;'/>");if($navRow.length>0&&(e.showPager==="both"||e.showPager==="top")){c.append($navRow)}if($navRow.length>0&&(e.showPager==="both"||e.showPager==="bottom")){c.prepend($navRow.clone(true))}}e.albumstore=b;t(false,c)}function k(b,c,d){var f,g="",h="";h=i(b.summary?b.summary.$t:"");if(e.showPhotoDate){if(b.exif$tags.exif$time){g=j(b.exif$tags.exif$time.$t)}else if(b.gphoto$timestamp){g=j(b.gphoto$timestamp.$t)}else{g=j(b.published.$t)}g+=" "}if(c){f=a("<div class='pwi_photo' style='display: none'/>");f.append("<a href='"+b.media$group.media$thumbnail[1].url+"' rel='lb-"+d+"' title='"+g+"'></a>");if(e.showPhotoDownloadPopup){var k=a("<div style='display: none'/>");k.append("<a class='downloadlink' href='"+b.media$group.media$content[0].url+"'/>");f.append(k)}return f}else{g+=h.replace(new RegExp("'","g"),"&#39;");f=a("<div class='pwi_photo' style='height:"+(e.thumbSize+(e.showPhotoCaption?15:1))+"px;"+(e.thumbAlign==1?"width:"+(e.thumbSize+1)+"px;":"")+"cursor: pointer;'/>");f.append("<a href='"+b.media$group.media$thumbnail[1].url+"' rel='lb-"+d+"' title='"+g+"'><img src='"+b.media$group.media$thumbnail[0].url+"'/></a>");if(e.showPhotoDownloadPopup){var k=a("<div style='display: none'/>");k.append("<a class='downloadlink' href='"+b.media$group.media$content[0].url+"'/>");f.append(k)}if(e.showPhotoCaption){if(e.showPhotoCaptionDate&&e.showPhotoDate){h=g}if(e.showPhotoDownload){h+='<a href="'+b.media$group.media$content[0].url+'">'+e.labels.downloadphotos+"</a>"}if(h.length>e.showCaptionLength){h=h.substring(0,e.showCaptionLength)}f.append("<br/>"+h)}if(typeof e.onclickThumb==="function"){var l=b;f.bind("click.pwi",l,p)}return f}}function j(a){var b=new Date(Number(a));$year=b.getUTCFullYear();if($year<1e3){$year+=1900}if(b=="Invalid Date"){return a}else{if(b.getUTCHours()==0&&b.getUTCMinutes()==0&&b.getUTCSeconds()==0){return b.getUTCDate()+"-"+(b.getUTCMonth()+1)+"-"+$year}else{return b.getUTCDate()+"-"+(b.getUTCMonth()+1)+"-"+$year+" "+b.getUTCHours()+":"+(b.getUTCMinutes()<10?"0"+b.getUTCMinutes():b.getUTCMinutes())}}}function i(a){return a.replace(/\n/g,"<br />\n")}function h(a){var b=new Date(Number(a)),c=b.getUTCFullYear();if(c<1e3){c+=1900}return b.getUTCDate()+"-"+(b.getUTCMonth()+1)+"-"+c}function g(){if(e.username===""){alert("Make sure you specify at least your username."+"\n"+"See http://pwi.googlecode.com for more info");return}if(e.useQueryParameters){var a=document.URL.split("?",2);if(a.length==2){var b=a[1].split("&");var c=false;var d=1;for($queryParam in b){var f=b[$queryParam].split("=",2);if(f.length==2){if(f[0]=="pwi_album_selected"){e.mode="album";e.album=f[1];c=true}if(f[0]=="pwi_albumpage"){d=f[1]}if(f[0]=="pwi_showpermalink"){e.showPermaLink=true}}}if(c){e.page=d;e.showPermaLink=false}}}switch(e.mode){case"latest":s();break;case"album":r();break;case"keyword":r();break;default:q();break}}function f(){e=c;ts=(new Date).getTime();e.id=ts;d=a("<div id='pwi_"+ts+"'/>").appendTo(b);d.addClass("pwi_container");g();return false}var d,e={};c=a.extend({},a.fn.pwi.defaults,c);b=this;f()};a.fn.pwi.defaults={mode:"albums",username:"",album:"",authKey:"",albums:[],keyword:"",albumKeywords:[],albumStartDateTime:"",albumEndDateTime:"",albumCrop:1,albumTitle:"",albumThumbSize:160,albumThumbAlign:1,albumMaxResults:999,albumsPerPage:999,albumPage:1,albumTypes:"public",page:1,photoSize:800,maxResults:50,showPager:"bottom",thumbSize:72,thumbCrop:0,thumbAlign:0,thumbCss:{margin:"5px"},onclickThumb:"",onclickAlbumThumb:"",popupExt:"",removeAlbumTypes:[],showAlbumTitles:true,showAlbumTitlesLength:9999,showAlbumThumbs:true,showAlbumdate:true,showAlbumPhotoCount:true,showAlbumDescription:true,showAlbumLocation:true,showSlideshow:true,showSlideshowLink:false,showPhotoCaption:false,showPhotoCaptionDate:false,showCaptionLength:9999,showPhotoDownload:false,showPhotoDownloadPopup:false,showPhotoDate:true,showPermaLink:false,useQueryParameters:true,loadingImage:"",labels:{photo:"photo",photos:"photos",downloadphotos:"Download photos",albums:"Back to albums",slideshow:"Display slideshow",noalbums:"No albums available",loading:"PWI fetching data...",page:"Page",prev:"Previous",next:"Next",showPermaLink:"Show PermaLink",devider:"|"},months:["January","February","March","April","May","June","July","August","September","October","November","December"],slimbox_config:{loop:false,overlayOpacity:.6,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initlaHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"{x}/{y}",closeKeys:[27,88,67,70],prevKeys:[37,80],nextKeys:[39,83]},blockUIConfig:{message:"<div class='lbLoading pwi_loader'>loading...</div>",css:"pwi_loader"},albumstore:{},photostore:{},token:""}})(jQuery)

;
(function ($) {
$(document).ready(function(){

	$(".view-topbanner ul > li:gt(0)").hide();

setInterval(function() {
  $('.view-topbanner ul > li:first')
    .fadeOut(1000)
    .next()
    .fadeIn(1000)
    .end()
    .appendTo('.view-topbanner ul');
},  3000);


$("ul.galleri li").hover(function() {
	$(this).css({'z-index' : '10'}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-110px',
			top: '50%',
			left: '50%',
			width: '174px', /* Set new width */
			height: '174px', /* Set new height */
			padding: '20px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	$(this).css({'z-index' : '0'}); /* Set z-index back to 0 */
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: '100px', /* Set width back to default */
			height: '100px', /* Set height back to default */
			padding: '5px'
		}, 400);
});

$("ul.rightpic a").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600, 
		'speedOut'		:	200, 
		'overlayShow'	:	false
	});
	
});
}(jQuery));;

