/*
Plugin Name: 	BrowserSelector
Written by: 	Okler Themes - (http://www.okler.net)
Theme Version:	7.0.0
*/

(function($) {
	$.extend({

		browserSelector: function() {

			// jQuery.browser.mobile (http://detectmobilebrowser.com/)
			(function(a){(jQuery.browser=jQuery.browser||{}).mobile=/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))})(navigator.userAgent||navigator.vendor||window.opera);

			// Touch
			var hasTouch = 'ontouchstart' in window || navigator.msMaxTouchPoints;

			var u = navigator.userAgent,
				ua = u.toLowerCase(),
				is = function (t) {
					return ua.indexOf(t) > -1;
				},
				g = 'gecko',
				w = 'webkit',
				s = 'safari',
				o = 'opera',
				h = document.documentElement,
				b = [(!(/opera|webtv/i.test(ua)) && /msie\s(\d)/.test(ua)) ? ('ie ie' + parseFloat(navigator.appVersion.split("MSIE")[1])) : is('firefox/2') ? g + ' ff2' : is('firefox/3.5') ? g + ' ff3 ff3_5' : is('firefox/3') ? g + ' ff3' : is('gecko/') ? g : is('opera') ? o + (/version\/(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery1 : (/opera(\s|\/)(\d+)/.test(ua) ? ' ' + o + RegExp.jQuery2 : '')) : is('konqueror') ? 'konqueror' : is('chrome') ? w + ' chrome' : is('iron') ? w + ' iron' : is('applewebkit/') ? w + ' ' + s + (/version\/(\d+)/.test(ua) ? ' ' + s + RegExp.jQuery1 : '') : is('mozilla/') ? g : '', is('j2me') ? 'mobile' : is('iphone') ? 'iphone' : is('ipod') ? 'ipod' : is('mac') ? 'mac' : is('darwin') ? 'mac' : is('webtv') ? 'webtv' : is('win') ? 'win' : is('freebsd') ? 'freebsd' : (is('x11') || is('linux')) ? 'linux' : '', 'js'];

			c = b.join(' ');

			if ($.browser.mobile) {
				c += ' mobile';
			}

			if (hasTouch) {
				c += ' touch';
			}

			h.className += ' ' + c;

			// Edge Detect
			var isEdge = /Edge/.test(navigator.userAgent);

			if(isEdge) {
				$('html').removeClass('chrome').addClass('edge');
			}

			// IE11 Detect
			var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;

			if (isIE11) {
				$('html').removeClass('gecko').addClass('ie ie11');
				return;
			}

			// Dark and Boxed Compatibility
			if($('body').hasClass('dark')) {
				$('html').addClass('dark');
			}

			if($('body').hasClass('boxed')) {
				$('html').addClass('boxed');
			}

		}

	});

	$.browserSelector();

})(jQuery);

/*
Plugin Name: 	Count To
Written by: 	Matt Huggins - https://github.com/mhuggins/jquery-countTo
*/

(function ($) {
	$.fn.countTo = function (options) {
		options = options || {};

		return $(this).each(function () {
			// set options for current element
			var settings = $.extend({}, $.fn.countTo.defaults, {
				from:            $(this).data('from'),
				to:              $(this).data('to'),
				speed:           $(this).data('speed'),
				refreshInterval: $(this).data('refresh-interval'),
				decimals:        $(this).data('decimals')
			}, options);

			// how many times to update the value, and how much to increment the value on each update
			var loops = Math.ceil(settings.speed / settings.refreshInterval),
				increment = (settings.to - settings.from) / loops;

			// references & variables that will change with each update
			var self = this,
				$self = $(this),
				loopCount = 0,
				value = settings.from,
				data = $self.data('countTo') || {};

			$self.data('countTo', data);

			// if an existing interval can be found, clear it first
			if (data.interval) {
				clearInterval(data.interval);
			}
			data.interval = setInterval(updateTimer, settings.refreshInterval);

			// initialize the element with the starting value
			render(value);

			function updateTimer() {
				value += increment;
				loopCount++;

				render(value);

				if (typeof(settings.onUpdate) == 'function') {
					settings.onUpdate.call(self, value);
				}

				if (loopCount >= loops) {
					// remove the interval
					$self.removeData('countTo');
					clearInterval(data.interval);
					value = settings.to;

					if (typeof(settings.onComplete) == 'function') {
						settings.onComplete.call(self, value);
					}
				}
			}

			function render(value) {
				var formattedValue = settings.formatter.call(self, value, settings);
				$self.html(formattedValue);
			}
		});
	};

	$.fn.countTo.defaults = {
		from: 0,               // the number the element should start at
		to: 0,                 // the number the element should end at
		speed: 1000,           // how long it should take to count between the target numbers
		refreshInterval: 100,  // how often the element should be updated
		decimals: 0,           // the number of decimal places to show
		formatter: formatter,  // handler for formatting the value before rendering
		onUpdate: null,        // callback method for every time the element is updated
		onComplete: null       // callback method for when the element finishes updating
	};

	function formatter(value, settings) {
		return value.toFixed(settings.decimals);
	}
}(jQuery));

/*
Plugin Name: 	Visible
Written by: 	https://github.com/customd/jquery-visible/blob/master/jquery.visible.js
Description: 	This is a jQuery plugin which allows us to quickly check if an element is within the browsers visual viewport.
*/
(function($){

	/**
	 * Copyright 2012, Digital Fusion
	 * Licensed under the MIT license.
	 * http://teamdf.com/jquery-plugins/license/
	 *
	 * @author Sam Sehnert
	 * @desc A small plugin that checks whether elements are within
	 *       the user visible viewport of a web browser.
	 *       only accounts for vertical position, not horizontal.
	 */
	var $w=$(window);
	$.fn.visible = function(partial,hidden,direction,container){

		if (this.length < 1)
			return;
	
	// Set direction default to 'both'.
	direction = direction || 'both';
		
		var $t          = this.length > 1 ? this.eq(0) : this,
						isContained = typeof container !== 'undefined' && container !== null,
						$c				  = isContained ? $(container) : $w,
						wPosition        = isContained ? $c.position() : 0,
			t           = $t.get(0),
			vpWidth     = $c.outerWidth(),
			vpHeight    = $c.outerHeight(),
			clientSize  = hidden === true ? t.offsetWidth * t.offsetHeight : true;

		if (typeof t.getBoundingClientRect === 'function'){

			// Use this native browser method, if available.
			var rec = t.getBoundingClientRect(),
				tViz = isContained ?
												rec.top - wPosition.top >= 0 && rec.top < vpHeight + wPosition.top :
												rec.top >= 0 && rec.top < vpHeight,
				bViz = isContained ?
												rec.bottom - wPosition.top > 0 && rec.bottom <= vpHeight + wPosition.top :
												rec.bottom > 0 && rec.bottom <= vpHeight,
				lViz = isContained ?
												rec.left - wPosition.left >= 0 && rec.left < vpWidth + wPosition.left - 50 :
												rec.left >= 0 && rec.left <  vpWidth - 50,
				rViz = isContained ?
												rec.right - wPosition.left > 0  && rec.right < vpWidth + wPosition.left - 50  :
												rec.right > 0 && rec.right <= vpWidth - 50,
				vVisible   = partial ? tViz || bViz : tViz && bViz,
				hVisible   = partial ? lViz || rViz : lViz && rViz,
		vVisible = (rec.top < 0 && rec.bottom > vpHeight) ? true : vVisible,
				hVisible = (rec.left < 0 && rec.right > vpWidth) ? true : hVisible;

			if(direction === 'both')
				return clientSize && vVisible && hVisible;
			else if(direction === 'vertical')
				return clientSize && vVisible;
			else if(direction === 'horizontal')
				return clientSize && hVisible;
		} else {

			var viewTop 				= isContained ? 0 : wPosition,
				viewBottom      = viewTop + vpHeight,
				viewLeft        = $c.scrollLeft(),
				viewRight       = viewLeft + vpWidth,
				position          = $t.position(),
				_top            = position.top,
				_bottom         = _top + $t.height(),
				_left           = position.left,
				_right          = _left + $t.width(),
				compareTop      = partial === true ? _bottom : _top,
				compareBottom   = partial === true ? _top : _bottom,
				compareLeft     = partial === true ? _right : _left,
				compareRight    = partial === true ? _left : _right;

			if(direction === 'both')
				return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop)) && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
			else if(direction === 'vertical')
				return !!clientSize && ((compareBottom <= viewBottom) && (compareTop >= viewTop));
			else if(direction === 'horizontal')
				return !!clientSize && ((compareRight <= viewRight) && (compareLeft >= viewLeft));
		}
	};

})(jQuery);

/*
Plugin Name: 	afterResize.js
Written by: 	https://github.com/mcshaman/afterResize.js
Description: 	Simple jQuery plugin designed to emulate an 'after resize' event.
*/
( function( $ ) {
	"use strict";
	
	// Define default settings
	var defaults = {
		action: function() {},
		runOnLoad: false,
		duration: 500
	};
	
	// Define global variables
	var settings = defaults,
		running = false,
		start;
	
	var methods = {};
	
	// Initial plugin configuration
	methods.init = function() {
		
		// Allocate passed arguments to settings based on type
		for( var i = 0; i <= arguments.length; i++ ) {
			var arg = arguments[i];
			switch ( typeof arg ) {
				case "function":
					settings.action = arg;
					break;
				case "boolean":
					settings.runOnLoad = arg;
					break;
				case "number":
					settings.duration = arg;
					break;
			}
		}
	
		// Process each matching jQuery object
		return this.each(function() {
		
			if( settings.runOnLoad ) { settings.action(); }
			
			$(this).resize( function() {
				
				methods.timedAction.call( this );
				
			} );
		
		} );
	};
	
	methods.timedAction = function( code, millisec ) {
		
		var doAction = function() {
			var remaining = settings.duration;
			
			if( running ) {
				var elapse = new Date() - start;
				remaining = settings.duration - elapse;
				if( remaining <= 0 ) {
					// Clear timeout and reset running variable
					clearTimeout(running);
					running = false;
					// Perform user defined function
					settings.action();
				
					return;
				}
			}
			wait( remaining );
		};
		
		var wait = function( time ) {
			running = setTimeout( doAction, time );
		};
		
		// Define new action starting time
		start = new Date();
		
		// Define runtime settings if function is run directly
		if( typeof millisec === 'number' ) { settings.duration = millisec; }
		if( typeof code === 'function' ) { settings.action = code; }
		
		// Only run timed loop if not already running
		if( !running ) { doAction(); }
		
	};

	
	$.fn.afterResize = function( method ) {
		
		if( methods[method] ) {
			return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ) );
		} else {
			return methods.init.apply( this, arguments );
		}
		
	};
	
})(jQuery);

/*
Plugin Name: 	matchHeight
Written by: 	Okler Themes - (http://www.okler.net)
Theme Version:	7.0.0

Based on:

	jquery.matchHeight-min.js v0.5.2
	Licensed under the terms of the MIT license.

*/

;(function($) {
	/*
	*  internal
	*/

	var _previousResizeWidth = -1,
		_updateTimeout = -1;

	/*
	*  _rows
	*  utility function returns array of jQuery selections representing each row
	*  (as displayed after float wrapping applied by browser)
	*/

	var _rows = function(elements) {
		var tolerance = 1,
			$elements = $(elements),
			lastTop = null,
			rows = [];

		// group elements by their top position
		$elements.each(function(){
			var $that = $(this),
				top = $that.offset().top - _parse($that.css('margin-top')),
				lastRow = rows.length > 0 ? rows[rows.length - 1] : null;

			if (lastRow === null) {
				// first item on the row, so just push it
				rows.push($that);
			} else {
				// if the row top is the same, add to the row group
				if (Math.floor(Math.abs(lastTop - top)) <= tolerance) {
					rows[rows.length - 1] = lastRow.add($that);
				} else {
					// otherwise start a new row group
					rows.push($that);
				}
			}

			// keep track of the last row top
			lastTop = top;
		});

		return rows;
	};

	/*
	*  _parse
	*  value parse utility function
	*/

	var _parse = function(value) {
		// parse value and convert NaN to 0
		return parseFloat(value) || 0;
	};

	/*
	*  _parseOptions
	*  handle plugin options
	*/

	var _parseOptions = function(options) {
		var opts = {
			byRow: true,
			remove: false,
			property: 'height'
		};

		if (typeof options === 'object') {
			return $.extend(opts, options);
		}

		if (typeof options === 'boolean') {
			opts.byRow = options;
		} else if (options === 'remove') {
			opts.remove = true;
		}

		return opts;
	};

	/*
	*  matchHeight
	*  plugin definition
	*/

	var matchHeight = $.fn.matchHeight = function(options) {
		var opts = _parseOptions(options);

		// handle remove
		if (opts.remove) {
			var that = this;

			// remove fixed height from all selected elements
			this.css(opts.property, '');

			// remove selected elements from all groups
			$.each(matchHeight._groups, function(key, group) {
				group.elements = group.elements.not(that);
			});

			// TODO: cleanup empty groups

			return this;
		}

		if (this.length <= 1)
			return this;

		// keep track of this group so we can re-apply later on load and resize events
		matchHeight._groups.push({
			elements: this,
			options: opts
		});

		// match each element's height to the tallest element in the selection
		matchHeight._apply(this, opts);

		return this;
	};

	/*
	*  plugin global options
	*/

	matchHeight._groups = [];
	matchHeight._throttle = 80;
	matchHeight._maintainScroll = false;
	matchHeight._beforeUpdate = null;
	matchHeight._afterUpdate = null;

	/*
	*  matchHeight._apply
	*  apply matchHeight to given elements
	*/

	matchHeight._apply = function(elements, options) {
		var opts = _parseOptions(options),
			$elements = $(elements),
			rows = [$elements];

		// take note of scroll position
		var scrollTop = $(window).scrollTop(),
			htmlHeight = $('html').outerHeight(true);

		// get hidden parents
		var $hiddenParents = $elements.parents().filter(':hidden');

		// cache the original inline style
		$hiddenParents.each(function() {
			var $that = $(this);
			$that.data('style-cache', $that.attr('style'));
		});

		// temporarily must force hidden parents visible
		$hiddenParents.css('display', 'block');

		// get rows if using byRow, otherwise assume one row
		if (opts.byRow) {

			// must first force an arbitrary equal height so floating elements break evenly
			$elements.each(function() {
				var $that = $(this),
					display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';

				// cache the original inline style
				$that.data('style-cache', $that.attr('style'));

				$that.css({
					'display': display,
					'padding-top': '0',
					'padding-bottom': '0',
					'margin-top': '0',
					'margin-bottom': '0',
					'border-top-width': '0',
					'border-bottom-width': '0',
					'height': '100px'
				});
			});

			// get the array of rows (based on element top position)
			rows = _rows($elements);

			// revert original inline styles
			$elements.each(function() {
				var $that = $(this);
				$that.attr('style', $that.data('style-cache') || '');
			});
		}

		$.each(rows, function(key, row) {
			var $row = $(row),
				maxHeight = 0;

			// skip apply to rows with only one item
			if (opts.byRow && $row.length <= 1) {
				$row.css(opts.property, '');
				return;
			}

			// iterate the row and find the max height
			$row.each(function(){
				var $that = $(this),
					display = $that.css('display') === 'inline-block' ? 'inline-block' : 'block';

				// ensure we get the correct actual height (and not a previously set height value)
				var css = { 'display': display };
				css[opts.property] = '';
				$that.css(css);

				// find the max height (including padding, but not margin)
				if ($that.outerHeight(false) > maxHeight)
					maxHeight = $that.outerHeight(false);

				// revert display block
				$that.css('display', '');
			});

			// iterate the row and apply the height to all elements
			$row.each(function(){
				var $that = $(this),
					verticalPadding = 0;

				// handle padding and border correctly (required when not using border-box)
				if ($that.css('box-sizing') !== 'border-box') {
					verticalPadding += _parse($that.css('border-top-width')) + _parse($that.css('border-bottom-width'));
					verticalPadding += _parse($that.css('padding-top')) + _parse($that.css('padding-bottom'));
				}

				// set the height (accounting for padding and border)
				$that.css(opts.property, maxHeight - verticalPadding);
			});
		});

		// revert hidden parents
		$hiddenParents.each(function() {
			var $that = $(this);
			$that.attr('style', $that.data('style-cache') || null);
		});

		// restore scroll position if enabled
		if (matchHeight._maintainScroll)
			$(window).scrollTop((scrollTop / htmlHeight) * $('html').outerHeight(true));

		return this;
	};

	/*
	*  matchHeight._applyDataApi
	*  applies matchHeight to all elements with a data-match-height attribute
	*/

	matchHeight._applyDataApi = function() {
		var groups = {};

		// generate groups by their groupId set by elements using data-match-height
		$('[data-match-height], [data-mh]').each(function() {
			var $this = $(this),
				groupId = $this.attr('data-match-height') || $this.attr('data-mh');
			if (groupId in groups) {
				groups[groupId] = groups[groupId].add($this);
			} else {
				groups[groupId] = $this;
			}
		});

		// apply matchHeight to each group
		$.each(groups, function() {
			this.matchHeight(true);
		});
	};

	/*
	*  matchHeight._update
	*  updates matchHeight on all current groups with their correct options
	*/

	var _update = function(event) {
		if (matchHeight._beforeUpdate)
			matchHeight._beforeUpdate(event, matchHeight._groups);

		$.each(matchHeight._groups, function() {
			matchHeight._apply(this.elements, this.options);
		});

		if (matchHeight._afterUpdate)
			matchHeight._afterUpdate(event, matchHeight._groups);
	};

	matchHeight._update = function(throttle, event) {
		// prevent update if fired from a resize event
		// where the viewport width hasn't actually changed
		// fixes an event looping bug in IE8
		if (event && event.type === 'resize') {
			var windowWidth = $(window).width();
			if (windowWidth === _previousResizeWidth)
				return;
			_previousResizeWidth = windowWidth;
		}

		// throttle updates
		if (!throttle) {
			_update(event);
		} else if (_updateTimeout === -1) {
			_updateTimeout = setTimeout(function() {
				_update(event);
				_updateTimeout = -1;
			}, matchHeight._throttle);
		}
	};

	/*
	*  bind events
	*/

	// apply on DOM ready event
	$(matchHeight._applyDataApi);

	// update heights on load and resize events
	$(window).bind('load', function(event) {
		matchHeight._update(false, event);
	});

	// throttled update heights on resize events
	$(window).bind('resize orientationchange', function(event) {
		matchHeight._update(true, event);
	});

})(jQuery);

/*
Plugin Name: 	jQuery.pin
Written by: 	Okler Themes - (http://www.okler.net)
Theme Version:	7.0.0

Based on:

	https://github.com/webpop/jquery.pin
	Licensed under the terms of the MIT license.

*/
(function ($) {
	"use strict";
	$.fn.pin = function (options) {
		var scrollY = 0, elements = [], disabled = false, $window = $(window);

		options = options || {};

		var recalculateLimits = function () {
			for (var i=0, len=elements.length; i<len; i++) {
				var $this = elements[i];

				if (options.minWidth && $window.width() <= options.minWidth) {
					if ($this.parent().is(".pin-wrapper")) { $this.unwrap(); }
					$this.css({width: "", left: "", top: "", position: ""});
					if (options.activeClass) { $this.removeClass(options.activeClass); }
					disabled = true;
					continue;
				} else {
					disabled = false;
				}

				var $container = options.containerSelector ? $this.closest(options.containerSelector) : $(document.body);
				var offset = $this.offset();
				var containerOffset = $container.offset();
				var parentOffset = $this.parent().offset();

				if (!$this.parent().is(".pin-wrapper")) {
					$this.wrap("<div class='pin-wrapper'>");
				}

				var pad = $.extend({
				  top: 0,
				  bottom: 0
				}, options.padding || {});

				$this.data("pin", {
					pad: pad,
					from: (options.containerSelector ? containerOffset.top : offset.top) - pad.top,
					to: containerOffset.top + $container.height() - $this.outerHeight() - pad.bottom,
					end: containerOffset.top + $container.height(),
					parentTop: parentOffset.top
				});

				$this.css({width: $this.outerWidth()});
				$this.parent().css("height", $this.outerHeight());
			}
		};

		var onScroll = function () {
			if (disabled) { return; }

			scrollY = $window.scrollTop();

			var elmts = [];
			for (var i=0, len=elements.length; i<len; i++) {          
				var $this = $(elements[i]),
					data  = $this.data("pin");

				if (!data) { // Removed element
				  continue;
				}

				elmts.push($this); 
				  
				var from = data.from - data.pad.bottom,
					to = data.to - data.pad.top;
			  
				if (from + $this.outerHeight() > data.end) {
					$this.css('position', '');
					continue;
				}
			  
				if (from < scrollY && to > scrollY) {
					!($this.css("position") == "fixed") && $this.css({
						left: $this.offset().left,
						top: data.pad.top
					}).css("position", "fixed");
					if (options.activeClass) { $this.addClass(options.activeClass); }
				} else if (scrollY >= to) {
					$this.css({
						left: "",
						top: to - data.parentTop + data.pad.top
					}).css("position", "absolute");
					if (options.activeClass) { $this.addClass(options.activeClass); }
				} else {
					$this.css({position: "", top: "", left: ""});
					if (options.activeClass) { $this.removeClass(options.activeClass); }
				}
		  }
		  elements = elmts;
		};

		var update = function () { recalculateLimits(); onScroll(); };

		this.each(function () {
			var $this = $(this), 
				data  = $(this).data('pin') || {};

			if (data && data.update) { return; }
			elements.push($this);
			$("img", this).one("load", recalculateLimits);
			data.update = update;
			$(this).data('pin', data);
		});

		$window.scroll(onScroll);
		$window.resize(function () { recalculateLimits(); });
		recalculateLimits();

		$window.on('load', update);

		return this;
	  };
})(jQuery);

/*
Browser Workarounds
*/
if (/iPad|iPhone|iPod/.test(navigator.platform)) {

	// iPad/Iphone/iPod Hover Workaround
	$(document).ready(function($) {
		$('.thumb-info').attr('onclick', 'return true');
	});
}

/* jQuery-FontSpy.js v3.0.0
 * https://github.com/patrickmarabeas/jQuery-FontSpy.js
 *
 * Copyright 2013, Patrick Marabeas http://pulse-dev.com
 * Released under the MIT license
 * http://opensource.org/licenses/mit-license.php
 *
 * Date: 02/11/2015
 */

(function( w, $ ) {

  fontSpy = function  ( fontName, conf ) {
	var $html = $('html'),
		$body = $('body'),
		fontFamilyName = fontName;

		// Throw error if fontName is not a string or not is left as an empty string
		if (typeof fontFamilyName !== 'string' || fontFamilyName === '') {
		  throw 'A valid fontName is required. fontName must be a string and must not be an empty string.';
		}

	var defaults = {
		font: fontFamilyName,
		fontClass: fontFamilyName.toLowerCase().replace( /\s/g, '' ),
		success: function() {},
		failure: function() {},
		testFont: 'Courier New',
		testString: 'QW@HhsXJ',
		glyphs: '',
		delay: 50,
		timeOut: 1000,
		callback: $.noop
	};

	var config = $.extend( defaults, conf );

	var $tester = $('<span>' + config.testString+config.glyphs + '</span>')
		.css('position', 'absolute')
		.css('top', '-9999px')
		.css('left', '-9999px')
		.css('visibility', 'hidden')
		.css('fontFamily', config.testFont)
		.css('fontSize', '250px');

	$body.append($tester);

	var fallbackFontWidth = $tester.outerWidth();

	$tester.css('fontFamily', config.font + ',' + config.testFont);

	var failure = function () {
	  $html.addClass("no-"+config.fontClass);
	  if( config && config.failure ) {
		config.failure();
	  }
	  config.callback(new Error('FontSpy timeout'));
	  $tester.remove();
	};

	var success = function () {
	  config.callback();
	  $html.addClass(config.fontClass);
	  if( config && config.success ) {
		config.success();
	  }
	  $tester.remove();
	};

	var retry = function () {
	  setTimeout(checkFont, config.delay);
	  config.timeOut = config.timeOut - config.delay;
	};

	var checkFont = function () {
	  var loadedFontWidth = $tester.outerWidth();

	  if (fallbackFontWidth !== loadedFontWidth){
		success();
	  } else if(config.timeOut < 0) {
		failure();
	  } else {
		retry();
	  }
	}

	checkFont();
	}
  })( this, jQuery );

/* waitForImages jQuery Plugin - v2.4.0 - 2018-02-13
 * https://github.com/alexanderdickson/waitForImages
 *
 * Copyright (c) 2016 Alex Dickson; Licensed MIT
 */
;(function (factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD. Register as an anonymous module.
		define(['jquery'], factory);
	} else if (typeof exports === 'object') {
		// CommonJS / nodejs module
		module.exports = factory(require('jquery'));
	} else {
		// Browser globals
		factory(jQuery);
	}
}(function ($) {
	// Namespace all events.
	var eventNamespace = 'waitForImages';

	// Is srcset supported by this browser?
	var hasSrcset = (function(img) {
		return img.srcset && img.sizes;
	})(new Image());

	// CSS properties which contain references to images.
	$.waitForImages = {
		hasImageProperties: [
			'backgroundImage',
			'listStyleImage',
			'borderImage',
			'borderCornerImage',
			'cursor'
		],
		hasImageAttributes: ['srcset']
	};

	// Custom selector to find all `img` elements with a valid `src` attribute.
	$.expr.pseudos['has-src'] = function (obj) {
		// Ensure we are dealing with an `img` element with a valid
		// `src` attribute.
		return $(obj).is('img[src][src!=""]');
	};

	// Custom selector to find images which are not already cached by the
	// browser.
	$.expr.pseudos.uncached = function (obj) {
		// Ensure we are dealing with an `img` element with a valid
		// `src` attribute.
		if (!$(obj).is(':has-src')) {
			return false;
		}

		return !obj.complete;
	};

	$.fn.waitForImages = function () {

		var allImgsLength = 0;
		var allImgsLoaded = 0;
		var deferred = $.Deferred();
		var originalCollection = this;
		var allImgs = [];

		// CSS properties which may contain an image.
		var hasImgProperties = $.waitForImages.hasImageProperties || [];
		// Element attributes which may contain an image.
		var hasImageAttributes = $.waitForImages.hasImageAttributes || [];
		// To match `url()` references.
		// Spec: http://www.w3.org/TR/CSS2/syndata.html#value-def-uri
		var matchUrl = /url\(\s*(['"]?)(.*?)\1\s*\)/g;

		var finishedCallback;
		var eachCallback;
		var waitForAll;

		// Handle options object (if passed).
		if ($.isPlainObject(arguments[0])) {

			waitForAll = arguments[0].waitForAll;
			eachCallback = arguments[0].each;
			finishedCallback = arguments[0].finished;

		} else {

			// Handle if using deferred object and only one param was passed in.
			if (arguments.length === 1 && $.type(arguments[0]) === 'boolean') {
				waitForAll = arguments[0];
			} else {
				finishedCallback = arguments[0];
				eachCallback = arguments[1];
				waitForAll = arguments[2];
			}

		}

		// Handle missing callbacks.
		finishedCallback = finishedCallback || $.noop;
		eachCallback = eachCallback || $.noop;

		// Convert waitForAll to Boolean.
		waitForAll = !! waitForAll;

		// Ensure callbacks are functions.
		if (!$.isFunction(finishedCallback) || !$.isFunction(eachCallback)) {
			throw new TypeError('An invalid callback was supplied.');
		}

		this.each(function () {
			// Build a list of all imgs, dependent on what images will
			// be considered.
			var obj = $(this);

			if (waitForAll) {

				// Get all elements (including the original), as any one of
				// them could have a background image.
				obj.find('*').addBack().each(function () {
					var element = $(this);

					// If an `img` element, add it. But keep iterating in
					// case it has a background image too.
					if (element.is('img:has-src') &&
						!element.is('[srcset]')) {
						allImgs.push({
							src: element.attr('src'),
							element: element[0]
						});
					}

					$.each(hasImgProperties, function (i, property) {
						var propertyValue = element.css(property);
						var match;

						// If it doesn't contain this property, skip.
						if (!propertyValue) {
							return true;
						}

						// Get all url() of this element.
						while (match = matchUrl.exec(propertyValue)) {
							allImgs.push({
								src: match[2],
								element: element[0]
							});
						}
					});

					$.each(hasImageAttributes, function (i, attribute) {
						var attributeValue = element.attr(attribute);
						var attributeValues;

						// If it doesn't contain this property, skip.
						if (!attributeValue) {
							return true;
						}

						allImgs.push({
							src: element.attr('src'),
							srcset: element.attr('srcset'),
							element: element[0]
						});
					});
				});
			} else {
				// For images only, the task is simpler.
				obj.find('img:has-src')
					.each(function () {
					allImgs.push({
						src: this.src,
						element: this
					});
				});
			}
		});

		allImgsLength = allImgs.length;
		allImgsLoaded = 0;

		// If no images found, don't bother.
		if (allImgsLength === 0) {
			finishedCallback.call(originalCollection);
			deferred.resolveWith(originalCollection);
		}

		// Now that we've found all imgs in all elements in this,
		// load them and attach callbacks.
		$.each(allImgs, function (i, img) {

			var image = new Image();
			var events =
			  'load.' + eventNamespace + ' error.' + eventNamespace;

			// Handle the image loading and error with the same callback.
			$(image).one(events, function me (event) {
				// If an error occurred with loading the image, set the
				// third argument accordingly.
				var eachArguments = [
					allImgsLoaded,
					allImgsLength,
					event.type == 'load'
				];
				allImgsLoaded++;

				eachCallback.apply(img.element, eachArguments);
				deferred.notifyWith(img.element, eachArguments);

				// Unbind the event listeners. I use this in addition to
				// `one` as one of those events won't be called (either
				// 'load' or 'error' will be called).
				$(this).off(events, me);

				if (allImgsLoaded == allImgsLength) {
					finishedCallback.call(originalCollection[0]);
					deferred.resolveWith(originalCollection[0]);
					return false;
				}

			});

			if (hasSrcset && img.srcset) {
				image.srcset = img.srcset;
				image.sizes = img.sizes;
			}
			image.src = img.src;
		});

		return deferred.promise();

	};
}));

// Tooltip and Popover
(function($) {
	$('[data-toggle="tooltip"]').tooltip();
	$('[data-toggle="popover"]').popover();
})(jQuery);

// Tabs
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
	$(this).parents('.nav-tabs').find('.active').removeClass('active');
	$(this).addClass('active').parent().addClass('active');
});

// On Load Scroll
if( !$('html').hasClass('disable-onload-scroll') && window.location.hash ) {

	window.scrollTo(0, 0);

	$(window).on('load', function() {
		setTimeout(function() {

			var target = window.location.hash,
				offset = ( $(window).width() < 768 ) ? 180 : 90;

			$('body').addClass('scrolling');

			$('html, body').animate({
				scrollTop: $(target).offset().top - offset
			}, 600, 'easeOutQuad', function() {
				$('body').removeClass('scrolling');
			});

		}, 1);
	});
}

/*
* Title Border
*/
if($('[data-title-border]').get(0)) {

	var $pageHeaderTitleBorder = $('<span class="page-header-title-border"></span>'),
		$pageHeaderTitle = $('[data-title-border]'),
		$window = $(window);

	$pageHeaderTitle.before($pageHeaderTitleBorder);

	var setPageHeaderTitleBorderWidth = function() {
		$pageHeaderTitleBorder.width($pageHeaderTitle.width());
	}

	$window.afterResize(function(){
		setPageHeaderTitleBorderWidth();
	});

	setPageHeaderTitleBorderWidth();

	$pageHeaderTitleBorder.addClass('visible');
}

/*
* Footer Reveal
*/
(function($) {
	var $footerReveal = {
		$wrapper: $('.footer-reveal'),
		init: function() {
			var self = this;

			self.build();
			self.events();
		},
		build: function() {
			var self = this, 
				footer_height = self.$wrapper.outerHeight(true),
				window_height = ( $(window).height() - $('.header-body').height() );

			if( footer_height > window_height ) {
				$('#footer').removeClass('footer-reveal');
				$('.main').css('margin-bottom', 0);
			} else {
				$('#footer').addClass('footer-reveal');
				$('.main').css('margin-bottom', footer_height);
			}

		},
		events: function() {
			var self = this,
				$window = $(window);

			$window.on('load', function(){
				$window.afterResize(function(){
					self.build();
				});
			});
		}
	}

	if( $('.footer-reveal').get(0) ) {
		$footerReveal.init();
	}
})(jQuery);

/*
* Text Rotator
*/
(function($) {
	$.fn.extend({
		textRotator: function(options) {

			var defaults = {
				fadeSpeed: 500,
				pauseSpeed: 100,
				child: null
			};

			var options = $.extend(defaults, options);

			return this.each(function() {
				var o = options;
				var obj = $(this);
				var items = $(obj.children(), obj);
				items.each(function() {
					$(this).hide();
				})
				if (!o.child) {
					var next = $(obj).children(':first');
				} else {
					var next = o.child;
				}
				$(next).fadeIn(o.fadeSpeed, function() {
					$(next).delay(o.pauseSpeed).fadeOut(o.fadeSpeed, function() {
						var next = $(this).next();
						if (next.length == 0) {
							next = $(obj).children(':first');
						}
						$(obj).textRotator({
							child: next,
							fadeSpeed: o.fadeSpeed,
							pauseSpeed: o.pauseSpeed
						});
					})
				});
			});
		}
	});
})(jQuery);

/*
* Notice Top bar
*/
(function($) {
	var $noticeTopBar = {
		$wrapper: $('.notice-top-bar'),
		$body: $('.body'),
		init: function() {
			var self = this;

			self.build();
		},
		build: function(){
			var self = this;

			$(window).on('load', function(){
				setTimeout(function(){
					self.$body.css({
						'margin-top': self.$wrapper.outerHeight(),
						'transition': 'ease margin 300ms'
					});

					$('#noticeTopBarContent').textRotator({
						fadeSpeed: 500,
						pauseSpeed: 5000
					});

				}, 1000);
			});
		}
	}

	if( $('.notice-top-bar').get(0) ) {
		$noticeTopBar.init();
	}
})(jQuery);

/*
* Theme Switcher
*/
(function($) {
	$('.close-theme-switcher-bar').on('click', function(){
		$(this).closest('.header-top').css({
			height: 0,
			'min-height': 0,
			overflow: 'hidden'
		})
	});
})(jQuery);

/*
* Tab
*/
(function($) {
	$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
		var $tabPane = $($(e.target).attr('href'));

		if($tabPane.get(0)) {

			// Carousel Refresh
			$tabPane.find('.owl-carousel').trigger('refresh.owl.carousel');
		}
	});
})(jQuery);

/*
* Tab to accordion
*/
/*
(function($) {

	"use strict";
  
	  var defaults = {
		  accordionOn: ['xs'] // xs, sm, md, lg
	  };
  
	  $.fn.responsiveTabs = function (options) {
  
		  var config = $.extend({}, defaults, options),
		  accordion = '';
  
		  $.each(config.accordionOn, function (index, value) {
			  accordion += ' accordion-' + value;
		  });
  
	  return this.each(function () {
  
		var $self = $(this),
			$navTabs = $self.find('> li > a'),
			$tabContent = $($navTabs.first().attr('href')).parent('.tab-content'),
			$tabs = $tabContent.children('.tab-pane');
  
		// Wrap the tabs
		$self.add($tabContent).wrapAll('<div class="responsive-tabs-container" />');
  
		var $container = $self.parent('.responsive-tabs-container');
  
		$container.addClass(accordion);
  
		// Duplicate links for accordion
		$navTabs.each(function (i) {
		  var $this = $(this),
			  id = $this.attr('href'),
			  active = '',
			  first = '',
			  last = '';
  
		  // Add active class
		  if ($this.parent('li').hasClass('active')) {
			active = ' active';
		  }
  
		  // Add first class
		  if (i === 0) {
			first = ' first';
		  }
  
		  // Add last class
		  if (i === $navTabs.length - 1) {
			last = ' last';
		  }
  
		  $this.clone(false).addClass('accordion-link' + active + first + last).insertBefore(id);
		});
  
		var $accordionLinks = $tabContent.children('.accordion-link');
  
		// Tabs Click Event
		$navTabs.on('click', function (event) {
		  event.preventDefault();
  
		  var $this = $(this),
			  $li = $this.parent('li'),
			  $siblings = $li.siblings('li'),
			  id = $this.attr('href'),
			  $accordionLink = $tabContent.children('a[href="' + id + '"]');
  
		  if (!$li.hasClass('active')) {
			$li.addClass('active');
			$siblings.removeClass('active');
  
			$tabs.removeClass('active');
			$(id).addClass('active');
  
			$accordionLinks.removeClass('active');
			$accordionLink.addClass('active');
		  }
		});
  
		// Accordion Click Event
		$accordionLinks.on('click', function (event) {
		  event.preventDefault();
  
		  var $this = $(this),
			  id = $this.attr('href'),
			  $tabLink = $self.find('li > a[href="' + id + '"]').parent('li');
  
		  if (!$this.hasClass('active')) {
			$accordionLinks.removeClass('active');
			$this.addClass('active');
  
			$tabs.removeClass('active');
			$(id).addClass('active');
  
			$navTabs.parent('li').removeClass('active');
			$tabLink.addClass('active');

			$(id).collapse('dispose');
		  }
		});
  
	  });
  
	  };
  
  }(jQuery));

(function($) {
	$('.nav-tabs').responsiveTabs({
		accordionOn: ['xs', 'sm'] // xs, sm, md, lg
	  });
})(jQuery);
*/

/*
jQuery Hover3d
=================================================
Version: 1.1.0
Author: Rian Ariona
Website: http://ariona.net
Docs: http://ariona.github.io/hover3d
Repo: http://github.com/ariona/hover3d
Issues: http://github.com/ariona/hover3d/issues
*/
(function($){
	
	$.fn.hover3d = function(options){
		
		var settings = $.extend({
			selector      : null,
			perspective   : 1000,
			sensitivity   : 20,
			invert        : false,
			shine         : false,
			hoverInClass  : "hover-in",
			hoverOutClass : "hover-out",
			hoverClass    : "hover-3d"
		}, options);
		
		if (!$.browser.mobile) {

			return this.each(function(){
				var $this = $(this),
					$card = $this.find(settings.selector);
					currentX = 0;
					currentY = 0;

				if( settings.shine ){
					$card.append('<div class="shine"></div>');
				}
				var $shine = $(this).find(".shine");

				// Set perspective and transformStyle value
				// for element and 3d object
				$shine.css({
					position  : "absolute",
					top       : 0,
					left      : 0,
					bottom    : 0,
					right     : 0,
					transform : 'translateZ(1px)',
					"z-index" : 9
				});
				
				// Mouse Enter function, this will add hover-in
				// Class so when mouse over it will add transition
				// based on hover-in class
				function enter(event){
					$card.addClass(settings.hoverInClass+" "+settings.hoverClass);
					currentX = currentY = 0;
					setTimeout(function(){
						$card.removeClass(settings.hoverInClass);
					}, 400);
				}
				
				// Mouse movement Parallax effect
				function move(event){
					
					var w      = $card.innerWidth(),
						h      = $card.innerHeight(),
						currentX = Math.round(event.pageX - $card.offset().left),
						currentY = Math.round(event.pageY - $card.offset().top),
						ax 	   = settings.invert ?  ( w / 2 - currentX)/settings.sensitivity : -( w / 2 - currentX)/settings.sensitivity,
						ay     = settings.invert ? -( h / 2 - currentY)/settings.sensitivity :  ( h / 2 - currentY)/settings.sensitivity,
						dx     = currentX - w / 2,
						dy     = currentY - h / 2,
						theta  = Math.atan2(dy, dx),
						angle  = theta * 180 / Math.PI - 90;

						
					if (angle < 0) {
						angle  = angle + 360;
					}
					

					$card.css({
						transform      : "perspective(1000px) rotateY("+ax/2+"deg) rotateX("+ay/2+"deg) translate3d("+ax/2+"px, 0, 0) scale(1.05)"
					});

					$card.find('.thumb-info-action').css({
						transform      : "perspective(1000px) rotateY("+ax/5+"deg) rotateX("+ay/5+"deg) translate3d("+ax/5+"px, "+((ay/5) - 15)+"px, 0)"
					});

					var t_y = ay/5 + 'px';
					if( $card.find('.thumb-info-title').css('top') == '50%' ) {
						t_y = ((ay/5) - 47) + '%';
					}

					$card.find('.thumb-info-title').css({
						transform      : "perspective(1000px) rotateY("+ax/5+"deg) rotateX("+ay/5+"deg) translate3d("+ax/5+"px, "+ t_y +", 0)",
					});

					$shine.css('background', 'linear-gradient(' + angle + 'deg, rgba(255,255,255,' + event.offsetY / h * .5 + ') 0%,rgba(255,255,255,0) 80%)');
				}
				
				// Mouse leave function, will set the transform
				// property to 0, and add transition class
				// for exit animation
				function leave(){
					$card.addClass(settings.hoverOutClass+" "+settings.hoverClass);
					$card.css({
						transform      : "none"
					});
					setTimeout( function(){
						$card.removeClass(settings.hoverOutClass+" "+settings.hoverClass);
						currentX = currentY = 0;
					}, 400 );
				}
				
				// Mouseenter event binding
				$this.on( "mouseenter", function(){
					return enter();
				});
				
				// Mousemove event binding
				$this.on( "mousemove", function(event){
					return move(event);
				});
				
				// Mouseleave event binding
				$this.on( "mouseleave", function(){
					return leave();
				});
				
			});

		}
		
	};

}(jQuery));

(function($) {
	if ($.isFunction($.fn['hover3d'])) {

		$(function() {
			$('.hover-effect-3d').each(function() {
				var $this = $(this);

				$this.hover3d({
					selector: ".thumb-info"
				});
			});
		});

	}
}).apply(this, [jQuery]);

/*
Plugin Name: 	Animated Headlines
Written by: 	Codyhouse - (https://codyhouse.co/demo/animated-headlines/index.html)
*/
jQuery(document).ready(function($){
	//set animation timing
	var animationDelay = 2500,
		//loading bar effect
		barAnimationDelay = 3800,
		barWaiting = barAnimationDelay - 3000, //3000 is the duration of the transition on the loading bar - set in the scss/css file
		//letters effect
		lettersDelay = 50,
		//type effect
		typeLettersDelay = 150,
		selectionDuration = 500,
		typeAnimationDelay = selectionDuration + 800,
		//clip effect 
		revealDuration = 600,
		revealAnimationDelay = 1500;
	
	initHeadline();	

	function initHeadline() {
		//insert <i> element for each letter of a changing word
		singleLetters($('.word-rotator.letters').find('b'));
		//initialise headline animation
		animateHeadline($('.word-rotator'));
	}

	function singleLetters($words) {
		$words.each(function(){
			var word = $(this),
				letters = word.text().split(''),
				selected = word.hasClass('is-visible');
			for (i in letters) {
				if(word.parents('.rotate-2').length > 0) letters[i] = '<em>' + letters[i] + '</em>';
				letters[i] = (selected) ? '<i class="in">' + letters[i] + '</i>': '<i>' + letters[i] + '</i>';
			}
		    var newLetters = letters.join('');
		    word.html(newLetters).css('opacity', 1);
		});
	}

	function animateHeadline($headlines) {
		var duration = animationDelay;
		$headlines.each(function(){
			var headline = $(this);
			
			if(headline.hasClass('loading-bar')) {
				duration = barAnimationDelay;
				setTimeout(function(){ headline.find('.word-rotator-words').addClass('is-loading') }, barWaiting);
			} else if (headline.hasClass('clip')){
				var spanWrapper = headline.find('.word-rotator-words'),
					newWidth = spanWrapper.outerWidth() + 10
				spanWrapper.css('width', newWidth);
			} else if (!headline.hasClass('type') ) {
				//assign to .word-rotator-words the width of its longest word
				var words = headline.find('.word-rotator-words b'),
					width = 0;
				words.each(function(){
					var wordWidth = $(this).outerWidth();
				    if (wordWidth > width) width = wordWidth;
				});
				headline.find('.word-rotator-words').css('width', width);
			};

			//trigger animation
			setTimeout(function(){ hideWord( headline.find('.is-visible').eq(0) ) }, duration);
		});
	}

	function hideWord($word) {
		var nextWord = takeNext($word);
		
		if($word.parents('.word-rotator').hasClass('type')) {
			var parentSpan = $word.parent('.word-rotator-words');
			parentSpan.addClass('selected').removeClass('waiting');	
			setTimeout(function(){ 
				parentSpan.removeClass('selected'); 
				$word.removeClass('is-visible').addClass('is-hidden').children('i').removeClass('in').addClass('out');
			}, selectionDuration);
			setTimeout(function(){ showWord(nextWord, typeLettersDelay) }, typeAnimationDelay);
		
		} else if($word.parents('.word-rotator').hasClass('letters')) {
			var bool = ($word.children('i').length >= nextWord.children('i').length) ? true : false;
			hideLetter($word.find('i').eq(0), $word, bool, lettersDelay);
			showLetter(nextWord.find('i').eq(0), nextWord, bool, lettersDelay);

		}  else if($word.parents('.word-rotator').hasClass('clip')) {
			$word.parents('.word-rotator-words').animate({ width : '2px' }, revealDuration, function(){
				switchWord($word, nextWord);
				showWord(nextWord);
			});

		} else if ($word.parents('.word-rotator').hasClass('loading-bar')){
			$word.parents('.word-rotator-words').removeClass('is-loading');
			switchWord($word, nextWord);
			setTimeout(function(){ hideWord(nextWord) }, barAnimationDelay);
			setTimeout(function(){ $word.parents('.word-rotator-words').addClass('is-loading') }, barWaiting);

		} else {
			switchWord($word, nextWord);
			setTimeout(function(){ hideWord(nextWord) }, animationDelay);
		}
	}

	function showWord($word, $duration) {
		if($word.parents('.word-rotator').hasClass('type')) {
			showLetter($word.find('i').eq(0), $word, false, $duration);
			$word.addClass('is-visible').removeClass('is-hidden');

		}  else if($word.parents('.word-rotator').hasClass('clip')) {
			$word.parents('.word-rotator-words').animate({ 'width' : $word.outerWidth() + 10 }, revealDuration, function(){ 
				setTimeout(function(){ hideWord($word) }, revealAnimationDelay); 
			});
		}
	}

	function hideLetter($letter, $word, $bool, $duration) {
		$letter.removeClass('in').addClass('out');
		
		if(!$letter.is(':last-child')) {
		 	setTimeout(function(){ hideLetter($letter.next(), $word, $bool, $duration); }, $duration);  
		} else if($bool) { 
		 	setTimeout(function(){ hideWord(takeNext($word)) }, animationDelay);
		}

		if($letter.is(':last-child') && $('html').hasClass('no-csstransitions')) {
			var nextWord = takeNext($word);
			switchWord($word, nextWord);
		} 
	}

	function showLetter($letter, $word, $bool, $duration) {
		$letter.addClass('in').removeClass('out');
		
		if(!$letter.is(':last-child')) { 
			setTimeout(function(){ showLetter($letter.next(), $word, $bool, $duration); }, $duration); 
		} else { 
			if($word.parents('.word-rotator').hasClass('type')) { setTimeout(function(){ $word.parents('.word-rotator-words').addClass('waiting'); }, 200);}
			if(!$bool) { setTimeout(function(){ hideWord($word) }, animationDelay) }

			if(!$word.closest('.word-rotator').hasClass('type')) {
				$word.closest('.word-rotator-words').animate({
					width: $word.outerWidth()
				});
			}
		}
	}

	function takeNext($word) {
		return (!$word.is(':last-child')) ? $word.next() : $word.parent().children().eq(0);
	}

	function takePrev($word) {
		return (!$word.is(':first-child')) ? $word.prev() : $word.parent().children().last();
	}

	function switchWord($oldWord, $newWord) {
		$oldWord.removeClass('is-visible').addClass('is-hidden');
		$newWord.removeClass('is-hidden').addClass('is-visible');

		if(!$newWord.closest('.word-rotator').hasClass('clip')) {
			var space = 0,
				delay = ( $newWord.outerWidth() > $oldWord.outerWidth() ) ? 0 : 600;

			if($newWord.closest('.word-rotator').hasClass('loading-bar') || $newWord.closest('.word-rotator').hasClass('slide')) {
				space = 3;
				delay = 0;
			}

			setTimeout(function(){
				$newWord.closest('.word-rotator-words').animate({
					width: $newWord.outerWidth() + space
				});
			}, delay);
		}
	}
});