﻿//*****************jquery easing 1.3**************
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend(jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c * (t /= d) * t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c * (t /= d) * (t - 2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t /= d / 2) < 1) return c / 2 * t * t + b;
		return -c / 2 * ((--t) * (t - 2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c * (t /= d) * t * t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c * ((t = t / d - 1) * t * t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
		return c / 2 * ((t -= 2) * t * t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c * (t /= d) * t * t * t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t = t / d - 1) * t * t * t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
		return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c * (t /= d) * t * t * t * t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
		return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t / d * (Math.PI / 2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t == 0) return b;
		if (t == d) return b + c;
		if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
		return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
		return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s = 1.70158; var p = 0; var a = c;
		if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
		if (a < Math.abs(c)) { a = c; var s = p / 4; }
		else var s = p / (2 * Math.PI) * Math.asin(c / a);
		return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s = 1.70158; var p = 0; var a = c;
		if (t == 0) return b; if ((t /= d) == 1) return b + c; if (!p) p = d * .3;
		if (a < Math.abs(c)) { a = c; var s = p / 4; }
		else var s = p / (2 * Math.PI) * Math.asin(c / a);
		return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s = 1.70158; var p = 0; var a = c;
		if (t == 0) return b; if ((t /= d / 2) == 2) return b + c; if (!p) p = d * (.3 * 1.5);
		if (a < Math.abs(c)) { a = c; var s = p / 4; }
		else var s = p / (2 * Math.PI) * Math.asin(c / a);
		if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
		return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c * (t /= d) * t * ((s + 1) * t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
		return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce(x, d - t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t /= d) < (1 / 2.75)) {
			return c * (7.5625 * t * t) + b;
		} else if (t < (2 / 2.75)) {
			return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
		} else if (t < (2.5 / 2.75)) {
			return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
		} else {
			return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d / 2) return jQuery.easing.easeInBounce(x, t * 2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce(x, t * 2 - d, 0, c, d) * .5 + c * .5 + b;
	}
});

//*************GalleryView*****************************
(function ($) {
	$.fn.galleryView = function (options) {
		var opts = $.extend($.fn.galleryView.defaults, options);

		var id;
		var iterator = 0;
		var gallery_width;
		var gallery_height;
		var frame_margin = 10;
		var strip_width;
		var wrapper_width;
		var item_count = 0;
		var slide_method;
		var img_path = '/Content/images/botoes';
		var paused = false;
		var frame_caption_size = 20;
		var frame_margin_top = 5;
		var pointer_width = 2;
		var j_gallery;
		var j_filmstrip;
		var j_frames;
		var j_panels;
		var j_pointer;

		function showItem(i) {
			//Disable next/prev buttons until transition is complete
			$('img.nav-next').unbind('click');
			$('img.nav-prev').unbind('click');
			j_frames.unbind('click');
			if (has_panels) {
				if (opts.fade_panels) {
					//Fade out all panels and fade in target panel
					j_panels.fadeOut(opts.transition_speed).eq(i % item_count).fadeIn(opts.transition_speed, function () {
						if (!has_filmstrip) {
							$('img.nav-prev').click(showPrevItem);
							$('img.nav-next').click(showNextItem);
						}
					});
				}
			}

			if (has_filmstrip) {
				//Slide either pointer or filmstrip, depending on transition method
				if (slide_method == 'strip') {
					//Stop filmstrip if it's currently in motion
					j_filmstrip.stop();

					//Determine distance between pointer (eventual destination) and target frame
					var distance = getPos(j_frames[i]).left - (getPos(j_pointer[0]).left + 2);
					var leftstr = (distance >= 0 ? '-=' : '+=') + Math.abs(distance) + 'px';

					//Animate filmstrip and slide target frame under pointer
					//If target frame is a duplicate, jump back to 'original' frame
					j_filmstrip.animate({
						'left': leftstr
					}, opts.transition_speed, opts.easing, function () {
						//Always ensure that there are a sufficient number of hidden frames on either
						//side of the filmstrip to avoid empty frames
						if (i > item_count) {
							i = i % item_count;
							iterator = i;
							j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
						} else if (i <= (item_count - strip_size)) {
							i = (i % item_count) + item_count;
							iterator = i;
							j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * i) + 'px');
						}

						if (!opts.fade_panels) {
							j_panels.hide().eq(i % item_count).show();
						}
						$('img.nav-prev').click(showPrevItem);
						$('img.nav-next').click(showNextItem);
						enableFrameClicking();
					});
				} else if (slide_method == 'pointer') {
					//Stop pointer if it's currently in motion
					j_pointer.stop();
					//Get position of target frame
					var pos = getPos(j_frames[i]);
					//Slide the pointer over the target frame
					j_pointer.animate({
						'left': (pos.left - 2 + 'px')
					}, opts.transition_speed, opts.easing, function () {
						if (!opts.fade_panels) {
							j_panels.hide().eq(i % item_count).show();
						}
						$('img.nav-prev').click(showPrevItem);
						$('img.nav-next').click(showNextItem);
						enableFrameClicking();
					});
				}

				if ($('a', j_frames[i])[0]) {
					j_pointer.unbind('click').click(function () {
						var a = $('a', j_frames[i]).eq(0);
						if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
						else { location.href = a.attr('href'); }
					});
				}
			}
		};
		function showNextItem() {
			$(document).stopTime("transition");
			if (++iterator == j_frames.length) { iterator = 0; }
			showItem(iterator);
			$(document).everyTime(opts.transition_interval, "transition", function () {
				showNextItem();
			});
		};
		function showPrevItem() {
			$(document).stopTime("transition");
			if (--iterator < 0) { iterator = item_count - 1; }
			showItem(iterator);
			$(document).everyTime(opts.transition_interval, "transition", function () {
				showNextItem();
			});
		};
		function getPos(el) {
			var left = 0, top = 0;
			var el_id = el.id;
			if (el.offsetParent) {
				do {
					left += el.offsetLeft;
					top += el.offsetTop;
				} while (el = el.offsetParent);
			}
			//If we want the position of the gallery itself, return it
			if (el_id == id) { return { 'left': left, 'top': top }; }
			//Otherwise, get position of element relative to gallery
			else {
				var gPos = getPos(j_gallery[0]);
				var gLeft = gPos.left;
				var gTop = gPos.top;

				return { 'left': left - gLeft, 'top': top - gTop };
			}
		};
		function enableFrameClicking() {
			j_frames.each(function (i) {
				//If there isn't a link in this frame, set up frame to slide on click
				//Frames with links will handle themselves
				if ($('a', this).length == 0) {
					$(this).click(function () {
						$(document).stopTime("transition");
						showItem(i);
						iterator = i;
						$(document).everyTime(opts.transition_interval, "transition", function () {
							showNextItem();
						});
					});
				}
			});
		};

		function buildPanels() {
			//If there are panel captions, add overlay divs
			if ($('.panel-overlay').length > 0) { j_panels.append('<div class="overlay"></div>'); }

			if (!has_filmstrip) {
				//Add navigation buttons
				$('<img />').addClass('nav-next').attr('src', img_path + '/next.gif').appendTo(j_gallery).css({
					'position': 'absolute',
					'zIndex': '1100',
					'cursor': 'pointer',
					'top': ((opts.panel_height - 22) / 2) + 'px',
					'right': '10px',
					'display': 'none'
				}).click(showNextItem);
				$('<img />').addClass('nav-prev').attr('src', img_path + '/prev.gif').appendTo(j_gallery).css({
					'position': 'absolute',
					'zIndex': '1100',
					'cursor': 'pointer',
					'top': ((opts.panel_height - 22) / 2) + 'px',
					'left': '10px',
					'display': 'none'
				}).click(showPrevItem);

				$('<img />').addClass('nav-overlay').attr('src', img_path + '/panel-nav-next.gif').appendTo(j_gallery).css({
					'position': 'absolute',
					'zIndex': '1099',
					'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
					'right': '0',
					'display': 'none'
				});

				$('<img />').addClass('nav-overlay').attr('src', img_path + '/panel-nav-prev.gif').appendTo(j_gallery).css({
					'position': 'absolute',
					'zIndex': '1099',
					'top': ((opts.panel_height - 22) / 2) - 10 + 'px',
					'left': '0',
					'display': 'none'
				});
			}
			j_panels.css({
				'width': (opts.panel_width - parseInt(j_panels.css('paddingLeft').split('px')[0], 10) - parseInt(j_panels.css('paddingRight').split('px')[0], 10)) + 'px',
				'height': (opts.panel_height - parseInt(j_panels.css('paddingTop').split('px')[0], 10) - parseInt(j_panels.css('paddingBottom').split('px')[0], 10)) + 'px',
				'position': 'absolute',
				'top': (opts.filmstrip_position == 'top' ? (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px' : '0px'),
				'left': '0px',
				'overflow': 'hidden',
				'background': 'white',
				'display': 'none'
			});
			$('.panel-overlay', j_panels).css({
				'position': 'absolute',
				'zIndex': '999',
				'width': (opts.panel_width - 20) + 'px',
				'height': opts.overlay_height + 'px',
				'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
				'left': '0',
				'padding': '0 10px',
				'color': opts.overlay_text_color,
				'fontSize': opts.overlay_font_size
			});
			$('.panel-overlay a', j_panels).css({
				'color': opts.overlay_text_color,
				'textDecoration': 'underline',
				'fontWeight': 'bold'
			});
			$('.overlay', j_panels).css({
				'position': 'absolute',
				'zIndex': '998',
				'width': opts.panel_width + 'px',
				'height': opts.overlay_height + 'px',
				'top': (opts.overlay_position == 'top' ? '0' : opts.panel_height - opts.overlay_height + 'px'),
				'left': '0',
				'background': opts.overlay_color,
				'opacity': opts.overlay_opacity
			});
			$('.panel iframe', j_panels).css({
				'width': opts.panel_width + 'px',
				'height': (opts.panel_height - opts.overlay_height) + 'px',
				'border': '0'
			});
		};

		function buildFilmstrip() {
			//Add wrapper to filmstrip to hide extra frames
			j_filmstrip.wrap('<div class="strip_wrapper"></div>');
			if (slide_method == 'strip') {
				j_frames.clone().appendTo(j_filmstrip);
				j_frames.clone().appendTo(j_filmstrip);
				j_frames = $('li', j_filmstrip);
			}
			//If captions are enabled, add caption divs and fill with the image titles
			if (opts.show_captions) {
				j_frames.append('<div class="caption"></div>').each(function (i) {
					$(this).find('.caption').html($(this).find('img').attr('title'));
				});
			}

			j_filmstrip.css({
				'listStyle': 'none',
				'margin': '0',
				'padding': '0',
				'width': strip_width + 'px',
				'position': 'absolute',
				'zIndex': '900',
				'top': '0',
				'left': '0',
				'height': (opts.frame_height + 10) + 'px',
				'background': opts.background_color
			});
			j_frames.css({
				'float': 'left',
				'position': 'relative',
				'height': opts.frame_height + 'px',
				'zIndex': '901',
				'marginTop': frame_margin_top + 'px',
				'marginBottom': '0px',
				'marginRight': frame_margin + 'px',
				'padding': '0',
				'cursor': 'pointer'
			});
			$('img', j_frames).css({
				'border': 'none'
			});
			$('.strip_wrapper', j_gallery).css({
				'position': 'absolute',
				'top': (opts.filmstrip_position == 'top' ? '0px' : opts.panel_height + 'px'),
				'left': ((gallery_width - wrapper_width) / 2) + 'px',
				'width': wrapper_width + 'px',
				'height': (opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top)) + 'px',
				'overflow': 'hidden'
			});
			$('.caption', j_gallery).css({
				'position': 'absolute',
				'top': opts.frame_height + 'px',
				'left': '0',
				'margin': '0',
				'width': opts.frame_width + 'px',
				'padding': '0',
				'color': opts.caption_text_color,
				'textAlign': 'center',
				'fontSize': '10px',
				'height': frame_caption_size + 'px',

				'lineHeight': frame_caption_size + 'px'
			});
			var pointer = $('<div></div>');
			pointer.attr('id', 'pointer').appendTo(j_gallery).css({
				'position': 'absolute',
				'zIndex': '1000',
				'cursor': 'pointer',
				'top': '463px',
				'left': ((612 - wrapper_width) / 2) + 'px',
				// 'top':getPos(j_frames[0]).top-(pointer_width/2)+'px',
				//'left':getPos(j_frames[0]).left-(pointer_width/2)+'px',
				'height': opts.frame_height - pointer_width + 'px',
				'width': opts.frame_width - pointer_width + 'px',
				'border': (has_panels ? pointer_width + 'px solid ' + (opts.nav_theme == 'dark' ? 'black' : 'black') : 'none')
			});
			j_pointer = $('#pointer', j_gallery);
			if (has_panels) {
				var pointerArrow = $('<img />');
				pointerArrow.attr('src', img_path + '/pointer' + (opts.filmstrip_position == 'top' ? '-down' : '') + '.png').appendTo($('#pointer')).css({
					'position': 'absolute',
					'zIndex': '1001',
					'top': (opts.filmstrip_position == 'bottom' ? '-' + (10 + pointer_width) + 'px' : opts.frame_height + 'px'),
					'left': ((opts.frame_width / 2) - 10) + 'px'
				});
			}

			//If the filmstrip is animating, move the strip to the middle third
			if (slide_method == 'strip') {
				j_filmstrip.css('left', '-' + ((opts.frame_width + frame_margin) * item_count) + 'px');
				iterator = item_count;
			}
			//If there's a link under the pointer, enable clicking on the pointer
			if ($('a', j_frames[iterator])[0]) {
				j_pointer.click(function () {
					var a = $('a', j_frames[iterator]).eq(0);
					if (a.attr('target') == '_blank') { window.open(a.attr('href')); }
					else { location.href = a.attr('href'); }
				});
			}

			//Add navigation buttons
			$('<img height="55px" width="22px"/>').addClass('nav-next').attr('src', img_path + '/next.gif').appendTo(j_gallery).css({
				'position': 'absolute',
				'cursor': 'pointer',
				//'top':(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
				'top': '465.5px',
				'right': (gallery_width / 2) - (wrapper_width / 2) - 10 - 22 + 'px'
			}).click(showNextItem);
			$('<img height="55px" width="22px"/>').addClass('nav-prev').attr('src', img_path + '/prev.gif').appendTo(j_gallery).css({
				'position': 'absolute',
				'cursor': 'pointer',
				'top': '465.5px',
				//'top':(opts.filmstrip_position=='top'?0:opts.panel_height)+frame_margin_top+((opts.frame_height-22)/2)+'px',
				'left': (gallery_width / 2) - (wrapper_width / 2) - 10 - 22 + 'px'
			}).click(showPrevItem);
		};

		//Check mouse to see if it is within the borders of the panel
		//More reliable than 'mouseover' event when elements overlay the panel
		function mouseIsOverPanels(x, y) {
			var pos = getPos(j_gallery[0]);
			var top = pos.top;
			var left = pos.left;
			return x > left && x < left + opts.panel_width && y > top && y < top + opts.panel_height;
		};

		return this.each(function () {
			j_gallery = $(this);

			//Hide gallery to prevent Flash of Unstyled Content (FoUC) in IE
			j_gallery.css('visibility', 'hidden');

			//Assign elements to variables for reuse
			j_filmstrip = $('.filmstrip', j_gallery);
			j_frames = $('li', j_filmstrip);
			j_panels = $('.panel', j_gallery);

			id = j_gallery.attr('id');

			has_panels = j_panels.length > 0;
			has_filmstrip = j_frames.length > 0;

			if (!has_panels) opts.panel_height = 0;

			//Number of frames in filmstrip
			item_count = has_panels ? j_panels.length : j_frames.length;

			//Number of frames that can display within the screen's width
			//64 = width of block for navigation button * 2
			//5 = minimum frame margin
			strip_size = has_panels ? Math.floor((opts.panel_width - 64) / (opts.frame_width + frame_margin)) : Math.min(item_count, opts.filmstrip_size);

			//If more items than strip size, slide filmstrip
			//Otherwise, slide pointer
			if (strip_size >= item_count) {
				slide_method = 'pointer';
				strip_size = item_count;
			}
			else { slide_method = 'strip'; }

			//Width of gallery block
			gallery_width = has_panels ? opts.panel_width : (strip_size * (opts.frame_width + frame_margin)) - frame_margin + 64;

			//Height of gallery block = screen + filmstrip + captions (optional)
			gallery_height = (has_panels ? opts.panel_height : 0) + (has_filmstrip ? opts.frame_height + frame_margin_top + (opts.show_captions ? frame_caption_size : frame_margin_top) : 0);

			//Width of filmstrip
			if (slide_method == 'pointer') { strip_width = (opts.frame_width * item_count) + (frame_margin * (item_count)); }
			else { strip_width = (opts.frame_width * item_count * 3) + (frame_margin * (item_count * 3)); }

			//Width of filmstrip wrapper (to hide overflow)
			wrapper_width = ((strip_size * opts.frame_width) + ((strip_size - 1) * frame_margin));

			j_gallery.css({
				'position': 'relative',
				'margin': '0',
				'background': opts.background_color,
				'border': opts.border,
				'width': gallery_width + 'px',
				'height': gallery_height + 'px'
			});
			if (has_filmstrip) {
				buildFilmstrip();
			}
			if (has_panels) {
				buildPanels();
			}

			if (has_filmstrip) enableFrameClicking();
			$().mousemove(function (e) {
				if (mouseIsOverPanels(e.pageX, e.pageY)) {
					if (opts.pause_on_hover) {
						$(document).oneTime(500, "animation_pause", function () {
							$(document).stopTime("transition");
							paused = true;
						});
					}
					if (has_panels && !has_filmstrip) {
						$('.nav-overlay').fadeIn('fast');
						$('.nav-next').fadeIn('fast');
						$('.nav-prev').fadeIn('fast');
					}
				} else {
					if (opts.pause_on_hover) {
						$(document).stopTime("animation_pause");
						if (paused) {
							$(document).everyTime(opts.transition_interval, "transition", function () {
								showNextItem();
							});
							paused = false;
						}
					}
					if (has_panels && !has_filmstrip) {
						$('.nav-overlay').fadeOut('fast');
						$('.nav-next').fadeOut('fast');
						$('.nav-prev').fadeOut('fast');
					}
				}
			});
			//Show the first panel
			j_panels.eq(0).show();

			//If we have more than one item, begin automated transitions
			if (item_count > 1) {
				$(document).everyTime(opts.transition_interval, "transition", function () {
					showNextItem();
				});
			}

			//Make gallery visible now that work is complete
			j_gallery.css('visibility', 'visible');
		});
	};

	$.fn.galleryView.defaults = {
		panel_width: 400,
		panel_height: 300,
		frame_width: 80,
		frame_height: 80,
		filmstrip_size: 3,
		overlay_height: 70,
		overlay_font_size: '1em',
		transition_speed: 300,
		transition_interval: 0,
		overlay_opacity: 0.6,
		overlay_color: 'black',
		background_color: 'white',
		overlay_text_color: 'white',
		caption_text_color: 'white',
		border: 'none',
		nav_theme: 'light',
		easing: 'swing',
		filmstrip_position: 'bottom',
		overlay_position: 'bottom',
		show_captions: false,
		fade_panels: true,
		pause_on_hover: false
	};
})(jQuery);

//***********************jquery timers *********************************+
jQuery.fn.extend({
	everyTime: function (interval, label, fn, times, belay) {
		return this.each(function () {
			jQuery.timer.add(this, interval, label, fn, times, belay);
		});
	},
	oneTime: function (interval, label, fn) {
		return this.each(function () {
			jQuery.timer.add(this, interval, label, fn, 1);
		});
	},
	stopTime: function (label, fn) {
		return this.each(function () {
			jQuery.timer.remove(this, label, fn);
		});
	}
});

jQuery.event.special

jQuery.extend({
	timer: {
		global: [],
		guid: 1,
		dataKey: "jQuery.timer",
		regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,
		powers: {
			'ms': 1,
			'cs': 10,
			'ds': 100,
			's': 1000,
			'das': 10000,
			'hs': 100000,
			'ks': 1000000
		},
		timeParse: function (value) {
			if (value == undefined || value == null)
				return null;
			var result = this.regex.exec(jQuery.trim(value.toString()));
			if (result[2]) {
				var num = parseFloat(result[1]);
				var mult = this.powers[result[2]] || 1;
				return num * mult;
			} else {
				return value;
			}
		},
		add: function (element, interval, label, fn, times, belay) {
			var counter = 0;

			if (jQuery.isFunction(label)) {
				if (!times)
					times = fn;
				fn = label;
				label = interval;
			}

			interval = jQuery.timer.timeParse(interval);

			if (typeof interval != 'number' || isNaN(interval) || interval <= 0)
				return;

			if (times && times.constructor != Number) {
				belay = !!times;
				times = 0;
			}

			times = times || 0;
			belay = belay || false;

			var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {});

			if (!timers[label])
				timers[label] = {};

			fn.timerID = fn.timerID || this.guid++;

			var handler = function () {
				if (belay && this.inProgress)
					return;
				this.inProgress = true;
				if ((++counter > times && times !== 0) || fn.call(element, counter) === false)
					jQuery.timer.remove(element, label, fn);
				this.inProgress = false;
			};

			handler.timerID = fn.timerID;

			if (!timers[label][fn.timerID])
				timers[label][fn.timerID] = window.setInterval(handler, interval);

			this.global.push(element);

		},
		remove: function (element, label, fn) {
			var timers = jQuery.data(element, this.dataKey), ret;

			if (timers) {

				if (!label) {
					for (label in timers)
						this.remove(element, label, fn);
				} else if (timers[label]) {
					if (fn) {
						if (fn.timerID) {
							window.clearInterval(timers[label][fn.timerID]);
							delete timers[label][fn.timerID];
						}
					} else {
						for (var fn in timers[label]) {
							window.clearInterval(timers[label][fn]);
							delete timers[label][fn];
						}
					}

					for (ret in timers[label]) break;
					if (!ret) {
						ret = null;
						delete timers[label];
					}
				}

				for (ret in timers) break;
				if (!ret)
					jQuery.removeData(element, this.dataKey);
			}
		}
	}
});

jQuery(window).bind("unload", function () {
	jQuery.each(jQuery.timer.global, function (index, item) {
		jQuery.timer.remove(item);
	});
});

//*************colorbox
(function (b, gb) { var v = "none", t = "click", N = "LoadedContent", d = false, x = "resize.", o = "y", u = "auto", f = true, M = "nofollow", q = "on", n = "x"; function e(a, c) { a = a ? ' id="' + k + a + '"' : ""; c = c ? ' style="' + c + '"' : ""; return b("<div" + a + c + "/>") } function p(a, b) { b = b === n ? m.width() : m.height(); return typeof a === "string" ? Math.round(a.match(/%/) ? b / 100 * parseInt(a, 10) : parseInt(a, 10)) : a } function Q(c) { c = b.isFunction(c) ? c.call(h) : c; return a.photo || c.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i) } function cb() { for (var c in a) if (b.isFunction(a[c]) && c.substring(0, 2) !== q) a[c] = a[c].call(h); a.rel = a.rel || h.rel || M; a.href = a.href || b(h).attr("href"); a.title = a.title || h.title } function db(d) { h = d; a = b.extend({}, b(h).data(r)); cb(); if (a.rel !== M) { i = b("." + H).filter(function () { return (b(this).data(r).rel || this.rel) === a.rel }); g = i.index(h); if (g === -1) { i = i.add(h); g = i.length - 1 } } else { i = b(h); g = 0 } if (!w) { w = F = f; R = h; try { R.blur() } catch (e) { } b.event.trigger(hb); a.onOpen && a.onOpen.call(h); y.css({ opacity: +a.opacity, cursor: a.overlayClose ? "pointer" : u }).show(); a.w = p(a.initialWidth, n); a.h = p(a.initialHeight, o); c.position(0); S && m.bind(x + O + " scroll." + O, function () { y.css({ width: m.width(), height: m.height(), top: m.scrollTop(), left: m.scrollLeft() }) }).trigger("scroll." + O) } T.add(I).add(J).add(z).add(U).hide(); V.html(a.close).show(); c.slideshow(); c.load() } var eb = { transition: "elastic", speed: 300, width: d, initialWidth: "600", innerWidth: d, maxWidth: d, height: d, initialHeight: "450", innerHeight: d, maxHeight: d, scalePhotos: f, scrolling: f, inline: d, html: d, iframe: d, photo: d, href: d, title: d, rel: d, opacity: .9, preloading: f, current: "Foto {current} de {total}", previous: "anterior", next: "seguinte", close: "fechar", open: d, loop: f, slideshow: d, slideshowAuto: f, slideshowSpeed: 2500, slideshowStart: "start slideshow", slideshowStop: "stop slideshow", onOpen: d, onLoad: d, onComplete: d, onCleanup: d, onClosed: d, overlayClose: f, escKey: f, arrowKey: f }, r = "colorbox", k = "cbox", hb = k + "_open", P = k + "_load", W = k + "_complete", X = k + "_cleanup", fb = k + "_closed", G = b.browser.msie && !b.support.opacity, S = G && b.browser.version < 7, O = k + "_IE6", y, j, E, s, Y, Z, ab, bb, i, m, l, K, L, U, T, z, J, I, V, C, D, A, B, h, R, g, a, w, F, c, H = k + "Element"; c = b.fn[r] = b[r] = function (c, d) { var a = this; if (!a[0] && a.selector) return a; c = c || {}; if (d) c.onComplete = d; if (!a[0] || a.selector === undefined) { a = b("<a/>"); c.open = f } a.each(function () { b(this).data(r, b.extend({}, b(this).data(r) || eb, c)).addClass(H) }); c.open && db(a[0]); return a }; c.init = function () { var h = "hover"; m = b(gb); j = e().attr({ id: r, "class": G ? k + "IE" : "" }); y = e("Overlay", S ? "position:absolute" : "").hide(); E = e("Wrapper"); s = e("Content").append(l = e(N, "width:0; height:0"), L = e("LoadingOverlay").add(e("LoadingGraphic")), U = e("Title"), T = e("Current"), J = e("Next"), I = e("Previous"), z = e("Slideshow"), V = e("Close")); E.append(e().append(e("TopLeft"), Y = e("TopCenter"), e("TopRight")), e().append(Z = e("MiddleLeft"), s, ab = e("MiddleRight")), e().append(e("BottomLeft"), bb = e("BottomCenter"), e("BottomRight"))).children().children().css({ "float": "left" }); K = e(d, "position:absolute; width:9999px; visibility:hidden; display:none"); b("body").prepend(y, j.append(E, K)); s.children().hover(function () { b(this).addClass(h) }, function () { b(this).removeClass(h) }).addClass(h); C = Y.height() + bb.height() + s.outerHeight(f) - s.height(); D = Z.width() + ab.width() + s.outerWidth(f) - s.width(); A = l.outerHeight(f); B = l.outerWidth(f); j.css({ "padding-bottom": C, "padding-right": D }).hide(); J.click(c.next); I.click(c.prev); V.click(c.close); s.children().removeClass(h); b("." + H).live(t, function (a) { if (a.button !== 0 && typeof a.button !== "undefined" || a.ctrlKey || a.shiftKey || a.altKey) return f; else { db(this); return d } }); y.click(function () { a.overlayClose && c.close() }); b(document).bind("keydown", function (b) { if (w && a.escKey && b.keyCode === 27) { b.preventDefault(); c.close() } if (w && a.arrowKey && !F && i[1]) if (b.keyCode === 37 && (g || a.loop)) { b.preventDefault(); I.click() } else if (b.keyCode === 39 && (g < i.length - 1 || a.loop)) { b.preventDefault(); J.click() } }) }; c.remove = function () { j.add(y).remove(); b("." + H).die(t).removeData(r).removeClass(H) }; c.position = function (f, b) { function c(a) { Y[0].style.width = bb[0].style.width = s[0].style.width = a.style.width; L[0].style.height = L[1].style.height = s[0].style.height = Z[0].style.height = ab[0].style.height = a.style.height } var e, h = Math.max(m.height() - a.h - A - C, 0) / 2 + m.scrollTop(), g = Math.max(m.width() - a.w - B - D, 0) / 2 + m.scrollLeft(); e = j.width() === a.w + B && j.height() === a.h + A ? 0 : f; E[0].style.width = E[0].style.height = "9999px"; j.dequeue().animate({ width: a.w + B, height: a.h + A, top: h, left: g }, { duration: e, complete: function () { c(this); F = d; E[0].style.width = a.w + B + D + "px"; E[0].style.height = a.h + A + C + "px"; b && b() }, step: function () { c(this) } }) }; c.resize = function (b) { if (w) { b = b || {}; if (b.width) a.w = p(b.width, n) - B - D; if (b.innerWidth) a.w = p(b.innerWidth, n); l.css({ width: a.w }); if (b.height) a.h = p(b.height, o) - A - C; if (b.innerHeight) a.h = p(b.innerHeight, o); if (!b.innerHeight && !b.height) { b = l.wrapInner("<div style='overflow:auto'></div>").children(); a.h = b.height(); b.replaceWith(b.children()) } l.css({ height: a.h }); c.position(a.transition === v ? 0 : a.speed) } }; c.prep = function (o) { var d = "hidden"; function n(t) { var o, q, s, n, d = i.length, e = a.loop; c.position(t, function () { function t() { G && j[0].style.removeAttribute("filter") } if (w) { G && p && l.fadeIn(100); a.iframe && b("<iframe frameborder=0" + (a.scrolling ? "" : " scrolling='no'") + (G ? " allowtransparency='true'" : "") + "/>").attr({ src: a.href, name: (new Date).getTime() }).appendTo(l); l.show(); U.show().html(a.title); if (d > 1) { T.html(a.current.replace(/\{current\}/, g + 1).replace(/\{total\}/, d)).show(); J[e || g < d - 1 ? "show" : "hide"]().html(a.next); I[e || g ? "show" : "hide"]().html(a.previous); o = g ? i[g - 1] : i[d - 1]; s = g < d - 1 ? i[g + 1] : i[0]; if (a.slideshow) { z.show(); g === d - 1 && !e && j.is("." + k + "Slideshow_on") && z.click() } if (a.preloading) { n = b(s).data(r).href || s.href; q = b(o).data(r).href || o.href; if (Q(n)) b("<img/>")[0].src = n; if (Q(q)) b("<img/>")[0].src = q } } L.hide(); a.transition === "fade" ? j.fadeTo(f, 1, function () { t() }) : t(); m.bind(x + k, function () { c.position(0) }); b.event.trigger(W); a.onComplete && a.onComplete.call(h) } }) } if (w) { var p, f = a.transition === v ? 0 : a.speed; m.unbind(x + k); l.remove(); l = e(N).html(o); l.hide().appendTo(K.show()).css({ width: function () { a.w = a.w || l.width(); a.w = a.mw && a.mw < a.w ? a.mw : a.w; return a.w } (), overflow: a.scrolling ? u : d }).css({ height: function () { a.h = a.h || l.height(); a.h = a.mh && a.mh < a.h ? a.mh : a.h; return a.h } () }).prependTo(s); K.hide(); b("#" + k + "Photo").css({ cssFloat: v }); S && b("select").not(j.find("select")).filter(function () { return this.style.visibility !== d }).css({ visibility: d }).one(X, function () { this.style.visibility = "inherit" }); a.transition === "fade" ? j.fadeTo(f, 0, function () { n(0) }) : n(f) } }; c.load = function () { var j, d, q, m = c.prep; F = f; h = i[g]; a = b.extend({}, b(h).data(r)); cb(); b.event.trigger(P); a.onLoad && a.onLoad.call(h); a.h = a.height ? p(a.height, o) - A - C : a.innerHeight && p(a.innerHeight, o); a.w = a.width ? p(a.width, n) - B - D : a.innerWidth && p(a.innerWidth, n); a.mw = a.w; a.mh = a.h; if (a.maxWidth) { a.mw = p(a.maxWidth, n) - B - D; a.mw = a.w && a.w < a.mw ? a.w : a.mw } if (a.maxHeight) { a.mh = p(a.maxHeight, o) - A - C; a.mh = a.h && a.h < a.mh ? a.h : a.mh } j = a.href; L.show(); if (a.inline) { e("InlineTemp").hide().insertBefore(b(j)[0]).bind(P + " " + X, function () { b(this).replaceWith(l.children()) }); m(b(j)) } else if (a.iframe) m(" "); else if (a.html) m(a.html); else if (Q(j)) { d = new Image; d.onload = function () { var e; d.onload = null; d.id = k + "Photo"; b(d).css({ margin: u, border: v, display: "block", cssFloat: "left" }); if (a.scalePhotos) { q = function () { d.height -= d.height * e; d.width -= d.width * e }; if (a.mw && d.width > a.mw) { e = (d.width - a.mw) / d.width; q() } if (a.mh && d.height > a.mh) { e = (d.height - a.mh) / d.height; q() } } if (a.h) d.style.marginTop = Math.max(a.h - d.height, 0) / 2 + "px"; setTimeout(function () { m(d) }, 1); i[1] && (g < i.length - 1 || a.loop) && b(d).css({ cursor: "pointer" }).click(c.next); if (G) d.style.msInterpolationMode = "bicubic" }; d.src = j } else e().appendTo(K).load(j, function (c, a, b) { m(a === "error" ? "Request unsuccessful: " + b.statusText : this) }) }; c.next = function () { if (!F) { g = g < i.length - 1 ? g + 1 : 0; c.load() } }; c.prev = function () { if (!F) { g = g ? g - 1 : i.length - 1; c.load() } }; c.slideshow = function () { function f() { z.text(a.slideshowStop).bind(W, function () { d = setTimeout(c.next, a.slideshowSpeed) }).bind(P, function () { clearTimeout(d) }).one(t, function () { e() }); j.removeClass(b + "off").addClass(b + q) } var e, d, b = k + "Slideshow_"; z.bind(fb, function () { z.unbind(); clearTimeout(d); j.removeClass(b + "off " + b + q) }); e = function () { clearTimeout(d); z.text(a.slideshowStart).unbind(W + " " + P).one(t, function () { f(); d = setTimeout(c.next, a.slideshowSpeed) }); j.removeClass(b + q).addClass(b + "off") }; if (a.slideshow && i[1]) a.slideshowAuto ? f() : e() }; c.close = function () { if (w) { w = d; b.event.trigger(X); a.onCleanup && a.onCleanup.call(h); m.unbind("." + k + " ." + O); y.fadeTo("fast", 0); j.stop().fadeTo("fast", 0, function () { j.find("iframe").attr("src", "about:blank"); l.remove(); j.add(y).css({ opacity: 1, cursor: u }).hide(); try { R.focus() } catch (c) { } setTimeout(function () { b.event.trigger(fb); a.onClosed && a.onClosed.call(h) }, 1) }) } }; c.element = function () { return b(h) }; c.settings = eb; b(c.init) })(jQuery, this)

