Team:Cornell NY/homeJS

/*!

* Masonry PACKAGED v3.2.2
* Cascading grid layout library
* http://masonry.desandro.com
* MIT License
* by David DeSandro
*/

!function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}return this.each(function(){var d=a.data(this,b);d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d))})}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;"function"==typeof define&&define.amd?define("jquery-bridget/jquery.bridget",["jquery"],c):c("object"==typeof exports?require("jquery"):a.jQuery)}(window),function(a){function b(b){var c=a.event;return c.target=c.target||c.srcElement||b,c}var c=document.documentElement,d=function(){};c.addEventListener?d=function(a,b,c){a.addEventListener(b,c,!1)}:c.attachEvent&&(d=function(a,c,d){a[c+d]=d.handleEvent?function(){var c=b(a);d.handleEvent.call(d,c)}:function(){var c=b(a);d.call(a,c)},a.attachEvent("on"+c,a[c+d])});var e=function(){};c.removeEventListener?e=function(a,b,c){a.removeEventListener(b,c,!1)}:c.detachEvent&&(e=function(a,b,c){a.detachEvent("on"+b,a[b+c]);try{delete a[b+c]}catch(d){a[b+c]=void 0}});var f={bind:d,unbind:e};"function"==typeof define&&define.amd?define("eventie/eventie",f):"object"==typeof exports?module.exports=f:a.eventie=f}(this),function(a){function b(a){"function"==typeof a&&(b.isReady?a():g.push(a))}function c(a){var c="readystatechange"===a.type&&"complete"!==f.readyState;b.isReady||c||d()}function d(){b.isReady=!0;for(var a=0,c=g.length;c>a;a++){var d=g[a];d()}}function e(e){return"complete"===f.readyState?d():(e.bind(f,"DOMContentLoaded",c),e.bind(f,"readystatechange",c),e.bind(a,"load",c)),b}var f=a.document,g=[];b.isReady=!1,"function"==typeof define&&define.amd?define("doc-ready/doc-ready",["eventie/eventie"],e):"object"==typeof exports?module.exports=e(require("eventie")):a.docReady=e(a.eventie)}(window),function(){function a(){}function b(a,b){for(var c=a.length;c--;)if(a[c].listener===b)return c;return-1}function c(a){return function(){return this[a].apply(this,arguments)}}var d=a.prototype,e=this,f=e.EventEmitter;d.getListeners=function(a){var b,c,d=this._getEvents();if(a instanceof RegExp){b={};for(c in d)d.hasOwnProperty(c)&&a.test(c)&&(b[c]=d[c])}else b=d[a]||(d[a]=[]);return b},d.flattenListeners=function(a){var b,c=[];for(b=0;b<a.length;b+=1)c.push(a[b].listener);return c},d.getListenersAsObject=function(a){var b,c=this.getListeners(a);return c instanceof Array&&(b={},b[a]=c),b||c},d.addListener=function(a,c){var d,e=this.getListenersAsObject(a),f="object"==typeof c;for(d in e)e.hasOwnProperty(d)&&-1===b(e[d],c)&&e[d].push(f?c:{listener:c,once:!1});return this},d.on=c("addListener"),d.addOnceListener=function(a,b){return this.addListener(a,{listener:b,once:!0})},d.once=c("addOnceListener"),d.defineEvent=function(a){return this.getListeners(a),this},d.defineEvents=function(a){for(var b=0;b<a.length;b+=1)this.defineEvent(a[b]);return this},d.removeListener=function(a,c){var d,e,f=this.getListenersAsObject(a);for(e in f)f.hasOwnProperty(e)&&(d=b(f[e],c),-1!==d&&f[e].splice(d,1));return this},d.off=c("removeListener"),d.addListeners=function(a,b){return this.manipulateListeners(!1,a,b)},d.removeListeners=function(a,b){return this.manipulateListeners(!0,a,b)},d.manipulateListeners=function(a,b,c){var d,e,f=a?this.removeListener:this.addListener,g=a?this.removeListeners:this.addListeners;if("object"!=typeof b||b instanceof RegExp)for(d=c.length;d--;)f.call(this,b,c[d]);else for(d in b)b.hasOwnProperty(d)&&(e=b[d])&&("function"==typeof e?f.call(this,d,e):g.call(this,d,e));return this},d.removeEvent=function(a){var b,c=typeof a,d=this._getEvents();if("string"===c)delete d[a];else if(a instanceof RegExp)for(b in d)d.hasOwnProperty(b)&&a.test(b)&&delete d[b];else delete this._events;return this},d.removeAllListeners=c("removeEvent"),d.emitEvent=function(a,b){var c,d,e,f,g=this.getListenersAsObject(a);for(e in g)if(g.hasOwnProperty(e))for(d=g[e].length;d--;)c=g[e][d],c.once===!0&&this.removeListener(a,c.listener),f=c.listener.apply(this,b||[]),f===this._getOnceReturnValue()&&this.removeListener(a,c.listener);return this},d.trigger=c("emitEvent"),d.emit=function(a){var b=Array.prototype.slice.call(arguments,1);return this.emitEvent(a,b)},d.setOnceReturnValue=function(a){return this._onceReturnValue=a,this},d._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},d._getEvents=function(){return this._events||(this._events={})},a.noConflict=function(){return e.EventEmitter=f,a},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return a}):"object"==typeof module&&module.exports?module.exports=a:e.EventEmitter=a}.call(this),function(a){function b(a){if(a){if("string"==typeof d[a])return a;a=a.charAt(0).toUpperCase()+a.slice(1);for(var b,e=0,f=c.length;f>e;e++)if(b=c[e]+a,"string"==typeof d[b])return b}}var c="Webkit Moz ms Ms O".split(" "),d=document.documentElement.style;"function"==typeof define&&define.amd?define("get-style-property/get-style-property",[],function(){return b}):"object"==typeof exports?module.exports=b:a.getStyleProperty=b}(window),function(a){function b(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function c(){}function d(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=g.length;c>b;b++){var d=g[b];a[d]=0}return a}function e(c){function e(){if(!m){m=!0;var d=a.getComputedStyle;if(j=function(){var a=d?function(a){return d(a,null)}:function(a){return a.currentStyle};return function(b){var c=a(b);return c||f("Style returned "+c+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),c}}(),k=c("boxSizing")){var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style[k]="border-box";var g=document.body||document.documentElement;g.appendChild(e);var h=j(e);l=200===b(h.width),g.removeChild(e)}}}function h(a){if(e(),"string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var c=j(a);if("none"===c.display)return d();var f={};f.width=a.offsetWidth,f.height=a.offsetHeight;for(var h=f.isBorderBox=!(!k||!c[k]||"border-box"!==c[k]),m=0,n=g.length;n>m;m++){var o=g[m],p=c[o];p=i(a,p);var q=parseFloat(p);f[o]=isNaN(q)?0:q}var r=f.paddingLeft+f.paddingRight,s=f.paddingTop+f.paddingBottom,t=f.marginLeft+f.marginRight,u=f.marginTop+f.marginBottom,v=f.borderLeftWidth+f.borderRightWidth,w=f.borderTopWidth+f.borderBottomWidth,x=h&&l,y=b(c.width);y!==!1&&(f.width=y+(x?0:r+v));var z=b(c.height);return z!==!1&&(f.height=z+(x?0:s+w)),f.innerWidth=f.width-(r+v),f.innerHeight=f.height-(s+w),f.outerWidth=f.width+t,f.outerHeight=f.height+u,f}}function i(b,c){if(a.getComputedStyle||-1===c.indexOf("%"))return c;var d=b.style,e=d.left,f=b.runtimeStyle,g=f&&f.left;return g&&(f.left=b.currentStyle.left),d.left=c,c=d.pixelLeft,d.left=e,g&&(f.left=g),c}var j,k,l,m=!1;return h}var f="undefined"==typeof console?c:function(a){console.error(a)},g=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"];"function"==typeof define&&define.amd?define("get-size/get-size",["get-style-property/get-style-property"],e):"object"==typeof exports?module.exports=e(require("desandro-get-style-property")):a.getSize=e(a.getStyleProperty)}(window),function(a){function b(a,b){return a[g](b)}function c(a){if(!a.parentNode){var b=document.createDocumentFragment();b.appendChild(a)}}function d(a,b){c(a);for(var d=a.parentNode.querySelectorAll(b),e=0,f=d.length;f>e;e++)if(d[e]===a)return!0;return!1}function e(a,d){return c(a),b(a,d)}var f,g=function(){if(a.matchesSelector)return"matchesSelector";for(var b=["webkit","moz","ms","o"],c=0,d=b.length;d>c;c++){var e=b[c],f=e+"MatchesSelector";if(a[f])return f}}();if(g){var h=document.createElement("div"),i=b(h,"div");f=i?b:e}else f=d;"function"==typeof define&&define.amd?define("matches-selector/matches-selector",[],function(){return f}):"object"==typeof exports?module.exports=f:window.matchesSelector=f}(Element.prototype),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){for(var b in a)return!1;return b=null,!0}function d(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}function e(a,e,f){function h(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}var i=f("transition"),j=f("transform"),k=i&&j,l=!!f("perspective"),m={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[i],n=["transform","transition","transitionDuration","transitionProperty"],o=function(){for(var a={},b=0,c=n.length;c>b;b++){var d=n[b],e=f(d);e&&e!==d&&(a[d]=e)}return a}();b(h.prototype,a.prototype),h.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},h.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},h.prototype.getSize=function(){this.size=e(this.element)},h.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=o[c]||c;b[d]=a[c]}},h.prototype.getPosition=function(){var a=g(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=parseInt(a[c?"left":"right"],10),f=parseInt(a[d?"top":"bottom"],10);e=isNaN(e)?0:e,f=isNaN(f)?0:f;var h=this.layout.size;e-=c?h.paddingLeft:h.paddingRight,f-=d?h.paddingTop:h.paddingBottom,this.position.x=e,this.position.y=f},h.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={};b.isOriginLeft?(c.left=this.position.x+a.paddingLeft+"px",c.right=""):(c.right=this.position.x+a.paddingRight+"px",c.left=""),b.isOriginTop?(c.top=this.position.y+a.paddingTop+"px",c.bottom=""):(c.bottom=this.position.y+a.paddingBottom+"px",c.top=""),this.css(c),this.emitEvent("layout",[this])};var p=l?function(a,b){return"translate3d("+a+"px, "+b+"px, 0)"}:function(a,b){return"translate("+a+"px, "+b+"px)"};h.prototype._transitionTo=function(a,b){this.getPosition();var c=this.position.x,d=this.position.y,e=parseInt(a,10),f=parseInt(b,10),g=e===this.position.x&&f===this.position.y;if(this.setPosition(a,b),g&&!this.isTransitioning)return void this.layoutPosition();var h=a-c,i=b-d,j={},k=this.layout.options;h=k.isOriginLeft?h:-h,i=k.isOriginTop?i:-i,j.transform=p(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},h.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},h.prototype.moveTo=k?h.prototype._transitionTo:h.prototype.goTo,h.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},h.prototype._nonTransition=function(a){this.css(a.to),a.isCleaning&&this._removeStyles(a.to);for(var b in a.onTransitionEnd)a.onTransitionEnd[b].call(this)},h.prototype._transition=function(a){if(!parseFloat(this.layout.options.transitionDuration))return void this._nonTransition(a);var b=this._transn;for(var c in a.onTransitionEnd)b.onEnd[c]=a.onTransitionEnd[c];for(c in a.to)b.ingProperties[c]=!0,a.isCleaning&&(b.clean[c]=!0);if(a.from){this.css(a.from);var d=this.element.offsetHeight;d=null}this.enableTransition(a.to),this.css(a.to),this.isTransitioning=!0};var q=j&&d(j)+",opacity";h.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:q,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(m,this,!1))},h.prototype.transition=h.prototype[i?"_transition":"_nonTransition"],h.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},h.prototype.onotransitionend=function(a){this.ontransitionend(a)};var r={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};h.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,d=r[a.propertyName]||a.propertyName;if(delete b.ingProperties[d],c(b.ingProperties)&&this.disableTransition(),d in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[d]),d in b.onEnd){var e=b.onEnd[d];e.call(this),delete b.onEnd[d]}this.emitEvent("transitionEnd",[this])}},h.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(m,this,!1),this.isTransitioning=!1},h.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var s={transitionProperty:"",transitionDuration:""};return h.prototype.removeTransitionStyles=function(){this.css(s)},h.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.emitEvent("remove",[this])},h.prototype.remove=function(){if(!i||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.on("transitionEnd",function(){return a.removeElem(),!0}),this.hide()},h.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options;this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0})},h.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options;this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:{opacity:function(){this.isHidden&&this.css({display:"none"})}}})},h.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},h}var f=a.getComputedStyle,g=f?function(a){return f(a,null)}:function(a){return a.currentStyle};"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property"],e):"object"==typeof exports?module.exports=e(require("wolfy87-eventemitter"),require("get-size"),require("desandro-get-style-property")):(a.Outlayer={},a.Outlayer.Item=e(a.EventEmitter,a.getSize,a.getStyleProperty))}(window),function(a){function b(a,b){for(var c in b)a[c]=b[c];return a}function c(a){return"[object Array]"===l.call(a)}function d(a){var b=[];if(c(a))b=a;else if(a&&"number"==typeof a.length)for(var d=0,e=a.length;e>d;d++)b.push(a[d]);else b.push(a);return b}function e(a,b){var c=n(b,a);-1!==c&&b.splice(c,1)}function f(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()}function g(c,g,l,n,o,p){function q(a,c){if("string"==typeof a&&(a=h.querySelector(a)),!a||!m(a))return void(i&&i.error("Bad "+this.constructor.namespace+" element: "+a));this.element=a,this.options=b({},this.constructor.defaults),this.option(c);var d=++r;this.element.outlayerGUID=d,s[d]=this,this._create(),this.options.isInitLayout&&this.layout()}var r=0,s={};return q.namespace="outlayer",q.Item=p,q.defaults={containerStyle:{position:"relative"},isInitLayout:!0,isOriginLeft:!0,isOriginTop:!0,isResizeBound:!0,isResizingContainer:!0,transitionDuration:"0.4s",hiddenStyle:{opacity:0,transform:"scale(0.001)"},visibleStyle:{opacity:1,transform:"scale(1)"}},b(q.prototype,l.prototype),q.prototype.option=function(a){b(this.options,a)},q.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),b(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},q.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},q.prototype._itemize=function(a){for(var b=this._filterFindItemElements(a),c=this.constructor.Item,d=[],e=0,f=b.length;f>e;e++){var g=b[e],h=new c(g,this);d.push(h)}return d},q.prototype._filterFindItemElements=function(a){a=d(a);for(var b=this.options.itemSelector,c=[],e=0,f=a.length;f>e;e++){var g=a[e];if(m(g))if(b){o(g,b)&&c.push(g);for(var h=g.querySelectorAll(b),i=0,j=h.length;j>i;i++)c.push(h[i])}else c.push(g)}return c},q.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},q.prototype.layout=function(){this._resetLayout(),this._manageStamps();var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;this.layoutItems(this.items,a),this._isLayoutInited=!0},q.prototype._init=q.prototype.layout,q.prototype._resetLayout=function(){this.getSize()},q.prototype.getSize=function(){this.size=n(this.element)},q.prototype._getMeasurement=function(a,b){var c,d=this.options[a];d?("string"==typeof d?c=this.element.querySelector(d):m(d)&&(c=d),this[a]=c?n(c)[b]:d):this[a]=0},q.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},q.prototype._getItemsForLayout=function(a){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c];e.isIgnored||b.push(e)}return b},q.prototype._layoutItems=function(a,b){function c(){d.emitEvent("layoutComplete",[d,a])}var d=this;if(!a||!a.length)return void c();this._itemsOn(a,"layout",c);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f],i=this._getItemLayoutPosition(h);i.item=h,i.isInstant=b||h.isLayoutInstant,e.push(i)}this._processLayoutQueue(e)},q.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},q.prototype._processLayoutQueue=function(a){for(var b=0,c=a.length;c>b;b++){var d=a[b];this._positionItem(d.item,d.x,d.y,d.isInstant)}},q.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},q.prototype._postLayout=function(){this.resizeContainer()},q.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},q.prototype._getContainerSize=k,q.prototype._setContainerMeasure=function(a,b){if(void 0!==a){var c=this.size;c.isBorderBox&&(a+=b?c.paddingLeft+c.paddingRight+c.borderLeftWidth+c.borderRightWidth:c.paddingBottom+c.paddingTop+c.borderTopWidth+c.borderBottomWidth),a=Math.max(a,0),this.element.style[b?"width":"height"]=a+"px"}},q.prototype._itemsOn=function(a,b,c){function d(){return e++,e===f&&c.call(g),!0}for(var e=0,f=a.length,g=this,h=0,i=a.length;i>h;h++){var j=a[h];j.on(b,d)}},q.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},q.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored},q.prototype.stamp=function(a){if(a=this._find(a)){this.stamps=this.stamps.concat(a);for(var b=0,c=a.length;c>b;b++){var d=a[b];this.ignore(d)}}},q.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e(d,this.stamps),this.unignore(d)}},q.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=d(a)):void 0},q.prototype._manageStamps=function(){if(this.stamps&&this.stamps.length){this._getBoundingRect();for(var a=0,b=this.stamps.length;b>a;a++){var c=this.stamps[a];this._manageStamp(c)}}},q.prototype._getBoundingRect=function(){var a=this.element.getBoundingClientRect(),b=this.size;this._boundingRect={left:a.left+b.paddingLeft+b.borderLeftWidth,top:a.top+b.paddingTop+b.borderTopWidth,right:a.right-(b.paddingRight+b.borderRightWidth),bottom:a.bottom-(b.paddingBottom+b.borderBottomWidth)}},q.prototype._manageStamp=k,q.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,d=n(a),e={left:b.left-c.left-d.marginLeft,top:b.top-c.top-d.marginTop,right:c.right-b.right-d.marginRight,bottom:c.bottom-b.bottom-d.marginBottom};return e},q.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},q.prototype.bindResize=function(){this.isResizeBound||(c.bind(a,"resize",this),this.isResizeBound=!0)},q.prototype.unbindResize=function(){this.isResizeBound&&c.unbind(a,"resize",this),this.isResizeBound=!1},q.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},q.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},q.prototype.needsResizeLayout=function(){var a=n(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},q.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},q.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},q.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){var c=this.items.slice(0);this.items=b.concat(c),this._resetLayout(),this._manageStamps(),this.layoutItems(b,!0),this.reveal(b),this.layoutItems(c)}},q.prototype.reveal=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.reveal()}},q.prototype.hide=function(a){var b=a&&a.length;if(b)for(var c=0;b>c;c++){var d=a[c];d.hide()}},q.prototype.getItem=function(a){for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];if(d.element===a)return d}},q.prototype.getItems=function(a){if(a&&a.length){for(var b=[],c=0,d=a.length;d>c;c++){var e=a[c],f=this.getItem(e);f&&b.push(f)}return b}},q.prototype.remove=function(a){a=d(a);var b=this.getItems(a);if(b&&b.length){this._itemsOn(b,"remove",function(){this.emitEvent("removeComplete",[this,b])});for(var c=0,f=b.length;f>c;c++){var g=b[c];g.remove(),e(g,this.items)}}},q.prototype.destroy=function(){var a=this.element.style;a.height="",a.position="",a.width="";for(var b=0,c=this.items.length;c>b;b++){var d=this.items[b];d.destroy()}this.unbindResize();var e=this.element.outlayerGUID;delete s[e],delete this.element.outlayerGUID,j&&j.removeData(this.element,this.constructor.namespace)},q.data=function(a){var b=a&&a.outlayerGUID;return b&&s[b]},q.create=function(a,c){function d(){q.apply(this,arguments)}return Object.create?d.prototype=Object.create(q.prototype):b(d.prototype,q.prototype),d.prototype.constructor=d,d.defaults=b({},q.defaults),b(d.defaults,c),d.prototype.settings={},d.namespace=a,d.data=q.data,d.Item=function(){p.apply(this,arguments)},d.Item.prototype=new p,g(function(){for(var b=f(a),c=h.querySelectorAll(".js-"+b),e="data-"+b+"-options",g=0,k=c.length;k>g;g++){var l,m=c[g],n=m.getAttribute(e);try{l=n&&JSON.parse(n)}catch(o){i&&i.error("Error parsing "+e+" on "+m.nodeName.toLowerCase()+(m.id?"#"+m.id:"")+": "+o);continue}var p=new d(m,l);j&&j.data(m,a,p)}}),j&&j.bridget&&j.bridget(a,d),d},q.Item=p,q}var h=a.document,i=a.console,j=a.jQuery,k=function(){},l=Object.prototype.toString,m="function"==typeof HTMLElement||"object"==typeof HTMLElement?function(a){return a instanceof HTMLElement}:function(a){return a&&"object"==typeof a&&1===a.nodeType&&"string"==typeof a.nodeName},n=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1};"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","doc-ready/doc-ready","eventEmitter/EventEmitter","get-size/get-size","matches-selector/matches-selector","./item"],g):"object"==typeof exports?module.exports=g(require("eventie"),require("doc-ready"),require("wolfy87-eventemitter"),require("get-size"),require("desandro-matches-selector"),require("./item")):a.Outlayer=g(a.eventie,a.docReady,a.EventEmitter,a.getSize,a.matchesSelector,a.Outlayer.Item)}(window),function(a){function b(a,b){var d=a.create("masonry");return d.prototype._resetLayout=function(){this.getSize(),this._getMeasurement("columnWidth","outerWidth"),this._getMeasurement("gutter","outerWidth"),this.measureColumns();var a=this.cols;for(this.colYs=[];a--;)this.colYs.push(0);this.maxY=0},d.prototype.measureColumns=function(){if(this.getContainerWidth(),!this.columnWidth){var a=this.items[0],c=a&&a.element;this.columnWidth=c&&b(c).outerWidth||this.containerWidth}this.columnWidth+=this.gutter,this.cols=Math.floor((this.containerWidth+this.gutter)/this.columnWidth),this.cols=Math.max(this.cols,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);this.containerWidth=c&&c.innerWidth},d.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth%this.columnWidth,d=b&&1>b?"round":"ceil",e=Math[d](a.size.outerWidth/this.columnWidth);e=Math.min(e,this.cols);for(var f=this._getColGroup(e),g=Math.min.apply(Math,f),h=c(f,g),i={x:this.columnWidth*h,y:g},j=g+a.size.outerHeight,k=this.cols+1-f.length,l=0;k>l;l++)this.colYs[h+l]=j;return i},d.prototype._getColGroup=function(a){if(2>a)return this.colYs;for(var b=[],c=this.cols+1-a,d=0;c>d;d++){var e=this.colYs.slice(d,d+a);b[d]=Math.max.apply(Math,e)}return b},d.prototype._manageStamp=function(a){var c=b(a),d=this._getElementOffset(a),e=this.options.isOriginLeft?d.left:d.right,f=e+c.outerWidth,g=Math.floor(e/this.columnWidth);g=Math.max(0,g);var h=Math.floor(f/this.columnWidth);h-=f%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var i=(this.options.isOriginTop?d.top:d.bottom)+c.outerHeight,j=g;h>=j;j++)this.colYs[j]=Math.max(i,this.colYs[j])},d.prototype._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var a={height:this.maxY};return this.options.isFitWidth&&(a.width=this._getContainerFitWidth()),a},d.prototype._getContainerFitWidth=function(){for(var a=0,b=this.cols;--b&&0===this.colYs[b];)a++;return(this.cols-a)*this.columnWidth-this.gutter},d.prototype.needsResizeLayout=function(){var a=this.containerWidth;return this.getContainerWidth(),a!==this.containerWidth},d}var c=Array.prototype.indexOf?function(a,b){return a.indexOf(b)}:function(a,b){for(var c=0,d=a.length;d>c;c++){var e=a[c];if(e===b)return c}return-1};"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size"],b):"object"==typeof exports?module.exports=b(require("outlayer"),require("get-size")):a.Masonry=b(a.Outlayer,a.getSize)}(window);

function mr_parallax(){"use strict";function a(a){for(var b=0;b<a.length;b++)if("undefined"!=typeof document.body.style[a[b]])return a[b];return null}function b(){var a,b=0;return j()?(b=jQuery(".viu").find("nav:first").outerHeight(!0),a=jQuery(".viu").find("nav:first").css("position"),("absolute"===a||"fixed"===a)&&(b=0)):b=jQuery(document).find("nav:first").outerHeight(!0),b}function c(a,b,c,d){var e=a-1;return e/=d,a/=d,e--,a--,c*(a*a*a*a*a+1)+b-(c*(e*e*e*e*e+1)+b)}function d(){if(F){for(var a=k.length,b=f();a--;)e(k[a],b,o,p);F=!1}s&&(D+=-v*c(u,0,A,C),(D>B||-B>D)&&(E.scrollBy(0,D),D=0),u++,u>C&&(u=0,s=!1,t=!0,v=0,w=0,x=0,D=0)),l(d)}function e(a,b,c,d){var e=j();e?b+q-r>a.elemTop&&b-r<a.elemBottom&&(a.isFirstSection?a.imageHolder.style[n]=c+b/2+d:a.imageHolder.style[n]=c+(b-a.elemTop-r)/2+d):b+q>a.elemTop&&b<a.elemBottom&&(a.isFirstSection?a.imageHolder.style[n]=c+b/2+d:a.imageHolder.style[n]=c+(b+q-a.elemTop)/2+d)}function f(){return E!=window?E.scrollTop:0===document.documentElement.scrollTop?document.body.scrollTop:document.documentElement.scrollTop}function g(){F=!0}function h(a){G.mr_scrollAssist===!0&&(a.preventDefault&&a.preventDefault(),v=a.notRealWheel?-a.deltaY/4:1==a.deltaMode?-a.deltaY/3:100===Math.abs(a.deltaY)?-a.deltaY/120:-a.deltaY/40,v=-y>v?-y:v,v=v>y?y:v,s=!0,u=z)}function i(a){var b={};return a&&"[object Function]"===b.toString.call(a)}function j(){return"undefined"==typeof window.mr_variant?!1:!0}var k,l=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,m=["transform","msTransform","webkitTransform","mozTransform","oTransform"],n=a(m),o="translate3d(0,",p="px,0)",q=Math.max(document.documentElement.clientHeight,window.innerHeight||0),r=0,s=!1,t=!0,u=0,v=0,w=0,x=0,y=2.2,z=2,A=350,B=1,C=35,D=0,E=window,F=(j(),!1),G=this;this.mr_scrollAssist=$("body").hasClass("scroll-assist")?!0:!1,jQuery(document).ready(function(){G.documentReady()}),jQuery(window).load(function(){G.windowLoad()}),this.getScrollingState=function(){return u>0?!0:!1},this.documentReady=function(a){return q=Math.max(document.documentElement.clientHeight,window.innerHeight||0),jQuery("body").hasClass("parallax-2d")&&(o="translate(0,",p="px)"),/Android|iPad|iPhone|iPod|BlackBerry|Windows Phone/i.test(navigator.userAgent||navigator.vendor||window.opera)?jQuery(".parallax").removeClass("parallax"):l&&(G.profileParallaxElements(),G.setupParallax()),i(a)?void a():void 0},this.windowLoad=function(){q=Math.max(document.documentElement.clientHeight,window.innerHeight||0),r=b(),window.mr_parallax.profileParallaxElements()},this.setupParallax=function(){j()&&(E=jQuery(".viu").get(0),"undefined"!=typeof E&&(E.scrollBy=function(a,b){this.scrollTop+=b,this.scrollLeft+=a})),"undefined"!=typeof E&&(E.addEventListener("scroll",g,!1),window.addWheelListener(E,h,!1),window.addEventListener("resize",function(){q=Math.max(document.documentElement.clientHeight,window.innerHeight||0),r=b(),G.profileParallaxElements()},!1),d())},this.profileParallaxElements=function(){k=[],r=b();var a=j(),c=".parallax > .background-image-holder, .parallax ul.slides > li > .background-image-holder, .parallax ul.slides .owl-item > li > .background-image-holder";a&&(c=".viu .parallax > .background-image-holder, .viu .parallax ul.slides > li > .background-image-holder, .parallax ul.slides .owl-item > li > .background-image-holder"),jQuery(c).each(function(b){var c=jQuery(this).closest(".parallax"),d=a?c.position().top:c.offset().top;k.push({section:c.get(0),outerHeight:c.outerHeight(),elemTop:d,elemBottom:d+c.outerHeight(),isFirstSection:c.is(":nth-of-type(1)")?!0:!1,imageHolder:jQuery(this).get(0)}),a?a&&(c.is(":nth-of-type(1)")?G.mr_setTranslate3DTransform(jQuery(this).get(0),0===f()?0:f()/2):G.mr_setTranslate3DTransform(jQuery(this).get(0),(f()-d-r)/2)):c.is(":nth-of-type(1)")?G.mr_setTranslate3DTransform(jQuery(this).get(0),0===f()?0:f()/2):G.mr_setTranslate3DTransform(jQuery(this).get(0),(f()+q-d)/2)})},this.mr_setTranslate3DTransform=function(a,b){a.style[n]=o+b+p}}window.mr_parallax=new mr_parallax,function(a,b){function c(b,c,g,h){b[d](f+c,"wheel"==e?g:function(b){!b&&(b=a.event);var c={originalEvent:b,target:b.target||b.srcElement,type:"wheel",deltaMode:"MozMousePixelScroll"==b.type?0:1,deltaX:0,deltaZ:0,notRealWheel:1,preventDefault:function(){b.preventDefault?b.preventDefault():b.returnValue=!1}};return"mousewheel"==e?(c.deltaY=-1/40*b.wheelDelta,b.wheelDeltaX&&(c.deltaX=-1/40*b.wheelDeltaX)):c.deltaY=b.detail/3,g(c)},h||!1)}var d,e,f="";a.addEventListener?d="addEventListener":(d="attachEvent",f="on"),e="onwheel"in b.createElement("div")?"wheel":"undefined"!=typeof b.onmousewheel?"mousewheel":"DOMMouseScroll",a.addWheelListener=function(a,b,d){c(a,e,b,d),"DOMMouseScroll"==e&&c(a,"MozMousePixelScroll",b,d)}}(window,document);

var mr_firstSectionHeight,

   mr_nav,
   mr_fixedAt,
   mr_navOuterHeight,
   mr_navScrolled = false,
   mr_navFixed = false,
   mr_outOfSight = false,
   mr_floatingProjectSections,
   mr_scrollTop = 0;

$(document).ready(function() {

   "use strict";
   // Smooth scroll to inner links
   
   $('.inner-link').each(function(){
       var href = $(this).attr('href');
       if(href.charAt(0) !== "#"){
           $(this).removeClass('inner-link');
       }
   });

if($('.inner-link').length){ $('.inner-link').smoothScroll({ offset: -55, speed: 800 });

   }
   // Update scroll variable for scrolling functions
   addEventListener('scroll', function() {
       mr_scrollTop = window.pageYOffset;
   }, false);
   // Append .background-image-holder <img>'s as CSS backgrounds
   $('.background-image-holder').each(function() {
       var imgSrc = $(this).children('img').attr('src');
       $(this).css('background', 'url("' + imgSrc + '")');
       $(this).children('img').hide();
       $(this).css('background-position', 'initial');
   });
   // Fade in background images
   setTimeout(function() {
       $('.background-image-holder').each(function() {
           $(this).addClass('fadeIn');
       });
   }, 200);
   // Initialize Tooltips
   $('[data-toggle="tooltip"]').tooltip();
   // Icon bulleted lists
   $('ul[data-bullet]').each(function(){
       var bullet = $(this).attr('data-bullet');
       $(this).find('li').prepend('');
   });
   // Progress Bars
   $('.progress-bar').each(function() {
       $(this).css('width', $(this).attr('data-progress') + '%');
   });
   // Navigation
   if (!$('nav').hasClass('fixed') && !$('nav').hasClass('absolute')) {
       // Make nav container height of nav
       $('.nav-container').css('min-height', $('nav').outerHeight(true));
       $(window).resize(function() {
           $('.nav-container').css('min-height', $('nav').outerHeight(true));
       });
       // Compensate the height of parallax element for inline nav
       if ($(window).width() > 768) {
           $('.parallax:nth-of-type(1) .background-image-holder').css('top', -($('nav').outerHeight(true)));
       }
       // Adjust fullscreen elements
       if ($(window).width() > 768) {
           $('section.fullscreen:nth-of-type(1)').css('height', ($(window).height() - $('nav').outerHeight(true)));
       }
   } else {
       $('body').addClass('nav-is-overlay');
   }
   if ($('nav').hasClass('bg-dark')) {
       $('.nav-container').addClass('bg-dark');
   }


   // Fix nav to top while scrolling
   mr_nav = $('body .nav-container nav:first');
   mr_navOuterHeight = $('body .nav-container nav:first').outerHeight();
       mr_fixedAt = typeof mr_nav.attr('data-fixed-at') !== typeof undefined ? parseInt(mr_nav.attr('data-fixed-at').replace('px', )) : parseInt($('section:nth-of-type(1)').outerHeight());
   window.addEventListener("scroll", updateNav, false);
   // Menu dropdown positioning
   $('.menu > li > ul').each(function() {
       var menu = $(this).offset();
       var farRight = menu.left + $(this).outerWidth(true);
       if (farRight > $(window).width() && !$(this).hasClass('mega-menu')) {
           $(this).addClass('make-right');
       } else if (farRight > $(window).width() && $(this).hasClass('mega-menu')) {
           var isOnScreen = $(window).width() - menu.left;
           var difference = $(this).outerWidth(true) - isOnScreen;
           $(this).css('margin-left', -(difference));
       }
   });
   // Mobile Menu
   $('.mobile-toggle').click(function() {
       $('.nav-bar').toggleClass('nav-open');
       $(this).toggleClass('active');
   });
   $('.menu li').click(function(e) {
       if (!e) e = window.event;
       e.stopPropagation();
       if ($(this).find('ul').length) {
           $(this).toggleClass('toggle-sub');
       } else {
           $(this).parents('.toggle-sub').removeClass('toggle-sub');
       }
   });
   $('.menu li a').click(function() {
       if ($(this).hasClass('inner-link')){
           $(this).closest('.nav-bar').removeClass('nav-open');
       }
   });
   $('.module.widget-handle').click(function() {
       $(this).toggleClass('toggle-widget-handle');
   });
   $('.search-widget-handle .search-form input').click(function(e){
       if (!e) e = window.event;
       e.stopPropagation();
   });
   
   // Offscreen Nav
   
   if($('.offscreen-toggle').length){
   	$('body').addClass('has-offscreen-nav');
   }
   else{
       $('body').removeClass('has-offscreen-nav');
   }
   
   $('.offscreen-toggle').click(function(){
   	$('.main-container').toggleClass('reveal-nav');
   	$('nav').toggleClass('reveal-nav');
   	$('.offscreen-container').toggleClass('reveal-nav');
   });
   
   $('.main-container').click(function(){
   	if($(this).hasClass('reveal-nav')){
   		$(this).removeClass('reveal-nav');
   		$('.offscreen-container').removeClass('reveal-nav');
   		$('nav').removeClass('reveal-nav');
   	}
   });
   
   $('.offscreen-container a').click(function(){
   	$('.offscreen-container').removeClass('reveal-nav');
   	$('.main-container').removeClass('reveal-nav');
   	$('nav').removeClass('reveal-nav');
   });
   // Populate filters
   
   $('.projects').each(function() {
       var filters = "";
       $(this).find('.project').each(function() {
           var filterTags = $(this).attr('data-filter').split(',');
           filterTags.forEach(function(tagName) {
               if (filters.indexOf(tagName) == -1) {
filters += '
  • ' + capitaliseFirstLetter(tagName) + '
  • ';
                   }
               });
               $(this).closest('.projects')
    
    .find('ul.filters').empty().append('
  • All
  • ').append(filters);
           });
       });
    
       $('.filters li').click(function() {
           var filter = $(this).attr('data-filter');
           $(this).closest('.filters').find('li').removeClass('active');
           $(this).addClass('active');
    
           $(this).closest('.projects').find('.project').each(function() {
               var filters = $(this).attr('data-filter');
    
               if (filters.indexOf(filter) == -1) {
                   $(this).addClass('inactive');
               } else {
                   $(this).removeClass('inactive');
               }
           });
    
           if (filter == 'all') {
               $(this).closest('.projects').find('.project').removeClass('inactive');
           }
       });
    
       // Twitter Feed
          jQuery('.tweets-feed').each(function(index) {
              jQuery(this).attr('id', 'tweets-' + index);
          }).each(function(index) {
              
              var TweetConfig = {
                  "id": jQuery('#tweets-' + index).attr('data-widget-id'),
                  "domId": ,
                  "maxTweets": jQuery('#tweets-' + index).attr('data-amount'),
                  "enableLinks": true,
                  "showUser": true,
                  "showTime": true,
                  "dateFunction": ,
                  "showRetweet": false,
                  "customCallback": handleTweets
              };
              function handleTweets(tweets) {
                  var x = tweets.length;
                  var n = 0;
                  var element = document.getElementById('tweets-' + index);
    
    var html = '
      '; while (n < x) { html += '
    • ' + tweets[n] + '
    • ';
                        n++;
                    }
      
      html += '
    ';
                  element.innerHTML = html;
                  return html;
              }
              twitterFetcher.fetch(TweetConfig);
          });
    
       // Instagram Feed
       
       if($('.instafeed').length){
       	jQuery.fn.spectragram.accessData = {
    

    accessToken: '1406933036.dc95b96.2ed56eddc62f41cbb22c1573d58625a2', clientID: '87e6d2b8a0ef4c7ab8bc45e80ddd0c6a' };

           $('.instafeed').each(function() {
               var feedID = $(this).attr('data-user-name');
               $(this).children('ul').spectragram('getUserFeed', {
                   query: feedID,
                   max: 12
               });
           });
       }   
    


       // Flickr Feeds
    
       if($('.flickr-feed').length){
           $('.flickr-feed').each(function(){
               var userID = $(this).attr('data-user-id');
               var albumID = $(this).attr('data-album-id');
    
    $(this).flickrPhotoStream({ id: userID, setId: albumID, container: '
  • ' }); setTimeout(function(){ initializeMasonry(); window.dispatchEvent(new Event('resize')); }, 1000); }); } // Image Sliders if($('.slider-all-controls, .slider-paging-controls, .slider-arrow-controls, .slider-thumb-controls, .logo-carousel').length){ $('.slider-all-controls').flexslider({ start: function(slider){ if(slider.find('.slides li:first-child').find('.fs-vid-background video').length){ slider.find('.slides li:first-child').find('.fs-vid-background video').get(0).play(); } }, after: function(slider){ if(slider.find('.fs-vid-background video').length){ if(slider.find('li:not(.flex-active-slide)').find('.fs-vid-background video').length){ slider.find('li:not(.flex-active-slide)').find('.fs-vid-background video').get(0).pause(); } if(slider.find('.flex-active-slide').find('.fs-vid-background video').length){ slider.find('.flex-active-slide').find('.fs-vid-background video').get(0).play(); } } } }); $('.slider-paging-controls').flexslider({ animation: "slide", directionNav: false }); $('.slider-arrow-controls').flexslider({ controlNav: false }); $('.slider-thumb-controls .slides li').each(function() { var imgSrc = $(this).find('img').attr('src'); $(this).attr('data-thumb', imgSrc); }); $('.slider-thumb-controls').flexslider({ animation: "slide", controlNav: "thumbnails", directionNav: true }); $('.logo-carousel').flexslider({ minItems: 1, maxItems: 4, move: 1, itemWidth: 200, itemMargin: 0, animation: "slide", slideshow: true, slideshowSpeed: 3000, directionNav: false, controlNav: false }); } // Lightbox gallery titles $('.lightbox-grid li a').each(function(){ var galleryTitle = $(this).closest('.lightbox-grid').attr('data-gallery-title'); $(this).attr('data-lightbox', galleryTitle); }); // Prepare embedded video modals $('iframe[data-provider]').each(function(){ var provider = jQuery(this).attr('data-provider'); var videoID = jQuery(this).attr('data-video-id'); var autoplay = jQuery(this).attr('data-autoplay'); var vidURL = ; if(provider == 'vimeo'){ vidURL = "http://player.vimeo.com/video/"+videoID+"?badge=0&title=0&byline=0&title=0&autoplay="+autoplay; $(this).attr('data-src', vidURL); }else if (provider == 'youtube'){ vidURL = "https://www.youtube.com/embed/"+videoID+"?showinfo=0&autoplay="+autoplay; $(this).attr('data-src', vidURL); }else{ console.log('Only Vimeo and Youtube videos are supported at this time'); } }); // Multipurpose Modals jQuery('.foundry_modal[modal-link]').remove(); if($('.foundry_modal').length && (!jQuery('.modal-screen').length)){ // Add a div.modal-screen if there isn't already one there. var modalScreen = jQuery('<div />').addClass('modal-screen').appendTo('body'); } jQuery('.foundry_modal').click(function(){ jQuery(this).addClass('modal-acknowledged'); }); jQuery(document).on('wheel mousewheel scroll', '.foundry_modal, .modal-screen', function(evt){ $(this).get(0).scrollTop += (evt.originalEvent.deltaY); return false; }); $('.modal-container:not([modal-link])').each(function(index) { if(jQuery(this).find('iframe[src]').length){ jQuery(this).find('.foundry_modal').addClass('iframe-modal'); var iframe = jQuery(this).find('iframe'); iframe.attr('data-src',iframe.attr('src')); iframe.attr('src', ); } jQuery(this).find('.btn-modal').attr('modal-link', index); // Only clone and append to body if there isn't already one there if(!jQuery('.foundry_modal[modal-link="'+index+'"]').length){ jQuery(this).find('.foundry_modal').clone().appendTo('body').attr('modal-link', index).prepend(jQuery('')); } }); $('.btn-modal').unbind('click').click(function(){ var linkedModal = jQuery('.foundry_modal[modal-link="' + jQuery(this).attr('modal-link') + '"]'), autoplayMsg = ""; jQuery('.modal-screen').toggleClass('reveal-modal'); if(linkedModal.find('iframe').length){ if(linkedModal.find('iframe').attr('data-autoplay') === '1'){ var autoplayMsg = '&autoplay=1' } linkedModal.find('iframe').attr('src', (linkedModal.find('iframe').attr('data-src') + autoplayMsg)); } if(linkedModal.find('video').length){ linkedModal.find('video').get(0).play(); } linkedModal.toggleClass('reveal-modal'); return false; }); // Autoshow modals $('.foundry_modal[data-time-delay]').each(function(){ var modal = $(this); var delay = modal.attr('data-time-delay'); modal.prepend($('<i class="ti-close close-modal">')); if(typeof modal.attr('data-cookie') != "undefined"){ if(!mr_cookies.hasItem(modal.attr('data-cookie'))){ setTimeout(function(){ modal.addClass('reveal-modal'); $('.modal-screen').addClass('reveal-modal'); },delay); } }else{ setTimeout(function(){ modal.addClass('reveal-modal'); $('.modal-screen').addClass('reveal-modal'); },delay); } }); // Exit modals $('.foundry_modal[data-show-on-exit]').each(function(){ var modal = $(this); var exitSelector = $(modal.attr('data-show-on-exit')); // If a valid selector is found, attach leave event to show modal. if($(exitSelector).length){ modal.prepend($('<i class="ti-close close-modal">')); $(document).on('mouseleave', exitSelector, function(){ if(!$('body .reveal-modal').length){ if(typeof modal.attr('data-cookie') !== typeof undefined){ if(!mr_cookies.hasItem(modal.attr('data-cookie'))){ modal.addClass('reveal-modal'); $('.modal-screen').addClass('reveal-modal'); } }else{ modal.addClass('reveal-modal'); $('.modal-screen').addClass('reveal-modal'); } } }); } }); // Autoclose modals $('.foundry_modal[data-hide-after]').each(function(){ var modal = $(this); var delay = modal.attr('data-hide-after'); if(typeof modal.attr('data-cookie') != "undefined"){ if(!mr_cookies.hasItem(modal.attr('data-cookie'))){ setTimeout(function(){ if(!modal.hasClass('modal-acknowledged')){ modal.removeClass('reveal-modal'); $('.modal-screen').removeClass('reveal-modal'); } },delay); } }else{ setTimeout(function(){ if(!modal.hasClass('modal-acknowledged')){ modal.removeClass('reveal-modal'); $('.modal-screen').removeClass('reveal-modal'); } },delay); } }); jQuery('.close-modal:not(.modal-strip .close-modal)').unbind('click').click(function(){ var modal = jQuery(this).closest('.foundry_modal'); modal.toggleClass('reveal-modal'); if(typeof modal.attr('data-cookie') !== "undefined"){ mr_cookies.setItem(modal.attr('data-cookie'), "true", Infinity); } if(modal.find('iframe').length){ modal.find('iframe').attr('src', ); } jQuery('.modal-screen').removeClass('reveal-modal'); }); jQuery('.modal-screen').unbind('click').click(function(){ if(jQuery('.foundry_modal.reveal-modal').find('iframe').length){ jQuery('.foundry_modal.reveal-modal').find('iframe').attr('src', ); } jQuery('.foundry_modal.reveal-modal').toggleClass('reveal-modal'); jQuery(this).toggleClass('reveal-modal'); }); jQuery(document).keyup(function(e) { if (e.keyCode == 27) { // escape key maps to keycode `27` if(jQuery('.foundry_modal').find('iframe').length){ jQuery('.foundry_modal').find('iframe').attr('src', ); } jQuery('.foundry_modal').removeClass('reveal-modal'); jQuery('.modal-screen').removeClass('reveal-modal'); } }); // Modal Strips jQuery('.modal-strip').each(function(){ if(!jQuery(this).find('.close-modal').length){ jQuery(this).append(jQuery('<i class="ti-close close-modal">')); } var modal = jQuery(this); if(typeof modal.attr('data-cookie') != "undefined"){ if(!mr_cookies.hasItem(modal.attr('data-cookie'))){ setTimeout(function(){ modal.addClass('reveal-modal'); },1000); } }else{ setTimeout(function(){ modal.addClass('reveal-modal'); },1000); } }); jQuery('.modal-strip .close-modal').click(function(){ var modal = jQuery(this).closest('.modal-strip'); if(typeof modal.attr('data-cookie') != "undefined"){ mr_cookies.setItem(modal.attr('data-cookie'), "true", Infinity); } jQuery(this).closest('.modal-strip').removeClass('reveal-modal'); return false; }); // Video Modals jQuery('.close-iframe').click(function() { jQuery(this).closest('.modal-video').removeClass('reveal-modal'); jQuery(this).siblings('iframe').attr('src', ); jQuery(this).siblings('video').get(0).pause(); }); // Checkboxes $('.checkbox-option').on("click",function() { $(this).toggleClass('checked'); var checkbox = $(this).find('input'); if (checkbox.prop('checked') === false) { checkbox.prop('checked', true); } else { checkbox.prop('checked', false); } }); // Radio Buttons $('.radio-option').click(function() { var checked = $(this).hasClass('checked'); // Get the current status of the radio var name = $(this).find('input').attr('name'); // Get the name of the input clicked if (!checked) { $('input[name="'+name+'"]').parent().removeClass('checked'); $(this).addClass('checked'); $(this).find('input').prop('checked', true); } }); // Accordions $('.accordion li').click(function() { if ($(this).closest('.accordion').hasClass('one-open')) { $(this).closest('.accordion').find('li').removeClass('active'); $(this).addClass('active'); } else { $(this).toggleClass('active'); } if(typeof window.mr_parallax !== "undefined"){ setTimeout(mr_parallax.windowLoad, 500); } }); // Tabbed Content $('.tabbed-content').each(function() { $(this).append('
      ');
         });
      
         $('.tabs li').each(function() {
             var originalTab = $(this),
                 activeClass = "";
             if (originalTab.is('.tabs>li:first-child')) {
                 activeClass = ' class="active"';
             }
             var tabContent = originalTab.find('.tab-content').detach().wrap('<li' + activeClass + '></li>').parent();
             originalTab.closest('.tabbed-content').find('.content').append(tabContent);
         });
      
         $('.tabs li').click(function() {
             $(this).closest('.tabs').find('li').removeClass('active');
             $(this).addClass('active');
             var liIndex = $(this).index() + 1;
             $(this).closest('.tabbed-content').find('.content>li').removeClass('active');
             $(this).closest('.tabbed-content').find('.content>li:nth-of-type(' + liIndex + ')').addClass('active');
         });
      
         // Local Videos
      
         $('section').closest('body').find('.local-video-container .play-button').click(function() {
             $(this).siblings('.background-image-holder').removeClass('fadeIn');
             $(this).siblings('.background-image-holder').css('z-index', -1);
             $(this).css('opacity', 0);
             $(this).siblings('video').get(0).play();
         });
      
         // Youtube Videos
      
         $('section').closest('body').find('.player').each(function() {
             var section = $(this).closest('section');
             section.find('.container').addClass('fadeOut');
             var src = $(this).attr('data-video-id');
             var startat = $(this).attr('data-start-at');
             $(this).attr('data-property', "{videoURL:'http://youtu.be/" + src + "',containment:'self',autoPlay:true, mute:true, startAt:" + startat + ", opacity:1, showControls:false}");
         });
      

      if($('.player').length){

             $('.player').each(function(){
      
                 var section = $(this).closest('section');
                 var player = section.find('.player');
                 player.YTPlayer();
                 player.on("YTPStart",function(e){
                     section.find('.container').removeClass('fadeOut');
                     section.find('.masonry-loader').addClass('fadeOut');
                 });
      
             });
         }
      
         // Interact with Map once the user has clicked (to prevent scrolling the page = zooming the map
      
         $('.map-holder').click(function() {
             $(this).addClass('interact');
         });
         
         if($('.map-holder').length){
         	$(window).scroll(function() {
      

      if ($('.map-holder.interact').length) { $('.map-holder.interact').removeClass('interact'); } });

         }
         
         // Countdown Timers
      
         if ($('.countdown').length) {
             $('.countdown').each(function() {
                 var date = $(this).attr('data-date');
                 $(this).countdown(date, function(event) {
                     $(this).text(
                         event.strftime('%D days %H:%M:%S')
                     );
                 });
             });
         }
         
         //                                                            //
         //                                                            //
         // Contact form code                                          //
         //                                                            //
         //                                                            //
      
         $('form.form-email, form.form-newsletter').submit(function(e) {
      
             // return false so form submits through jQuery rather than reloading page.
             if (e.preventDefault) e.preventDefault();
             else e.returnValue = false;
      
             var thisForm = $(this).closest('form.form-email, form.form-newsletter'),
                 submitButton = thisForm.find('button[type="submit"]'),
                 error = 0,
                 originalError = thisForm.attr('original-error'),
                 preparedForm, iFrame, userEmail, userFullName, userFirstName, userLastName, successRedirect, formError, formSuccess;
      
             // Mailchimp/Campaign Monitor Mail List Form Scripts
             iFrame = $(thisForm).find('iframe.mail-list-form');
      
             thisForm.find('.form-error, .form-success').remove();
             submitButton.attr('data-text', submitButton.text());
      
      thisForm.append(''); thisForm.append('');
             formError = thisForm.find('.form-error');
             formSuccess = thisForm.find('.form-success');
             thisForm.addClass('attempted-submit');
      
             // Do this if there is an iframe, and it contains usable Mail Chimp / Campaign Monitor iframe embed code
             if ((iFrame.length) && (typeof iFrame.attr('srcdoc') !== "undefined") && (iFrame.attr('srcdoc') !== "")) {
      
                 console.log('Mail list form signup detected.');
                 if (typeof originalError !== typeof undefined && originalError !== false) {
                     formError.html(originalError);
                 }
                 userEmail = $(thisForm).find('.signup-email-field').val();
                 userFullName = $(thisForm).find('.signup-name-field').val();
                 if ($(thisForm).find('input.signup-first-name-field').length) {
                     userFirstName = $(thisForm).find('input.signup-first-name-field').val();
                 } else {
                     userFirstName = $(thisForm).find('.signup-name-field').val();
                 }
                 userLastName = $(thisForm).find('.signup-last-name-field').val();
      
                 // validateFields returns 1 on error;
                 if (validateFields(thisForm) !== 1) {
                     preparedForm = prepareSignup(iFrame);
      
                     preparedForm.find('#mce-EMAIL, #fieldEmail').val(userEmail);
                     preparedForm.find('#mce-LNAME, #fieldLastName').val(userLastName);
                     preparedForm.find('#mce-FNAME, #fieldFirstName').val(userFirstName);
                     preparedForm.find('#mce-NAME, #fieldName').val(userFullName);
                     thisForm.removeClass('attempted-submit');
      
                     // Hide the error if one was shown
                     formError.fadeOut(200);
                     // Create a new loading spinner in the submit button.
                     submitButton.html(jQuery('<div />').addClass('form-loading')).attr('disabled', 'disabled');
                     
                     try{
                         $.ajax({
                             url: preparedForm.attr('action'),
                             crossDomain: true,
                             data: preparedForm.serialize(),
                             method: "GET",
                             cache: false,
                             dataType: 'json',
                             contentType: 'application/json; charset=utf-8',
                             success: function(data){
                                 // Request was a success, what was the response?
                                 if (data.result != "success" && data.Status != 200) {
                                     
                                     // Error from Mail Chimp or Campaign Monitor
      
                                     // Keep the current error text in a data attribute on the form
                                     formError.attr('original-error', formError.text());
                                     // Show the error with the returned error text.
                                     formError.html(data.msg).fadeIn(1000);
                                     formSuccess.fadeOut(1000);
      
                                     submitButton.html(submitButton.attr('data-text')).removeAttr('disabled');
                                 } else {
                                     
                                     // Got Success from Mail Chimp
                                     
                                     submitButton.html(submitButton.attr('data-text')).removeAttr('disabled');
      
                                     successRedirect = thisForm.attr('success-redirect');
                                     // For some browsers, if empty `successRedirect` is undefined; for others,
                                     // `successRedirect` is false.  Check for both.
                                     if (typeof successRedirect !== typeof undefined && successRedirect !== false && successRedirect !== "") {
                                         window.location = successRedirect;
                                     }
      
                                     thisForm.find('input[type="text"]').val("");
                                     thisForm.find('textarea').val("");
                                     formSuccess.fadeIn(1000);
      
                                     formError.fadeOut(1000);
                                     setTimeout(function() {
                                         formSuccess.fadeOut(500);
                                     }, 5000);
                                 }
                             }
                         });
                     }catch(err){
                         // Keep the current error text in a data attribute on the form
                         formError.attr('original-error', formError.text());
                         // Show the error with the returned error text.
                         formError.html(err.message).fadeIn(1000);
                         formSuccess.fadeOut(1000);
                         setTimeout(function() {
                             formError.fadeOut(500);
                         }, 5000);
      
                         submitButton.html(submitButton.attr('data-text')).removeAttr('disabled');
                     }
                 
      


                 } else {
                     formError.fadeIn(1000);
                     setTimeout(function() {
                         formError.fadeOut(500);
                     }, 5000);
                 }
             } else {
                 // If no iframe detected then this is treated as an email form instead.
                 console.log('Send email form detected.');
                 if (typeof originalError !== typeof undefined && originalError !== false) {
                     formError.text(originalError);
                 }
      
                 error = validateFields(thisForm);
      
                 if (error === 1) {
                     formError.fadeIn(200);
                     setTimeout(function() {
                         formError.fadeOut(500);
                     }, 3000);
                 } else {
      
                     thisForm.removeClass('attempted-submit');
      
                     // Hide the error if one was shown
                     formError.fadeOut(200);
                     
                     // Create a new loading spinner in the submit button.
                     submitButton.html(jQuery('<div />').addClass('form-loading')).attr('disabled', 'disabled');
      
                     jQuery.ajax({
                         type: "POST",
                         url: "mail/mail.php",
                         data: thisForm.serialize()+"&url="+window.location.href,
                         success: function(response) {
                             // Swiftmailer always sends back a number representing numner of emails sent.
                             // If this is numeric (not Swift Mailer error text) AND greater than 0 then show success message.
      
                             submitButton.html(submitButton.attr('data-text')).removeAttr('disabled');
      
                             if ($.isNumeric(response)) {
                                 if (parseInt(response) > 0) {
                                     // For some browsers, if empty 'successRedirect' is undefined; for others,
                                     // 'successRedirect' is false.  Check for both.
                                     successRedirect = thisForm.attr('success-redirect');
                                     if (typeof successRedirect !== typeof undefined && successRedirect !== false && successRedirect !== "") {
                                         window.location = successRedirect;
                                     }
      


                                     thisForm.find('input[type="text"]').val("");
                                     thisForm.find('textarea').val("");
                                     thisForm.find('.form-success').fadeIn(1000);
      
                                     formError.fadeOut(1000);
                                     setTimeout(function() {
                                         formSuccess.fadeOut(500);
                                     }, 5000);
                                 }
                             }
                             // If error text was returned, put the text in the .form-error div and show it.
                             else {
                                 // Keep the current error text in a data attribute on the form
                                 formError.attr('original-error', formError.text());
                                 // Show the error with the returned error text.
                                 formError.text(response).fadeIn(1000);
                                 formSuccess.fadeOut(1000);
                             }
                         },
                         error: function(errorObject, errorText, errorHTTP) {
                             // Keep the current error text in a data attribute on the form
                             formError.attr('original-error', formError.text());
                             // Show the error with the returned error text.
                             formError.text(errorHTTP).fadeIn(1000);
                             formSuccess.fadeOut(1000);
                             submitButton.html(submitButton.attr('data-text')).removeAttr('disabled');
                         }
                     });
                 }
             }
             return false;
         });
      
         $('.validate-required, .validate-email').on('blur change', function() {
             validateFields($(this).closest('form'));
         });
      
         $('form').each(function() {
             if ($(this).find('.form-error').length) {
                 $(this).attr('original-error', $(this).find('.form-error').text());
             }
         });
      
         function validateFields(form) {
                 var name, error, originalErrorMessage;
      
                 $(form).find('.validate-required[type="checkbox"]').each(function() {
                     if (!$('[name="' + $(this).attr('name') + '"]:checked').length) {
                         error = 1;
                         name = $(this).attr('name').replace('[]', );
                         form.find('.form-error').text('Please tick at least one ' + name + ' box.');
                     }
                 });
      
                 $(form).find('.validate-required').each(function() {
                     if ($(this).val() === ) {
                         $(this).addClass('field-error');
                         error = 1;
                     } else {
                         $(this).removeClass('field-error');
                     }
                 });
      
                 $(form).find('.validate-email').each(function() {
                     if (!(/(.+)@(.+){2,}\.(.+){2,}/.test($(this).val()))) {
                         $(this).addClass('field-error');
                         error = 1;
                     } else {
                         $(this).removeClass('field-error');
                     }
                 });
      
                 if (!form.find('.field-error').length) {
                     form.find('.form-error').fadeOut(1000);
                 }
      
                 return error;
             }
      
         //
         //    
         // End contact form code
         //
         //
      


         // Get referrer from URL string 
         if (getURLParameter("ref")) {
             $('form.form-email').append('<input type="text" name="referrer" class="hidden" value="' + getURLParameter("ref") + '"/>');
         }
      
         function getURLParameter(name) {
             return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
         }
      
         // Disable parallax on mobile
      
         if ((/Android|iPhone|iPad|iPod|BlackBerry|Windows Phone/i).test(navigator.userAgent || navigator.vendor || window.opera)) {
             $('section').removeClass('parallax');
         }
         
         // Disqus Comments
         
         if($('.disqus-comments').length){
      

      /* * * CONFIGURATION VARIABLES * * */ var disqus_shortname = $('.disqus-comments').attr('data-shortname');

      /* * * DON'T EDIT BELOW THIS LINE * * */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

         }
      
         // Load Google MAP API JS with callback to initialise when fully loaded
         if(document.querySelector('[data-maps-api-key]') && !document.querySelector('.gMapsAPI')){
             if($('[data-maps-api-key]').length){
                 var script = document.createElement('script');
                 var apiKey = $('[data-maps-api-key]:first').attr('data-maps-api-key');
                 script.type = 'text/javascript';
                 script.src = 'https://maps.googleapis.com/maps/api/js?key='+apiKey+'&callback=initializeMaps';
                 script.className = 'gMapsAPI';
                 document.body.appendChild(script);  
             } 
         }
      

      });

      $(window).load(function() {

         "use strict";
      
         // Initialize Masonry
      
         setTimeout(initializeMasonry, 1000);
      
         // Initialize twitter feed
      
         var setUpTweets = setInterval(function() {
             if ($('.tweets-slider').find('li.flex-active-slide').length) {
                 clearInterval(setUpTweets);
                 return;
             } else {
                 if ($('.tweets-slider').length) {
                     $('.tweets-slider').flexslider({
                         directionNav: false,
                         controlNav: false
                     });
                 }
             }
         }, 500);
      
         mr_firstSectionHeight = $('.main-container section:nth-of-type(1)').outerHeight(true);
      


      }); function updateNav() {

         var scrollY = mr_scrollTop;
      
         if (scrollY <= 0) {
             if (mr_navFixed) {
                 mr_navFixed = false;
                 mr_nav.removeClass('fixed');
             }
             if (mr_outOfSight) {
                 mr_outOfSight = false;
                 mr_nav.removeClass('outOfSight');
             }
             if (mr_navScrolled) {
                 mr_navScrolled = false;
                 mr_nav.removeClass('scrolled');
             }
             return;
         }
      
         if (scrollY > mr_navOuterHeight + mr_fixedAt) {
             if (!mr_navScrolled) {
                 mr_nav.addClass('scrolled');
                 mr_navScrolled = true;
                 return;
             }
         } else {
             if (scrollY > mr_navOuterHeight) {
                if (!mr_navFixed) {
                     mr_nav.addClass('fixed');
                     mr_navFixed = true;
                 }
      
                 if (scrollY > mr_navOuterHeight +10) {
                     if (!mr_outOfSight) {
                         mr_nav.addClass('outOfSight');
                         mr_outOfSight = true;
                     }
                 } else {
                     if (mr_outOfSight) {
                         mr_outOfSight = false;
                         mr_nav.removeClass('outOfSight');
                     }
                 }
             } else {
                 if (mr_navFixed) {
                     mr_navFixed = false;
                     mr_nav.removeClass('fixed');
                 }
                 if (mr_outOfSight) {
                     mr_outOfSight = false;
                     mr_nav.removeClass('outOfSight');
                 }
             }
      
             if (mr_navScrolled) {
                 mr_navScrolled = false;
                 mr_nav.removeClass('scrolled');
             }
      
         }
      

      }


      function capitaliseFirstLetter(string) {

         return string.charAt(0).toUpperCase() + string.slice(1);
      

      }

      function initializeMasonry(){

         $('.masonry').each(function(){
             var container = $(this).get(0);
             var msnry = new Masonry(container, {
                 itemSelector: '.masonry-item'
             });
      
             msnry.on('layoutComplete', function() {
      
                 mr_firstSectionHeight = $('.main-container section:nth-of-type(1)').outerHeight(true);
      
                 // Fix floating project filters to bottom of projects container
      
                 if ($('.filters.floating').length) {
                     setupFloatingProjectFilters();
                     updateFloatingFilters();
                     window.addEventListener("scroll", updateFloatingFilters, false);
                 }
      
                 $('.masonry').addClass('fadeIn');
                 $('.masonry-loader').addClass('fadeOut');
                 if ($('.masonryFlyIn').length) {
                     masonryFlyIn();
                 }
             });
      
             msnry.layout();
         });
      

      }

      function masonryFlyIn() {

         var $items = $('.masonryFlyIn .masonry-item');
         var time = 0;
      
         $items.each(function() {
             var item = $(this);
             setTimeout(function() {
                 item.addClass('fadeIn');
             }, time);
             time += 170;
         });
      

      }

      function setupFloatingProjectFilters() {

         mr_floatingProjectSections = [];
         $('.filters.floating').closest('section').each(function() {
             var section = $(this);
      
             mr_floatingProjectSections.push({
                 section: section.get(0),
                 outerHeight: section.outerHeight(),
                 elemTop: section.offset().top,
                 elemBottom: section.offset().top + section.outerHeight(),
                 filters: section.find('.filters.floating'),
                 filersHeight: section.find('.filters.floating').outerHeight(true)
             });
         });
      

      }

      function updateFloatingFilters() {

         var l = mr_floatingProjectSections.length;
         while (l--) {
             var section = mr_floatingProjectSections[l];
      
             if ((section.elemTop < mr_scrollTop) && typeof window.mr_variant == "undefined" ) {
                 section.filters.css({
                     position: 'fixed',
                     top: '16px',
                     bottom: 'auto'
                 });
                 if (mr_navScrolled) {
                     section.filters.css({
                         transform: 'translate3d(-50%,48px,0)'
                     });
                 }
                 if (mr_scrollTop > (section.elemBottom - 70)) {
                     section.filters.css({
                         position: 'absolute',
                         bottom: '16px',
                         top: 'auto'
                     });
                     section.filters.css({
                         transform: 'translate3d(-50%,0,0)'
                     });
                 }
             } else {
                 section.filters.css({
                     position: 'absolute',
                     transform: 'translate3d(-50%,0,0)'
                 });
             }
         }
      

      }

      window.initializeMaps = function(){

         if(typeof google !== "undefined"){
             if(typeof google.maps !== "undefined"){
                 $('.map-canvas[data-maps-api-key]').each(function(){
                         var mapInstance   = this,
                             mapJSON       = typeof $(this).attr('data-map-style') !== "undefined" ? $(this).attr('data-map-style'): false,
                             mapStyle      = JSON.parse(mapJSON) || [{"featureType":"landscape","stylers":[{"saturation":-100},{"lightness":65},{"visibility":"on"}]},{"featureType":"poi","stylers":[{"saturation":-100},{"lightness":51},{"visibility":"simplified"}]},{"featureType":"road.highway","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"road.arterial","stylers":[{"saturation":-100},{"lightness":30},{"visibility":"on"}]},{"featureType":"road.local","stylers":[{"saturation":-100},{"lightness":40},{"visibility":"on"}]},{"featureType":"transit","stylers":[{"saturation":-100},{"visibility":"simplified"}]},{"featureType":"administrative.province","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"on"},{"lightness":-25},{"saturation":-100}]},{"featureType":"water","elementType":"geometry","stylers":[{"hue":"#ffff00"},{"lightness":-25},{"saturation":-97}]}],
                             zoomLevel     = (typeof $(this).attr('data-map-zoom') !== "undefined" && $(this).attr('data-map-zoom') !== "") ? $(this).attr('data-map-zoom') * 1: 17,
                             latlong       = typeof $(this).attr('data-latlong') != "undefined" ? $(this).attr('data-latlong') : false,
                             latitude      = latlong ? 1 *latlong.substr(0, latlong.indexOf(',')) : false,
                             longitude     = latlong ? 1 * latlong.substr(latlong.indexOf(",") + 1) : false,
                             geocoder      = new google.maps.Geocoder(),
                             address       = typeof $(this).attr('data-address') !== "undefined" ? $(this).attr('data-address').split(';'): [""],
                             markerTitle   = "We Are Here",
                             isDraggable = $(document).width() > 766 ? true : false,
                             map, marker, markerImage,
                             mapOptions = {
                                 draggable: isDraggable,
                                 scrollwheel: false,
                                 zoom: zoomLevel,
                                 disableDefaultUI: true,
                                 styles: mapStyle
                             };
      
                         if($(this).attr('data-marker-title') != undefined && $(this).attr('data-marker-title') != "" )
                         {
                             markerTitle = $(this).attr('data-marker-title');
                         }
      
                         if(address != undefined && address[0] != ""){
                                 geocoder.geocode( { 'address': address[0].replace('[nomarker]',)}, function(results, status) {
                                     if (status == google.maps.GeocoderStatus.OK) {
                                     var map = new google.maps.Map(mapInstance, mapOptions); 
                                     map.setCenter(results[0].geometry.location);
                                     
                                     address.forEach(function(address){
                                         var markerGeoCoder;
                                         
                                         markerImage = {url: window.mr_variant == undefined ? 'img/mapmarker.png' : '../img/mapmarker.png', size: new google.maps.Size(50,50), scaledSize: new google.maps.Size(50,50)};
                                         if(/(\-?\d+(\.\d+)?),\s*(\-?\d+(\.\d+)?)/.test(address) ){
                                             var latlong = address.split(','),
                                             marker = new google.maps.Marker({
                                                             position: { lat: 1*latlong[0], lng: 1*latlong[1] },
                                                             map: map,
                                                             icon: markerImage,
                                                             title: markerTitle,
                                                             optimised: false
                                                         });
                                         }
                                         else if(address.indexOf('[nomarker]') < 0){
                                             markerGeoCoder = new google.maps.Geocoder();
                                             markerGeoCoder.geocode( { 'address': address.replace('[nomarker]',)}, function(results, status) {
                                                 if (status == google.maps.GeocoderStatus.OK) {
                                                     marker = new google.maps.Marker({
                                                         map: map,
                                                         icon: markerImage,
                                                         title: markerTitle,
                                                         position: results[0].geometry.location,
                                                         optimised: false
                                                     });
                                                 }
                                             });
                                         }
      
                                     });
                                 } else {
                                     console.log('There was a problem geocoding the address.');
                                 }
                             });
                         }
                         else if(latitude != undefined && latitude != "" && latitude != false && longitude != undefined && longitude != "" && longitude != false ){
                             mapOptions.center   = { lat: latitude, lng: longitude};
                             map = new google.maps.Map(mapInstance, mapOptions); 
                             marker              = new google.maps.Marker({
                                                         position: { lat: latitude, lng: longitude },
                                                         map: map,
                                                         icon: markerImage,
                                                         title: markerTitle
                                                     });
      
                         }
      
                     }); 
             }
         }
      

      } initializeMaps();

      // End of Maps



      // Prepare Signup Form - It is used to retrieve form details from an iframe Mail Chimp or Campaign Monitor form.

      function prepareSignup(iFrame){

         var form   = jQuery('<form />'),
             div    = jQuery('<div />'),
             action;
      
         jQuery(div).html(iFrame.attr('srcdoc'));
         action = jQuery(div).find('form').attr('action');
      


         // Alter action for a Mail Chimp-compatible ajax request url.
         if(/list-manage\.com/.test(action)){
            action = action.replace('/post?', '/post-json?') + "&c=?";
            if(action.substr(0,2) == "//"){
                action = 'http:' + action;
            }
         }
      
         // Alter action for a Campaign Monitor-compatible ajax request url.
         if(/createsend\.com/.test(action)){
            action = action + '?callback=?';
         }
      


         // Set action on the form
         form.attr('action', action);
      
         // Clone form input fields from 
         jQuery(div).find('input, select, textarea').not('input[type="submit"]').each(function(){
             jQuery(this).clone().appendTo(form);
      
         });
      
         return form;
             
      

      }


      /*\ |*| COOKIE LIBRARY THANKS TO MDN |*| |*| A complete cookies reader/writer framework with full unicode support. |*| |*| Revision #1 - September 4, 2014 |*| |*| https://developer.mozilla.org/en-US/docs/Web/API/document.cookie |*| https://developer.mozilla.org/User:fusionchess |*| |*| This framework is released under the GNU Public License, version 3 or later. |*| http://www.gnu.org/licenses/gpl-3.0-standalone.html |*| |*| Syntaxes: |*| |*| * mr_cookies.setItem(name, value[, end[, path[, domain[, secure]]]]) |*| * mr_cookies.getItem(name) |*| * mr_cookies.removeItem(name[, path[, domain]]) |*| * mr_cookies.hasItem(name) |*| * mr_cookies.keys() |*| \*/

      var mr_cookies = {

       getItem: function (sKey) {
         if (!sKey) { return null; }
         return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null;
       },
       setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
         if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
         var sExpires = "";
         if (vEnd) {
           switch (vEnd.constructor) {
             case Number:
               sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
               break;
             case String:
               sExpires = "; expires=" + vEnd;
               break;
             case Date:
               sExpires = "; expires=" + vEnd.toUTCString();
               break;
           }
         }
         document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
         return true;
       },
       removeItem: function (sKey, sPath, sDomain) {
         if (!this.hasItem(sKey)) { return false; }
         document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "");
         return true;
       },
       hasItem: function (sKey) {
         if (!sKey) { return false; }
         return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie);
       },
       keys: function () {
         var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/);
         for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); }
         return aKeys;
       }
      

      };

      /*\ |*| END COOKIE LIBRARY \*/