﻿var DNN_COL_DELIMITER=String.fromCharCode(16);var DNN_ROW_DELIMITER=String.fromCharCode(15);var __dnn_m_bPageLoaded=false;if(window.addEventListener){window.addEventListener("load",__dnn_Page_OnLoad,false)}else{window.attachEvent("onload",__dnn_Page_OnLoad)}function __dnn_ClientAPIEnabled(){return typeof(dnn)!="undefined"&&typeof (dnn.dom)!="undefined"}function __dnn_Page_OnLoad(){if(__dnn_ClientAPIEnabled()){dnn.dom.attachEvent(window,"onscroll",__dnn_bodyscroll)}__dnn_m_bPageLoaded=true}function __dnn_KeyDown(iKeyCode,sFunc,e){if(e==null){e=window.event}if(e.keyCode==iKeyCode){eval(unescape(sFunc));return false}}function __dnn_bodyscroll(){var a=document.forms[0];if(__dnn_ClientAPIEnabled()&&__dnn_m_bPageLoaded&&typeof(a.ScrollTop)!="undefined"){a.ScrollTop.value=document.documentElement.scrollTop?document.documentElement.scrollTop:dnn.dom.getByTagName("body")[0].scrollTop}}function __dnn_setScrollTop(c){if(__dnn_ClientAPIEnabled()){if(c==null){c=document.forms[0].ScrollTop.value}var a=dnn.getVar("ScrollToControl");if(a!=null&&a.length>0){var b=dnn.dom.getById(a);if(b!=null){c=dnn.dom.positioning.elementTop(b);dnn.setVar("ScrollToControl","")}}if(document.getElementsByTagName("html")[0].style.overflow!="hidden"){window.scrollTo(0,c)}}}function __dnn_SetInitialFocus(a){var b=dnn.dom.getById(a);if(b!=null&&__dnn_CanReceiveFocus(b)){b.focus()}}function __dnn_CanReceiveFocus(b){if(b.style.display!="none"&&b.tabIndex>-1&&b.disabled==false&&b.style.visible!="hidden"){var a=b.parentElement;while(a!=null&&a.tagName!="BODY"){if(a.style.display=="none"||a.disabled||a.style.visible=="hidden"){return false}a=a.parentElement}return true}else{return false}}function __dnn_ContainerMaxMin_OnClick(i,b){var g=dnn.dom.getById(b);if(g!=null){var e=i.childNodes[0];var l=dnn.getVar("containerid_"+b);var j=dnn.getVar("cookieid_"+b);var d=e.src.toLowerCase().substr(e.src.lastIndexOf("/"));var a;var h;var k;if(dnn.getVar("min_icon_"+l)){k=dnn.getVar("min_icon_"+l)}else{k=dnn.getVar("min_icon")}if(dnn.getVar("max_icon_"+l)){h=dnn.getVar("max_icon_"+l)}else{h=dnn.getVar("max_icon")}a=h.toLowerCase().substr(h.lastIndexOf("/"));var c=5;var f=dnn.getVar("animf_"+b);if(f!=null){c=new Number(f)}if(d==a){e.src=k;dnn.dom.expandElement(g,c);e.title=dnn.getVar("min_text");if(j!=null){if(dnn.getVar("__dnn_"+l+":defminimized")=="true"){dnn.dom.setCookie(j,"true",365)}else{dnn.dom.deleteCookie(j)}}else{dnn.setVar("__dnn_"+l+"_Visible","true")}}else{e.src=h;dnn.dom.collapseElement(g,c);e.title=dnn.getVar("max_text");if(j!=null){if(dnn.getVar("__dnn_"+l+":defminimized")=="true"){dnn.dom.deleteCookie(j)}else{dnn.dom.setCookie(j,"false",365)}}else{dnn.setVar("__dnn_"+l+"_Visible","false")}}return true}return false}function __dnn_Help_OnClick(a){var b=dnn.dom.getById(a);if(b!=null){if(b.style.display=="none"){b.style.display=""}else{b.style.display="none"}return true}return false}function __dnn_SectionMaxMin(f,c){var d=dnn.dom.getById(c);if(d!=null){var g=f.getAttribute("max_icon");var e=f.getAttribute("min_icon");var a=f.getAttribute("userctr")!=null;var b;if(d.style.display=="none"){f.src=e;d.style.display="";if(a){b="True"}else{dnn.setVar(f.id+":exp",1)}}else{f.src=g;d.style.display="none";if(a){b="False"}else{dnn.setVar(f.id+":exp",0)}}if(a){dnncore.setUserProp(f.getAttribute("userctr"),f.getAttribute("userkey"),b,null)}return true}return false}function __dnn_enableDragDrop(){var b=dnn.getVar("__dnn_dragDrop").split(";");var e;for(var c=0;c<b.length;c++){e=b[c].split(" ");if(e[0].length>0){var a=dnn.dom.getById(e[0]);var d=dnn.dom.getById(e[1]);if(a!=null&&d!=null){a.setAttribute("moduleid",e[2]);dnn.dom.positioning.enableDragAndDrop(a,d,"__dnn_dragComplete()","__dnn_dragOver()")}}}}var __dnn_oPrevSelPane;var __dnn_oPrevSelModule;var __dnn_dragEventCount=0;function __dnn_dragOver(){__dnn_dragEventCount++;if(__dnn_dragEventCount%75!=0){return}var c=dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);var a=__dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);if(__dnn_oPrevSelPane!=null){__dnn_oPrevSelPane.pane.style.border=__dnn_oPrevSelPane.origBorder}if(a!=null){__dnn_oPrevSelPane=a;a.pane.style.border="4px double "+DNN_HIGHLIGHT_COLOR;var e=__dnn_getPaneControlIndex(c,a);var b;var f;for(var d=0;d<a.controls.length;d++){if(e>d&&a.controls[d].id!=c.id){b=a.controls[d]}if(e<=d&&a.controls[d].id!=c.id){f=a.controls[d];break}}if(__dnn_oPrevSelModule!=null){dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border=__dnn_oPrevSelModule.origBorder}if(f!=null){__dnn_oPrevSelModule=f;dnn.dom.getNonTextNode(f.control).style.borderTop="5px groove "+DNN_HIGHLIGHT_COLOR}else{if(b!=null){__dnn_oPrevSelModule=b;dnn.dom.getNonTextNode(b.control).style.borderBottom="5px groove "+DNN_HIGHLIGHT_COLOR}}}}function __dnn_dragComplete(){var f=dnn.dom.getById(dnn.dom.positioning.dragCtr.contID);var d=f.getAttribute("moduleid");if(__dnn_oPrevSelPane!=null){__dnn_oPrevSelPane.pane.style.border=__dnn_oPrevSelPane.origBorder}if(__dnn_oPrevSelModule!=null){dnn.dom.getNonTextNode(__dnn_oPrevSelModule.control).style.border=__dnn_oPrevSelModule.origBorder}var b=__dnn_getMostSelectedPane(dnn.dom.positioning.dragCtr);var e;if(b==null){var a=__dnn_Panes();for(var c=0;c<a.length;c++){if(a[c].id==f.parentNode.id){b=a[c]}}}if(b!=null){e=__dnn_getPaneControlIndex(f,b);__dnn_MoveToPane(b,f,e);dnn.callPostBack("MoveToPane","moduleid="+d,"pane="+b.paneName,"order="+e*2)}}function __dnn_MoveToPane(a,e,d){if(a!=null){var c=new Array();for(var b=d;b<a.controls.length;b++){if(a.controls[b].control.id!=e.id){c[c.length]=a.controls[b].control}dnn.dom.removeChild(a.controls[b].control)}dnn.dom.appendChild(a.pane,e);e.style.top=0;e.style.left=0;e.style.position="relative";for(var b=0;b<c.length;b++){dnn.dom.appendChild(a.pane,c[b])}__dnn_RefreshPanes()}else{e.style.top=0;e.style.left=0;e.style.position="relative"}}function __dnn_RefreshPanes(){var b=dnn.getVar("__dnn_Panes").split(";");var a=dnn.getVar("__dnn_PaneNames").split(";");__dnn_m_aryPanes=new Array();for(var c=0;c<b.length;c++){if(b[c].length>0){__dnn_m_aryPanes[__dnn_m_aryPanes.length]=new __dnn_Pane(dnn.dom.getById(b[c]),a[c])}}}var __dnn_m_aryPanes;var __dnn_m_aryModules;function __dnn_Panes(){if(__dnn_m_aryPanes==null){__dnn_m_aryPanes=new Array();__dnn_RefreshPanes()}return __dnn_m_aryPanes}function __dnn_Modules(a){if(__dnn_m_aryModules==null){__dnn_RefreshPanes()}return __dnn_m_aryModules[a]}function __dnn_getMostSelectedPane(g){var c=new dnn.dom.positioning.dims(g);var f=0;var a;var h;for(var e=0;e<__dnn_Panes().length;e++){var b=__dnn_Panes()[e];var d=new dnn.dom.positioning.dims(b.pane);a=dnn.dom.positioning.elementOverlapScore(d,c);if(a>f){f=a;h=b}}return h}function __dnn_getPaneControlIndex(f,b){if(b==null){return}var a=new dnn.dom.positioning.dims(f);var e;if(b.controls.length==0){return 0}for(var c=0;c<b.controls.length;c++){e=b.controls[c];var d=new dnn.dom.positioning.dims(e.control);if(a.t<d.t){return e.index}}if(e!=null){return e.index+1}else{return 0}}function __dnn_Pane(a,b){this.pane=a;this.id=a.id;this.controls=new Array();this.origBorder=a.style.border;this.paneName=b;var f=0;var e="";for(var d=0;d<a.childNodes.length;d++){var g=a.childNodes[d];if(dnn.dom.isNonTextNode(g)){if(__dnn_m_aryModules==null){__dnn_m_aryModules=new Array()}var c=g.getAttribute("moduleid");if(c!=null&&c.length>0){e+=c+"~";this.controls[this.controls.length]=new __dnn_PaneControl(g,f);__dnn_m_aryModules[c]=g.id;f+=1}}}this.moduleOrder=e}function __dnn_PaneControl(a,b){this.control=a;this.id=a.id;this.index=b;this.origBorder=a.style.border}function __dnn_ShowModalPage(a){dnnModal.show(a,true,550,950,true,"")}function __dnncore(){this.GetUserVal=0;this.SetUserVal=1}__dnncore.prototype={getUserProp:function(b,c,a){this._doUserCallBack(dnncore.GetUserVal,b,c,null,new dnncore.UserPropArgs(b,c,a))},setUserProp:function(c,d,a,b){this._doUserCallBack(dnncore.SetUserVal,c,d,a,new dnncore.UserPropArgs(c,d,b))},_doUserCallBack:function(c,d,e,a,b){if(dnn&&dnn.xmlhttp){var f=c+COL_DELIMITER+d+COL_DELIMITER+e+COL_DELIMITER+a;dnn.xmlhttp.doCallBack("__Page",f,dnncore._callBackSuccess,b,dnncore._callBackFail,null,true,null,0)}else{alert("Client Personalization not enabled")}},_callBackSuccess:function(a,b,c){if(b.pFunc){b.pFunc(b.namingCtr,b.key,a)}},_callBackFail:function(a,b){window.status=a}};__dnncore.prototype.UserPropArgs=function(b,c,a){this.namingCtr=b;this.key=c;this.pFunc=a};var dnncore=new __dnncore();
;;;/*
    RateIt
    version 0.99.2
    03/07/2011
    http://rateit.codeplex.com
    Twitter: @gjunge

*/
(function ($) {
	$.fn.rateit = function (p1, p2) {
		//quick way out.
		var options = {}; var mode = 'init';
		if (this.length == 0) return this;


		var tp1 = $.type(p1);
		if (tp1 == 'object' || p1 === undefined || p1 == null) {
			options = $.extend({}, $.fn.rateit.defaults, p1); //wants to init new rateit plugin(s).
		}
		else if (tp1 == 'string' && p2 === undefined) {
			return this.data('rateit-' + p1); //wants to get a value.
		}
		else if (tp1 == 'string') {
			mode = 'setvalue'
		}

		return this.each(function () {
			var item = $(this);

			//shorten all the item.data('rateit-XXX'), will save space in closure compiler, will be like item.data('XXX') will become x('XXX')
			var itemdata = function (k, v) {
				k = 'rateit-' + k;

				if (arguments.length === 1)
					return item.data(k);

				item.data(k, v);
				return v;
			};

			//add the rate it class.
			if (!item.hasClass('rateit')) item.addClass('rateit');

			var ltr = item.css('direction') != 'rtl';

			// set value mode
			if (mode == 'setvalue') {
				if (!itemdata('init')) throw 'Can\'t set value before init';


				//if readonly now and it wasn't readonly, remove the eventhandlers.
				if (p1 == 'readonly' && !itemdata('readonly')) {
					item.find('.rateit-range').unbind();
					itemdata('wired', false);
				}

				if (itemdata('backingfld')) {
					//if we have a backing field, check which fields we should update. 
					//In case of input[type=range], although we did read its attributes even in browsers that don't support it (using fld.attr())
					//we only update it in browser that support it (&& fld[0].min only works in supporting browsers), not only does it save us from checking if it is range input type, it also is unnecessary.
					var fld = $(itemdata('backingfld'));
					if (p1 == 'value') fld.val(p2);
					if (p1 == 'min' && fld[0].min) fld[0].min = p2;
					if (p1 == 'max' && fld[0].max) fld[0].max = p2;
					if (p1 == 'step' && fld[0].step) fld[0].step = p2;
				}

				itemdata(p1, p2);
			}

			//init rateit plugin
			if (!itemdata('init')) {

				//get our values, either from the data-* html5 attribute or from the options.
				itemdata('min', itemdata('min') || options.min);
				itemdata('max', itemdata('max') || options.max);
				itemdata('step', itemdata('step') || options.step);
				itemdata('readonly', itemdata('readonly') !== undefined ? itemdata('readonly') : options.readonly);
				itemdata('resetable', itemdata('resetable') !== undefined ? itemdata('resetable') : options.resetable);
				itemdata('backingfld', itemdata('backingfld') || options.backingfld);
				itemdata('starwidth', itemdata('starwidth') || options.starwidth);
				itemdata('starheight', itemdata('starheight') || options.starheight);
				itemdata('value', itemdata('value') || options.min);
				//are we LTR or RTL?

				if (itemdata('backingfld')) {
					//if we have a backing field, hide it, and get its value, and override defaults if range.
					var fld = $(itemdata('backingfld'));
					itemdata('value', fld.hide().val());

					if (fld[0].nodeName == 'INPUT') {
						if (fld[0].type == 'range' || fld[0].type == 'text') { //in browsers not support the range type, it defaults to text

							itemdata('min', parseInt(fld.attr('min')) || itemdata('min')); //if we would have done fld[0].min it wouldn't have worked in browsers not supporting the range type.
							itemdata('max', parseInt(fld.attr('max')) || itemdata('max'));
							itemdata('step', parseInt(fld.attr('step')) || itemdata('step'));
						}
					}
					if (fld[0].nodeName == 'SELECT' && fld[0].options.length > 1) {
						itemdata('min', Number(fld[0].options[0].value));
						itemdata('max', Number(fld[0].options[fld[0].length - 1].value));
						itemdata('step', Number(fld[0].options[1].value) - Number(fld[0].options[0].value));
					}
				}

				//Create the necessart tags.
				item.append('<div class="rateit-reset"></div><div class="rateit-range"><div class="rateit-selected" style="height:' + itemdata('starheight') + 'px"></div><div class="rateit-hover" style="height:' + itemdata('starheight') + 'px"></div></div>');

				//if we are in RTL mode, we have to change the float of the "reset button"
				if (!ltr) {
					item.find('.rateit-reset').css('float', 'right');
					item.find('.rateit-selected').addClass('rateit-selected-rtl');
					item.find('.rateit-hover').addClass('rateit-hover-rtl');
				}
				itemdata('init', true);
			}


			//set the range element to fit all the stars.
			var range = item.find('.rateit-range');
			range.width(itemdata('starwidth') * (itemdata('max') - itemdata('min'))).height(itemdata('starheight'));


			//set the value if we have it.
			if (itemdata('value')) {
				var score = (itemdata('value') - itemdata('min')) * itemdata('starwidth');
				item.find('.rateit-selected').width(score);
			}

			var resetbtn = item.find('.rateit-reset');

			var calcRawScore = function (element, event) {
				var pageX = (event.changedTouches) ? event.changedTouches[0].pageX : event.pageX;

				var offsetx = pageX - $(element).offset().left;
				if (!ltr) offsetx = range.width() - offsetx;
				if (offsetx > range.width()) offsetx = range.width();
				if (offsetx < 0) offsetx = 0;

				return score = Math.ceil(offsetx / itemdata('starwidth') * (1 / itemdata('step')));
			};


			//

			if (!itemdata('readonly')) {
				//if we are not read only, add all the events

				//if we have a reset button, set the event handler.
				if (itemdata('resetable')) {
					resetbtn.click(function () {
						itemdata('value', itemdata('min'));
						range.find('.rateit-hover').hide().width(0);
						range.find('.rateit-selected').width(0).show();
						if (itemdata('backingfld')) $(itemdata('backingfld')).val(itemdata('min'));
						item.trigger('reset');
					});

				}
				else {
					resetbtn.hide();
				}



				//when the mouse goes over the range div, we set the "hover" stars.
				if (!itemdata('wired')) {
					range.bind('touchmove touchend', touchHandler); //bind touch events
					range.mousemove(function (e) {
						var score = calcRawScore(this, e);
						var w = score * itemdata('starwidth') * itemdata('step');
						var h = range.find('.rateit-hover');
						if (h.data('width') != w) {
							range.find('.rateit-selected').hide();
							h.width(w).show().data('width', w);
							item.trigger('hover', [(score * itemdata('step')) + itemdata('min')]);
						}
					});
					//when the mouse leaves the range, we have to hide the hover stars, and show the current value.
					range.mouseleave(function (e) {
						range.find('.rateit-hover').hide().width(0).data('width', '');
						item.trigger('hover', [null]);
						range.find('.rateit-selected').show();
					});
					//when we click on the range, we have to set the value, hide the hover.
					range.mouseup(function (e) {
						var score = calcRawScore(this, e);

						var newvalue = (score * itemdata('step')) + itemdata('min');
						itemdata('value', newvalue);
						if (itemdata('backingfld')) {
							$(itemdata('backingfld')).val(newvalue);
						}
						range.find('.rateit-hover').hide();
						range.find('.rateit-selected').width(score * itemdata('starwidth') * itemdata('step')).show();
						item.trigger('hover', [null]).trigger('rated', [newvalue]);
					});

					itemdata('wired', true);
				}
				if (itemdata('resetable')) {
					resetbtn.show();
				}
			}
			else {
				resetbtn.hide();
			}
		});
	};

	//touch converter http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript/
	function touchHandler(event) {

		var touches = event.originalEvent.changedTouches,
                first = touches[0],
                type = "";
		switch (event.type) {
			case "touchmove": type = "mousemove"; break;
			case "touchend": type = "mouseup"; break;
			default: return;
		}

		var simulatedEvent = document.createEvent("MouseEvent");
		simulatedEvent.initMouseEvent(type, true, true, window, 1,
                              first.screenX, first.screenY,
                              first.clientX, first.clientY, false,
                              false, false, false, 0/*left*/, null);

		first.target.dispatchEvent(simulatedEvent);
		event.preventDefault();
	};


	//some default values.
	$.fn.rateit.defaults = { min: 0, max: 5, step: 0.5, starwidth: 16, starheight: 16, readonly: false, resetable: true };
	eds3_5_jq(document).ready(function ($) {
		//invoke it on all div.rateit elements. This could be removed if not wanted.
		$('div.rateit').rateit();
	});
})(eds3_5_jq);
;;;/*!
 * jQuery Cookie Plugin v1.3
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2011, Klaus Hartl
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/GPL-2.0
 */
(function (document, undefined) {
var eds_cookie = function ($) {

	var pluses = /\+/g;

	function raw(s) {
		return s;
	}

	function decoded(s) {
		return decodeURIComponent(s.replace(pluses, ' '));
	}

	var config = $.cookie = function (key, value, options) {

		// write
		if (value !== undefined) {
			options = $.extend({}, config.defaults, options);

			if (value === null) {
				options.expires = -1;
			}

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setDate(t.getDate() + days);
			}

			value = config.json ? JSON.stringify(value) : String(value);

			return (document.cookie = [
				encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path    ? '; path=' + options.path : '',
				options.domain  ? '; domain=' + options.domain : '',
				options.secure  ? '; secure' : ''
			].join(''));
		}

		var decode = config.raw ? raw : decoded;
		var cookies = document.cookie.split('; ');
		for (var i = 0, l = cookies.length; i < l; i++) {
			var parts = cookies[i].split('=');
			if (decode(parts.shift()) === key) {
				var cookie = decode(parts.join('='));
				return config.json ? JSON.parse(cookie) : cookie;
			}
		}

		return null;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		if ($.cookie(key) !== null) {
			$.cookie(key, null, options);
			return true;
		}
		return false;
	};

};

if (typeof jQuery !== 'undefined')
	eds_cookie(jQuery);

	if (typeof eds3_5_jq !== 'undefined')
		eds_cookie(eds3_5_jq);

})(document);

;;;(function ($) {

var defaultOptions = {
		instanceGlobal: 'EasyDnnSolutions1_1_instance',
		google: {
			maps: {
				api: {
					key: '',
					libraries: []
				}
			}
		}
	},
	$window = $(window),

	getExplicitStyleValue = function ($element, styleProperty) {
		var propertyValue = '',
			styleAttribute = $element.attr('style'),
			zIndexStartPosition,
			semicolonPosition;

		if (typeof styleAttribute != 'string')
			return propertyValue;

		zIndexStartPosition = styleAttribute.indexOf(' ' + styleProperty + ':');

		if (zIndexStartPosition == -1) {
			zIndexStartPosition = styleAttribute.indexOf(';' + styleProperty + ':');

			if (zIndexStartPosition == -1) {
				zIndexStartPosition = styleAttribute.indexOf(styleProperty + ':');

				if (zIndexStartPosition != 0)
					return propertyValue;
			} else
				zIndexStartPosition++;
		} else
			zIndexStartPosition++;

		propertyValue = styleAttribute.substr(zIndexStartPosition + styleProperty.length + 1);
		semicolonPosition = propertyValue.indexOf(';');

		if (semicolonPosition == -1)
			return propertyValue.trim();

		propertyValue = propertyValue.substr(0, semicolonPosition).trim();

		return propertyValue;
	};

GoogleHelper = function (parent) {
	var self = this;

	self.parent = parent;
	self.maps = {
		api: {
			loaded: (typeof window.google == 'object' && typeof window.google.maps == 'object'),
			callbacks: []
		}
	}
	self.options = parent.options.google;

	self.public = {
		maps: {
			api: {
				callback: function () {
					var i = 0,
						l = self.maps.api.callbacks.length;

					self.maps.api.loaded = true;

					for (; i < l; i++)
						self.maps.api.callbacks[i]();
				},

				load: function () {
					var tagId = 'eds_googleMapsApi',
						gMapsKey = self.options.maps.api.key,
						script,
						src = 'https://maps.googleapis.com/maps/api/js?v=3.50&callback=' + self.parent.options.instanceGlobal + '.google.maps.api.callback';

					if ($('script#' + tagId, self.parent.$head).length == 0) {
						if (typeof gMapsKey != 'string')
							gMapsKey = '';

						if (gMapsKey != '')
							gMapsKey = '&key=' + gMapsKey;

						script = document.createElement('script');
						script.type = 'text/javascript';
						script.id = tagId;

						if (self.options.maps.api.libraries)
							src += '&libraries=' + self.options.maps.api.libraries.join(',');

						src += gMapsKey;

						script.src = src;

						self.parent.$head[0].appendChild(script);
					}

					return self.parent;
				},

				onLoad: function (toExecute) {
					if (self.maps.api.loaded)
						toExecute();
					else {
						self.maps.api.callbacks.push(toExecute)
						self.public.maps.api.load();
					}

					return self.parent;
				}
			}
		}
	};

	return self.public;
}

window.EasyDnnSolutions1_1 = function (instanceOptions) {
	var self = this;

	self.options = $.extend(true, {}, defaultOptions, instanceOptions);

	self.google = new GoogleHelper(this);
	self.$head = $('html > head');

	$(function () {
		$('body')
			.on('click', '.eds_openModal', function () {
				var $clicked = $(this),
					$modalTarget = $('.eds_modalWrapper')
						.filter(function () {
							return $clicked.data('targetId') == this.id || $(this).hasClass($clicked.data('targetClass'));
						}),
					$dnnModuleElements = $modalTarget.parents('.DnnModule'),
					$modalContent,
					$modalResizeWrapper,
					$modalContentTitle,
					initialHeight,

					resizeContent = function () {
						var windowHeight = $window.height(),
							ContentHDiff = Math.round($modalContent.outerHeight(true) - $modalContent.height()),
							resizeWrapperHDiff = Math.round($modalResizeWrapper.outerHeight(true) - $modalResizeWrapper.height()),
							titleHeight = $modalContentTitle.outerHeight(true),
							maxHeight = windowHeight - ContentHDiff - resizeWrapperHDiff - titleHeight;

						if (maxHeight < initialHeight)
							$modalResizeWrapper.height(maxHeight);
						else
							$modalResizeWrapper.css('height', '');
					};

				$dnnModuleElements.each(function () {
					var $this = $(this);

					$this
						.data('previousZIndex', getExplicitStyleValue($this, 'z-index'))
						.css('z-index', 99999);
				});

				$modalTarget.addClass("eds_modalVisible");
				$("> .eds_modalContent", $modalTarget).addClass("eds_fadeInDown");

				if ($modalTarget.hasClass('eds_resizable')) {
					$modalContent = $('>', $modalTarget);
					$modalContentTitle = $('> h3', $modalContent);
					$modalResizeWrapper = $('> div', $modalContent);

					initialHeight = $modalResizeWrapper.height();

					resizeContent()

					$window.on('resize.eds_modalWrapper', function () {
						resizeContent();
					});
				}
			})
			.on('click', '.eds_modalClose', function () {
				var $clicked = $(this),
					$modalTarget = $('.eds_modalWrapper'),
					$dnnModuleElements = $modalTarget.parents('.DnnModule');

				$dnnModuleElements.each(function () {
					var $this = $(this);

					$this.css('z-index', $this.data('previousZIndex'));
				});

				$modalTarget
					.filter(function () {
						return $clicked.data('targetId') == this.id || $(this).hasClass($clicked.data('targetClass'));
					})
						.removeClass("eds_modalVisible")
						.css('z-index', '');
			});
	});
	}

var initOptions = null;
if ($('#eds_js1_1').length > 0) {
	initOptions = $('#eds_js1_1').data('initJson')
}
if ($('meta[name="eds__GmapsInitData"]').length > 0) {
	initOptions = JSON.parse($('meta[name="eds__GmapsInitData"]').attr("content"));
}

if (window[initOptions.instanceGlobal] == undefined && initOptions != null)
	window[initOptions.instanceGlobal] = new EasyDnnSolutions1_1(initOptions);

})(eds3_5_jq);

;;;/*! fluidvids.js v2.4.1 | (c) 2014 @toddmotto | https://github.com/toddmotto/fluidvids */
!function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t:e.edn_fluidvids=t()}(this,function(){"use strict";function e(e){return new RegExp("^(https?:)?//(?:"+d.players.join("|")+").*$","i").test(e)}function t(e,t){return parseInt(e,10)/parseInt(t,10)*100+"%"}function i(i){if((e(i.src)||e(i.data))&&!i.getAttribute("edn_data-fluidvids")){var n=document.createElement("div");i.parentNode.insertBefore(n,i),i.className+=(i.className?" ":"")+"edn_fluidvids-item",i.setAttribute("edn_data-fluidvids","loaded"),n.className+="edn_fluidvids",n.style.paddingTop=t(i.height,i.width),n.appendChild(i)}}function n(){var e=document.createElement("div");e.innerHTML="<p>x</p><style>"+o+"</style>",r.appendChild(e.childNodes[1])}var d={selector:["iframe","object"],players:["www.youtube.com","player.vimeo.com"]},o=[".edn_fluidvids {","width: 100%; max-width: 100%; position: relative;","}",".edn_fluidvids-item {","position: absolute; top: 0px; left: 0px; width: 100%; height: 100%;","}"].join(""),r=document.head||document.getElementsByTagName("head")[0];return d.render=function(){for(var e=document.querySelectorAll(d.selector.join()),t=e.length;t--;)i(e[t])},d.init=function(e){for(var t in e)d[t]=e[t];d.render(),n()},d});
;;;/*!
 * imagesLoaded PACKAGED v3.1.4
 * JavaScript is all like "You images are done yet or what?"
 * MIT License
 */

(function () { function e() { } function t(e, t) { for (var n = e.length; n--;)if (e[n].listener === t) return n; return -1 } function n(e) { return function () { return this[e].apply(this, arguments) } } var i = e.prototype, r = this, o = r.EventEmitter; i.getListeners = function (e) { var t, n, i = this._getEvents(); if ("object" == typeof e) { t = {}; for (n in i) i.hasOwnProperty(n) && e.test(n) && (t[n] = i[n]) } else t = i[e] || (i[e] = []); return t }, i.flattenListeners = function (e) { var t, n = []; for (t = 0; e.length > t; t += 1)n.push(e[t].listener); return n }, i.getListenersAsObject = function (e) { var t, n = this.getListeners(e); return n instanceof Array && (t = {}, t[e] = n), t || n }, i.addListener = function (e, n) { var i, r = this.getListenersAsObject(e), o = "object" == typeof n; for (i in r) r.hasOwnProperty(i) && -1 === t(r[i], n) && r[i].push(o ? n : { listener: n, once: !1 }); return this }, i.on = n("addListener"), i.addOnceListener = function (e, t) { return this.addListener(e, { listener: t, once: !0 }) }, i.once = n("addOnceListener"), i.defineEvent = function (e) { return this.getListeners(e), this }, i.defineEvents = function (e) { for (var t = 0; e.length > t; t += 1)this.defineEvent(e[t]); return this }, i.removeListener = function (e, n) { var i, r, o = this.getListenersAsObject(e); for (r in o) o.hasOwnProperty(r) && (i = t(o[r], n), -1 !== i && o[r].splice(i, 1)); return this }, i.off = n("removeListener"), i.addListeners = function (e, t) { return this.manipulateListeners(!1, e, t) }, i.removeListeners = function (e, t) { return this.manipulateListeners(!0, e, t) }, i.manipulateListeners = function (e, t, n) { var i, r, o = e ? this.removeListener : this.addListener, s = e ? this.removeListeners : this.addListeners; if ("object" != typeof t || t instanceof RegExp) for (i = n.length; i--;)o.call(this, t, n[i]); else for (i in t) t.hasOwnProperty(i) && (r = t[i]) && ("function" == typeof r ? o.call(this, i, r) : s.call(this, i, r)); return this }, i.removeEvent = function (e) { var t, n = typeof e, i = this._getEvents(); if ("string" === n) delete i[e]; else if ("object" === n) for (t in i) i.hasOwnProperty(t) && e.test(t) && delete i[t]; else delete this._events; return this }, i.removeAllListeners = n("removeEvent"), i.emitEvent = function (e, t) { var n, i, r, o, s = this.getListenersAsObject(e); for (r in s) if (s.hasOwnProperty(r)) for (i = s[r].length; i--;)n = s[r][i], n.once === !0 && this.removeListener(e, n.listener), o = n.listener.apply(this, t || []), o === this._getOnceReturnValue() && this.removeListener(e, n.listener); return this }, i.trigger = n("emitEvent"), i.emit = function (e) { var t = Array.prototype.slice.call(arguments, 1); return this.emitEvent(e, t) }, i.setOnceReturnValue = function (e) { return this._onceReturnValue = e, this }, i._getOnceReturnValue = function () { return this.hasOwnProperty("_onceReturnValue") ? this._onceReturnValue : !0 }, i._getEvents = function () { return this._events || (this._events = {}) }, e.noConflict = function () { return r.EventEmitter = o, e }, "function" == typeof define && define.amd ? define("eventEmitter/EventEmitter", [], function () { return e }) : "object" == typeof module && module.exports ? module.exports = e : this.EventEmitter = e }).call(this), function (e) { function t(t) { var n = e.event; return n.target = n.target || n.srcElement || t, n } var n = document.documentElement, i = function () { }; n.addEventListener ? i = function (e, t, n) { e.addEventListener(t, n, !1) } : n.attachEvent && (i = function (e, n, i) { e[n + i] = i.handleEvent ? function () { var n = t(e); i.handleEvent.call(i, n) } : function () { var n = t(e); i.call(e, n) }, e.attachEvent("on" + n, e[n + i]) }); var r = function () { }; n.removeEventListener ? r = function (e, t, n) { e.removeEventListener(t, n, !1) } : n.detachEvent && (r = function (e, t, n) { e.detachEvent("on" + t, e[t + n]); try { delete e[t + n] } catch (i) { e[t + n] = void 0 } }); var o = { bind: i, unbind: r }; "function" == typeof define && define.amd ? define("eventie/eventie", o) : e.eventie = o }(this), function (e, t) { "function" == typeof define && define.amd ? define(["eventEmitter/EventEmitter", "eventie/eventie"], function (n, i) { return t(e, n, i) }) : "object" == typeof exports ? module.exports = t(e, require("eventEmitter"), require("eventie")) : e.imagesLoaded = t(e, e.EventEmitter, e.eventie) }(this, function (e, t, n) { function i(e, t) { for (var n in t) e[n] = t[n]; return e } function r(e) { return "[object Array]" === d.call(e) } function o(e) { var t = []; if (r(e)) t = e; else if ("number" == typeof e.length) for (var n = 0, i = e.length; i > n; n++)t.push(e[n]); else t.push(e); return t } function s(e, t, n) { if (!(this instanceof s)) return new s(e, t); "string" == typeof e && (e = document.querySelectorAll(e)), this.elements = o(e), this.options = i({}, this.options), "function" == typeof t ? n = t : i(this.options, t), n && this.on("always", n), this.getImages(), a && (this.jqDeferred = new a.Deferred); var r = this; setTimeout(function () { r.check() }) } function c(e) { this.img = e } function f(e) { this.src = e, v[e] = this } var a = e.eds3_5_jq,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);for(var i=n.querySelectorAll("img"),r=0,o=i.length;o>r;r++){var s=i[r];this.addImage(s)}}},s.prototype.addImage=function(e){var t=new c(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),c.prototype=new t,c.prototype.check=function(){var e=v[this.img.src]||new f(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},c.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return f.prototype=new t,f.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},f.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},f.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},f.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},f.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},f.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});
;;;(function ($, window) {
	'use strict';

	var defaultOptions = {
		portalId: 0,
		moduleId: 0,
		tabId: 0,
		autoplayVideo: false,
		userLoggedIn: false,
		googleReCaptchaSiteKey: '',
		websiteRoot: '',
		portfolioMode: false,
		openAt: 0,
		wrapperResizeDuration: 200,
		flowplayerSwf: '',
		flowplayer: {
			key: '',
			logo: ''
		},
		socialButtons: {
			facebook: false,
			gplus: false,
			twitter: false,
			inshare: false,
			pinterest: false
		},
		cssClass: '',
		events: {
			onBeforeClose: function () { }
		},
		comments: {
			requireAuthorInfo: true,
			useReCaptcha: false,
			permissions: {
				show: false,
				commenting: false
			}
		},
		like: {
			permissions: {
				liking: false
			}
		},
		mobile: false,
		i18n: {}
	},

		ajaxState = {
			UNSET: 0,
			SENT: 1,
			DONE: 2
		},

		activeClass = 'activeElement',
		imageNotLoadedClass = 'imageNotLoaded',
		smbLightBodyClass = 'smbLightFixed',

		audioItemTypeClass = 'audioItem',
		videoItemTypeClass = 'videoItem',
		imageItemTypeClass = 'imageItem',
		positionAnimationClass = 'positionAnimation',
		swipeAnimationClass = 'swipeAnimation',
		itemDomInitKey = 'initialized',

		emailVerification = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,

		preloadImage = function (itemIndex, callback) {
			var self = this,
				item = self.items[itemIndex];
			if (!item)
				return;

			if (item.type != 'image')
				return;

			var imageMeta = self.images[item.src];

			if (imageMeta) {
				if (typeof callback == 'function') {
					if (imageMeta.stats.preloadFinished)
						callback(imageMeta.stats);
					else
						imageMeta.callbacks.push(callback);
				}

				return;
			}

			imageMeta = self.images[item.src] = {
				callbacks: [],
				stats: {
					preloadFinished: false,
					isLoaded: false,
					width: 0,
					height: 0
				}
			};

			if (typeof callback == 'function')
				imageMeta.callbacks.push(callback);

			var $img = $('<img class="smbLightImage_' + item.id + '" />');

			$img.imagesLoaded()
				.progress(function (instance, imageInfo) {
					if (self.viewClosed)
						return;

					var imageMeta = self.images[item.src];

					imageMeta.stats.preloadFinished = true;
					imageMeta.stats.isLoaded = imageInfo.isLoaded;

					if (!self.smbPlus && imageInfo.isLoaded)
						self.$imagesWrapper.append($img);

					imageMeta.stats.width = $img.width();
					imageMeta.stats.height = $img.height();

					if (self.smbPlus) {
						$img.css(getItemDimensions.call(self, imageMeta.stats.width, imageMeta.stats.height, false));

						$img.parent().removeClass('loading');
					} else {
						var currentItem = self.items[self.currentItemIndex];

						if (currentItem.type == 'image' && currentItem.src == item.src) {
							self.initialItemLoaded = true;
							showItem.call(self);
						}
					}

					$img = null;

					for (var i = 0, l = imageMeta.callbacks.length; i < l; i++) {
						imageMeta.callbacks[i](imageMeta.stats);
					}
				});

			if (self.smbPlus) {
				$img.appendTo($('> div.item_' + itemIndex, self.$contentWrapper));
			}

			$img.attr('src', item.src);
		},

		preloadImages = function () {
			var self = this,
				i = 0,
				numberOfItems = self.items.length;

			for (; i < numberOfItems; i++) {
				preloadImage.call(self, i);
			};
		},

		getItemDimensions = function (itemWidth, itemHeight, maximizeDimensions, fixedHeight) {
			var self = this,

				containerRatio,
				itemRatio,

				maxItemWidth = self.overlayWidth - self.main.horizontalSpace,
				maxItemHeight = self.overlayHeight - self.main.verticalSpace,
				displayWidth = itemWidth,
				displayHeight = itemHeight;

			if (maximizeDimensions || itemWidth > maxItemWidth || itemHeight > maxItemHeight) {
				containerRatio = maxItemWidth / maxItemHeight;
				itemRatio = itemWidth / itemHeight;

				displayWidth = maxItemWidth;
				displayHeight = maxItemHeight;

				if (itemRatio < containerRatio) {
					displayWidth = Math.round(maxItemHeight / itemHeight * itemWidth);
				} else if (itemRatio > containerRatio) {
					displayHeight = Math.round(maxItemWidth / itemWidth * itemHeight);
				}
			}

			if (fixedHeight)
				displayHeight = itemHeight;

			return {
				width: displayWidth,
				height: displayHeight,
				top: Math.floor((maxItemHeight - displayHeight) / 2),
				left: Math.floor((maxItemWidth - displayWidth) / 2)
			};
		},

		setItemDimensions = function (itemDimensions) {
			var self = this,

				resizeFinished = function () {
					self.$loadingOverlay
						.stop(true)
						.fadeTo(200, 0, function () {
							self.$loadingOverlay.css('display', 'none');
						});

					setItemInfo.call(self);
				},

				doResize = function (properties, complete) {
					if (self.options.wrapperResizeDuration == 0) {
						self.$mainWrapper.css(properties);
						complete();
					} else {
						self.$mainWrapper
							.stop(true)
							.animate(
								properties,
								{
									duration: self.options.wrapperResizeDuration,
									complete: function () {
										self.$mainWrapper.css('overflow', '');
										complete();
									}
								}
							);
					}
				},

				resizeHeight = function () {
					if (self.$mainWrapper.height() != itemDimensions.height)
						doResize(
							{
								height: itemDimensions.height,
								top: itemDimensions.top
							},
							resizeFinished
						);
					else
						resizeFinished();
				};

			self.$loadingOverlay.removeClass('inProgress');

			if (self.$mainWrapper.width() != itemDimensions.width)
				doResize(
					{
						width: itemDimensions.width,
						left: itemDimensions.left
					},
					resizeHeight
				);
			else
				resizeHeight();
		},

		showImage = function (currentItem) {
			var self = this,
				imageInfo = self.images[currentItem.src].stats,
				width,
				height;

			if (!imageInfo.preloadFinished)
				return;

			self.$mainWrapper.addClass(imageItemTypeClass);

			$('> img', self.$imagesWrapper)
				.removeClass(activeClass)
				.filter('.smbLightImage_' + currentItem.id)
					.addClass(activeClass);

			if (imageInfo.isLoaded) {
				width = imageInfo.width;
				height = imageInfo.height;
			} else {
				width = 400;
				height = 400;

				self.$imagesWrapper.addClass(imageNotLoadedClass);
			}

			self.$imagesWrapper.addClass(activeClass);

			setItemDimensions.call(
				self,
				getItemDimensions.call(self, width, height)
			);
		},

		showVideo = function (currentItemIndex) {
			var self = this,
				videoHtml = '',
				videoType = '',
				currentItem = self.items[currentItemIndex];

			if (!self.smbPlus)
				self.$mainWrapper.addClass(videoItemTypeClass);

			switch (currentItem.source) {
				case 'youtube':
					videoHtml = '<iframe src="//www.youtube.com/embed/' +
						currentItem.videoId + (self.options.autoplayVideo ? '?autoplay=1' : '') +
						'" frameborder="0" allowfullscreen></iframe>';
					break;

				case 'vimeo':
					videoHtml = '<iframe src="//player.vimeo.com/video/' +
						currentItem.videoId + (self.options.autoplayVideo ? '?autoplay=1' : '') +
						'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
					break;

				case 'wistia':
					videoHtml = '<iframe name="wistia_embed" src="//fast.wistia.net/embed/iframe/' +
						currentItem.videoId +
						'" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>';
					break;

				case 'flowplayer':
					if (stringEndsWith(currentItem.src, '.mp4')) {
						videoType = 'video/mp4';
					} else if (stringEndsWith(currentItem.src, '.webm')) {
						videoType = 'video/webm';
					} else if (stringEndsWith(currentItem.src, '.ogg')) {
						videoType = 'video/ogg';
					} else if (stringEndsWith(currentItem.src, '.flv')) {
						videoType = 'video/flash';
					}

					videoHtml = '<div class="flowplayerContainer"></div>';
			}

			var $playerContainer = self.$audioVideo;

			if (self.smbPlus) {
				if (currentItem.source != 'flowplayer')
					videoHtml = '<div>' + videoHtml + '</div>';

				$playerContainer = $('> div.item_' + self.currentItemIndex, self.$contentWrapper);
			} else
				$playerContainer.addClass(activeClass);

			$playerContainer
				.html(videoHtml)
				.removeClass('loading');

			if (currentItem.source == 'flowplayer')
				$('> .flowplayerContainer', $playerContainer)
					.flowplayer({
						swf: self.options.flowplayerSwf,
						ratio: currentItem.height / currentItem.width,
						autoplay: self.options.autoplayVideo,
						tooltip: false,
						embed: false,
						clip: {
							sources: [
								{
									type: videoType,
									src: currentItem.src
								}
							]
						},
						key: self.options.flowplayer.key,
						logo: self.options.flowplayer.logo
					});

			var playerCss = getItemDimensions.call(self, currentItem.width, currentItem.height, true);

			if (self.smbPlus)
				$('>', $playerContainer).css(playerCss);
			else
				setItemDimensions.call(
					self,
					playerCss
				);

			self.initialItemLoaded = true;
		},

		showAudio = function (currentItem) {
			var self = this;

			if (!self.smbPlus)
				self.$mainWrapper.addClass(audioItemTypeClass);

			var $playerContainer = self.$audioVideo,
				audioHtml = '<audio src="' + currentItem.src + '" />',
				selector = '> audio';

			if (self.smbPlus) {
				audioHtml = '<div>' + audioHtml + '</div>';
				selector = '> div > audio';
				$playerContainer = $('> div.item_' + self.currentItemIndex, self.$contentWrapper);
			} else
				$playerContainer.addClass(activeClass);

			$playerContainer
				.html(audioHtml)
				.removeClass('loading');

			audiojs.create($(selector, $playerContainer)[0]);

			var playerCss = getItemDimensions.call(self, 460, 36, false, true);

			if (self.smbPlus)
				$('>', $playerContainer).css(playerCss);
			else
				setItemDimensions.call(
					self,
					playerCss
				);

			self.initialItemLoaded = true;
		},

		setItemInfo = function () {
			var self = this,
				currentItem = self.items[self.currentItemIndex];

			if (typeof currentItem.title == 'string' && currentItem.title != '')
				self.$itemTitle
					.html(currentItem.title)
					.stop(true)
					.fadeTo(200, 1);

			if (
				(
					self.options.socialButtons.facebook
					|| self.options.socialButtons.twitter
					|| self.options.socialButtons.gplus
					|| self.options.socialButtons.inshare
					|| (self.options.socialButtons.pinterest && currentItem.type == 'image')
				)
				&& typeof currentItem.socialUrl == 'string'
				&& currentItem.socialUrl != ''
			)
				self.$socialButtonsTrigger.css('display', '');
			else
				self.$socialButtonsTrigger.css('display', 'none');
		},

		validItemIndex = function (index) {
			var numberOfItems = this.items.length;

			if (index < 0)
				index = numberOfItems - 1;
			else if (index >= numberOfItems)
				index = 0;

			return index;
		},

		showItem = function () {
			var self = this;

			self.$itemTitle
				.text('')
				.stop(true)
				.fadeTo(0, 0);

			self.$socialButtonsTrigger.removeClass('show');
			self.$socialButtonsWrapper
				.removeClass('show')
				.html('');

			self.currentItemIndex = validItemIndex.call(self, self.currentItemIndex);

			self.$root.removeClass('firstItem lastItem');

			if (self.currentItemIndex === 0)
				self.$root.addClass('firstItem');

			if (self.currentItemIndex === self.items.length - 1)
				self.$root.addClass('lastItem');

			if (self.smbPlus) {
				var prevItemIndex = validItemIndex.call(self, self.currentItemIndex - 1),
					nextItemIndex = validItemIndex.call(self, self.currentItemIndex + 1);

				$(
					'> div.videoItem.item_' + prevItemIndex + ',' +
					'> div.audioItem.item_' + prevItemIndex + ',' +
					'> div.videoItem.item_' + nextItemIndex + ',' +
					'> div.audioItem.item_' + nextItemIndex,
					self.$contentWrapper
				)
					.html('');

				setItemInfo.call(self);
			}

			var item = self.items[self.currentItemIndex],
				itemTypeClass = 'imageActive';

			if (item.type == 'video')
				itemTypeClass = 'videoActive';
			else if (item.type == 'audio')
				itemTypeClass = 'audioActive';

			self.$root
				.removeClass('imageActive videoActive audioActive')
				.addClass(itemTypeClass);

			self.showItem();
		},

		size = function () {
			var self = this;

			if (self.smbPlus) {
				var windowHeight = self.$window.height();

				if (window.innerHeight)
					windowHeight = window.innerHeight;

				windowHeight += 1;

				self.$root.height(windowHeight);
				self.overlayWidth = self.$root.width();
				self.overlayHeight = windowHeight;
			} else {
				self.overlayWidth = self.$contentWrapper.width();
				self.overlayHeight = self.$contentWrapper.height();
			}

			self.center();
		},

		swipe = function (indexModifier) {
			var self = this;

			if (
				self.skipGestures ||
				indexModifier == -1 && self.currentItemIndex == 0 ||
				indexModifier == 1 && self.currentItemIndex == this.items.length - 1
			)
				return;

			self.skipGestures = true;

			var newX = -self.currentItemIndex * self.overlayWidth;

			if (indexModifier == 1)
				newX -= self.overlayWidth;
			else
				newX += self.overlayWidth;

			self.$contentWrapper
				.removeClass(positionAnimationClass)
				.addClass(swipeAnimationClass)
				.css({
					transform: 'translate3d(' + newX + 'px, 0, 0)'
				});

			setTimeout(function () {
				self.currentItemIndex += indexModifier;
				showItem.call(self);

				self.skipGestures = false;
			}, 250);
		},

		showPrevItem = function () {
			var self = this;

			if (!self.initialItemLoaded)
				return;

			if (self.smbPlus) {
				swipe.call(self, -1);

				return;
			}

			self.currentItemIndex -= 1;
			showItem.call(self);
		},

		showNextItem = function () {
			var self = this;

			if (!self.initialItemLoaded)
				return;

			if (self.smbPlus) {
				swipe.call(self, 1);

				return;
			}

			self.currentItemIndex += 1;
			showItem.call(self);
		},

		close = function () {
			var self = this;

			if (
				typeof self.options.events.onBeforeClose == 'function' &&
				self.options.events.onBeforeClose({
				activeItem: self.currentItemIndex,
				displayItems: self.items
			}) === false
			)
				return;

			self.$document.off('.smbLightEvent');
			self.$window.off('.smbLightEvent');

			self.viewClosed = true;

			self.$root
				.stop(true)
				.fadeOut(200, function () {
					self.$root.remove();

					self.$body.removeClass(smbLightBodyClass);
				});

			if (self.smbPlus) {
				if (self.oldViewportMetaContent === undefined)
					self.$viewportMeta.remove();
				else
					self.$viewportMeta.attr('content', self.oldViewportMetaContent);

				if (self.oldIeTapHighlight === undefined)
					self.$ieTapHighlight.remove();
				else
					self.$ieTapHighlight.attr('content', self.oldIeTapHighlight);
			}
		},

		inFullscreenMode = function () {
			if (document.fullscreenElement && document.fullscreenElement != null)
				return true;
			else if (document.mozFullScreenElement && document.mozFullScreenElement != null)
				return true;
			else if (document.webkitFullscreenElement && document.webkitFullscreenElement != null)
				return true;

			return false;
		},

		eventListener = function (events, callback) {
			var el = this,
				registerEvent = function (ev) {
					if (el.addEventListener)
						el.addEventListener(ev, callback, false);
					else if (el.attachEvent)
						el.attachEvent(ev, callback);
				},
				eventsArray,
				i,
				l;

			if (events.indexOf(' ') == -1) {
				registerEvent(events);
				return;
			}

			eventsArray = events.split(' ');
			i = 0;
			l = eventsArray.length;

			for (; i < l; i++) {
				if (eventsArray[i] == '')
					break;

				registerEvent(eventsArray[i])
			}
		},

		stringEndsWith = function (s, e) {
			return s.indexOf(e, s.length - e.length) !== -1;
		},

		updateCommentsUi = function () {
			var self = this,
				currentItem = self.items[self.currentItemIndex],
				itemCommentMeta = self.comments[currentItem.id],
				commentsHtml = '';

			self.$mainCommentsCount.text(itemCommentMeta.count);
			self.$internalCommentsCount.text(itemCommentMeta.count);

			if (itemCommentMeta.cache.comments.length == 0) {
				self.$commentList.html('');
				self.$commentsModal.addClass('noComments');

				return;
			}

			self.$commentsModal.removeClass('noComments');

			$.each(itemCommentMeta.cache.comments, function () {
				var author = itemCommentMeta.cache.authors[this.author],
					encodedAuthorUrl = encodeURI(author.url),
					commentHtml =
						'<li>' +
							'<a class="authorAvatar" href="' + encodedAuthorUrl + '"><img src="' + encodeURI(author.avatar) + '" alt="" /></a>' +
							'<a class="author" href="' + encodedAuthorUrl + '">' + $('<p />').text(author.name).html() + '</a>' +
							'<div>' + this.content + '</div>' +
							'<p class="datetime">' + this.dateHtml + '</p>' +
						'</li>';

				if (self.commentSorting == 'asc')
					commentsHtml += commentHtml;
				else
					commentsHtml = commentHtml + commentsHtml;
			});

			self.$commentList.html(commentsHtml);
		},

		initEnviroment = function (items, options) {
			var self = this;

			self.$body = $('body');

			if (self.$body.hasClass(smbLightBodyClass) || items.length == 0)
				return false;

			self.$body.addClass(smbLightBodyClass);

			self.$window = $(window);
			self.$document = $(document);
			self.initialItemLoaded = false;
			self.viewClosed = false;
			self.items = items;
			self.options = $.extend(true, {}, defaultOptions, options);

			self.currentItemIndex = self.options.openAt;

			if (self.currentItemIndex < 0 || self.currentItemIndex >= items.length)
				self.currentItemIndex = 0;

			self.images = {};

			return true;
		},

		postInit = function () {
			var self = this;

			self.$window
				.on('resize.smbLightEvent', function () {
					if (self.comments) {
						var currentItem = self.items[self.currentItemIndex],
							itemCommentMeta = self.comments ? self.comments[currentItem.id] : undefined;

						if (self.desktopVersion && itemCommentMeta && itemCommentMeta.state.open)
							self.$root.width(self.$window.width() - self.$commentsModal.outerWidth(true));
					}
					size.call(self);
				});

			self.$document
				.on('keyup.smbLightEvent', function (e) {
					switch (e.keyCode) {
						case 37:
							showPrevItem.call(self);
							break;

						case 39:
							showNextItem.call(self);
							break;

						case 27:
							if (self.commentsOpened) {
								self.closeComments();
								return false;
							}

							close.call(self);
							break;

						default:
					}

					return false;
				});

			self.$root
				.on('click', '.navigation', function () {
					if (self.$root.hasClass('initializing'))
						return;

					if ($(this).hasClass('prev'))
						showPrevItem.call(self);
					else
						showNextItem.call(self);
				})
				.on('click', '.close', function () {
					close.call(self);
				});

			self.$socialButtonsTrigger.on('click', function () {
				if (self.$root.hasClass('initializing'))
					return;

				var currentItem = self.items[self.currentItemIndex];

				var encodedUri = encodeURIComponent(currentItem.socialUrl);
				var escapedTitle = '';
				var encodedTitle = '';
				var twitterTitle = '';

				if (typeof currentItem.title == 'string' && currentItem.title != '') {
					twitterTitle = escapedTitle = currentItem.title
						.replace(/&/g, '&amp;')
						.replace(/"/g, '&quot;')
						.replace(/'/g, '&#39;')
						.replace(/</g, '&lt;')
						.replace(/>/g, '&gt;');

					twitterTitle += ' ' + currentItem.socialUrl
						.replace(/&/g, '&amp;')
						.replace(/"/g, '&quot;')
						.replace(/'/g, '&#39;')
						.replace(/</g, '&lt;')
						.replace(/>/g, '&gt;');

					encodedTitle = encodeURIComponent(currentItem.title);
				}

				var socialButtonsHtml = '';

				if (self.options.socialButtons.facebook)
					socialButtonsHtml = '<div><iframe src="//www.facebook.com/plugins/like.php?href=' + encodedUri + '&amp;width&amp;layout=button_count&amp;action=like&amp;show_faces=false&amp;share=false&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px; width: 135px;" allowTransparency="true"></iframe></div>';

				if (self.options.socialButtons.twitter)
					socialButtonsHtml += '<div><a href="//twitter.com/share" class="twitter-share-button" data-url="' + encodedUri + '" data-text="' + twitterTitle + '">Tweet</a><script type="text/javascript">twttr.widgets.load();</script></div>';

				if (self.options.socialButtons.inshare)
					socialButtonsHtml += '<div><script type="IN/Share" data-url="' + currentItem.socialUrl + '" data-counter="right"></script><script type="text/javascript">if (IN.parse) IN.parse();</script></div>';

				if (self.options.socialButtons.pinterest && currentItem.type == 'image')
					socialButtonsHtml += '<div><a href="//www.pinterest.com/pin/create/button/?url=' + encodedUri + '&media=' + encodeURIComponent(currentItem.src) + '&description=' + encodedTitle + '" data-pin-do="buttonPin" data-pin-config="beside"><img src="//assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png" /></a></div>';

				if (socialButtonsHtml == '')
					return;

				self.$socialButtonsWrapper
					.toggleClass('show')
					.html(socialButtonsHtml);

				if (self.options.socialButtons.pinterest && currentItem.type == 'image')
					$.ajax({ url: '//assets.pinterest.com/js/pinit.js', dataType: 'script', cache: true });

				$(this).toggleClass('show');
			});
		},

		_ = function (s) {
			var self = this,
				translation = self.options.i18n[s];

			if (!translation)
				return s;

			return translation;
		};

	function Standard(items, options) {
		var self = this,
			currentItem,
			controlsHtml = '';

		if (!initEnviroment.call(self, items, options))
			return;

		self.$root = $('<div class="smbLightOverlayWrapper initializing"><div class="contentWrapper"></div></div>');
		self.$root.addClass(self.options.cssClass);

		self.$contentWrapper = $('> div.contentWrapper', self.$root);

		if (items.length > 1)
			controlsHtml = '<span class="navigation prev"><span></span></span>' +
				'<span class="navigation next"><span></span></span>';

		controlsHtml += '<span class="close"><span></span></span>' +
			'<div class="socialButtonsWrapper"></div>' +
			'<span class="actions socialButtonsTrigger"><span>' + _.call(self, 'Share') + '</span></span>';

		self.$mainWrapper = $(
			'<div class="mainWrapper">' +
				'<div class="viewWrapper">' +
					'<div class="images"><p>' + _.call(self, 'This image is currently unavailable') + '</p></div>' +
					'<div class="audioVideo"></div>' +
				'</div>' +
				controlsHtml +
			'</div>'
		)
			.appendTo(self.$contentWrapper);

		self.$itemTitle = $('<h2 class="itemTitle" />').appendTo(self.$mainWrapper);
		self.$loadingOverlay = $('<div class="loadingOverlay inProgress"></div>').appendTo(self.$mainWrapper);
		self.$imagesWrapper = $('> .viewWrapper > .images', self.$mainWrapper);
		self.$audioVideo = $('> .viewWrapper > .audioVideo', self.$mainWrapper);
		self.$socialButtonsWrapper = $('.socialButtonsWrapper', self.$mainWrapper);
		self.$socialButtonsTrigger = $('.socialButtonsTrigger', self.$mainWrapper);

		currentItem = self.items[self.currentItemIndex];
		if (currentItem.type == 'image') {
			preloadImage.call(
				self,
				self.currentItemIndex,
				function () {
					preloadImages.call(self);
				}
			);
		} else {
			preloadImages.call(self);
		}

		self.$root.appendTo(self.$body);

		self.main = {
			horizontalSpace: self.$mainWrapper.outerWidth(true) - self.$mainWrapper.width(),
			verticalSpace: self.$mainWrapper.outerHeight(true) - self.$mainWrapper.height()
		};

		size.call(self);

		self.$root
			.fadeTo(
				200,
				1,
				function () {
					if (currentItem.type == 'image')
						return;

					showItem.call(self);
				}
			);

		postInit.call(self);

		return self;
	}

	Standard.prototype = {
		center: function () {
			var self = this,
				css = {},
				currentItem,
				imageInfo,
				dimensionsSet = false,

				width = 0,
				height = 0,
				maximizeItem = false,
				fixedHeight = false;

			if (self.initialItemLoaded) {
				currentItem = self.items[self.currentItemIndex];

				switch (currentItem.type) {
					case 'image':
						imageInfo = self.images[currentItem.src].stats;

						if (imageInfo.isLoaded) {
							width = imageInfo.width;
							height = imageInfo.height;
						} else {
							width = 400;
							height = 400;
						}
						break;

					case 'video':
						width = currentItem.width;
						height = currentItem.height;
						maximizeItem = true;
						break;

					case 'audio':
						width = 460;
						height = 36;
						fixedHeight = true;
						break;
				}

				css = getItemDimensions.call(self, width, height, maximizeItem, fixedHeight);

				dimensionsSet = true;
			}

			if (!dimensionsSet) {
				css.width = self.$mainWrapper.width();
				css.height = self.$mainWrapper.height();

				css.left = Math.floor((self.overlayWidth - (css.width + self.main.horizontalSpace)) / 2);
				css.top = Math.floor((self.overlayHeight - (css.height + self.main.verticalSpace)) / 2);
			}

			self.$mainWrapper
				.stop(true)
				.css(css);
		},
		showItem: function () {
			var self = this;

			self.$imagesWrapper.removeClass(imageNotLoadedClass);

			self.$loadingOverlay
				.addClass('inProgress')
				.stop(true)
				.fadeTo(0, 1, function () {
					self.$loadingOverlay.css('display', '');
				});

			self.$audioVideo.html('');

			$('> .viewWrapper > div', self.$mainWrapper).removeClass(activeClass);

			self.$mainWrapper
				.removeClass(audioItemTypeClass)
				.removeClass(videoItemTypeClass)
				.removeClass(imageItemTypeClass);

			var currentItem = self.items[self.currentItemIndex];

			switch (currentItem.type) {
				case 'image':
					showImage.call(self, currentItem);
					break;

				case 'video':
					showVideo.call(self, self.currentItemIndex);
					break;

				case 'audio':
					showAudio.call(self, currentItem);
					break;

				default:
					self.initialItemLoaded = true;
			}

			if (self.initialItemLoaded)
				self.$root.removeClass('initializing');
		}
	};

	function Mobile(items, options) {
		var self = this,
			currentItem,
			touch = {
				newTouch: false,
				startX: 0
			},
			controlsHtml = '';

		self.smbPlus = true;

		if (!initEnviroment.call(self, items, options))
			return;

		self.options.wrapperResizeDuration = 0;

		self.$viewportMeta = $('meta[name="viewport"]');
		self.oldViewportMetaContent = undefined;

		if (self.$viewportMeta.length > 0) {
			self.oldViewportMetaContent = self.$viewportMeta.attr('content');
			self.$viewportMeta.attr('content', 'user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1');
		} else
			self.$viewportMeta = $('<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1" />').appendTo($('head'));

		self.$ieTapHighlight = $('meta[name="msapplication-tap-highlight"]');
		self.oldIeTapHighlight = undefined;

		if (self.$ieTapHighlight.length > 0) {
			self.oldIeTapHighlight = self.$ieTapHighlight.attr('content');
			self.$ieTapHighlight.attr('content', 'no');
		} else
			self.$ieTapHighlight = $('<meta name="msapplication-tap-highlight" content="no" />').appendTo($('head'));

		self.$root = $(
			'<div class="smbLightOverlayWrapper smbPlus initializing">' +
				'<div class="contentWrapper"></div>' +
			'</div>'
		)
			.addClass(self.options.cssClass);

		if (!/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())) {
			self.$root.addClass('desktopUserAgent');
			self.desktopVersion = true;
		}

		self.$contentWrapper = $('> div.contentWrapper', self.$root);

		controlsHtml = '<div class="mobileOverlay"></div><div class="modalOverlay"></div>';

		if (items.length > 1)
			controlsHtml += '<span class="navigation prev"><span></span></span>' +
				'<span class="navigation next"><span></span></span>';

		controlsHtml += '<span class="close"><span></span></span>' +
			'<div class="socialButtonsWrapper"></div>' +
			'<span class="actions socialButtonsTrigger"><span>' + _.call(self, 'Share') + '</span></span>';

		self.$root.append(controlsHtml);

		self.$itemTitle = $('<h2 class="itemTitle" />').appendTo(self.$root);
		self.$socialButtonsWrapper = $('.socialButtonsWrapper', self.$root);
		self.$socialButtonsTrigger = $('.socialButtonsTrigger', self.$root);
		self.$modalOverlay = $('> .modalOverlay', self.$root);

		if (self.options.comments.permissions.show) {
			self.comments = {};
			self.$root.append(
				'<span class="actions commentsTrigger"><span>0</span></span>' +
				'<div class="commentsModalWrapper">' +
					'<div class="main">' +
						'<div class="top">' +
							'<span class="comments">0</span>' +
							'<span class="likes">0</span>' +
							'<span class="sort">' + _.call(self, 'Sort') + '</span>' +
						'</div>' +
						'<ul />' +
						'<p class="noComments">' + _.call(self, 'No comments yet') + '</p>' +
						'<div class="newCommentWrapper">' +
							'<textarea placeholder="' + _.call(self, 'Write a comment') + '"></textarea>' +
							'<button>' + _.call(self, 'Post') + '</button>' +
						'</div>' +
					'</div>' +
					'<div class="anonymCommentWrapper">' +
						'<p>' + _.call(self, 'Add a comment') + '</p>' +
						'<div class="authorName"><input type="text" placeholder="' + _.call(self, 'Name') + '" /></div>' +
						'<div class="authorEmail"><input type="text" placeholder="' + _.call(self, 'Email') + '" /></div>' +
						'<div class="authorTextarea"><textarea placeholder="' + _.call(self, 'Write a comment') + '"></textarea></div>' +
						(self.options.comments.requireAuthorInfo && self.options.comments.useReCaptcha
							? '<div class="captchaContainer"><p class="captchaError">' + _.call(self, 'Please solve the test correctly.') + '</p><div class="captcha"></div></div>'
							: ''
						) +
						'<div class="actions"><button class="cancel">' + _.call(self, 'Cancel') + '</button><button class="post">' + _.call(self, 'Post') + '</button></div>' +
					'</div>' +
					'<span class="closeComments">' + _.call(self, 'Hide') + '</span>' +
					'<p class="loading">' + _.call(self, 'Loading comments') + '</p>' +
				'</div>'
			);
			self.$commentsTrigger = $('> .actions.commentsTrigger', self.$root);
			self.$mainCommentsCount = $('> span', self.$commentsTrigger);
			self.$commentsModal = $('> .commentsModalWrapper', self.$root);
			self.$commentsMainWrapper = $('> .main', self.$commentsModal);
			self.$newCommentWrapper = $('> .newCommentWrapper', self.$commentsMainWrapper);
			self.$newCommentInput = $('> textarea', self.$newCommentWrapper);
			self.$newCommentButton = $('> button', self.$newCommentWrapper);
			self.$commentsTopBar = $('> .top', self.$commentsMainWrapper);
			self.$internalCommentsCount = $('> .comments', self.$commentsTopBar);
			self.$commentsLikes = $('> .likes', self.$commentsTopBar);
			self.$commentsSorting = $('> .sort', self.$commentsTopBar);
			self.$commentList = $('> ul', self.$commentsMainWrapper);
			self.$anonymCommentWrapper = $('> .anonymCommentWrapper', self.$commentsModal);
			self.$anonymCommenterNameInput = $('> .authorName > input', self.$anonymCommentWrapper);
			self.$anonymCommenterEmailInput = $('> .authorEmail > input', self.$anonymCommentWrapper);
			self.$anonymCommentInput = $('> .authorTextarea > textarea', self.$anonymCommentWrapper);
			self.$anonymCommentCancel = $('> .actions > .cancel', self.$anonymCommentWrapper);
			self.$anonymCommentPost = $('> .actions > .post', self.$anonymCommentWrapper);
			self.$newCommentCaptchaContainer = $('> .captchaContainer', self.$anonymCommentWrapper);

			self.commentSorting = 'asc';

			self.addingAjaxRequest = undefined;

			self.commentsOpened = false;
			self.commentsAnimationTimeout;

			var reCaptchaId;

			self.$commentsTrigger.on('click', function () {
				if (self.desktopVersion && self.commentsOpened == true) {
					self.closeComments();
					return;
				}

				self.updateItemComments();

				if (self.desktopVersion) {
					self.commentsOpened = true;
					clearTimeout(self.commentsAnimationTimeout);

					self.$root.addClass('animateComments moveComments');

					self.commentsAnimationTimeout = setTimeout(function () {
						self.$root.removeClass('animateComments moveComments');

						self.$root.width(self.$root.width() - self.$commentsModal.outerWidth(true));
						size.call(self);
					}, 200);
				} else {
					self.$root.addClass('modalActive');

					self.$modalOverlay
						.stop(true)
						.animate(
							{
								opacity: 1
							},
							{
								duration: 200
							}
						);
				}
			});

			self.$commentsSorting.on('click', function () {
				if (self.commentSorting == 'asc')
					self.commentSorting = 'desc';
				else
					self.commentSorting = 'asc';

				self.$commentsSorting.toggleClass('desc', self.commentSorting == 'desc');

				updateCommentsUi.call(self);
			});

			self.$commentsModal.on('click', '> span.closeComments', function () {
				self.closeComments();
			});

			self.$newCommentInput
				.on('change keyup', function () {
					var val = self.$newCommentInput.val();

					self.$newCommentWrapper.toggleClass('filledIn', val !== '');
				})
				.on('focus', function () {
					if (!self.options.comments.requireAuthorInfo)
						return;

					self.$anonymCommenterNameInput
						.trigger('focus')
						.val('')
						.parent()
							.removeClass('error');
					self.$anonymCommenterEmailInput
						.val('')
						.parent()
							.removeClass('error');
					self.$anonymCommentInput
						.val('')
						.parent()
							.removeClass('error');
					self.$newCommentCaptchaContainer.removeClass('error');

					if (self.options.comments.useReCaptcha) {
						if (reCaptchaId)
							grecaptcha.reset(reCaptchaId);
						else
							reCaptchaId = grecaptcha.render($('> .captcha', self.$newCommentCaptchaContainer)[0], {
								sitekey: self.options.googleReCaptchaSiteKey,
								size: 'compact'
							});
					}

					self.$commentsModal.addClass('showAnonymWindow');
				});

			self.$anonymCommentCancel.on('click', function () {
				self.$commentsModal.removeClass('showAnonymWindow');
				self.$anonymCommentWrapper.removeClass('addingAnonComment');

				if (self.addingAjaxRequest) {
					self.addingAjaxRequest.abort();
					self.addingAjaxRequest = undefined;
				}
			});

			var submitComment = function (e, authorName, authorEmail, comment, captcha, anonComment) {
				var activeItemIndex = self.currentItemIndex,
					currentItem = self.items[activeItemIndex],
					itemCommentMeta = self.comments[currentItem.id],
					newComment = self.options.comments.requireAuthorInfo ? comment : self.$newCommentInput.val(),
					params = {
						action: 'add_comment'
					},
					error = false;

				if (newComment === '' || self.$newCommentWrapper.hasClass('addingComment'))
					return;

				self.$newCommentCaptchaContainer.removeClass('error');
				self.$newCommentInput.val('');
				self.$newCommentWrapper
					.removeClass('filledIn')
					.addClass('addingComment');

				params.comment = newComment;

				if (self.options.comments.requireAuthorInfo) {
					params.name = authorName;
					params.email = authorEmail;
				}

				if (captcha)
					params.captcha = captcha;

				self.addingAjaxRequest = $.ajax({
					data: params,
					dataType: 'json',
					type: 'POST',
					url: currentItem.comments.backend,
					timeout: 30000,
					cache: false,
					error: function () { },
					success: function (response) {
						if (response.status == undefined)
							return;

						if (response.status == 'success') {
							itemCommentMeta.cache.comments.push({
								author: response.author.id,
								content: response.comment,
								raw: newComment,
								id: response.id,
								dateHtml: response.dateHtml
							});
							itemCommentMeta.count += 1;

							if (itemCommentMeta.cache.authors[response.author.id] == undefined)
								itemCommentMeta.cache.authors[response.author.id] = {
									avatar: response.author.avatar,
									name: response.author.name,
									url: response.author.url
								};
						} else if (response.status == 'captcha_error') {
							self.$newCommentCaptchaContainer.addClass('error');
							error = true;
						}
					},
					complete: function () {
						self.addingAjaxRequest = undefined;

						if (!itemCommentMeta.state.open || activeItemIndex != self.currentItemIndex)
							return;

						if (anonComment) {
							self.$anonymCommentWrapper.removeClass('addingAnonComment');
							self.$anonymCommentPost.text(_.call(self, 'Post'));
						}

						self.$newCommentWrapper.removeClass('addingComment');

						if (error)
							return;

						if (anonComment) {
							self.$commentsModal.removeClass('showAnonymWindow');
							self.$newCommentCaptchaContainer.removeClass('error');
						}

						updateCommentsUi.call(self);
					}
				});
			};

			self.$anonymCommentPost.on('click', function () {
				var authorName = self.$anonymCommenterNameInput.val(),
					authorEmail = self.$anonymCommenterEmailInput.val(),
					comment = self.$anonymCommentInput.val(),
					hasErrors = false,
					captcha = undefined;

				self.$anonymCommenterNameInput.attr('placeholder', _.call(self, 'Name'));
				self.$anonymCommenterEmailInput.attr('placeholder', _.call(self, 'Email'));
				self.$anonymCommentInput.attr('placeholder', _.call(self, 'Write a comment'));

				self.$anonymCommenterNameInput.parent().removeClass('error');
				self.$anonymCommenterEmailInput.parent().removeClass('error');
				self.$anonymCommentInput.parent().removeClass('error');

				if (!authorName) {
					self.$anonymCommenterNameInput
						.attr('placeholder', _.call(self, 'Please specify your name'))
						.parent()
							.addClass('error');
					hasErrors = true;
				}

				if (!authorEmail || !emailVerification.test(authorEmail)) {
					self.$anonymCommenterEmailInput
						.attr('placeholder', _.call(self, 'Please specify your email'))
						.parent()
							.addClass('error');
					hasErrors = true;
				}

				if (!comment) {
					self.$anonymCommentInput
						.attr('placeholder', _.call(self, 'Please write a comment'))
						.parent()
							.addClass('error');
					hasErrors = true;
				}

				if (self.options.comments.useReCaptcha) {
					captcha = grecaptcha.getResponse(reCaptchaId);

					if (captcha.length == 0) {
						self.$newCommentCaptchaContainer.addClass('error');

						hasErrors = true;
					}
				}

				if (hasErrors) {
					return;
				}

				self.$anonymCommentWrapper.addClass('addingAnonComment');
				self.$anonymCommentPost.text(_.call(self, 'Commenting'));

				submitComment({}, authorName, authorEmail, comment, captcha, true);
			});

			self.$newCommentButton.on('click', submitComment);
		}

		if (self.options.like.permissions.liking) {
			self.$root.append('<span class="actions likeTrigger"><span>0</span></span>');

			self.$likeTrigger = $('> .actions.likeTrigger', self.$root);
			self.$mainLikeCount = $('> span', self.$likeTrigger);

			self.$likeTrigger.on('click', function () {
				if (self.$root.hasClass('initializing'))
					return;

				var activeItemIndex = self.currentItemIndex,
					currentItem = self.items[activeItemIndex],
					liked = !currentItem.likes.likedByUser,
					params = {
						portalId: self.options.portalId,
						moduleId: self.options.moduleId,
						mediaId: currentItem.id
					};

				currentItem.likes.likedByUser = liked;

				if (liked)
					currentItem.likes.numOfLikes += 1;
				else
					if (currentItem.likes.numOfLikes > 0)
						currentItem.likes.numOfLikes -= 1;

				self.$mainLikeCount.text(currentItem.likes.numOfLikes);
				self.$likeTrigger.toggleClass('liked', liked);

				if (typeof currentItem.journalId == 'number') {
					params.action = 'like';
					params.journalid = currentItem.journalId;
					params.liked = liked;
				} else {
					params.action = 'media_like';
					params.vote = liked ? 1 : -1;
				}

				$.ajax({
					data: params,
					dataType: 'json',
					type: 'POST',
					url: self.options.websiteRoot + 'DesktopModules/EasyDNNGallery/Services/SocialMediaBox.ashx',
					timeout: 10000,
					cache: false,
					error: function () { },
					success: function () { },
					complete: function () { }
				});
			});
		}

		self.$root.appendTo(self.$body);

		self.main = {
			horizontalSpace: 0,
			verticalSpace: 0
		};

		$.each(self.items, function (itemIndex) {
			var $itemDiv = $('<div></div>');

			$itemDiv
				.addClass('loading item_' + itemIndex)
				.data('itemIndex', itemIndex);

			if (this.type == 'image') {
				$itemDiv.addClass('imageItem');
			} else if (this.type == 'video') {
				$itemDiv.addClass('videoItem');
			} else if (this.type == 'audio') {
				$itemDiv.addClass('audioItem');
			}

			$itemDiv.appendTo(self.$contentWrapper)
		});

		size.call(self);

		self.$root.addClass('show');

		setTimeout(function () {
			showItem.call(self);
		}, 200);

		var hammerTime = new Hammer($('> .mobileOverlay', self.$root)[0]);

		self.skipGestures = false;
		var tapTimeout;

		hammerTime.on('swipeleft swiperight panleft panright panend tap', function (event) {
			var currentItemOffset = -(self.currentItemIndex * self.overlayWidth),
				deltaX = event.deltaX;

			if (event.type == 'tap') {
				clearTimeout(tapTimeout);

				if (self.$root.hasClass('hideControls')) {
					self.$root.removeClass('hideControls fadeOutControls');
				} else {
					self.$root.addClass('fadeOutControls');
					tapTimeout = setTimeout(function () {
						self.$root.addClass('hideControls');
					}, 500);
				}

				return;
			}

			if (self.skipGestures || !self.initialItemLoaded)
				return;

			if ((event.type == 'swipeleft' || event.type == 'swiperight') && items.length > 1) {
				if (event.type == 'swipeleft')
					if (self.currentItemIndex < self.items.length - 1)
						showNextItem.call(self);
					else
						if (self.currentItemIndex == 0)
							showPrevItem.call(self);

				return;
			}

			if (event.type == 'panend') {
				if (
					self.currentItemIndex == 0 && deltaX >= 0 ||
					self.currentItemIndex == self.items.length - 1 && deltaX < 0 ||
					Math.abs(deltaX) < self.overlayWidth / 2
				) {
					self.$contentWrapper
						.removeClass(swipeAnimationClass)
						.addClass(positionAnimationClass)
						.css({
							transform: 'translate3d(' + currentItemOffset + 'px, 0, 0)'
						});

					return;
				}

				self.skipGestures = true;

				var newX = -self.overlayWidth;
				var indexModifier = 1;

				if (deltaX > 0) {
					newX = self.overlayWidth;
					indexModifier = -1;
				}

				newX = currentItemOffset + newX;

				self.$contentWrapper
					.addClass(positionAnimationClass)
					.removeClass(swipeAnimationClass)
					.css({
						transform: 'translate3d(' + newX + 'px, 0, 0)'
					});

				setTimeout(function () {
					self.skipGestures = false;
					self.currentItemIndex += indexModifier;
					showItem.call(self);
				}, 550);

				return;
			}

			if (
				self.currentItemIndex == 0 && deltaX >= 0 ||
				self.currentItemIndex == self.items.length - 1 && deltaX < 0
			) {
				deltaX = 1 - Math.abs(deltaX) / self.overlayWidth;

				if (deltaX < .5) {
					deltaX = Math.round(self.overlayWidth / 4);

					if (event.deltaX < 1)
						deltaX = -deltaX;
				} else
					deltaX = Math.round(deltaX * event.deltaX);
			}

			self.$contentWrapper
				.removeClass(positionAnimationClass)
				.removeClass(swipeAnimationClass)
				.css({
					transform: 'translate3d(' + (currentItemOffset + deltaX) + 'px, 0, 0)'
				});
		});

		postInit.call(self);

		return self;
	}

	Mobile.prototype = {
		center: function () {
			var self = this,
				commentListHeight = 0;

			if (self.options.comments.permissions.show) {
				commentListHeight = $('>', self.$commentsModal).height() - self.$commentsTopBar.outerHeight(true) - self.$newCommentWrapper.outerHeight(true);

				if (commentListHeight < 0)
					commentListHeight = 0;

				self.$commentList.css('height', commentListHeight);
			};

			self.$contentWrapper
				.removeClass(positionAnimationClass)
				.removeClass(swipeAnimationClass)
				.css({
					width: self.items.length * self.overlayWidth,
					transform: 'translate3d(-' + self.currentItemIndex * self.overlayWidth + 'px, 0, 0)'
				});

			$('>', self.$contentWrapper)
				.width(self.overlayWidth)
				.each(function () {
					var $itemContainer = $(this),
						itemIndex = $itemContainer.data('itemIndex'),
						item = self.items[itemIndex];

					if ($itemContainer.hasClass('loading') || (item.type != 'image' && itemIndex != self.currentItemIndex))
						return;

					if (item.type == 'image') {
						var imageStats = self.images[item.src].stats;

						$('> img', $itemContainer).css(getItemDimensions.call(self, imageStats.width, imageStats.height, false));
					} else if (item.type == 'video') {
						$('> div', $itemContainer).css(getItemDimensions.call(self, item.width, item.height, true));
					} else if (item.type == 'audio') {
						$('> div', $itemContainer).css(getItemDimensions.call(self, 460, 36, false, true));
					}
				});
		},
		showItem: function () {
			var self = this,
				$currentDomItem = $('> div.item_' + self.currentItemIndex, self.$contentWrapper),
				thisItemIndex = self.currentItemIndex,
				currentItem = self.items[thisItemIndex],
				preloadNeighbours = function () {
					if (thisItemIndex > 0)
						preloadImage.call(
							self,
							validItemIndex.call(self, thisItemIndex - 1)
						);

					if (thisItemIndex < self.items.length - 1)
						preloadImage.call(
							self,
							validItemIndex.call(self, thisItemIndex + 1)
						);
				};

			self.$contentWrapper
				.removeClass(positionAnimationClass)
				.removeClass(swipeAnimationClass)
				.css({
					transform: 'translate3d(-' + thisItemIndex * self.overlayWidth + 'px, 0, 0)'
				});

			if (self.options.comments.permissions.show) {
				self.$newCommentInput.val('');
				self.$newCommentWrapper.removeClass('filledIn');

				if (!self.comments[currentItem.id])
					self.comments[currentItem.id] = {
						state: {
							open: false,
							commentsRequest: ajaxState.UNSET
						},
						count: currentItem.comments.count,
						cache: {
							authors: {},
							comments: []
						}
					};

				self.$mainCommentsCount.text(self.comments[currentItem.id].count);

				if (self.desktopVersion) {
					$.each(self.comments, function () {
						this.state.open = false;
					});

					self.updateItemComments();
				}
			}

			if (self.options.like.permissions.liking) {
				self.$likeTrigger.toggleClass('liked', currentItem.likes.likedByUser);
				self.$mainLikeCount.text(currentItem.likes.numOfLikes);
			}

			switch (currentItem.type) {
				case 'image':
					if ($currentDomItem.data(itemDomInitKey))
						return;

					preloadImage.call(
						self,
						thisItemIndex,
						function () {
							if (self.currentItemIndex != thisItemIndex)
								return;

							self.initialItemLoaded = true;
							preloadNeighbours();
						}
					);

					$currentDomItem.data(itemDomInitKey, true);
					break;

				case 'video':
					showVideo.call(self, self.currentItemIndex);
					break;

				case 'audio':
					showAudio.call(self, currentItem);
					break;

				default:
					self.initialItemLoaded = true;
			}

			if (currentItem.type != 'image')
				preloadNeighbours();

			self.$root.removeClass('initializing');
		},
		updateItemComments: function () {
			var self = this,
				activeItemIndex = self.currentItemIndex,
				currentItem = self.items[activeItemIndex],
				itemCommentMeta = self.comments[currentItem.id];

			if (itemCommentMeta.state.open || self.$root.hasClass('initializing'))
				return;

			itemCommentMeta.state.open = true;

			if (itemCommentMeta.state.commentsRequest == ajaxState.UNSET) {
				itemCommentMeta.state.commentsRequest = ajaxState.SENT;

				self.$commentsModal.addClass('loading');

				$.ajax({
					data: {
						action: 'list_comments'
					},
					dataType: 'json',
					type: 'GET',
					url: currentItem.comments.backend,
					timeout: 15000,
					cache: false,
					error: function () {
						itemCommentMeta.state.commentsRequest = ajaxState.UNSET;
					},
					success: function (response) {
						itemCommentMeta.cache = response;
						itemCommentMeta.count = response.comments.length;
						itemCommentMeta.state.commentsRequest = ajaxState.DONE;
					},
					complete: function () {
						if (!itemCommentMeta.state.open || activeItemIndex != self.currentItemIndex)
							return;

						self.$commentsModal.removeClass('loading');
						updateCommentsUi.call(self);
					}
				});
			} else {
				updateCommentsUi.call(self);
				self.$commentsModal.removeClass('loading');
			}

			self.$internalCommentsCount.text(itemCommentMeta.count);
			self.$commentsLikes
				.text(currentItem.likes.numOfLikes)
				.toggleClass('liked', currentItem.likes.likedByUser);
		},
		closeComments: function () {
			var self = this,
				currentItem = self.items[self.currentItemIndex],
				itemCommentMeta = self.comments[currentItem.id];

			itemCommentMeta.state.open = false;

			if (self.desktopVersion) {
				clearTimeout(self.commentsAnimationTimeout);

				self.$root.addClass('moveComments');
				self.$root.css('width', '');
				size.call(self);

				self.$root
					.addClass('animateComments')
					.removeClass('moveComments');

				self.commentsAnimationTimeout = setTimeout(function () {
					self.$root.removeClass('animateComments');
				}, 300);
			} else {
				self.$root.removeClass('modalActive');

				self.$modalOverlay
					.stop(true)
					.animate(
						{
							opacity: 0
						},
						{
							duration: 200
						}
					);
			}

			self.$commentsModal.removeClass('showAnonymWindow');
			self.$anonymCommentWrapper.removeClass('addingAnonComment');
			self.commentsOpened = false;
		}
	};

	window.SmbLight_1 = function (items, options) {
		if (!(this instanceof SmbLight_1))
			return new SmbLight_1(items, options);

		if (options.mobile)
			return new Mobile(items, options);

		return new Standard(items, options);
	}

})(eds3_5_jq, window);

;;;/*! Hammer.JS - v2.0.4 - 2014-09-28
 * http://hammerjs.github.io/
 *
 * Copyright (c) 2014 Jorik Tangelder;
 * Licensed under the MIT license */
!function(a,b,c,d){"use strict";function e(a,b,c){return setTimeout(k(a,c),b)}function f(a,b,c){return Array.isArray(a)?(g(a,c[b],c),!0):!1}function g(a,b,c){var e;if(a)if(a.forEach)a.forEach(b,c);else if(a.length!==d)for(e=0;e<a.length;)b.call(c,a[e],e,a),e++;else for(e in a)a.hasOwnProperty(e)&&b.call(c,a[e],e,a)}function h(a,b,c){for(var e=Object.keys(b),f=0;f<e.length;)(!c||c&&a[e[f]]===d)&&(a[e[f]]=b[e[f]]),f++;return a}function i(a,b){return h(a,b,!0)}function j(a,b,c){var d,e=b.prototype;d=a.prototype=Object.create(e),d.constructor=a,d._super=e,c&&h(d,c)}function k(a,b){return function(){return a.apply(b,arguments)}}function l(a,b){return typeof a==kb?a.apply(b?b[0]||d:d,b):a}function m(a,b){return a===d?b:a}function n(a,b,c){g(r(b),function(b){a.addEventListener(b,c,!1)})}function o(a,b,c){g(r(b),function(b){a.removeEventListener(b,c,!1)})}function p(a,b){for(;a;){if(a==b)return!0;a=a.parentNode}return!1}function q(a,b){return a.indexOf(b)>-1}function r(a){return a.trim().split(/\s+/g)}function s(a,b,c){if(a.indexOf&&!c)return a.indexOf(b);for(var d=0;d<a.length;){if(c&&a[d][c]==b||!c&&a[d]===b)return d;d++}return-1}function t(a){return Array.prototype.slice.call(a,0)}function u(a,b,c){for(var d=[],e=[],f=0;f<a.length;){var g=b?a[f][b]:a[f];s(e,g)<0&&d.push(a[f]),e[f]=g,f++}return c&&(d=b?d.sort(function(a,c){return a[b]>c[b]}):d.sort()),d}function v(a,b){for(var c,e,f=b[0].toUpperCase()+b.slice(1),g=0;g<ib.length;){if(c=ib[g],e=c?c+f:b,e in a)return e;g++}return d}function w(){return ob++}function x(a){var b=a.ownerDocument;return b.defaultView||b.parentWindow}function y(a,b){var c=this;this.manager=a,this.callback=b,this.element=a.element,this.target=a.options.inputTarget,this.domHandler=function(b){l(a.options.enable,[a])&&c.handler(b)},this.init()}function z(a){var b,c=a.options.inputClass;return new(b=c?c:rb?N:sb?Q:qb?S:M)(a,A)}function A(a,b,c){var d=c.pointers.length,e=c.changedPointers.length,f=b&yb&&d-e===0,g=b&(Ab|Bb)&&d-e===0;c.isFirst=!!f,c.isFinal=!!g,f&&(a.session={}),c.eventType=b,B(a,c),a.emit("hammer.input",c),a.recognize(c),a.session.prevInput=c}function B(a,b){var c=a.session,d=b.pointers,e=d.length;c.firstInput||(c.firstInput=E(b)),e>1&&!c.firstMultiple?c.firstMultiple=E(b):1===e&&(c.firstMultiple=!1);var f=c.firstInput,g=c.firstMultiple,h=g?g.center:f.center,i=b.center=F(d);b.timeStamp=nb(),b.deltaTime=b.timeStamp-f.timeStamp,b.angle=J(h,i),b.distance=I(h,i),C(c,b),b.offsetDirection=H(b.deltaX,b.deltaY),b.scale=g?L(g.pointers,d):1,b.rotation=g?K(g.pointers,d):0,D(c,b);var j=a.element;p(b.srcEvent.target,j)&&(j=b.srcEvent.target),b.target=j}function C(a,b){var c=b.center,d=a.offsetDelta||{},e=a.prevDelta||{},f=a.prevInput||{};(b.eventType===yb||f.eventType===Ab)&&(e=a.prevDelta={x:f.deltaX||0,y:f.deltaY||0},d=a.offsetDelta={x:c.x,y:c.y}),b.deltaX=e.x+(c.x-d.x),b.deltaY=e.y+(c.y-d.y)}function D(a,b){var c,e,f,g,h=a.lastInterval||b,i=b.timeStamp-h.timeStamp;if(b.eventType!=Bb&&(i>xb||h.velocity===d)){var j=h.deltaX-b.deltaX,k=h.deltaY-b.deltaY,l=G(i,j,k);e=l.x,f=l.y,c=mb(l.x)>mb(l.y)?l.x:l.y,g=H(j,k),a.lastInterval=b}else c=h.velocity,e=h.velocityX,f=h.velocityY,g=h.direction;b.velocity=c,b.velocityX=e,b.velocityY=f,b.direction=g}function E(a){for(var b=[],c=0;c<a.pointers.length;)b[c]={clientX:lb(a.pointers[c].clientX),clientY:lb(a.pointers[c].clientY)},c++;return{timeStamp:nb(),pointers:b,center:F(b),deltaX:a.deltaX,deltaY:a.deltaY}}function F(a){var b=a.length;if(1===b)return{x:lb(a[0].clientX),y:lb(a[0].clientY)};for(var c=0,d=0,e=0;b>e;)c+=a[e].clientX,d+=a[e].clientY,e++;return{x:lb(c/b),y:lb(d/b)}}function G(a,b,c){return{x:b/a||0,y:c/a||0}}function H(a,b){return a===b?Cb:mb(a)>=mb(b)?a>0?Db:Eb:b>0?Fb:Gb}function I(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return Math.sqrt(d*d+e*e)}function J(a,b,c){c||(c=Kb);var d=b[c[0]]-a[c[0]],e=b[c[1]]-a[c[1]];return 180*Math.atan2(e,d)/Math.PI}function K(a,b){return J(b[1],b[0],Lb)-J(a[1],a[0],Lb)}function L(a,b){return I(b[0],b[1],Lb)/I(a[0],a[1],Lb)}function M(){this.evEl=Nb,this.evWin=Ob,this.allow=!0,this.pressed=!1,y.apply(this,arguments)}function N(){this.evEl=Rb,this.evWin=Sb,y.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}function O(){this.evTarget=Ub,this.evWin=Vb,this.started=!1,y.apply(this,arguments)}function P(a,b){var c=t(a.touches),d=t(a.changedTouches);return b&(Ab|Bb)&&(c=u(c.concat(d),"identifier",!0)),[c,d]}function Q(){this.evTarget=Xb,this.targetIds={},y.apply(this,arguments)}function R(a,b){var c=t(a.touches),d=this.targetIds;if(b&(yb|zb)&&1===c.length)return d[c[0].identifier]=!0,[c,c];var e,f,g=t(a.changedTouches),h=[],i=this.target;if(f=c.filter(function(a){return p(a.target,i)}),b===yb)for(e=0;e<f.length;)d[f[e].identifier]=!0,e++;for(e=0;e<g.length;)d[g[e].identifier]&&h.push(g[e]),b&(Ab|Bb)&&delete d[g[e].identifier],e++;return h.length?[u(f.concat(h),"identifier",!0),h]:void 0}function S(){y.apply(this,arguments);var a=k(this.handler,this);this.touch=new Q(this.manager,a),this.mouse=new M(this.manager,a)}function T(a,b){this.manager=a,this.set(b)}function U(a){if(q(a,bc))return bc;var b=q(a,cc),c=q(a,dc);return b&&c?cc+" "+dc:b||c?b?cc:dc:q(a,ac)?ac:_b}function V(a){this.id=w(),this.manager=null,this.options=i(a||{},this.defaults),this.options.enable=m(this.options.enable,!0),this.state=ec,this.simultaneous={},this.requireFail=[]}function W(a){return a&jc?"cancel":a&hc?"end":a&gc?"move":a&fc?"start":""}function X(a){return a==Gb?"down":a==Fb?"up":a==Db?"left":a==Eb?"right":""}function Y(a,b){var c=b.manager;return c?c.get(a):a}function Z(){V.apply(this,arguments)}function $(){Z.apply(this,arguments),this.pX=null,this.pY=null}function _(){Z.apply(this,arguments)}function ab(){V.apply(this,arguments),this._timer=null,this._input=null}function bb(){Z.apply(this,arguments)}function cb(){Z.apply(this,arguments)}function db(){V.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}function eb(a,b){return b=b||{},b.recognizers=m(b.recognizers,eb.defaults.preset),new fb(a,b)}function fb(a,b){b=b||{},this.options=i(b,eb.defaults),this.options.inputTarget=this.options.inputTarget||a,this.handlers={},this.session={},this.recognizers=[],this.element=a,this.input=z(this),this.touchAction=new T(this,this.options.touchAction),gb(this,!0),g(b.recognizers,function(a){var b=this.add(new a[0](a[1]));a[2]&&b.recognizeWith(a[2]),a[3]&&b.requireFailure(a[3])},this)}function gb(a,b){var c=a.element;g(a.options.cssProps,function(a,d){c.style[v(c.style,d)]=b?a:""})}function hb(a,c){var d=b.createEvent("Event");d.initEvent(a,!0,!0),d.gesture=c,c.target.dispatchEvent(d)}var ib=["","webkit","moz","MS","ms","o"],jb=b.createElement("div"),kb="function",lb=Math.round,mb=Math.abs,nb=Date.now,ob=1,pb=/mobile|tablet|ip(ad|hone|od)|android/i,qb="ontouchstart"in a,rb=v(a,"PointerEvent")!==d,sb=qb&&pb.test(navigator.userAgent),tb="touch",ub="pen",vb="mouse",wb="kinect",xb=25,yb=1,zb=2,Ab=4,Bb=8,Cb=1,Db=2,Eb=4,Fb=8,Gb=16,Hb=Db|Eb,Ib=Fb|Gb,Jb=Hb|Ib,Kb=["x","y"],Lb=["clientX","clientY"];y.prototype={handler:function(){},init:function(){this.evEl&&n(this.element,this.evEl,this.domHandler),this.evTarget&&n(this.target,this.evTarget,this.domHandler),this.evWin&&n(x(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&o(this.element,this.evEl,this.domHandler),this.evTarget&&o(this.target,this.evTarget,this.domHandler),this.evWin&&o(x(this.element),this.evWin,this.domHandler)}};var Mb={mousedown:yb,mousemove:zb,mouseup:Ab},Nb="mousedown",Ob="mousemove mouseup";j(M,y,{handler:function(a){var b=Mb[a.type];b&yb&&0===a.button&&(this.pressed=!0),b&zb&&1!==a.which&&(b=Ab),this.pressed&&this.allow&&(b&Ab&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[a],changedPointers:[a],pointerType:vb,srcEvent:a}))}});var Pb={pointerdown:yb,pointermove:zb,pointerup:Ab,pointercancel:Bb,pointerout:Bb},Qb={2:tb,3:ub,4:vb,5:wb},Rb="pointerdown",Sb="pointermove pointerup pointercancel";a.MSPointerEvent&&(Rb="MSPointerDown",Sb="MSPointerMove MSPointerUp MSPointerCancel"),j(N,y,{handler:function(a){var b=this.store,c=!1,d=a.type.toLowerCase().replace("ms",""),e=Pb[d],f=Qb[a.pointerType]||a.pointerType,g=f==tb,h=s(b,a.pointerId,"pointerId");e&yb&&(0===a.button||g)?0>h&&(b.push(a),h=b.length-1):e&(Ab|Bb)&&(c=!0),0>h||(b[h]=a,this.callback(this.manager,e,{pointers:b,changedPointers:[a],pointerType:f,srcEvent:a}),c&&b.splice(h,1))}});var Tb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Ub="touchstart",Vb="touchstart touchmove touchend touchcancel";j(O,y,{handler:function(a){var b=Tb[a.type];if(b===yb&&(this.started=!0),this.started){var c=P.call(this,a,b);b&(Ab|Bb)&&c[0].length-c[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}});var Wb={touchstart:yb,touchmove:zb,touchend:Ab,touchcancel:Bb},Xb="touchstart touchmove touchend touchcancel";j(Q,y,{handler:function(a){var b=Wb[a.type],c=R.call(this,a,b);c&&this.callback(this.manager,b,{pointers:c[0],changedPointers:c[1],pointerType:tb,srcEvent:a})}}),j(S,y,{handler:function(a,b,c){var d=c.pointerType==tb,e=c.pointerType==vb;if(d)this.mouse.allow=!1;else if(e&&!this.mouse.allow)return;b&(Ab|Bb)&&(this.mouse.allow=!0),this.callback(a,b,c)},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});var Yb=v(jb.style,"touchAction"),Zb=Yb!==d,$b="compute",_b="auto",ac="manipulation",bc="none",cc="pan-x",dc="pan-y";T.prototype={set:function(a){a==$b&&(a=this.compute()),Zb&&(this.manager.element.style[Yb]=a),this.actions=a.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var a=[];return g(this.manager.recognizers,function(b){l(b.options.enable,[b])&&(a=a.concat(b.getTouchAction()))}),U(a.join(" "))},preventDefaults:function(a){if(!Zb){var b=a.srcEvent,c=a.offsetDirection;if(this.manager.session.prevented)return void b.preventDefault();var d=this.actions,e=q(d,bc),f=q(d,dc),g=q(d,cc);return e||f&&c&Hb||g&&c&Ib?this.preventSrc(b):void 0}},preventSrc:function(a){this.manager.session.prevented=!0,a.preventDefault()}};var ec=1,fc=2,gc=4,hc=8,ic=hc,jc=16,kc=32;V.prototype={defaults:{},set:function(a){return h(this.options,a),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(a){if(f(a,"recognizeWith",this))return this;var b=this.simultaneous;return a=Y(a,this),b[a.id]||(b[a.id]=a,a.recognizeWith(this)),this},dropRecognizeWith:function(a){return f(a,"dropRecognizeWith",this)?this:(a=Y(a,this),delete this.simultaneous[a.id],this)},requireFailure:function(a){if(f(a,"requireFailure",this))return this;var b=this.requireFail;return a=Y(a,this),-1===s(b,a)&&(b.push(a),a.requireFailure(this)),this},dropRequireFailure:function(a){if(f(a,"dropRequireFailure",this))return this;a=Y(a,this);var b=s(this.requireFail,a);return b>-1&&this.requireFail.splice(b,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(a){return!!this.simultaneous[a.id]},emit:function(a){function b(b){c.manager.emit(c.options.event+(b?W(d):""),a)}var c=this,d=this.state;hc>d&&b(!0),b(),d>=hc&&b(!0)},tryEmit:function(a){return this.canEmit()?this.emit(a):void(this.state=kc)},canEmit:function(){for(var a=0;a<this.requireFail.length;){if(!(this.requireFail[a].state&(kc|ec)))return!1;a++}return!0},recognize:function(a){var b=h({},a);return l(this.options.enable,[this,b])?(this.state&(ic|jc|kc)&&(this.state=ec),this.state=this.process(b),void(this.state&(fc|gc|hc|jc)&&this.tryEmit(b))):(this.reset(),void(this.state=kc))},process:function(){},getTouchAction:function(){},reset:function(){}},j(Z,V,{defaults:{pointers:1},attrTest:function(a){var b=this.options.pointers;return 0===b||a.pointers.length===b},process:function(a){var b=this.state,c=a.eventType,d=b&(fc|gc),e=this.attrTest(a);return d&&(c&Bb||!e)?b|jc:d||e?c&Ab?b|hc:b&fc?b|gc:fc:kc}}),j($,Z,{defaults:{event:"pan",threshold:10,pointers:1,direction:Jb},getTouchAction:function(){var a=this.options.direction,b=[];return a&Hb&&b.push(dc),a&Ib&&b.push(cc),b},directionTest:function(a){var b=this.options,c=!0,d=a.distance,e=a.direction,f=a.deltaX,g=a.deltaY;return e&b.direction||(b.direction&Hb?(e=0===f?Cb:0>f?Db:Eb,c=f!=this.pX,d=Math.abs(a.deltaX)):(e=0===g?Cb:0>g?Fb:Gb,c=g!=this.pY,d=Math.abs(a.deltaY))),a.direction=e,c&&d>b.threshold&&e&b.direction},attrTest:function(a){return Z.prototype.attrTest.call(this,a)&&(this.state&fc||!(this.state&fc)&&this.directionTest(a))},emit:function(a){this.pX=a.deltaX,this.pY=a.deltaY;var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this._super.emit.call(this,a)}}),j(_,Z,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.scale-1)>this.options.threshold||this.state&fc)},emit:function(a){if(this._super.emit.call(this,a),1!==a.scale){var b=a.scale<1?"in":"out";this.manager.emit(this.options.event+b,a)}}}),j(ab,V,{defaults:{event:"press",pointers:1,time:500,threshold:5},getTouchAction:function(){return[_b]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime>b.time;if(this._input=a,!d||!c||a.eventType&(Ab|Bb)&&!f)this.reset();else if(a.eventType&yb)this.reset(),this._timer=e(function(){this.state=ic,this.tryEmit()},b.time,this);else if(a.eventType&Ab)return ic;return kc},reset:function(){clearTimeout(this._timer)},emit:function(a){this.state===ic&&(a&&a.eventType&Ab?this.manager.emit(this.options.event+"up",a):(this._input.timeStamp=nb(),this.manager.emit(this.options.event,this._input)))}}),j(bb,Z,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[bc]},attrTest:function(a){return this._super.attrTest.call(this,a)&&(Math.abs(a.rotation)>this.options.threshold||this.state&fc)}}),j(cb,Z,{defaults:{event:"swipe",threshold:10,velocity:.65,direction:Hb|Ib,pointers:1},getTouchAction:function(){return $.prototype.getTouchAction.call(this)},attrTest:function(a){var b,c=this.options.direction;return c&(Hb|Ib)?b=a.velocity:c&Hb?b=a.velocityX:c&Ib&&(b=a.velocityY),this._super.attrTest.call(this,a)&&c&a.direction&&a.distance>this.options.threshold&&mb(b)>this.options.velocity&&a.eventType&Ab},emit:function(a){var b=X(a.direction);b&&this.manager.emit(this.options.event+b,a),this.manager.emit(this.options.event,a)}}),j(db,V,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:2,posThreshold:10},getTouchAction:function(){return[ac]},process:function(a){var b=this.options,c=a.pointers.length===b.pointers,d=a.distance<b.threshold,f=a.deltaTime<b.time;if(this.reset(),a.eventType&yb&&0===this.count)return this.failTimeout();if(d&&f&&c){if(a.eventType!=Ab)return this.failTimeout();var g=this.pTime?a.timeStamp-this.pTime<b.interval:!0,h=!this.pCenter||I(this.pCenter,a.center)<b.posThreshold;this.pTime=a.timeStamp,this.pCenter=a.center,h&&g?this.count+=1:this.count=1,this._input=a;var i=this.count%b.taps;if(0===i)return this.hasRequireFailures()?(this._timer=e(function(){this.state=ic,this.tryEmit()},b.interval,this),fc):ic}return kc},failTimeout:function(){return this._timer=e(function(){this.state=kc},this.options.interval,this),kc},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==ic&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}}),eb.VERSION="2.0.4",eb.defaults={domEvents:!1,touchAction:$b,enable:!0,inputTarget:null,inputClass:null,preset:[[bb,{enable:!1}],[_,{enable:!1},["rotate"]],[cb,{direction:Hb}],[$,{direction:Hb},["swipe"]],[db],[db,{event:"doubletap",taps:2},["tap"]],[ab]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var lc=1,mc=2;fb.prototype={set:function(a){return h(this.options,a),a.touchAction&&this.touchAction.update(),a.inputTarget&&(this.input.destroy(),this.input.target=a.inputTarget,this.input.init()),this},stop:function(a){this.session.stopped=a?mc:lc},recognize:function(a){var b=this.session;if(!b.stopped){this.touchAction.preventDefaults(a);var c,d=this.recognizers,e=b.curRecognizer;(!e||e&&e.state&ic)&&(e=b.curRecognizer=null);for(var f=0;f<d.length;)c=d[f],b.stopped===mc||e&&c!=e&&!c.canRecognizeWith(e)?c.reset():c.recognize(a),!e&&c.state&(fc|gc|hc)&&(e=b.curRecognizer=c),f++}},get:function(a){if(a instanceof V)return a;for(var b=this.recognizers,c=0;c<b.length;c++)if(b[c].options.event==a)return b[c];return null},add:function(a){if(f(a,"add",this))return this;var b=this.get(a.options.event);return b&&this.remove(b),this.recognizers.push(a),a.manager=this,this.touchAction.update(),a},remove:function(a){if(f(a,"remove",this))return this;var b=this.recognizers;return a=this.get(a),b.splice(s(b,a),1),this.touchAction.update(),this},on:function(a,b){var c=this.handlers;return g(r(a),function(a){c[a]=c[a]||[],c[a].push(b)}),this},off:function(a,b){var c=this.handlers;return g(r(a),function(a){b?c[a].splice(s(c[a],b),1):delete c[a]}),this},emit:function(a,b){this.options.domEvents&&hb(a,b);var c=this.handlers[a]&&this.handlers[a].slice();if(c&&c.length){b.type=a,b.preventDefault=function(){b.srcEvent.preventDefault()};for(var d=0;d<c.length;)c[d](b),d++}},destroy:function(){this.element&&gb(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}},h(eb,{INPUT_START:yb,INPUT_MOVE:zb,INPUT_END:Ab,INPUT_CANCEL:Bb,STATE_POSSIBLE:ec,STATE_BEGAN:fc,STATE_CHANGED:gc,STATE_ENDED:hc,STATE_RECOGNIZED:ic,STATE_CANCELLED:jc,STATE_FAILED:kc,DIRECTION_NONE:Cb,DIRECTION_LEFT:Db,DIRECTION_RIGHT:Eb,DIRECTION_UP:Fb,DIRECTION_DOWN:Gb,DIRECTION_HORIZONTAL:Hb,DIRECTION_VERTICAL:Ib,DIRECTION_ALL:Jb,Manager:fb,Input:y,TouchAction:T,TouchInput:Q,MouseInput:M,PointerEventInput:N,TouchMouseInput:S,SingleTouchInput:O,Recognizer:V,AttrRecognizer:Z,Tap:db,Pan:$,Swipe:cb,Pinch:_,Rotate:bb,Press:ab,on:n,off:o,each:g,merge:i,extend:h,inherit:j,bindFn:k,prefixed:v}),typeof define==kb&&define.amd?define(function(){return eb}):"undefined"!=typeof module&&module.exports?module.exports=eb:a[c]=eb}(window,document,"Hammer");
//# sourceMappingURL=hammer.min.map
;;;