PageSourceSearch

https://www.tavi.pt/lib/cache.js?v=bcb173dc161fa7e083a64cae48d81e32

js tavi.pt collected 2026-10-02 12:36:51 UTC 140,387 bytes, 3,294 lines download raw bytes

vendor: 4,178 bytes, lines 1-7
1/*!
2 * imagesLoaded PACKAGED v4.1.0
3 * JavaScript is all like "You images are done yet or what?"
4 * MIT License
5 */
6
7!function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}(this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||[];return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,e),n+=s?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define(["ev-emitter/ev-emitter"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}(window,function(t,e){function i(t,e){for(var i in e)t[i]=e[i];return t}function n(t){var e=[];if(Array.isArray(t))e=t;else if("number"==typeof t.length)for(var i=0;i<t.length;i++)e.push(t[i]);else e.push(t);return e}function o(t,e,r){return this instanceof o?("string"==typeof t&&(t=document.querySelectorAll(t)),this.elements=n(t),this.options=i({},this.options),"function"==typeof e?r=e:i(this.options,e),r&&this.on("always",r),this.getImages(),h&&(this.jqDeferred=new h.Deferred),void setTimeout(function(){this.check()}.bind(this))):new o(t,e,r)}function r(t){this.img=t}function s(t,e){this.url=t,this.element=e,this.img=new Image}var h=t.jQuery,a=t.console;o.prototype=Object.create(e.prototype),o.prototype.options={},o.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)},o.prototype.addElementImages=function(t){"IMG"==t.nodeName&&this.addImage(t),this.options.background===!0&&this.addElementBackgroundImages(t);var e=t.nodeType;if(e&&d[e]){for(var i=t.querySelectorAll("img"),n=0;n<i.length;n++){var o=i[n];this.addImage(o)}if("string"==typeof this.options.background){var r=t.querySelectorAll(this.options.background);for(n=0;n<r.length;n++){var s=r[n];this.addElementBackgroundImages(s)}}}};var d={1:!0,9:!0,11:!0};return o.prototype.addElementBackgroundImages=function(t){var e=getComputedStyle(t);if(e)for(var i=/url\((['"])?(.*?)\1\)/gi,n=i.exec(e.backgroundImage);null!==n;){var o=n&&n[2];o&&this.addBackground(o,t),n=i.exec(e.backgroundImage)}},o.prototype.addImage=function(t){var e=new r(t);this.images.push(e)},o.prototype.addBackground=function(t,e){var i=new s(t,e);this.images.push(i)},o.prototype.check=function(){function t(t,i,n){setTimeout(function(){e.progress(t,i,n)})}var e=this;return this.progressedCount=0,this.hasAnyBroken=!1,this.images.length?void this.images.forEach(function(e){e.once("progress",t),e.check()}):void this.complete()},o.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount==this.images.length&&this.complete(),this.options.debug&&a&&a.log("progress: "+i,t,e)},o.prototype.complete=function(){var t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){var e=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[e](this)}},r.prototype=Object.create(e.prototype),r.prototype.check=function(){var t=this.getIsImageComplete();return t?void this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),void(this.proxyImage.src=this.img.src))},r.prototype.getIsImageComplete=function(){return this.img.complete&&void 0!==this.img.naturalWi
7dth},r.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.img,e])},r.prototype.handleEvent=function(t){var e="on"+t.type;this[e]&&this[e](t)},r.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},r.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},r.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype=Object.create(r.prototype),s.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url;var t=this.getIsImageComplete();t&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},s.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},s.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},o.makeJQueryPlugin=function(e){e=e||t.jQuery,e&&(h=e,h.fn.imagesLoaded=function(t,e){var i=new o(this,t,e);return i.jqDeferred.promise(h(this))})},o.makeJQueryPlugin(),o});/*!
8 * Isotope PACKAGED v2.2.2
9 *
10 * Licensed GPLv3 for open source use
11 * or Isotope Commercial License for commercial use
12 *
13 * http://isotope.metafizzy.co
14 * Copyright 2015 Metafizzy
15 */
16
17!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}(window),function(){"use strict";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]);
17else 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,b){function c(a){var b=parseFloat(a),c=-1===a.indexOf("%")&&!isNaN(b);return c&&b}function d(){}function e(){for(var a={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},b=0,c=h.length;c>b;b++){var d=h[b];a[d]=0}return a}function f(b){function d(){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||g("Style returned "+c+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),c}}(),k=b("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 f=document.body||document.documentElement;f.appendChild(e);var h=j(e);l=200===c(h.width),f.removeChild(e)}}}function f(a){if(d(),"string"==typeof a&&(a=document.querySelector(a)),a&&"object"==typeof a&&a.nodeType){var b=j(a);if("none"===b.display)return e();var f={};f.width=a.offsetWidth,f.height=a.offsetHeight;for(var g=f.isBorderBox=!(!k||!b[k]||"border-box"!==b[k]),m=0,n=h.length;n>m;m++){var o=h[m],p=b[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=g&&l,y=c(b.width);y!==!1&&(f.width=y+(x?0:r+v));var z=c(b.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 f}var g="undefined"==typeof console?d:function(a){console.error(a)},h=["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"],f):"object"==typeof exports?module.exports=f(require("desandro-get-style-property")):a.getSize=f(a.getStyleProperty)}(window),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)
17),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(a){"use strict";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.matches)return"matches";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,b){"use strict";"function"==typeof define&&define.amd?define("fizzy-ui-utils/utils",["doc-ready/doc-ready","matches-selector/matches-selector"],function(c,d){return b(a,c,d)}):"object"==typeof exports?module.exports=b(a,require("doc-ready"),require("desandro-matches-selector")):a.fizzyUIUtils=b(a,a.docReady,a.matchesSelector)}(window,function(a,b,c){var d={};d.extend=function(a,b){for(var c in b)a[c]=b[c];return a},d.modulo=function(a,b){return(a%b+b)%b};var e=Object.prototype.toString;d.isArray=function(a){return"[object Array]"==e.call(a)},d.makeArray=function(a){var b=[];if(d.isArray(a))b=a;else if(a&&"number"==typeof a.length)for(var c=0,e=a.length;e>c;c++)b.push(a[c]);else b.push(a);return b},d.indexOf=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},d.removeFrom=function(a,b){var c=d.indexOf(a,b);-1!=c&&a.splice(c,1)},d.isElement="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},d.setText=function(){function a(a,c){b=b||(void 0!==document.documentElement.textContent?"textContent":"innerText"),a[b]=c}var b;return a}(),d.getParent=function(a,b){for(;a!=document.body;)if(a=a.parentNode,c(a,b))return a},d.getQueryElement=function(a){return"string"==typeof a?document.querySelector(a):a},d.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},d.filterFindElements=function(a,b){a=d.makeArray(a);for(var e=[],f=0,g=a.length;g>f;f++){var h=a[f];if(d.isElement(h))if(b){c(h,b)&&e.push(h);for(var i=h.querySelectorAll(b),j=0,k=i.length;k>j;j++)e.push(i[j])}else e.push(h)}return e},d.debounceMethod=function(a,b,c){var d=a.prototype[b],e=b+"Timeout";a.prototype[b]=function(){var a=this[e];a&&clearTimeout(a);var b=arguments,f=this;this[e]=setTimeout(function(){d.apply(f,b),delete f[e]},c||100)}},d.toDashed=function(a){return a.replace(/(.)([A-Z])/g,function(a,b,c){return b+"-"+c}).toLowerCase()};var f=a.console;return d.htmlInit=function(c,e){b(function(){for(var b=d.toDashed(e),g=document.querySelectorAll(".js-"+b),h="data-"+b+"-options",i=0,j=g.length;j>i;i++){var k,l=g[i],m=l.getAttribute(h);try{k=m&&JSON.parse(m)}catch(n){f&&f.error("Error parsing "+h+" on "+l.nodeName.toLowerCase()+(l.id?"#"+l.id:"")+": "+n);continue}var o=new c(l,k),p=a.jQuery;p&&p.data(l,e,o)}})},d}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("outlayer/item",["eventEmitter/EventEmitter","get-size/get-size","get-style-property/get-style-property","fizzy-ui-utils/utils"],function(c,d,e,f){return b(a,c,d,e,f)}):"object"==typeof exports?module.exports=b(a,require("wolfy87-eventemitter"),require("get-size"),require("desandro-get-style-property"),require("fizzy-ui-utils")):(a.Outlayer={},a.Outlayer.Item=b(a,a.EventEmitter,a.getSize,a.getStyleProperty,a.fizzyUIUtils))}(window,function(a,b,c,d,e){"use strict";function f(a){for(var b in a)return!1;return b=null,!0}function g(a,b){a&&(this.element=a,this.layout=b,this.position={x:0,y:0},this._create())}function h(a){return a.replace(/([A-Z])/g,function(a){return"-"+a.toLowerCase()})}var i=a.getComputedStyle,j=i?function(a){return i(a,null)}:function(a){return a.currentStyle},k=d("transition"),l=d("transform"),m=k&&l,n=!!d("perspective"),o={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"otransitionend",transition:"transitionend"}[k],p=["transform","transition","transitionDuration","transitionProperty"],q=function(){for(var a={},b=0,c=p.length;c>b;b++){var e=p[b],f=d(e);f&&f!==e&&(a[e]=f)}return a}();e.extend(g.prototype,b.prototype),g.prototype._create=function(){this._transn={ingProperties:{},clean:{},onEnd:{}},this.css({position:"absolute"})},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.getSize=function(){this.size=c(this.element)},g.prototype.css=function(a){var b=this.element.style;for(var c in a){var d=q[c]||c;b[d]=a[c]}},g.prototype.getPosition=function(){var a=j(this.element),b=this.layout.options,c=b.isOriginLeft,d=b.isOriginTop,e=a[c?"left":"right"],f=a[d?"top":"bottom"],g=this.layout.size,h=-1!=e.indexOf("%")?parseFloat(e)/100*g.width:parseInt(e,10),i=-1!=f.indexOf("%")?parseFloat(f)/100*g.height:parseInt(f,10);h=isNaN(h)?0:h,i=isNaN(i)?0:i,h-=c?g.paddingLeft:g.paddingRight,i-=d?g.paddingTop:g.paddingBottom,this.position.x=h,this.position.y=i},g.prototype.layoutPosition=function(){var a=this.layout.size,b=this.layout.options,c={},d=b.isOriginLeft?"paddingLeft":"paddingRight",e=b.isOriginLeft?"left"
17:"right",f=b.isOriginLeft?"right":"left",g=this.position.x+a[d];c[e]=this.getXValue(g),c[f]="";var h=b.isOriginTop?"paddingTop":"paddingBottom",i=b.isOriginTop?"top":"bottom",j=b.isOriginTop?"bottom":"top",k=this.position.y+a[h];c[i]=this.getYValue(k),c[j]="",this.css(c),this.emitEvent("layout",[this])},g.prototype.getXValue=function(a){var b=this.layout.options;return b.percentPosition&&!b.isHorizontal?a/this.layout.size.width*100+"%":a+"px"},g.prototype.getYValue=function(a){var b=this.layout.options;return b.percentPosition&&b.isHorizontal?a/this.layout.size.height*100+"%":a+"px"},g.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={};j.transform=this.getTranslate(h,i),this.transition({to:j,onTransitionEnd:{transform:this.layoutPosition},isCleaning:!0})},g.prototype.getTranslate=function(a,b){var c=this.layout.options;return a=c.isOriginLeft?a:-a,b=c.isOriginTop?b:-b,n?"translate3d("+a+"px, "+b+"px, 0)":"translate("+a+"px, "+b+"px)"},g.prototype.goTo=function(a,b){this.setPosition(a,b),this.layoutPosition()},g.prototype.moveTo=m?g.prototype._transitionTo:g.prototype.goTo,g.prototype.setPosition=function(a,b){this.position.x=parseInt(a,10),this.position.y=parseInt(b,10)},g.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)},g.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 r="opacity,"+h(q.transform||"transform");g.prototype.enableTransition=function(){this.isTransitioning||(this.css({transitionProperty:r,transitionDuration:this.layout.options.transitionDuration}),this.element.addEventListener(o,this,!1))},g.prototype.transition=g.prototype[k?"_transition":"_nonTransition"],g.prototype.onwebkitTransitionEnd=function(a){this.ontransitionend(a)},g.prototype.onotransitionend=function(a){this.ontransitionend(a)};var s={"-webkit-transform":"transform","-moz-transform":"transform","-o-transform":"transform"};g.prototype.ontransitionend=function(a){if(a.target===this.element){var b=this._transn,c=s[a.propertyName]||a.propertyName;if(delete b.ingProperties[c],f(b.ingProperties)&&this.disableTransition(),c in b.clean&&(this.element.style[a.propertyName]="",delete b.clean[c]),c in b.onEnd){var d=b.onEnd[c];d.call(this),delete b.onEnd[c]}this.emitEvent("transitionEnd",[this])}},g.prototype.disableTransition=function(){this.removeTransitionStyles(),this.element.removeEventListener(o,this,!1),this.isTransitioning=!1},g.prototype._removeStyles=function(a){var b={};for(var c in a)b[c]="";this.css(b)};var t={transitionProperty:"",transitionDuration:""};return g.prototype.removeTransitionStyles=function(){this.css(t)},g.prototype.removeElem=function(){this.element.parentNode.removeChild(this.element),this.css({display:""}),this.emitEvent("remove",[this])},g.prototype.remove=function(){if(!k||!parseFloat(this.layout.options.transitionDuration))return void this.removeElem();var a=this;this.once("transitionEnd",function(){a.removeElem()}),this.hide()},g.prototype.reveal=function(){delete this.isHidden,this.css({display:""});var a=this.layout.options,b={},c=this.getHideRevealTransitionEndProperty("visibleStyle");b[c]=this.onRevealTransitionEnd,this.transition({from:a.hiddenStyle,to:a.visibleStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onRevealTransitionEnd=function(){this.isHidden||this.emitEvent("reveal")},g.prototype.getHideRevealTransitionEndProperty=function(a){var b=this.layout.options[a];if(b.opacity)return"opacity";for(var c in b)return c},g.prototype.hide=function(){this.isHidden=!0,this.css({display:""});var a=this.layout.options,b={}
17,c=this.getHideRevealTransitionEndProperty("hiddenStyle");b[c]=this.onHideTransitionEnd,this.transition({from:a.visibleStyle,to:a.hiddenStyle,isCleaning:!0,onTransitionEnd:b})},g.prototype.onHideTransitionEnd=function(){this.isHidden&&(this.css({display:"none"}),this.emitEvent("hide"))},g.prototype.destroy=function(){this.css({position:"",left:"",right:"",top:"",bottom:"",transition:"",transform:""})},g}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("outlayer/outlayer",["eventie/eventie","eventEmitter/EventEmitter","get-size/get-size","fizzy-ui-utils/utils","./item"],function(c,d,e,f,g){return b(a,c,d,e,f,g)}):"object"==typeof exports?module.exports=b(a,require("eventie"),require("wolfy87-eventemitter"),require("get-size"),require("fizzy-ui-utils"),require("./item")):a.Outlayer=b(a,a.eventie,a.EventEmitter,a.getSize,a.fizzyUIUtils,a.Outlayer.Item)}(window,function(a,b,c,d,e,f){"use strict";function g(a,b){var c=e.getQueryElement(a);if(!c)return void(h&&h.error("Bad element for "+this.constructor.namespace+": "+(c||a)));this.element=c,i&&(this.$element=i(this.element)),this.options=e.extend({},this.constructor.defaults),this.option(b);var d=++k;this.element.outlayerGUID=d,l[d]=this,this._create(),this.options.isInitLayout&&this.layout()}var h=a.console,i=a.jQuery,j=function(){},k=0,l={};return g.namespace="outlayer",g.Item=f,g.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)"}},e.extend(g.prototype,c.prototype),g.prototype.option=function(a){e.extend(this.options,a)},g.prototype._create=function(){this.reloadItems(),this.stamps=[],this.stamp(this.options.stamp),e.extend(this.element.style,this.options.containerStyle),this.options.isResizeBound&&this.bindResize()},g.prototype.reloadItems=function(){this.items=this._itemize(this.element.children)},g.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},g.prototype._filterFindItemElements=function(a){return e.filterFindElements(a,this.options.itemSelector)},g.prototype.getItemElements=function(){for(var a=[],b=0,c=this.items.length;c>b;b++)a.push(this.items[b].element);return a},g.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},g.prototype._init=g.prototype.layout,g.prototype._resetLayout=function(){this.getSize()},g.prototype.getSize=function(){this.size=d(this.element)},g.prototype._getMeasurement=function(a,b){var c,f=this.options[a];f?("string"==typeof f?c=this.element.querySelector(f):e.isElement(f)&&(c=f),this[a]=c?d(c)[b]:f):this[a]=0},g.prototype.layoutItems=function(a,b){a=this._getItemsForLayout(a),this._layoutItems(a,b),this._postLayout()},g.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},g.prototype._layoutItems=function(a,b){if(this._emitCompleteOnItems("layout",a),a&&a.length){for(var c=[],d=0,e=a.length;e>d;d++){var f=a[d],g=this._getItemLayoutPosition(f);g.item=f,g.isInstant=b||f.isLayoutInstant,c.push(g)}this._processLayoutQueue(c)}},g.prototype._getItemLayoutPosition=function(){return{x:0,y:0}},g.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)}},g.prototype._positionItem=function(a,b,c,d){d?a.goTo(b,c):a.moveTo(b,c)},g.prototype._postLayout=function(){this.resizeContainer()},g.prototype.resizeContainer=function(){if(this.options.isResizingContainer){var a=this._getContainerSize();a&&(this._setContainerMeasure(a.width,!0),this._setContainerMeasure(a.height,!1))}},g.prototype._getContainerSize=j,g.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"}},g.prototype._emitCompleteOnItems=function(a,b){function c(){e.dispatchEvent(a+"Complete",null,[b])}function d(){g++,g===f&&c()}var e=this,f=b.length;if(!b||!f)return void c();for(var g=0,h=0,i=b.length;i>h;h++){var j=b[h];j.once(a,d)}},g.prototype.dispatchEvent=function(a,b,c){var d=b?[b].concat(c):c;if(this.emitEvent(a,d),i)if(this.$element=this.$element||i(this.element),b){var e=i.Event(b);e.type=a,this.$element.trigger(e,c)}else this.$element.trigger(a,c)},g.prototype.ignore=function(a){var b=this.getItem(a);b&&(b.isIgnored=!0)},g.prototype.unignore=function(a){var b=this.getItem(a);b&&delete b.isIgnored}
17,g.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)}}},g.prototype.unstamp=function(a){if(a=this._find(a))for(var b=0,c=a.length;c>b;b++){var d=a[b];e.removeFrom(this.stamps,d),this.unignore(d)}},g.prototype._find=function(a){return a?("string"==typeof a&&(a=this.element.querySelectorAll(a)),a=e.makeArray(a)):void 0},g.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)}}},g.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)}},g.prototype._manageStamp=j,g.prototype._getElementOffset=function(a){var b=a.getBoundingClientRect(),c=this._boundingRect,e=d(a),f={left:b.left-c.left-e.marginLeft,top:b.top-c.top-e.marginTop,right:c.right-b.right-e.marginRight,bottom:c.bottom-b.bottom-e.marginBottom};return f},g.prototype.handleEvent=function(a){var b="on"+a.type;this[b]&&this[b](a)},g.prototype.bindResize=function(){this.isResizeBound||(b.bind(a,"resize",this),this.isResizeBound=!0)},g.prototype.unbindResize=function(){this.isResizeBound&&b.unbind(a,"resize",this),this.isResizeBound=!1},g.prototype.onresize=function(){function a(){b.resize(),delete b.resizeTimeout}this.resizeTimeout&&clearTimeout(this.resizeTimeout);var b=this;this.resizeTimeout=setTimeout(a,100)},g.prototype.resize=function(){this.isResizeBound&&this.needsResizeLayout()&&this.layout()},g.prototype.needsResizeLayout=function(){var a=d(this.element),b=this.size&&a;return b&&a.innerWidth!==this.size.innerWidth},g.prototype.addItems=function(a){var b=this._itemize(a);return b.length&&(this.items=this.items.concat(b)),b},g.prototype.appended=function(a){var b=this.addItems(a);b.length&&(this.layoutItems(b,!0),this.reveal(b))},g.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)}},g.prototype.reveal=function(a){this._emitCompleteOnItems("reveal",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.reveal()}},g.prototype.hide=function(a){this._emitCompleteOnItems("hide",a);for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.hide()}},g.prototype.revealItemElements=function(a){var b=this.getItems(a);this.reveal(b)},g.prototype.hideItemElements=function(a){var b=this.getItems(a);this.hide(b)},g.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}},g.prototype.getItems=function(a){a=e.makeArray(a);for(var b=[],c=0,d=a.length;d>c;c++){var f=a[c],g=this.getItem(f);g&&b.push(g)}return b},g.prototype.remove=function(a){var b=this.getItems(a);if(this._emitCompleteOnItems("remove",b),b&&b.length)for(var c=0,d=b.length;d>c;c++){var f=b[c];f.remove(),e.removeFrom(this.items,f)}},g.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 l[e],delete this.element.outlayerGUID,i&&i.removeData(this.element,this.constructor.namespace)},g.data=function(a){a=e.getQueryElement(a);var b=a&&a.outlayerGUID;return b&&l[b]}
17,g.create=function(a,b){function c(){g.apply(this,arguments)}return Object.create?c.prototype=Object.create(g.prototype):e.extend(c.prototype,g.prototype),c.prototype.constructor=c,c.defaults=e.extend({},g.defaults),e.extend(c.defaults,b),c.prototype.settings={},c.namespace=a,c.data=g.data,c.Item=function(){f.apply(this,arguments)},c.Item.prototype=new f,e.htmlInit(c,a),i&&i.bridget&&i.bridget(a,c),c},g.Item=f,g}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("isotope/js/item",["outlayer/outlayer"],b):"object"==typeof exports?module.exports=b(require("outlayer")):(a.Isotope=a.Isotope||{},a.Isotope.Item=b(a.Outlayer))}(window,function(a){"use strict";function b(){a.Item.apply(this,arguments)}b.prototype=new a.Item,b.prototype._create=function(){this.id=this.layout.itemGUID++,a.Item.prototype._create.call(this),this.sortData={}},b.prototype.updateSortData=function(){if(!this.isIgnored){this.sortData.id=this.id,this.sortData["original-order"]=this.id,this.sortData.random=Math.random();var a=this.layout.options.getSortData,b=this.layout._sorters;for(var c in a){var d=b[c];this.sortData[c]=d(this.element,this)}}};var c=b.prototype.destroy;return b.prototype.destroy=function(){c.apply(this,arguments),this.css({display:""})},b}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("isotope/js/layout-mode",["get-size/get-size","outlayer/outlayer"],b):"object"==typeof exports?module.exports=b(require("get-size"),require("outlayer")):(a.Isotope=a.Isotope||{},a.Isotope.LayoutMode=b(a.getSize,a.Outlayer))}(window,function(a,b){"use strict";function c(a){this.isotope=a,a&&(this.options=a.options[this.namespace],this.element=a.element,this.items=a.filteredItems,this.size=a.size)}return function(){function a(a){return function(){return b.prototype[a].apply(this.isotope,arguments)}}for(var d=["_resetLayout","_getItemLayoutPosition","_manageStamp","_getContainerSize","_getElementOffset","needsResizeLayout"],e=0,f=d.length;f>e;e++){var g=d[e];c.prototype[g]=a(g)}}(),c.prototype.needsVerticalResizeLayout=function(){var b=a(this.isotope.element),c=this.isotope.size&&b;return c&&b.innerHeight!=this.isotope.size.innerHeight},c.prototype._getMeasurement=function(){this.isotope._getMeasurement.apply(this,arguments)},c.prototype.getColumnWidth=function(){this.getSegmentSize("column","Width")},c.prototype.getRowHeight=function(){this.getSegmentSize("row","Height")},c.prototype.getSegmentSize=function(a,b){var c=a+b,d="outer"+b;if(this._getMeasurement(c,d),!this[c]){var e=this.getFirstItemSize();this[c]=e&&e[d]||this.isotope.size["inner"+b]}},c.prototype.getFirstItemSize=function(){var b=this.isotope.filteredItems[0];return b&&b.element&&a(b.element)},c.prototype.layout=function(){this.isotope.layout.apply(this.isotope,arguments)},c.prototype.getSize=function(){this.isotope.getSize(),this.size=this.isotope.size},c.modes={},c.create=function(a,b){function d(){c.apply(this,arguments)}return d.prototype=new c,b&&(d.options=b),d.prototype.namespace=a,c.modes[a]=d,d},c}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("masonry/masonry",["outlayer/outlayer","get-size/get-size","fizzy-ui-utils/utils"],b):"object"==typeof exports?module.exports=b(require("outlayer"),require("get-size"),require("fizzy-ui-utils")):a.Masonry=b(a.Outlayer,a.getSize,a.fizzyUIUtils)}(window,function(a,b,c){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}var d=this.columnWidth+=this.gutter,e=this.containerWidth+this.gutter,f=e/d,g=d-e%d,h=g&&1>g?"round":"floor";f=Math[h](f),this.cols=Math.max(f,1)},d.prototype.getContainerWidth=function(){var a=this.options.isFitWidth?this.element.parentNode:this.element,c=b(a);
17this.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.indexOf(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}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("isotope/js/layout-modes/masonry",["../layout-mode","masonry/masonry"],b):"object"==typeof exports?module.exports=b(require("../layout-mode"),require("masonry-layout")):b(
17a.Isotope.LayoutMode,a.Masonry)}(window,function(a,b){"use strict";function c(a,b){for(var c in b)a[c]=b[c];return a}var d=a.create("masonry"),e=d.prototype._getElementOffset,f=d.prototype.layout,g=d.prototype._getMeasurement;
18c(d.prototype,b.prototype),d.prototype._getElementOffset=e,d.prototype.layout=f,d.prototype._getMeasurement=g;var h=d.prototype.measureColumns;d.prototype.measureColumns=function(){this.items=this.isotope.filteredItems,h.call(this)};var i=d.prototype._manageStamp;return d.prototype._manageStamp=function(){this.options.isOriginLeft=this.isotope.options.isOriginLeft,this.options.isOriginTop=this.isotope.options.isOriginTop,i.apply(this,arguments)},d}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("isotope/js/layout-modes/fit-rows",["../layout-mode"],b):"object"==typeof exports?module.exports=b(require("../layout-mode")):b(a.Isotope.LayoutMode)}(window,function(a){"use strict";var b=a.create("fitRows");return b.prototype._resetLayout=function(){this.x=0,this.y=0,this.maxY=0,this._getMeasurement("gutter","outerWidth")},b.prototype._getItemLayoutPosition=function(a){a.getSize();var b=a.size.outerWidth+this.gutter,c=this.isotope.size.innerWidth+this.gutter;0!==this.x&&b+this.x>c&&(this.x=0,this.y=this.maxY);var d={x:this.x,y:this.y};return this.maxY=Math.max(this.maxY,this.y+a.size.outerHeight),this.x+=b,d},b.prototype._getContainerSize=function(){return{height:this.maxY}},b}),function(a,b){"use strict";"function"==typeof define&&define.amd?define("isotope/js/layout-modes/vertical",["../layout-mode"],b):"object"==typeof exports?module.exports=b(require("../layout-mode")):b(a.Isotope.LayoutMode)}(window,function(a){"use strict";var b=a.create("vertical",{horizontalAlignment:0});return b.prototype._resetLayout=function(){this.y=0},b.prototype._getItemLayoutPosition=function(a){a.getSize();var b=(this.isotope.size.innerWidth-a.size.outerWidth)*this.options.horizontalAlignment,c=this.y;return this.y+=a.size.outerHeight,{x:b,y:c}},b.prototype._getContainerSize=function(){return{height:this.y}},b}),function(a,b){"use strict";"function"==typeof define&&define.amd?define(["outlayer/outlayer","get-size/get-size","matches-selector/matches-selector","fizzy-ui-utils/utils","isotope/js/item","isotope/js/layout-mode","isotope/js/layout-modes/masonry","isotope/js/layout-modes/fit-rows","isotope/js/layout-modes/vertical"],function(c,d,e,f,g,h){return b(a,c,d,e,f,g,h)}):"object"==typeof exports?module.exports=b(a,require("outlayer"),require("get-size"),require("desandro-matches-selector"),require("fizzy-ui-utils"),require("./item"),require("./layout-mode"),require("./layout-modes/masonry"),require("./layout-modes/fit-rows"),require("./layout-modes/vertical")):a.Isotope=b(a,a.Outlayer,a.getSize,a.matchesSelector,a.fizzyUIUtils,a.Isotope.Item,a.Isotope.LayoutMode)}(window,function(a,b,c,d,e,f,g){function h(a,b){return function(c,d){for(var e=0,f=a.length;f>e;e++){var g=a[e],h=c.sortData[g],i=d.sortData[g];if(h>i||i>h){var j=void 0!==b[g]?b[g]:b,k=j?1:-1;return(h>i?1:-1)*k}}return 0}}var i=a.jQuery,j=String.prototype.trim?function(a){return a.trim()}:function(a){return a.replace(/^\s+|\s+$/g,"")},k=document.documentElement,l=k.textContent?function(a){return a.textContent}:function(a){return a.innerText},m=b.create("isotope",{layoutMode:"masonry",isJQueryFiltering:!0,sortAscending:!0});m.Item=f,m.LayoutMode=g,m.prototype._create=function(){this.itemGUID=0,this._sorters={},this._getSorters(),b.prototype._create.call(this),this.modes={},this.filteredItems=this.items,this.sortHistory=["original-order"];for(var a in g.modes)this._initLayoutMode(a)},m.prototype.reloadItems=function(){this.itemGUID=0,b.prototype.reloadItems.call(this)},m.prototype._itemize=function(){for(var a=b.prototype._itemize.apply(this,arguments),c=0,d=a.length;d>c;c++){var e=a[c];e.id=this.itemGUID++}return this._updateItemsSortData(a),a},m.prototype._initLayoutMode=function(a){var b=g.modes[a],c=this.options[a]||{};this.options[a]=b.options?e.extend(b.options,c):c,this.modes[a]=new b(this)},m.prototype.layout=function(){return!this._isLayoutInited&&this.options.isInitLayout?void this.arrange():void this._layout()},m.prototype._layout=function(){var a=this._getIsInstant();this._resetLayout(),this._manageStamps(),this.layoutItems(this.filteredItems,a),this._isLayoutInited=!0},m.prototype.arrange=function(a){function b(){d.reveal(c.needReveal),d.hide(c.needHide)}this.option(a),this._getIsInstant();var c=this._filter(this.items);this.filteredItems=c.matches;var d=this;this._bindArrangeComplete(),this._isInstant?this._noTransition(b):b(),this._sort(),this._layout()},m.prototype._init=m.prototype.arrange,m.prototype._getIsInstant=function(){var a=void 0!==this.options.isLayoutInstant?this.options.isLayoutInstant:!this._isLayoutInited;return this._isInstant=a,a},m.prototype._bindArrangeComplete=function(){function a(){b&&c&&d&&e.dispatchEvent("arrangeComplete",null,[e.filteredItems])}var b,c,d,e=this;this.once("layoutComplete",function(){b=!0,a()}),this.once("hideComplete",function(){c=!0,a()}),this.once("revealComplete",function(){d=!0,a()})},m.prototype._filter=function(a){var b=this.options.filter;b=b||"*";for(var c=[],d=[],e=[],f=this._getFilterTest(b),g=0,h=a.length;h>g;g++){var i=a[g];if(!i.isIgnored){var j=f(i);j&&c.push(i),j&&i.isHidden?d.push(i):j||i.isHidden||e.push(i)}}return{matches:c,needReveal:d,needHide:e}},m.prototype._getFilterTest=function(a){return i&&this.options.isJQueryFiltering?function(b){return i(b.element).is(a)}:"function"==typeof a?function(b){return a(b.element)}:function(b){return d(b.element,a)}},m.prototype.updateSortData=function(a){var b;a?(a=e.makeArray(a),b=this.getItems(a)):b=this.items,this._getSorters(),this._updateItemsSortData(b)},m.prototype._getSorters=function(){var a=this.options.getSortData;for(var b in a){var c=a[b];this._sorters[b]=n(c)}},m.prototype._updateItemsSortData=function(a){for(var b=a&&a.length,c=0;b&&b>c;c++){var d=a[c];d.updateSortData()}};var n=function(){function a(a){if("string"!=typeof a)return a;var c=j(a).split(" "),d=c[0],e=d.match(/^\[(.+)\]$/),f=e&&e[1],g=b(f,d),h=m.sortDataParsers[c[1]];return a=h?function(a){return a&&h(g(a))}:function(a){return a&&g(a)}}function b(a,b){var c;return c=a?function(b){return b.getAttribute(a)}:function(a){var c=a.querySelector(b);return c&&l(c)}}return a}();m.sortDataParsers={parseInt:function(a){return parseInt(a,10)},parseFloat:function(a){return parseFloat(a)}},m.prototype._sort=function(){var a=this.options.sortBy;if(a){var b=[].concat.apply(a,this.sortHistory),c=h(b,this.options.sortAscending);this.filteredItems.sort(c),a!=this.sortHistory[0]&&this.sortHistory.unshift(a)}},m.prototype._mode=function(){var a=this.options.layoutMode,b=this.modes[a];if(!b)throw new Error("No layout mode: "+a);return b.options=this.options[a],b},m.prototype._resetLayout=function(){b.prototype._resetLayout.call(this),this._mode()._resetLayout()},m.prototype._getItemLayoutPosition=function(a){return this._mode()._getItemLayoutPosition(a)},m.prototype._manageStamp=function(a){this._mode()._manageStamp(a)},m.prototype._getContainerSize=function(){return this._mode()._getContainerSize()},m.prototype.needsResizeLayout=function(){return this._mode().needsResizeLayout()},m.prototype.appended=function(a){var b=this.addItems(a);if(b.length){var c=this._filterRevealAdded(b);this.filteredItems=this.filteredItems.concat(c)}},m.prototype.prepended=function(a){var b=this._itemize(a);if(b.length){this._resetLayout(),this._manageStamps();var c=this._filterRevealAdded(b);this.layoutItems(this.filteredItems),this.filteredItems=c.concat(this.filteredItems),this.items=b.concat(this.items)}},m.prototype._filterRevealAdded=function(a){var b=this._filter(a);return this.hide(b.needHide),this.reveal(b.matches),this.layoutItems(b.matches,!0),b.matches},m.prototype.insert=function(a){var b=this.addItems(a);if(b.length){var c,d,e=b.length;for(c=0;e>c;c++)d=b[c],this.element.appendChild(d.element);var f=this._filter(b).matches;for(c=0;e>c;c++)b[c].isLayoutInstant=!0;for(this.arrange(),c=0;e>c;c++)delete b[c].isLayoutInstant;this.reveal(f)}};var o=m.prototype.remove;return m.prototype.remove=function(a){a=e.makeArray(a);var b=this.getItems(a);o.call(this,a);var c=b&&b.length;if(c)for(var d=0;c>d;d++){var f=b[d];e.removeFrom(this.filteredItems,f)}},m.prototype.shuffle=function(){for(var a=0,b=this.items.length;b>a;a++){var c=this.items[a];c.sortData.random=Math.random()}this.options.sortBy="random",this._sort(),this._layout()},m.prototype._noTransition=function(a){var b=this.options.transitionDuration;this.options.transitionDuration=0;var c=a.call(this);return this.options.transitionDuration=b,c},m.prototype.getFilteredItemElements=function(){for(var a=[],b=0,c=this.filteredItems.length;c>b;b++)a.push(this.filteredItems[b].element);return a},m});/*!
vendor: 5,734 bytes, lines 19-230
19 * fancyBox - jQuery Plugin
20 * version: 2.1.5 (Fri, 14 Jun 2013)
21 * @requires jQuery v1.6 or later
22 *
23 * Examples at http://fancyapps.com/fancybox/
24 * License: www.fancyapps.com/fancybox/#license
25 *
26 * Copyright 2012 Janis Skarnelis - [email protected]
27 *
28 */
29
30(function (window, document, $, undefined) {
31	"use strict";
32
33	var H = $("html"),
34		W = $(window),
35		D = $(document),
36		F = $.fancybox = function () {
37			F.open.apply( this, arguments );
38		},
39		IE =  navigator.userAgent.match(/msie/i),
40		didUpdate	= null,
41		isTouch		= document.createTouch !== undefined,
42
43		isQuery	= function(obj) {
44			return obj && obj.hasOwnProperty && obj instanceof $;
45		},
46		isString = function(str) {
47			return str && $.type(str) === "string";
48		},
49		isPercentage = function(str) {
50			return isString(str) && str.indexOf('%') > 0;
51		},
52		isScrollable = function(el) {
53			return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
54		},
55		getScalar = function(orig, dim) {
56			var value = parseInt(orig, 10) || 0;
57
58			if (dim && isPercentage(orig)) {
59				value = F.getViewport()[ dim ] / 100 * value;
60			}
61
62			return Math.ceil(value);
63		},
64		getValue = function(value, dim) {
65			return getScalar(value, dim) + 'px';
66		};
67
68	$.extend(F, {
69		// The current version of fancyBox
70		version: '2.1.5',
71
72		defaults: {
73			padding : 15,
74			margin  : 20,
75
76			width     : 800,
77			height    : 600,
78			minWidth  : 100,
79			minHeight : 100,
80			maxWidth  : 9999,
81			maxHeight : 9999,
82			pixelRatio: 1, // Set to 2 for retina display support
83
84			autoSize   : true,
85			autoHeight : false,
86			autoWidth  : false,
87
88			autoResize  : true,
89			autoCenter  : !isTouch,
90			fitToView   : true,
91			aspectRatio : false,
92			topRatio    : 0.5,
93			leftRatio   : 0.5,
94
95			scrolling : 'auto', // 'auto', 'yes' or 'no'
96			wrapCSS   : '',
97
98			arrows     : true,
99			closeBtn   : true,
100			closeClick : false,
101			nextClick  : false,
102			mouseWheel : true,
103			autoPlay   : false,
104			playSpeed  : 3000,
105			preload    : 3,
106			modal      : false,
107			loop       : true,
108
109			ajax  : {
110				dataType : 'html',
111				headers  : { 'X-fancyBox': true }
112			},
113			iframe : {
114				scrolling : 'auto',
115				preload   : true
116			},
117			swf : {
118				wmode: 'transparent',
119				allowfullscreen   : 'true',
120				allowscriptaccess : 'always'
121			},
122
123			keys  : {
124				next : {
125					13 : 'left', // enter
126					34 : 'up',   // page down
127					39 : 'left', // right arrow
128					40 : 'up'    // down arrow
129				},
130				prev : {
131					8  : 'right',  // backspace
132					33 : 'down',   // page up
133					37 : 'right',  // left arrow
134					38 : 'down'    // up arrow
135				},
136				close  : [27], // escape key
137				play   : [32], // space - start/stop slideshow
138				toggle : [70]  // letter "f" - toggle fullscreen
139			},
140
141			direction : {
142				next : 'left',
143				prev : 'right'
144			},
145
146			scrollOutside  : true,
147
148			// Override some properties
149			index   : 0,
150			type    : null,
151			href    : null,
152			content : null,
153			title   : null,
154
155			// HTML templates
156			tpl: {
157				wrap     : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
158				image    : '<img class="fancybox-image" src="{href}" alt="" />',
159				iframe   : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>',
160				error    : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
161				closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
162				next     : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
163				prev     : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
164			},
165
166			// Properties for each animation type
167			// Opening fancyBox
168			openEffect  : 'fade', // 'elastic', 'fade' or 'none'
169			openSpeed   : 250,
170			openEasing  : 'swing',
171			openOpacity : true,
172			openMethod  : 'zoomIn',
173
174			// Closing fancyBox
175			closeEffect  : 'fade', // 'elastic', 'fade' or 'none'
176			closeSpeed   : 250,
177			closeEasing  : 'swing',
178			closeOpacity : true,
179			closeMethod  : 'zoomOut',
180
181			// Changing next gallery item
182			nextEffect : 'elastic', // 'elastic', 'fade' or 'none'
183			nextSpeed  : 250,
184			nextEasing : 'swing',
185			nextMethod : 'changeIn',
186
187			// Changing previous gallery item
188			prevEffect : 'elastic', // 'elastic', 'fade' or 'none'
189			prevSpeed  : 250,
190			prevEasing : 'swing',
191			prevMethod : 'changeOut',
192
193			// Enable default helpers
194			helpers : {
195				overlay : true,
196				title   : true
197			},
198
199			// Callbacks
200			onCancel     : $.noop, // If canceling
201			beforeLoad   : $.noop, // Before loading
202			afterLoad    : $.noop, // After loading
203			beforeShow   : $.noop, // Before changing in current item
204			afterShow    : $.noop, // After opening
205			beforeChange : $.noop, // Before changing gallery item
206			beforeClose  : $.noop, // Before closing
207			afterClose   : $.noop  // After closing
208		},
209
210		//Current state
211		group    : {}, // Selected group
212		opts     : {}, // Group options
213		previous : null,  // Previous element
214		coming   : null,  // Element being loaded
215		current  : null,  // Currently loaded element
216		isActive : false, // Is activated
217		isOpen   : false, // Is currently open
218		isOpened : false, // Have been fully opened at least once
219
220		wrap  : null,
221		skin  : null,
222		outer : null,
223		inner : null,
224
225		player : {
226			timer    : null,
227			isActive : false
228		},
229
230		// Loaders
vendor: 12,016 bytes, lines 231-778
231		ajaxLoad   : null,
232		imgPreload : null,
233
234		// Some collections
235		transitions : {},
236		helpers     : {},
237
238		/*
239		 *	Static methods
240		 */
241
242		open: function (group, opts) {
243			if (!group) {
244				return;
245			}
246
247			if (!$.isPlainObject(opts)) {
248				opts = {};
249			}
250
251			// Close if already active
252			if (false === F.close(true)) {
253				return;
254			}
255
256			// Normalize group
257			if (!$.isArray(group)) {
258				group = isQuery(group) ? $(group).get() : [group];
259			}
260
261			// Recheck if the type of each element is `object` and set content type (image, ajax, etc)
262			$.each(group, function(i, element) {
263				var obj = {},
264					href,
265					title,
266					content,
267					type,
268					rez,
269					hrefParts,
270					selector;
271
272				if ($.type(element) === "object") {
273					// Check if is DOM element
274					if (element.nodeType) {
275						element = $(element);
276					}
277
278					if (isQuery(element)) {
279						obj = {
280							href    : element.data('fancybox-href') || element.attr('href'),
281							title   : element.data('fancybox-title') || element.attr('title'),
282							isDom   : true,
283							element : element
284						};
285
286						if ($.metadata) {
287							$.extend(true, obj, element.metadata());
288						}
289
290					} else {
291						obj = element;
292					}
293				}
294
295				href  = opts.href  || obj.href || (isString(element) ? element : null);
296				title = opts.title !== undefined ? opts.title : obj.title || '';
297
298				content = opts.content || obj.content;
299				type    = content ? 'html' : (opts.type  || obj.type);
300
301				if (!type && obj.isDom) {
302					type = element.data('fancybox-type');
303
304					if (!type) {
305						rez  = element.prop('class').match(/fancybox\.(\w+)/);
306						type = rez ? rez[1] : null;
307					}
308				}
309
310				if (isString(href)) {
311					// Try to guess the content type
312					if (!type) {
313						if (F.isImage(href)) {
314							type = 'image';
315
316						} else if (F.isSWF(href)) {
317							type = 'swf';
318
319						} else if (href.charAt(0) === '#') {
320							type = 'inline';
321
322						} else if (isString(element)) {
323							type    = 'html';
324							content = element;
325						}
326					}
327
328					// Split url into two pieces with source url and content selector, e.g,
329					// "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id"
330					if (type === 'ajax') {
331						hrefParts = href.split(/\s+/, 2);
332						href      = hrefParts.shift();
333						selector  = hrefParts.shift();
334					}
335				}
336
337				if (!content) {
338					if (type === 'inline') {
339						if (href) {
340							content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
341
342						} else if (obj.isDom) {
343							content = element;
344						}
345
346					} else if (type === 'html') {
347						content = href;
348
349					} else if (!type && !href && obj.isDom) {
350						type    = 'inline';
351						content = element;
352					}
353				}
354
355				$.extend(obj, {
356					href     : href,
357					type     : type,
358					content  : content,
359					title    : title,
360					selector : selector
361				});
362
363				group[ i ] = obj;
364			});
365
366			// Extend the defaults
367			F.opts = $.extend(true, {}, F.defaults, opts);
368
369			// All options are merged recursive except keys
370			if (opts.keys !== undefined) {
371				F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
372			}
373
374			F.group = group;
375
376			return F._start(F.opts.index);
377		},
378
379		// Cancel image loading or abort ajax request
380		cancel: function () {
381			var coming = F.coming;
382
383			if (!coming || false === F.trigger('onCancel')) {
384				return;
385			}
386
387			F.hideLoading();
388
389			if (F.ajaxLoad) {
390				F.ajaxLoad.abort();
391			}
392
393			F.ajaxLoad = null;
394
395			if (F.imgPreload) {
396				F.imgPreload.onload = F.imgPreload.onerror = null;
397			}
398
399			if (coming.wrap) {
400				coming.wrap.stop(true, true).trigger('onReset').remove();
401			}
402
403			F.coming = null;
404
405			// If the first item has been canceled, then clear everything
406			if (!F.current) {
407				F._afterZoomOut( coming );
408			}
409		},
410
411		// Start closing animation if is open; remove immediately if opening/closing
412		close: function (event) {
413			F.cancel();
414
415			if (false === F.trigger('beforeClose')) {
416				return;
417			}
418
419			F.unbindEvents();
420
421			if (!F.isActive) {
422				return;
423			}
424
425			if (!F.isOpen || event === true) {
426				$('.fancybox-wrap').stop(true).trigger('onReset').remove();
427
428				F._afterZoomOut();
429
430			} else {
431				F.isOpen = F.isOpened = false;
432				F.isClosing = true;
433
434				$('.fancybox-item, .fancybox-nav').remove();
435
436				F.wrap.stop(true, true).removeClass('fancybox-opened');
437
438				F.transitions[ F.current.closeMethod ]();
439			}
440		},
441
442		// Manage slideshow:
443		//   $.fancybox.play(); - toggle slideshow
444		//   $.fancybox.play( true ); - start
445		//   $.fancybox.play( false ); - stop
446		play: function ( action ) {
447			var clear = function () {
448					clearTimeout(F.player.timer);
449				},
450				set = function () {
451					clear();
452
453					if (F.current && F.player.isActive) {
454						F.player.timer = setTimeout(F.next, F.current.playSpeed);
455					}
456				},
457				stop = function () {
458					clear();
459
460					D.unbind('.player');
461
462					F.player.isActive = false;
463
464					F.trigger('onPlayEnd');
465				},
466				start = function () {
467					if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
468						F.player.isActive = true;
469
470						D.bind({
471							'onCancel.player beforeClose.player' : stop,
472							'onUpdate.player'   : set,
473							'beforeLoad.player' : clear
474						});
475
476						set();
477
478						F.trigger('onPlayStart');
479					}
480				};
481
482			if (action === true || (!F.player.isActive && action !== false)) {
483				start();
484			} else {
485				stop();
486			}
487		},
488
489		// Navigate to next gallery item
490		next: function ( direction ) {
491			var current = F.current;
492
493			if (current) {
494				if (!isString(direction)) {
495					direction = current.direction.next;
496				}
497
498				F.jumpto(current.index + 1, direction, 'next');
499			}
500		},
501
502		// Navigate to previous gallery item
503		prev: function ( direction ) {
504			var current = F.current;
505
506			if (current) {
507				if (!isString(direction)) {
508					direction = current.direction.prev;
509				}
510
511				F.jumpto(current.index - 1, direction, 'prev');
512			}
513		},
514
515		// Navigate to gallery item by index
516		jumpto: function ( index, direction, router ) {
517			var current = F.current;
518
519			if (!current) {
520				return;
521			}
522
523			index = getScalar(index);
524
525			F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ];
526			F.router    = router || 'jumpto';
527
528			if (current.loop) {
529				if (index < 0) {
530					index = current.group.length + (index % current.group.length);
531				}
532
533				index = index % current.group.length;
534			}
535
536			if (current.group[ index ] !== undefined) {
537				F.cancel();
538
539				F._start(index);
540			}
541		},
542
543		// Center inside viewport and toggle position type to fixed or absolute if needed
544		reposition: function (e, onlyAbsolute) {
545			var current = F.current,
546				wrap    = current ? current.wrap : null,
547				pos;
548
549			if (wrap) {
550				pos = F._getPosition(onlyAbsolute);
551
552				if (e && e.type === 'scroll') {
553					delete pos.position;
554
555					wrap.stop(true, true).animate(pos, 200);
556
557				} else {
558					wrap.css(pos);
559
560					current.pos = $.extend({}, current.dim, pos);
561				}
562			}
563		},
564
565		update: function (e) {
566			var type = (e && e.type),
567				anyway = !type || type === 'orientationchange';
568
569			if (anyway) {
570				clearTimeout(didUpdate);
571
572				didUpdate = null;
573			}
574
575			if (!F.isOpen || didUpdate) {
576				return;
577			}
578
579			didUpdate = setTimeout(function() {
580				var current = F.current;
581
582				if (!current || F.isClosing) {
583					return;
584				}
585
586				F.wrap.removeClass('fancybox-tmp');
587
588				if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
589					F._setDimension();
590				}
591
592				if (!(type === 'scroll' && current.canShrink)) {
593					F.reposition(e);
594				}
595
596				F.trigger('onUpdate');
597
598				didUpdate = null;
599
600			}, (anyway && !isTouch ? 0 : 300));
601		},
602
603		// Shrink content to fit inside viewport or restore if resized
604		toggle: function ( action ) {
605			if (F.isOpen) {
606				F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
607
608				// Help browser to restore document dimensions
609				if (isTouch) {
610					F.wrap.removeAttr('style').addClass('fancybox-tmp');
611
612					F.trigger('onUpdate');
613				}
614
615				F.update();
616			}
617		},
618
619		hideLoading: function () {
620			D.unbind('.loading');
621
622			$('#fancybox-loading').remove();
623		},
624
625		showLoading: function () {
626			var el, viewport;
627
628			F.hideLoading();
629
630			el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
631
632			// If user will press the escape-button, the request will be canceled
633			D.bind('keydown.loading', function(e) {
634				if ((e.which || e.keyCode) === 27) {
635					e.preventDefault();
636
637					F.cancel();
638				}
639			});
640
641			if (!F.defaults.fixed) {
642				viewport = F.getViewport();
643
644				el.css({
645					position : 'absolute',
646					top  : (viewport.h * 0.5) + viewport.y,
647					left : (viewport.w * 0.5) + viewport.x
648				});
649			}
650		},
651
652		getViewport: function () {
653			var locked = (F.current && F.current.locked) || false,
654				rez    = {
655					x: W.scrollLeft(),
656					y: W.scrollTop()
657				};
658
659			if (locked) {
660				rez.w = locked[0].clientWidth;
661				rez.h = locked[0].clientHeight;
662
663			} else {
664				// See http://bugs.jquery.com/ticket/6724
665				rez.w = isTouch && window.innerWidth  ? window.innerWidth  : W.width();
666				rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height();
667			}
668
669			return rez;
670		},
671
672		// Unbind the keyboard / clicking actions
673		unbindEvents: function () {
674			if (F.wrap && isQuery(F.wrap)) {
675				F.wrap.unbind('.fb');
676			}
677
678			D.unbind('.fb');
679			W.unbind('.fb');
680		},
681
682		bindEvents: function () {
683			var current = F.current,
684				keys;
685
686			if (!current) {
687				return;
688			}
689
690			// Changing document height on iOS devices triggers a 'resize' event,
691			// that can change document height... repeating infinitely
692			W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
693
694			keys = current.keys;
695
696			if (keys) {
697				D.bind('keydown.fb', function (e) {
698					var code   = e.which || e.keyCode,
699						target = e.target || e.srcElement;
700
701					// Skip esc key if loading, because showLoading will cancel preloading
702					if (code === 27 && F.coming) {
703						return false;
704					}
705
706					// Ignore key combinations and key events within form elements
707					if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
708						$.each(keys, function(i, val) {
709							if (current.group.length > 1 && val[ code ] !== undefined) {
710								F[ i ]( val[ code ] );
711
712								e.preventDefault();
713								return false;
714							}
715
716							if ($.inArray(code, val) > -1) {
717								F[ i ] ();
718
719								e.preventDefault();
720								return false;
721							}
722						});
723					}
724				});
725			}
726
727			if ($.fn.mousewheel && current.mouseWheel) {
728				F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) {
729					var target = e.target || null,
730						parent = $(target),
731						canScroll = false;
732
733					while (parent.length) {
734						if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) {
735							break;
736						}
737
738						canScroll = isScrollable( parent[0] );
739						parent    = $(parent).parent();
740					}
741
742					if (delta !== 0 && !canScroll) {
743						if (F.group.length > 1 && !current.canShrink) {
744							if (deltaY > 0 || deltaX > 0) {
745								F.prev( deltaY > 0 ? 'down' : 'left' );
746
747							} else if (deltaY < 0 || deltaX < 0) {
748								F.next( deltaY < 0 ? 'up' : 'right' );
749							}
750
751							e.preventDefault();
752						}
753					}
754				});
755			}
756		},
757
758		trigger: function (event, o) {
759			var ret, obj = o || F.coming || F.current;
760
761			if (!obj) {
762				return;
763			}
764
765			if ($.isFunction( obj[event] )) {
766				ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
767			}
768
769			if (ret === false) {
770				return false;
771			}
772
773			if (obj.helpers) {
774				$.each(obj.helpers, function (helper, opts) {
775					if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
776						F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj);
777					}
778				});
vendor: 8,050 bytes, lines 778-1137
778
779			}
780
781			D.trigger(event);
782		},
783
784		isImage: function (str) {
785			return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i);
786		},
787
788		isSWF: function (str) {
789			return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
790		},
791
792		_start: function (index) {
793			var coming = {},
794				obj,
795				href,
796				type,
797				margin,
798				padding;
799
800			index = getScalar( index );
801			obj   = F.group[ index ] || null;
802
803			if (!obj) {
804				return false;
805			}
806
807			coming = $.extend(true, {}, F.opts, obj);
808
809			// Convert margin and padding properties to array - top, right, bottom, left
810			margin  = coming.margin;
811			padding = coming.padding;
812
813			if ($.type(margin) === 'number') {
814				coming.margin = [margin, margin, margin, margin];
815			}
816
817			if ($.type(padding) === 'number') {
818				coming.padding = [padding, padding, padding, padding];
819			}
820
821			// 'modal' propery is just a shortcut
822			if (coming.modal) {
823				$.extend(true, coming, {
824					closeBtn   : false,
825					closeClick : false,
826					nextClick  : false,
827					arrows     : false,
828					mouseWheel : false,
829					keys       : null,
830					helpers: {
831						overlay : {
832							closeClick : false
833						}
834					}
835				});
836			}
837
838			// 'autoSize' property is a shortcut, too
839			if (coming.autoSize) {
840				coming.autoWidth = coming.autoHeight = true;
841			}
842
843			if (coming.width === 'auto') {
844				coming.autoWidth = true;
845			}
846
847			if (coming.height === 'auto') {
848				coming.autoHeight = true;
849			}
850
851			/*
852			 * Add reference to the group, so it`s possible to access from callbacks, example:
853			 * afterLoad : function() {
854			 *     this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
855			 * }
856			 */
857
858			coming.group  = F.group;
859			coming.index  = index;
860
861			// Give a chance for callback or helpers to update coming item (type, title, etc)
862			F.coming = coming;
863
864			if (false === F.trigger('beforeLoad')) {
865				F.coming = null;
866
867				return;
868			}
869
870			type = coming.type;
871			href = coming.href;
872
873			if (!type) {
874				F.coming = null;
875
876				//If we can not determine content type then drop silently or display next/prev item if looping through gallery
877				if (F.current && F.router && F.router !== 'jumpto') {
878					F.current.index = index;
879
880					return F[ F.router ]( F.direction );
881				}
882
883				return false;
884			}
885
886			F.isActive = true;
887
888			if (type === 'image' || type === 'swf') {
889				coming.autoHeight = coming.autoWidth = false;
890				coming.scrolling  = 'visible';
891			}
892
893			if (type === 'image') {
894				coming.aspectRatio = true;
895			}
896
897			if (type === 'iframe' && isTouch) {
898				coming.scrolling = 'scroll';
899			}
900
901			// Build the neccessary markup
902			coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
903
904			$.extend(coming, {
905				skin  : $('.fancybox-skin',  coming.wrap),
906				outer : $('.fancybox-outer', coming.wrap),
907				inner : $('.fancybox-inner', coming.wrap)
908			});
909
910			$.each(["Top", "Right", "Bottom", "Left"], function(i, v) {
911				coming.skin.css('padding' + v, getValue(coming.padding[ i ]));
912			});
913
914			F.trigger('onReady');
915
916			// Check before try to load; 'inline' and 'html' types need content, others - href
917			if (type === 'inline' || type === 'html') {
918				if (!coming.content || !coming.content.length) {
919					return F._error( 'content' );
920				}
921
922			} else if (!href) {
923				return F._error( 'href' );
924			}
925
926			if (type === 'image') {
927				F._loadImage();
928
929			} else if (type === 'ajax') {
930				F._loadAjax();
931
932			} else if (type === 'iframe') {
933				F._loadIframe();
934
935			} else {
936				F._afterLoad();
937			}
938		},
939
940		_error: function ( type ) {
941			$.extend(F.coming, {
942				type       : 'html',
943				autoWidth  : true,
944				autoHeight : true,
945				minWidth   : 0,
946				minHeight  : 0,
947				scrolling  : 'no',
948				hasError   : type,
949				content    : F.coming.tpl.error
950			});
951
952			F._afterLoad();
953		},
954
955		_loadImage: function () {
956			// Reset preload image so it is later possible to check "complete" property
957			var img = F.imgPreload = new Image();
958
959			img.onload = function () {
960				this.onload = this.onerror = null;
961
962				F.coming.width  = this.width / F.opts.pixelRatio;
963				F.coming.height = this.height / F.opts.pixelRatio;
964
965				F._afterLoad();
966			};
967
968			img.onerror = function () {
969				this.onload = this.onerror = null;
970
971				F._error( 'image' );
972			};
973
974			img.src = F.coming.href;
975
976			if (img.complete !== true) {
977				F.showLoading();
978			}
979		},
980
981		_loadAjax: function () {
982			var coming = F.coming;
983
984			F.showLoading();
985
986			F.ajaxLoad = $.ajax($.extend({}, coming.ajax, {
987				url: coming.href,
988				error: function (jqXHR, textStatus) {
989					if (F.coming && textStatus !== 'abort') {
990						F._error( 'ajax', jqXHR );
991
992					} else {
993						F.hideLoading();
994					}
995				},
996				success: function (data, textStatus) {
997					if (textStatus === 'success') {
998						coming.content = data;
999
1000						F._afterLoad();
1001					}
1002				}
1003			}));
1004		},
1005
1006		_loadIframe: function() {
1007			var coming = F.coming,
1008				iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime()))
1009					.attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling)
1010					.attr('src', coming.href);
1011
1012			// This helps IE
1013			$(coming.wrap).bind('onReset', function () {
1014				try {
1015					$(this).find('iframe').hide().attr('src', '//about:blank').end().empty();
1016				} catch (e) {}
1017			});
1018
1019			if (coming.iframe.preload) {
1020				F.showLoading();
1021
1022				iframe.one('load', function() {
1023					$(this).data('ready', 1);
1024
1025					// iOS will lose scrolling if we resize
1026					if (!isTouch) {
1027						$(this).bind('load.fb', F.update);
1028					}
1029
1030					// Without this trick:
1031					//   - iframe won't scroll on iOS devices
1032					//   - IE7 sometimes displays empty iframe
1033					$(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show();
1034
1035					F._afterLoad();
1036				});
1037			}
1038
1039			coming.content = iframe.appendTo( coming.inner );
1040
1041			if (!coming.iframe.preload) {
1042				F._afterLoad();
1043			}
1044		},
1045
1046		_preloadImages: function() {
1047			var group   = F.group,
1048				current = F.current,
1049				len     = group.length,
1050				cnt     = current.preload ? Math.min(current.preload, len - 1) : 0,
1051				item,
1052				i;
1053
1054			for (i = 1; i <= cnt; i += 1) {
1055				item = group[ (current.index + i ) % len ];
1056
1057				if (item.type === 'image' && item.href) {
1058					new Image().src = item.href;
1059				}
1060			}
1061		},
1062
1063		_afterLoad: function () {
1064			var coming   = F.coming,
1065				previous = F.current,
1066				placeholder = 'fancybox-placeholder',
1067				current,
1068				content,
1069				type,
1070				scrolling,
1071				href,
1072				embed;
1073
1074			F.hideLoading();
1075
1076			if (!coming || F.isActive === false) {
1077				return;
1078			}
1079
1080			if (false === F.trigger('afterLoad', coming, previous)) {
1081				coming.wrap.stop(true).trigger('onReset').remove();
1082
1083				F.coming = null;
1084
1085				return;
1086			}
1087
1088			if (previous) {
1089				F.trigger('beforeChange', previous);
1090
1091				previous.wrap.stop(true).removeClass('fancybox-opened')
1092					.find('.fancybox-item, .fancybox-nav')
1093					.remove();
1094			}
1095
1096			F.unbindEvents();
1097
1098			current   = coming;
1099			content   = coming.content;
1100			type      = coming.type;
1101			scrolling = coming.scrolling;
1102
1103			$.extend(F, {
1104				wrap  : current.wrap,
1105				skin  : current.skin,
1106				outer : current.outer,
1107				inner : current.inner,
1108				current  : current,
1109				previous : previous
1110			});
1111
1112			href = current.href;
1113
1114			switch (type) {
1115				case 'inline':
1116				case 'ajax':
1117				case 'html':
1118					if (current.selector) {
1119						content = $('<div>').html(content).find(current.selector);
1120
1121					} else if (isQuery(content)) {
1122						if (!content.data(placeholder)) {
1123							content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() );
1124						}
1125
1126						content = content.show().detach();
1127
1128						current.wrap.bind('onReset', function () {
1129							if ($(this).find(content).length) {
1130								content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
1131							}
1132						});
1133					}
1134				break;
1135
1136				case 'image':
1137					content = current.tpl.image.replace(
vendor: 19,741 bytes, lines 1137-1909
1137'{href}', href);
1138				break;
1139
1140				case 'swf':
1141					content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
1142					embed   = '';
1143
1144					$.each(current.swf, function(name, val) {
1145						content += '<param name="' + name + '" value="' + val + '"></param>';
1146						embed   += ' ' + name + '="' + val + '"';
1147					});
1148
1149					content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>';
1150				break;
1151			}
1152
1153			if (!(isQuery(content) && content.parent().is(current.inner))) {
1154				current.inner.append( content );
1155			}
1156
1157			// Give a chance for helpers or callbacks to update elements
1158			F.trigger('beforeShow');
1159
1160			// Set scrolling before calculating dimensions
1161			current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1162
1163			// Set initial dimensions and start position
1164			F._setDimension();
1165
1166			F.reposition();
1167
1168			F.isOpen = false;
1169			F.coming = null;
1170
1171			F.bindEvents();
1172
1173			if (!F.isOpened) {
1174				$('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
1175
1176			} else if (previous.prevMethod) {
1177				F.transitions[ previous.prevMethod ]();
1178			}
1179
1180			F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
1181
1182			F._preloadImages();
1183		},
1184
1185		_setDimension: function () {
1186			var viewport   = F.getViewport(),
1187				steps      = 0,
1188				canShrink  = false,
1189				canExpand  = false,
1190				wrap       = F.wrap,
1191				skin       = F.skin,
1192				inner      = F.inner,
1193				current    = F.current,
1194				width      = current.width,
1195				height     = current.height,
1196				minWidth   = current.minWidth,
1197				minHeight  = current.minHeight,
1198				maxWidth   = current.maxWidth,
1199				maxHeight  = current.maxHeight,
1200				scrolling  = current.scrolling,
1201				scrollOut  = current.scrollOutside ? current.scrollbarWidth : 0,
1202				margin     = current.margin,
1203				wMargin    = getScalar(margin[1] + margin[3]),
1204				hMargin    = getScalar(margin[0] + margin[2]),
1205				wPadding,
1206				hPadding,
1207				wSpace,
1208				hSpace,
1209				origWidth,
1210				origHeight,
1211				origMaxWidth,
1212				origMaxHeight,
1213				ratio,
1214				width_,
1215				height_,
1216				maxWidth_,
1217				maxHeight_,
1218				iframe,
1219				body;
1220
1221			// Reset dimensions so we could re-check actual size
1222			wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
1223
1224			wPadding = getScalar(skin.outerWidth(true)  - skin.width());
1225			hPadding = getScalar(skin.outerHeight(true) - skin.height());
1226
1227			// Any space between content and viewport (margin, padding, border, title)
1228			wSpace = wMargin + wPadding;
1229			hSpace = hMargin + hPadding;
1230
1231			origWidth  = isPercentage(width)  ? (viewport.w - wSpace) * getScalar(width)  / 100 : width;
1232			origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
1233
1234			if (current.type === 'iframe') {
1235				iframe = current.content;
1236
1237				if (current.autoHeight && iframe.data('ready') === 1) {
1238					try {
1239						if (iframe[0].contentWindow.document.location) {
1240							inner.width( origWidth ).height(9999);
1241
1242							body = iframe.contents().find('body');
1243
1244							if (scrollOut) {
1245								body.css('overflow-x', 'hidden');
1246							}
1247
1248							origHeight = body.outerHeight(true);
1249						}
1250
1251					} catch (e) {}
1252				}
1253
1254			} else if (current.autoWidth || current.autoHeight) {
1255				inner.addClass( 'fancybox-tmp' );
1256
1257				// Set width or height in case we need to calculate only one dimension
1258				if (!current.autoWidth) {
1259					inner.width( origWidth );
1260				}
1261
1262				if (!current.autoHeight) {
1263					inner.height( origHeight );
1264				}
1265
1266				if (current.autoWidth) {
1267					origWidth = inner.width();
1268				}
1269
1270				if (current.autoHeight) {
1271					origHeight = inner.height();
1272				}
1273
1274				inner.removeClass( 'fancybox-tmp' );
1275			}
1276
1277			width  = getScalar( origWidth );
1278			height = getScalar( origHeight );
1279
1280			ratio  = origWidth / origHeight;
1281
1282			// Calculations for the content
1283			minWidth  = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
1284			maxWidth  = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
1285
1286			minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
1287			maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
1288
1289			// These will be used to determine if wrap can fit in the viewport
1290			origMaxWidth  = maxWidth;
1291			origMaxHeight = maxHeight;
1292
1293			if (current.fitToView) {
1294				maxWidth  = Math.min(viewport.w - wSpace, maxWidth);
1295				maxHeight = Math.min(viewport.h - hSpace, maxHeight);
1296			}
1297
1298			maxWidth_  = viewport.w - wMargin;
1299			maxHeight_ = viewport.h - hMargin;
1300
1301			if (current.aspectRatio) {
1302				if (width > maxWidth) {
1303					width  = maxWidth;
1304					height = getScalar(width / ratio);
1305				}
1306
1307				if (height > maxHeight) {
1308					height = maxHeight;
1309					width  = getScalar(height * ratio);
1310				}
1311
1312				if (width < minWidth) {
1313					width  = minWidth;
1314					height = getScalar(width / ratio);
1315				}
1316
1317				if (height < minHeight) {
1318					height = minHeight;
1319					width  = getScalar(height * ratio);
1320				}
1321
1322			} else {
1323				width = Math.max(minWidth, Math.min(width, maxWidth));
1324
1325				if (current.autoHeight && current.type !== 'iframe') {
1326					inner.width( width );
1327
1328					height = inner.height();
1329				}
1330
1331				height = Math.max(minHeight, Math.min(height, maxHeight));
1332			}
1333
1334			// Try to fit inside viewport (including the title)
1335			if (current.fitToView) {
1336				inner.width( width ).height( height );
1337
1338				wrap.width( width + wPadding );
1339
1340				// Real wrap dimensions
1341				width_  = wrap.width();
1342				height_ = wrap.height();
1343
1344				if (current.aspectRatio) {
1345					while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
1346						if (steps++ > 19) {
1347							break;
1348						}
1349
1350						height = Math.max(minHeight, Math.min(maxHeight, height - 10));
1351						width  = getScalar(height * ratio);
1352
1353						if (width < minWidth) {
1354							width  = minWidth;
1355							height = getScalar(width / ratio);
1356						}
1357
1358						if (width > maxWidth) {
1359							width  = maxWidth;
1360							height = getScalar(width / ratio);
1361						}
1362
1363						inner.width( width ).height( height );
1364
1365						wrap.width( width + wPadding );
1366
1367						width_  = wrap.width();
1368						height_ = wrap.height();
1369					}
1370
1371				} else {
1372					width  = Math.max(minWidth,  Math.min(width,  width  - (width_  - maxWidth_)));
1373					height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
1374				}
1375			}
1376
1377			if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
1378				width += scrollOut;
1379			}
1380
1381			inner.width( width ).height( height );
1382
1383			wrap.width( width + wPadding );
1384
1385			width_  = wrap.width();
1386			height_ = wrap.height();
1387
1388			canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
1389			canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
1390
1391			$.extend(current, {
1392				dim : {
1393					width	: getValue( width_ ),
1394					height	: getValue( height_ )
1395				},
1396				origWidth  : origWidth,
1397				origHeight : origHeight,
1398				canShrink  : canShrink,
1399				canExpand  : canExpand,
1400				wPadding   : wPadding,
1401				hPadding   : hPadding,
1402				wrapSpace  : height_ - skin.outerHeight(true),
1403				skinSpace  : skin.height() - height
1404			});
1405
1406			if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
1407				inner.height('auto');
1408			}
1409		},
1410
1411		_getPosition: function (onlyAbsolute) {
1412			var current  = F.current,
1413				viewport = F.getViewport(),
1414				margin   = current.margin,
1415				width    = F.wrap.width()  + margin[1] + margin[3],
1416				height   = F.wrap.height() + margin[0] + margin[2],
1417				rez      = {
1418					position: 'absolute',
1419					top  : margin[0],
1420					left : margin[3]
1421				};
1422
1423			if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1424				rez.position = 'fixed';
1425
1426			} else if (!current.locked) {
1427				rez.top  += viewport.y;
1428				rez.left += viewport.x;
1429			}
1430
1431			rez.top  = getValue(Math.max(rez.top,  rez.top  + ((viewport.h - height) * current.topRatio)));
1432			rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width)  * current.leftRatio)));
1433
1434			return rez;
1435		},
1436
1437		_afterZoomIn: function () {
1438			var current = F.current;
1439
1440			if (!current) {
1441				return;
1442			}
1443
1444			F.isOpen = F.isOpened = true;
1445
1446			F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
1447
1448			F.update();
1449
1450			// Assign a click event
1451			if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
1452				F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1453					if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1454						e.preventDefault();
1455
1456						F[ current.closeClick ? 'close' : 'next' ]();
1457					}
1458				});
1459			}
1460
1461			// Create a close button
1462			if (current.closeBtn) {
1463				$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
1464					e.preventDefault();
1465
1466					F.close();
1467				});
1468			}
1469
1470			// Create navigation arrows
1471			if (current.arrows && F.group.length > 1) {
1472				if (current.loop || current.index > 0) {
1473					$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1474				}
1475
1476				if (current.loop || current.index < F.group.length - 1) {
1477					$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1478				}
1479			}
1480
1481			F.trigger('afterShow');
1482
1483			// Stop the slideshow if this is the last item
1484			if (!current.loop && current.index === current.group.length - 1) {
1485				F.play( false );
1486
1487			} else if (F.opts.autoPlay && !F.player.isActive) {
1488				F.opts.autoPlay = false;
1489
1490				F.play();
1491			}
1492		},
1493
1494		_afterZoomOut: function ( obj ) {
1495			obj = obj || F.current;
1496
1497			$('.fancybox-wrap').trigger('onReset').remove();
1498
1499			$.extend(F, {
1500				group  : {},
1501				opts   : {},
1502				router : false,
1503				current   : null,
1504				isActive  : false,
1505				isOpened  : false,
1506				isOpen    : false,
1507				isClosing : false,
1508				wrap   : null,
1509				skin   : null,
1510				outer  : null,
1511				inner  : null
1512			});
1513
1514			F.trigger('afterClose', obj);
1515		}
1516	});
1517
1518	/*
1519	 *	Default transitions
1520	 */
1521
1522	F.transitions = {
1523		getOrigPosition: function () {
1524			var current  = F.current,
1525				element  = current.element,
1526				orig     = current.orig,
1527				pos      = {},
1528				width    = 50,
1529				height   = 50,
1530				hPadding = current.hPadding,
1531				wPadding = current.wPadding,
1532				viewport = F.getViewport();
1533
1534			if (!orig && current.isDom && element.is(':visible')) {
1535				orig = element.find('img:first');
1536
1537				if (!orig.length) {
1538					orig = element;
1539				}
1540			}
1541
1542			if (isQuery(orig)) {
1543				pos = orig.offset();
1544
1545				if (orig.is('img')) {
1546					width  = orig.outerWidth();
1547					height = orig.outerHeight();
1548				}
1549
1550			} else {
1551				pos.top  = viewport.y + (viewport.h - height) * current.topRatio;
1552				pos.left = viewport.x + (viewport.w - width)  * current.leftRatio;
1553			}
1554
1555			if (F.wrap.css('position') === 'fixed' || current.locked) {
1556				pos.top  -= viewport.y;
1557				pos.left -= viewport.x;
1558			}
1559
1560			pos = {
1561				top     : getValue(pos.top  - hPadding * current.topRatio),
1562				left    : getValue(pos.left - wPadding * current.leftRatio),
1563				width   : getValue(width  + wPadding),
1564				height  : getValue(height + hPadding)
1565			};
1566
1567			return pos;
1568		},
1569
1570		step: function (now, fx) {
1571			var ratio,
1572				padding,
1573				value,
1574				prop       = fx.prop,
1575				current    = F.current,
1576				wrapSpace  = current.wrapSpace,
1577				skinSpace  = current.skinSpace;
1578
1579			if (prop === 'width' || prop === 'height') {
1580				ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
1581
1582				if (F.isClosing) {
1583					ratio = 1 - ratio;
1584				}
1585
1586				padding = prop === 'width' ? current.wPadding : current.hPadding;
1587				value   = now - padding;
1588
1589				F.skin[ prop ](  getScalar( prop === 'width' ?  value : value - (wrapSpace * ratio) ) );
1590				F.inner[ prop ]( getScalar( prop === 'width' ?  value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
1591			}
1592		},
1593
1594		zoomIn: function () {
1595			var current  = F.current,
1596				startPos = current.pos,
1597				effect   = current.openEffect,
1598				elastic  = effect === 'elastic',
1599				endPos   = $.extend({opacity : 1}, startPos);
1600
1601			// Remove "position" property that breaks older IE
1602			delete endPos.position;
1603
1604			if (elastic) {
1605				startPos = this.getOrigPosition();
1606
1607				if (current.openOpacity) {
1608					startPos.opacity = 0.1;
1609				}
1610
1611			} else if (effect === 'fade') {
1612				startPos.opacity = 0.1;
1613			}
1614
1615			F.wrap.css(startPos).animate(endPos, {
1616				duration : effect === 'none' ? 0 : current.openSpeed,
1617				easing   : current.openEasing,
1618				step     : elastic ? this.step : null,
1619				complete : F._afterZoomIn
1620			});
1621		},
1622
1623		zoomOut: function () {
1624			var current  = F.current,
1625				effect   = current.closeEffect,
1626				elastic  = effect === 'elastic',
1627				endPos   = {opacity : 0.1};
1628
1629			if (elastic) {
1630				endPos = this.getOrigPosition();
1631
1632				if (current.closeOpacity) {
1633					endPos.opacity = 0.1;
1634				}
1635			}
1636
1637			F.wrap.animate(endPos, {
1638				duration : effect === 'none' ? 0 : current.closeSpeed,
1639				easing   : current.closeEasing,
1640				step     : elastic ? this.step : null,
1641				complete : F._afterZoomOut
1642			});
1643		},
1644
1645		changeIn: function () {
1646			var current   = F.current,
1647				effect    = current.nextEffect,
1648				startPos  = current.pos,
1649				endPos    = { opacity : 1 },
1650				direction = F.direction,
1651				distance  = 200,
1652				field;
1653
1654			startPos.opacity = 0.1;
1655
1656			if (effect === 'elastic') {
1657				field = direction === 'down' || direction === 'up' ? 'top' : 'left';
1658
1659				if (direction === 'down' || direction === 'right') {
1660					startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
1661					endPos[ field ]   = '+=' + distance + 'px';
1662
1663				} else {
1664					startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
1665					endPos[ field ]   = '-=' + distance + 'px';
1666				}
1667			}
1668
1669			// Workaround for http://bugs.jquery.com/ticket/12273
1670			if (effect === 'none') {
1671				F._afterZoomIn();
1672
1673			} else {
1674				F.wrap.css(startPos).animate(endPos, {
1675					duration : current.nextSpeed,
1676					easing   : current.nextEasing,
1677					complete : F._afterZoomIn
1678				});
1679			}
1680		},
1681
1682		changeOut: function () {
1683			var previous  = F.previous,
1684				effect    = previous.prevEffect,
1685				endPos    = { opacity : 0.1 },
1686				direction = F.direction,
1687				distance  = 200;
1688
1689			if (effect === 'elastic') {
1690				endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
1691			}
1692
1693			previous.wrap.animate(endPos, {
1694				duration : effect === 'none' ? 0 : previous.prevSpeed,
1695				easing   : previous.prevEasing,
1696				complete : function () {
1697					$(this).trigger('onReset').remove();
1698				}
1699			});
1700		}
1701	};
1702
1703	/*
1704	 *	Overlay helper
1705	 */
1706
1707	F.helpers.overlay = {
1708		defaults : {
1709			closeClick : true,      // if true, fancyBox will be closed when user clicks on the overlay
1710			speedOut   : 200,       // duration of fadeOut animation
1711			showEarly  : true,      // indicates if should be opened immediately or wait until the content is ready
1712			css        : {},        // custom CSS properties
1713			locked     : !isTouch,  // if true, the content will be locked into overlay
1714			fixed      : true       // if false, the overlay CSS position property will not be set to "fixed"
1715		},
1716
1717		overlay : null,      // current handle
1718		fixed   : false,     // indicates if the overlay has position "fixed"
1719		el      : $('html'), // element that contains "the lock"
1720
1721		// Public methods
1722		create : function(opts) {
1723			opts = $.extend({}, this.defaults, opts);
1724
1725			if (this.overlay) {
1726				this.close();
1727			}
1728
1729			this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent );
1730			this.fixed   = false;
1731
1732			if (opts.fixed && F.defaults.fixed) {
1733				this.overlay.addClass('fancybox-overlay-fixed');
1734
1735				this.fixed = true;
1736			}
1737		},
1738
1739		open : function(opts) {
1740			var that = this;
1741
1742			opts = $.extend({}, this.defaults, opts);
1743
1744			if (this.overlay) {
1745				this.overlay.unbind('.overlay').width('auto').height('auto');
1746
1747			} else {
1748				this.create(opts);
1749			}
1750
1751			if (!this.fixed) {
1752				W.bind('resize.overlay', $.proxy( this.update, this) );
1753
1754				this.update();
1755			}
1756
1757			if (opts.closeClick) {
1758				this.overlay.bind('click.overlay', function(e) {
1759					if ($(e.target).hasClass('fancybox-overlay')) {
1760						if (F.isActive) {
1761							F.close();
1762						} else {
1763							that.close();
1764						}
1765
1766						return false;
1767					}
1768				});
1769			}
1770
1771			this.overlay.css( opts.css ).show();
1772		},
1773
1774		close : function() {
1775			var scrollV, scrollH;
1776
1777			W.unbind('resize.overlay');
1778
1779			if (this.el.hasClass('fancybox-lock')) {
1780				$('.fancybox-margin').removeClass('fancybox-margin');
1781
1782				scrollV = W.scrollTop();
1783				scrollH = W.scrollLeft();
1784
1785				this.el.removeClass('fancybox-lock');
1786
1787				W.scrollTop( scrollV ).scrollLeft( scrollH );
1788			}
1789
1790			$('.fancybox-overlay').remove().hide();
1791
1792			$.extend(this, {
1793				overlay : null,
1794				fixed   : false
1795			});
1796		},
1797
1798		// Private, callbacks
1799
1800		update : function () {
1801			var width = '100%', offsetWidth;
1802
1803			// Reset width/height so it will not mess
1804			this.overlay.width(width).height('100%');
1805
1806			// jQuery does not return reliable result for IE
1807			if (IE) {
1808				offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1809
1810				if (D.width() > offsetWidth) {
1811					width = D.width();
1812				}
1813
1814			} else if (D.width() > W.width()) {
1815				width = D.width();
1816			}
1817
1818			this.overlay.width(width).height(D.height());
1819		},
1820
1821		// This is where we can manipulate DOM, because later it would cause iframes to reload
1822		onReady : function (opts, obj) {
1823			var overlay = this.overlay;
1824
1825			$('.fancybox-overlay').stop(true, true);
1826
1827			if (!overlay) {
1828				this.create(opts);
1829			}
1830
1831			if (opts.locked && this.fixed && obj.fixed) {
1832				if (!overlay) {
1833					this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false;
1834				}
1835
1836				obj.locked = this.overlay.append( obj.wrap );
1837				obj.fixed  = false;
1838			}
1839
1840			if (opts.showEarly === true) {
1841				this.beforeShow.apply(this, arguments);
1842			}
1843		},
1844
1845		beforeShow : function(opts, obj) {
1846			var scrollV, scrollH;
1847
1848			if (obj.locked) {
1849				if (this.margin !== false) {
1850					$('*').filter(function(){
1851						return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
1852					}).addClass('fancybox-margin');
1853
1854					this.el.addClass('fancybox-margin');
1855				}
1856
1857				scrollV = W.scrollTop();
1858				scrollH = W.scrollLeft();
1859
1860				this.el.addClass('fancybox-lock');
1861
1862				W.scrollTop( scrollV ).scrollLeft( scrollH );
1863			}
1864
1865			this.open(opts);
1866		},
1867
1868		onUpdate : function() {
1869			if (!this.fixed) {
1870				this.update();
1871			}
1872		},
1873
1874		afterClose: function (opts) {
1875			// Remove overlay if exists and fancyBox is not opening
1876			// (e.g., it is not being open using afterClose callback)
1877			//if (this.overlay && !F.isActive) {
1878			if (this.overlay && !F.coming) {
1879				this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
1880			}
1881		}
1882	};
1883
1884	/*
1885	 *	Title helper
1886	 */
1887
1888	F.helpers.title = {
1889		defaults : {
1890			type     : 'float', // 'float', 'inside', 'outside' or 'over',
1891			position : 'bottom' // 'top' or 'bottom'
1892		},
1893
1894		beforeShow: function (opts) {
1895			var current = F.current,
1896				text    = current.title,
1897				type    = opts.type,
1898				title,
1899				target;
1900
1901			if ($.isFunction(text)) {
1902				text = text.call(current.element, current);
1903			}
1904
1905			if (!isString(text) || $.trim(text) === '') {
1906				return;
1907			}
1908
1909			title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">
1909' + text + '</div>');
1910
1911			switch (type) {
1912				case 'inside':
1913					target = F.skin;
1914				break;
1915
1916				case 'outside':
1917					target = F.wrap;
1918				break;
1919
1920				case 'over':
1921					target = F.inner;
1922				break;
1923
1924				default: // 'float'
1925					target = F.skin;
1926
1927					title.appendTo('body');
1928
1929					if (IE) {
1930						title.width( title.width() );
1931					}
1932
1933					title.wrapInner('<span class="child"></span>');
1934
1935					//Increase bottom margin so this title will also fit into viewport
1936					F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
1937				break;
1938			}
1939
1940			title[ (opts.position === 'top' ? 'prependTo'  : 'appendTo') ](target);
1941		}
1942	};
1943
1944	// jQuery plugin initialization
1945	$.fn.fancybox = function (options) {
1946		var index,
1947			that     = $(this),
1948			selector = this.selector || '',
1949			run      = function(e) {
1950				var what = $(this).blur(), idx = index, relType, relVal;
1951
1952				if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
1953					relType = options.groupAttr || 'data-fancybox-group';
1954					relVal  = what.attr(relType);
1955
1956					if (!relVal) {
1957						relType = 'rel';
1958						relVal  = what.get(0)[ relType ];
1959					}
1960
1961					if (relVal && relVal !== '' && relVal !== 'nofollow') {
1962						what = selector.length ? $(selector) : that;
1963						what = what.filter('[' + relType + '="' + relVal + '"]');
1964						idx  = what.index(this);
1965					}
1966
1967					options.index = idx;
1968
1969					// Stop an event from bubbling if everything is fine
1970					if (F.open(what, options) !== false) {
1971						e.preventDefault();
1972					}
1973				}
1974			};
1975
1976		options = options || {};
1977		index   = options.index || 0;
1978
1979		if (!selector || options.live === false) {
1980			that.unbind('click.fb-start').bind('click.fb-start', run);
1981
1982		} else {
1983			D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
1984		}
1985
1986		this.filter('[data-fancybox-start=1]').trigger('click');
1987
1988		return this;
1989	};
1990
1991	// Tests that need a body at doc ready
1992	D.ready(function() {
1993		var w1, w2;
1994
1995		if ( $.scrollbarWidth === undefined ) {
1996			// http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
1997			$.scrollbarWidth = function() {
1998				var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'),
1999					child  = parent.children(),
2000					width  = child.innerWidth() - child.height( 99 ).innerWidth();
2001
2002				parent.remove();
2003
2004				return width;
2005			};
2006		}
2007
2008		if ( $.support.fixedPosition === undefined ) {
2009			$.support.fixedPosition = (function() {
2010				var elem  = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'),
2011					fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
2012
2013				elem.remove();
2014
2015				return fixed;
2016			}());
2017		}
2018
2019		$.extend(F.defaults, {
2020			scrollbarWidth : $.scrollbarWidth(),
2021			fixed  : $.support.fixedPosition,
2022			parent : $('body')
2023		});
2024
2025		//Get real width of page scroll-bar
2026		w1 = $(window).width();
2027
2028		H.addClass('fancybox-lock-test');
2029
2030		w2 = $(window).width();
2031
2032		H.removeClass('fancybox-lock-test');
2033
2034		$("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head");
2035	});
2036
2037}(window, document, jQuery));/* Core AgorisCMS frontend JS
2038 * [email protected]
2039 */
2040function createCookie(name,value,days){
2041	var expires = '';
2042	if (days){
2043		var secs = days*24*60*60*1000;
2044		var date = new Date();
2045		date.setTime(date.getTime() + secs);
2046		expires = '; expires=' + date.toGMTString();
2047	}
2048	else{
2049		expires = '';
2050	}
2051	document.cookie = name + '=' + value + expires + '; path=/';
2052}
2053function readCookie(name) {
2054	var nameEQ = name + '=';
2055	var ca = document.cookie.split(';');
2056	for(var i=0;i < ca.length;i++) {
2057		var c = ca[i];
2058		while (c.charAt(0) == ' ') c = c.substring(1,c.length);
2059		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
2060	}
2061	return null;
2062}
2063function eraseCookie(name){
2064	createCookie(name,'',-1);
2065}
2066
2067function init(json) {
2068    window.userInfo = ( json == null ? {} : json );
2069    window.geocoder = '';
2070    if(!window.isMobile) {
2071        var mobileMedia = 'only screen and (max-device-width: 736px)';
2072        window.isMobile = ( window.matchMedia(mobileMedia).matches && navigator.userAgent.indexOf('Macintosh') === -1 );
2073    }
2074
2075    $.ajaxSetup({
2076        cache: true
2077    });
2078
2079    /* Scroll handler
2080     */
2081    function scrollCheck(e) {
2082        var navTop = $('#nav-top');
2083        if ( $(window).scrollTop() >= ($(window).height() - 120)) {
2084            if(window.isMobile === false) {
2085                $('body').addClass('hasSmallLogo');
2086            }
2087            navTop.fadeIn();
2088        } else {
2089            if($('.top-banner').length > 0 && window.isMobile === false) {
2090                $('body').removeClass('hasSmallLogo');
2091            }
2092            navTop.fadeOut();
2093        }
2094    }
2095
2096    if(window.isMobile === true) {
2097        $('html').addClass('isMobile');
2098        $('body').addClass('hasSmallLogo');
2099    }
2100
2101    $('#nav-top').on('click', function() {
2102        $('html, body').animate({
2103            scrollTop: 0
2104        });
2105    });
2106
2107    $(window)
2108        .on('scroll', function() {
2109            scrollCheck();
2110        });
2111
2112    // Handle hash
2113    $(window).on('load hashchange', function() {
2114        var hash = window.location.hash;
2115        if(hash.indexOf('#menu-') >
2115 -1 && $('body').is('.pg-menu') === true) {
2116            openMenu(hash);
2117        }
2118        if(/(#glfButton0)/.test(hash) === true) {
2119            $('#glfButton0').click();
2120            window.location.hash = '';
2121        }
2122        if(/(#glfButton1)/.test(hash) === true) {
2123            $('#glfButton1').click();
2124            window.location.hash = '';
2125        }
2126        if(/(#theFork)/.test(hash) === true) {
2127            theforkModal();
2128            window.location.hash = '';
2129        }
2130    });
2131
2132    $('#delivery span').on('click', function(e) {
2133      try {
2134        ga('send', 'event', {
2135          eventCategory: 'DeliveryLnk',
2136          eventAction: 'click',
2137          eventLabel: 'Nav link',
2138          transport: 'beacon'
2139        });
2140      } catch(err) {}
2141    });
2142    $('#deliveryFooter span').on('click', function(e) {
2143      try {
2144        ga('send', 'event', {
2145          eventCategory: 'DeliveryLnk',
2146          eventAction: 'click',
2147          eventLabel: 'Footer link',
2148          transport: 'beacon'
2149        });
2150      } catch(err) {}
2151    });
2152
2153    if($('#navDailySpecial').length > 0) {
2154        var now = new Date(),
2155            hourNow = now.getHours(),
2156            dayNow = now.getDay();
2157
2158        /* 0 = sunday, 6 = saturday
2159         */
2160        if((hourNow >= 0 && hourNow <= 15) && dayNow > 0) {
2161            $('#navDailySpecial').removeClass('hidden');
2162        }
2163    }
2164
2165    if($('.top-banner').length === 0){
2166        $('body').addClass('hasSmallLogo');
2167    }
2168
2169    /* Easter
2170     */
2171    function addEgg(where, hRand, vRand) {
2172        if(where) {
2173            $(where).append('<div class="container"><div class="egg side-' + hRand + ' vert-' + vRand + '"><a href="/pascoa?go=hunt">Páscoa</a></div></div>');
2174        }
2175    }
2176    function easterHunt() {
2177        if($('#section.lang-pt').length > 0) {
2178            var hRand,
2179                vRand;
2180
2181            //home
2182            if($('.id_1').length > 0) {
2183                hRand = Math.floor(Math.random() * 2);
2184                vRand = Math.floor(Math.random() * 2);
2185                addEgg('.id_11 .home-gallery .item.pos_1', hRand, vRand);
2186            }
2187            //about
2188            if($('.id_2').length > 0) {
2189                hRand = Math.floor(Math.random() * 2);
2190                vRand = Math.floor(Math.random() * 2);
2191                addEgg('.id_2 .item.pos_1', hRand, vRand);
2192            }
2193            //carta
2194            if($('.id_3').length > 0) {
2195                hRand = Math.floor(Math.random() * 2);
2196                vRand = Math.floor(Math.random() * 2);
2197                addEgg('.id_3 .item.pos_7', hRand, vRand);
2198            }
2199            //blog
2200            if($('.id_4').length > 0) {
2201                hRand = Math.floor(Math.random() * 2);
2202                vRand = Math.floor(Math.random() * 2);
2203                addEgg('.id_4 .item.pos_1', hRand, vRand);
2204
2205                hRand = Math.floor(Math.random() * 2);
2206                vRand = Math.floor(Math.random() * 2);
2207                addEgg('.id_4 .zone.pos_5', hRand, vRand);
2208            }
2209            //confeitaria
2210            if($('.id_5').length > 0) {
2211                hRand = Math.floor(Math.random() * 2);
2212                vRand = Math.floor(Math.random() * 2);
2213                addEgg('.id_5 .item.pos_1', hRand, vRand);
2214            }
2215            //contactos
2216            if($('.id_6').length > 0) {
2217                hRand = Math.floor(Math.random() * 2);
2218                vRand = Math.floor(Math.random() * 2);
2219                addEgg('.id_6 .item.pos_1', hRand, vRand);
2220
2221                hRand = Math.floor(Math.random() * 2);
2222                vRand = Math.floor(Math.random() * 2);
2223                addEgg('.id_6 .item.pos_3', hRand, vRand);
2224            }
2225            //padaria
2226            if($('.id_50').length > 0) {
2227                hRand = Math.floor(Math.random() * 2);
2228                vRand = Math.floor(Math.random() * 2);
2229                addEgg('.id_50 .item.pos_2', hRand, vRand);
2230
2231                hRand = Math.floor(Math.random() * 2);
2232                vRand = Math.floor(Math.random() * 2);
2233                addEgg('.id_50 .item.pos_4', hRand, vRand);
2234            }
2235
2236            // criar cookie
2237            if(!readCookie('eastr2k17')) {
2238                $('.egg a').on('click', function(e) {
2239                    if(!readCookie('eastr2k17')) {
2240                        createCookie('eastr2k17','YTZiMWU5YjkzYTdhMDk2YTE1NmI1NjlkOTUyZjQ4YzA=',30);
2241                    }
2242                });
2243            }
2244        }
2245        if($('body').hasClass('easterBoard-selected') === true &&
2246           window.location.search.indexOf('?go=hunt') > -1 &&
2247           $('#easter-board').find('div.intro').length > 0) {
2248            var refId = document.referrer.replace('https://www.tavi.pt','');
2249            ga('send', {
2250                hitType: 'event',
2251                eventCategory: 'Contest',
2252                eventAction: 'EggClick',
2253                eventLabel: 'Easter2017',
2254                eventValue: refId,
2255                hitCallback: function() {
2256                    console.log('callback');
2257                }
2258            });
2259        }
2260    }
2261    easterHunt();
2262
2263    /* Banner Carousel
2264     */
2265    if( $('.top-banner').length ) {
2266        var placeHolder = $('#carouselBanner'),
2267            itemHolder = placeHolder.closest('div.row-fluid'),
2268            innerHolder = placeHolder.find('div.carousel-inner'),
2269            indicatorsHolder = placeHolder.find('ol.carousel-indicators'),
2270            itemLength = placeHolder.find('.carousel-inner .item').length,
2271            i;
2272
2273        innerHolder
2274            .find('.module.r_images li .item-img')
2275                .each(function() {
2276                    var slideHeight = $(window).height(),
2277                        firstSlideHeight = $(window).height(),
2278                        imgWrapper = $(this),
2279                        img = imgWrapper.find('img'),
2280                        imgSrc = img.data('src') || img.attr('src') || img.data('cfsrc'),
2281                        imgLink = imgWrapper.closest('a'),
2282                        imgTitle = imgLink.next('.rn-title'),
2283                        imgCaption = imgTitle.next('.carousel-caption');
2284
2285                        imgWrapper
2286                            .append('<div class="fill" style="background-image: url(' + imgSrc + '); height: ' + ( itemHolder == 0 ? firstSlideHeight : slideHeight ) + 'px;"></div>')
2287                            .append('<div class="fill dark-over" style="height: ' + ( itemHolder == 0 ? firstSlideHeight : slideHeight ) + 'px;"></div>')
2288                            .append(imgCaption)
2289                            .find('.carousel-caption')
2290                                .end();
2291                        img.remove();
2292                })
2293                .unwrap()
2294                .unwrap()
2295                .unwrap()
2296                .unwrap()
2297                .end()
2298            .find('.item')
2299                .first()
2300                    .addClass('active');
2301
2302        /* Move caption description before Title
2303         */
2304/*
2305        innerHolder
2306            .find('.carousel-caption .rn-lead')
2307                .appendTo('.carousel-caption');
2308*/
2309        /* Move Button Link inside Caption
2310         */
2311        $('.carousel-inner .item').each(function() {
2312            $(this).find('.module.r_links').detach().appendTo($(this).find('.carousel-caption'));
2313        });
2314
2315        /* Hide Carousel Indicators if less then 2
2316         */
2317        if ( itemLength < 2 ) {
2318            placeHolder
2319                .find('ol li')
2320                    .addClass('hide')
2321                    .end();
2322        } else {
2323            for( i = 0; i < itemLength; i++ ) {
2324                indicatorsHolder.append('<li data-target="#carouselBanner" data-slide-to="' + i + '" class="' + ( i == 0 ? 'active' : '' ) + '"></li>');
2325            }
2326        }
2327
2328        /* Banner pages
2329         * scroll down to content
2330         */
2331        (function(){
2332            if ( $('div.banner-sd').length === 0 ) {
2333                $('.top-banner').prepend('<a class="banner-sd">Scroll</a>');
2334            }
2335
2336            $('a.banner-sd').on('click', function() {
2337                var topBanner = $('section.top-banner').height(),
2338                    topNav = $('nav.navbar').height(),
2339                    offsetTop = (topBanner - topNav);
2340                $('html,body').animate({
2341                    scrollTop: offsetTop
2342                }, 800);
2343            });
2344        })();
2345
2346        /* Banner Arrows
2347         * Remove if only one slide
2348         */
2349        if( $('.carousel-inner .item').length ===1 ) {
2350            $('.carousel-control').hide();
2351            $('#carouselBannerl').hide();
2352        }
2353
2354        /* Swipe Support
2355         */
2356/*
2357        $("#carouselBanner").on('swiperight', function() {
2358	  $(this).carousel('prev');
2359	});
2360        $("#carouselBanner").on('swipeleft', function() {
2361	  $(this).carousel('next');
2362        });
2363*/
2364    }
2365
2366    /* Banner Carousel
2367     */
2368    if( $('.top-l-banner').length ) {
2369        var placeHolder = $('#carouselBanner'),
2370            itemHolder = placeHolder.closest('div.row-fluid'),
2371            innerHolder = placeHolder.find('div.carousel-inner'),
2372            indicatorsHolder = placeHolder.find('ol.carousel-indicators'),
2373            itemLength = placeHolder.find('.carousel-inner .item').length,
2374            i;
2375
2376        innerHolder
2377            .find('.module.r_images li .item-img')
2378                .each(function() {
2379                    var slideHeight = $(window).height(),
2380                        firstSlideHeight = $(window).height(),
2381                        imgWrapper = $(this),
2382                        img = imgWrapper.find('img'),
2383                        imgLink = imgWrapper.closest('a'),
2384                        imgLinkUrlData = imgWrapper.closest('a').data('src'),
2385                        imgTitle = imgLink.next('.rn-title'),
2386                        imgCaption = imgTitle.next('.carousel-caption');
2387                        imgWrapper
2388                            .append('<div class="fill" style="background-image: url(' + img.attr('src') + ');"></div>')
2389                            .append('<div class="fill dark-over"></div>')
2390                            .append(imgCaption)
2391                            .find('.carousel-caption')
2392                                .end();
2393                        img.remove();
2394                })
2395                .unwrap()
2396                .unwrap()
2397                .unwrap()
2398                .unwrap()
2399                .end()
2400            .find('.item')
2401                .first()
2402                    .addClass('active');
2403
2404        /* Move caption description before Title
2405         */
2406        innerHolder
2407            .find('.carousel-caption .rn-lead')
2408                .prependTo('.carousel-caption');
2409
2410
2411        /* Hide Carousel Indicators if less then 2
2412         */
2413        if ( itemLength < 2 ) {
2414            placeHolder
2415                .find('ol li')
2416                    .addClass('hide')
2417                    .end();
2418        } else {
2419            for( i = 0; i < itemLength; i++ ) {
2420                indicatorsHolder.append('<li data-target="#carouselBanner" data-sli
2420de-to="' + i + '" class="' + ( i == 0 ? 'active' : '' ) + '"></li>');
2421            }
2422        }
2423
2424        /* Banner pages
2425         * scroll down to content
2426         */
2427        (function(){
2428            if ( $('div.banner-sd').length === 0 ) {
2429                $('.top-banner').prepend('<div class="banner-sd">scroll</div>');
2430            }
2431
2432            $('div.banner-sd').on('click', function() {
2433                var newsOffset = $('.zone').first().offset().top,
2434                    offsetTop = (newsOffset - 100);
2435                $('html,body').animate({
2436                    scrollTop: offsetTop
2437                }, 800);
2438            });
2439        })();
2440
2441        /* Banner Arrows
2442         * Remove if only one slide
2443         */
2444        if( $('.carousel-inner .item').length ===1 ) {
2445            $('.carousel-control').hide();
2446            $('#carouselBannerl').hide();
2447        }
2448
2449        /* Swipe Support
2450         */
2451/*
2452        $("#carouselBanner").swiperight(function() {
2453    		  $(this).carousel('prev');
2454        });
2455        $("#carouselBanner").swipeleft(function() {
2456		    $(this).carousel('next');
2457        });
2458*/
2459    }
2460
2461    /* Google Map
2462     */
2463    if( $('.g-map').length ) {
2464        $('.g-map')
2465            .detach()
2466            .insertBefore('.info-social')
2467            .append('<div id="map"></div>');
2468
2469        $.getScript('https://www.google.com/jsapi', function() {
2470            google.load('maps', '3', { 'other_params': 'sensor=false&key=AIzaSyC1gOfuechvnV1j9P8ZR9QpXI6KGr8RRsA&language=' + window.lang, callback: function() {
2471                var myLatlng = new google.maps.LatLng(41.152088,-8.677468),
2472                    mapOptions = {
2473                        zoom: 16,
2474                        scrollwheel: false,
2475                        zoomControl: true,
2476                        streetViewControl: true,
2477                        mapTypeControl: true,
2478                        mapTypeControlOptions: {
2479                            position: google.maps.ControlPosition.TOP_RIGHT
2480                        },
2481                        center: myLatlng,
2482                        disableDefaultUI: true
2483                    },
2484                    map = new google.maps.Map(document.getElementById('map'), mapOptions),
2485                    marker = new google.maps.Marker({
2486                        position: myLatlng,
2487                        map: map,
2488                        optimized: false
2489                    });
2490            }});
2491        });
2492    }
2493
2494    /* Remove image default links
2495    */
2496    if(
2497        $('.pg-gallery').length ||
2498        $('.pg-contacts').length ||
2499        $('.pg-home section.blog').length ||
2500        $('.pg-home section.menu').length ||
2501        $('.pg-menu section.menu').length ||
2502        $('#view.pg-blog').length
2503    ) {
2504        $('.r_images a').removeAttr("href");
2505    }
2506
2507    /* Page Home
2508     */
2509    if($('#index').length > 0) {
2510        var nav = $('#navbar-collapse-1').find('nav ul')
2511//          , calUrl = nav.find('li.li_pg-calendar > a').attr('href')
2512          , blogUrl = nav.find('li.li_pg-blog > a').attr('href')
2513//          , bakeryUrl = nav.find('li.li_bakery > a').attr('href')
2514        ;
2515
2516        /* Advent */
2517        if(typeof(calUrl) !== 'undefined') {
2518            $('#zone_1')
2519                .after('<section class="zone default home-cal"/>');
2520
2521            $('body').addClass('pg-calendar-selected');
2522            $('.home-cal').load(calUrl + ' #zone_1 > .row', function() {
2523                $(this).find('.row').wrap('<div class="container"/>');
2524                handleCalendarList();
2525            });
2526        }
2527
2528        /* Home Blog */
2529        if(typeof(blogUrl) !== 'undefined') {
2530            $('#zone_1')
2531                .find('div.home-blog div.col-md-10 div.content-text > div.more-text')
2532                .load(blogUrl + ' section.blog .grid > .element-item:lt(3)', function() {
2533                    $('.home-blog .r_images a')
2534                        .removeAttr("href")
2535                        .find('.carousel-caption')
2536                            .remove();
2537                });
2538        }
2539
2540        /* Home Bakery */
2541        if(typeof(bakeryUrl) !== 'undefined') {
2542            $('#zone_1')
2543                .find('div.home-bakery div.col-md-10 div.content-text > div.more-text')
2544                .load(bakeryUrl + ' #zone_1 div.item.bread div.more-text');
2545        }
2546
2547    }
2548
2549    /* TheFork Reservations
2550     */
2551    $('body').on('click', '.modalBtn', function(e) {
2552        if(e) {
2553            e.preventDefault();
2554        }
2555        theforkModal();
2556    });
2557    function theforkModal() {
2558        var thefork = $('#theforkModal'),
2559            theforkLang = thefork.data('lang');
2560        if(thefork.find('iframe').length == 0) {
2561            thefork
2562                .find('.modal-body')
2563                .html('<iframe src="https://module.lafourchette.com/' + theforkLang + '/module/200733-036fe" width="90%" height="652" marginwidth="0" marginheight="0" scrolling="No" frameborder="0"></iframe>');
2564        }
2565        $(thefork)
2566            .modal();
2567    }
2568
2569    /* Bakery menu
2570     * https://www.w3schools.com/howto/howto_css_parallax.asp
2571     */
2572    if($('#section.bakery-selected').length > 0) {
2573        $('#zone_1').find('.item').each(function() {
2574            var imgContainer = $(this).find('.container-fluid'),
2575                imgFirst = imgContainer.find('.r_images .rn1').first(),
2576                imgSrc;
2577            if(imgFirst.length > 0) {
2578                imgSrc = imgFirst.find('img').data('src');
2579                imgContainer
2580                    .css({
2581                        height: $(window).height(),
2582                        backgroundImage: 'url(' + imgSrc + ')'
2583                    });
2584            }
2585            imgContainer.find('div.row').remove();
2586        });
2587    }
2588
2589    /* Page Menu
2590     */
2591    if($('.pg-menu').length) {
2592        $('section.menu')
2593            .find('.carousel-caption')
2594                .remove()
2595                .end()
2596            .find('.item')
2597                .each(function(index) {
2598                    var el = $(this);
2599                    if(index%2 !== 0 && window.isMobile === false && $('body').is('.pg-menu-selected') === true) {
2600                        var wrapper = el.find('.col-md-10'),
2601                            imgBlock = wrapper.find('.menu-bloc-img'),
2602                            contentBlock = wrapper.find('.menu-bloc-content');
2603                        contentBlock.after(imgBlock);
2604                    }
2605                    el.find('.more-btn a')
2606                        .on('click', function(e) {
2607                            if(e) {
2608                                e.preventDefault();
2609                            }
2610                            if($(this).prop('hash').length > 0) {
2611                                if(window.location.hash === $(this).prop('hash')) {
2612                                    $(window).trigger('hashchange');
2613                                } else {
2614                                    window.location.hash = $(this).prop('hash');
2615                                }
2616                            }
2617                        });
2618                })
2619                .end()
2620            .find('.menu-today .more-btn a')
2621                .text(window.i18n[window.lang]['##I18N_MENU##']);
2622
2623        // Load content to modal
2624        function openMenu(category) {
2625            var hash = category.split('#menu-')[1],
2626                url = $('#navbar-collapse-1').find('nav li.li_pg-menu > a').attr('href');
2627
2628            if(hash === 'delivery') {
2629              $('#delivery').find('span.glf-button-tavi').click();
2630              return;
2631            }
2632
2633            $('.menu-modal .mm-content').load(url + '/' + hash + ' #zone_1 > *', function() {
2634                if(url !== 'today') {
2635                    $('.menu-modal .not-highlight').each(function() {
2636                        $(this).find('.resources').detach().prependTo($(this).find('.col-md-10'));
2637                        $(this).find('.subtitle').detach().appendTo($(this).find('h1'));
2638                        $(this).find('h1').prepend('<hr>');
2639                    });
2640                }
2641                $('.menu-modal').fadeToggle();
2642                removeScroll();
2643                $('.menu-modal').find('.carousel-caption').remove();
2644                $('.menu-modal .r_images a').removeAttr("href");
2645            });
2646        }
2647
2648        // Handle close
2649        $('.menu-modal .close-btn').on('click', function() {
2650            $('.menu-modal .mm-content').empty();
2651            $('.menu-modal').fadeOut(addScroll);
2652        });
2653        // Close on ESC
2654        $(document).keydown(function(e) {
2655            if(e.keyCode == 27) {
2656                $('.menu-modal .close-btn').trigger('click');
2657            }
2658        });
2659
2660        function addScroll() {
2661            $('body').removeClass('modal-open');
2662        }
2663        function removeScroll() {
2664            $('body').addClass('modal-open');
2665        }
2666    }
2667
2668    /* Page Gallery
2669     */
2670    if($('.pg-gallery').length) {
2671        var defaultFilter = $('.filter-button-subgroup').find('.is-checked').data('filter') || $('.filter-button-group').find('.is-checked').data('filter');
2672        $('.grid').isotope({
2673            filter: defaultFilter,
2674            animationOptions: {
2675                duration: 750,
2676                easing: 'linear',
2677                queue: false,
2678            },
2679            itemSelector: '.element-item'
2680        });
2681
2682        // layout Isotope after each image loads
2683        $('.grid').imagesLoaded().progress( function() {
2684            $('.grid').isotope('layout');
2685        });
2686
2687        $('.filter-button-group button').on('click', function(e) {
2688            e.preventDefault();
2689            var el = $(this),
2690                selector = el.data('filter'),
2691                elDesc = el.closest('div.filter-button-group').next('div.filter-button-desc').find('> div'),
2692                grid = el.closest('div.filters').next('div.grid');
2693
2694            if(el.hasClass('is-checked') === false) {
2695                el
2696                    .addClass('is-checked')
2697                    .siblings('button.button')
2698                        .removeClass('is-checked');
2699            }
2700            if(elDesc.length > 0) {
2701                elDesc
2702                    .addClass('hidden')
2703                    .filter('.desc-' + selector.replace('.', ''))
2704                        .removeClass('hidden')
2705                        .find('.filter-button-subgroup button:first-child')
2706                            .addClass('is-checked')
2707                            .siblings()
2708                                .removeClass('is-checked');
2709                selector = elDesc
2710                    .filter('.desc-' + selector.replace('.', ''))
2711                        .find('.filter-button-subgroup button:first-child')
2712                            .data('filter');
2713            }
2714
2715            grid.isotope({
2716                filter: selector,
2717                animationOptions: {
2718                    duration: 750,
2719                    easing: 'linear',
2720                    queue: false
2721                }
2722            });
2723        });
2724
2725        $('section.gallery .element-item').each(function() {
2726            var myLink = $(this).find('a');
2727            myLink
2728                .addClass('fancybox')
2729                .attr('data-fancybox-group', 'fancybox')
2730                .attr('href', myLink.attr('data-src'));
2731
2732            $(this).find('.item-img').prepend('<div class="r-mask"></div>');
2733            var mask = $(this).find('.r-mask');
2734            $(this).find('.carousel-caption').detach().appendTo(mask);
2735        });
2736
2737        $('.fancybox').fancybox({
2738            padding: 0,
2739            openEffect: 'elastic',
2740            closeEffect: 'elastic'
2741        });
2742    }
2743
2744
2745    /* Page About
2746     */
2747    if($('.pg-about .clipping').length) {
2748        $('.pg-about .clipping').find('.carousel-caption').remove();
2749
2750        $('.clipping .element-item').each(function() {
2751            var el = $(this),
2752                myLink = el.find('a').eq(0);
2753
2754            myLink
2755                .addClass('fancybox')
2756                .attr('data-fancybox-group', 'fancybox')
2757                .attr('href', myLink.attr('data-src'));
2758            el
2759                .find('.content-text')
2760                    .on('click', function(e) {
2761                        myLink
2762                            .trigger('click');
2763                  });
2764        });
2765
2766        $('.grid').isotope({
2767            itemSelector: '.element-item',
2768            layoutMode: 'fitRows'
2769        });
2770        // layout Isotope after each image loads
2771        $('.grid').imagesLoaded().progress( function() {
2772            $('.grid').isotope('layout');
2773        });
2774
2775        $('.fancybox').fancybox({
2776            padding: 0,
2777            openEffect: 'elastic',
2778            closeEffect: 'elastic'
2779        });
2780    }
2781
2782    /* Page Blog
2783     */
2784    if($('.pg-blog').length) {
2785        $('.illustrations .r_images li').each(function() {
2786            var el = $(this),
2787                link = el.find('a'),
2788                img = link.find('img');
2789            link
2790                .attr('href', link.data('src'))
2791                .hover(function() {
2792                    console.log('in');
2793                    img.attr('src', link.data('img'));
2794                }, function() {
2795                    console.log('out');
2796                    img.attr('src', link.data('thumb'));
2797                });
2798        });
2799
2800        $('section.blog').find('.carousel-caption').remove();
2801
2802        $('.grid').isotope({
2803            itemSelector: '.element-item'
2804        });
2805        // layout Isotope after each image loads
2806        $('.grid').imagesLoaded().progress( function() {
2807            $('.grid').isotope('layout');
2808        });
2809    }
2810    if($('#section.pg-blog-item-selected').length) {
2811        var topBanner = $('.top-l-banner'),
2812            zoneMain = $('.zone.default'),
2813            badgeImgWrapper = zoneMain.find('.item.pos_1 .resources'),
2814            badgeImgSrc = badgeImgWrapper.find('.r_images li.rn1 img').attr('src');
2815        topBanner
2816            .after('<div class="top-l-badge"/>')
2817            .next('.top-l-badge')
2818                .css({ backgroundImage: 'url(' + badgeImgSrc + ')' });
2819        badgeImgWrapper.remove();
2820
2821    }
2822    if($('#view.pg-blog').length) {
2823        $('#view.pg-blog').find('.carousel-caption').remove();
2824        $('#zone_1').find('.resources .r_images a').each(function() {
2825            if($(this).data('src').indexOf('http') !== -1) {
2826                $(this).attr('href', $(this).data('src'));
2827            }
2828        });
2829    }
2830
2831    /* Page Contacts
2832     */
2833    if($('.pg-contacts').length) {
2834        $('section.contacts > .item').each(function() {
2835             if (!$(this).hasClass('pos_1')) {
2836                 $(this).find('.content-text .row').remove();
2837             }
2838        });
2839
2840        $('.reserve-bloc')
2841            .removeClass('container')
2842            .find('.resources .module.r_links a')
2843                .attr('href', '#theforkModal')
2844                .attr('data-toggle', 'modal')
2845                .addClass('modalBtn');
2846
2847        $('.form-bloc')
2848            .find('.col-md-10')
2849                .removeClass('col-md-10')
2850                .addClass('col-xs-12 col-md-6')
2851                .end()
2852            .find('.col-md-1')
2853                .removeClass('col-md-1')
2854                .addClass('hidden-xs-down col-md-3');
2855    }
2856
2857    /* Easter
2858     */
2859    if($('.easterBoard-selected').length > 0 && $('#formEaster2017').length > 0) {
2860        $.getScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js', function() {
2861            $.getScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/localization/messages_pt_PT.js');
2862            $('#formEaster2017').validate({ submitHandler: function (form) {
2863                var userData = {
2864                        name: $('#id_name').val(),
2865                        surname: $('#id_surname').val(),
2866                        idcard: $('#id_idcard').val(),
2867                        email: $('#id_email').val(),
2868                        phone: $('#id_phone').val()
2869                    },
2870                    dataString = JSON.stringify(userData);
2871
2872                ga('send', {
2873                    hitType: 'event',
2874                    eventCategory: 'Contest',
2875                    eventAction: 'FormSent',
2876                    eventLabel: 'Easter2017',
2877                    eventValue: 'Winner'
2878                });
2879                $.ajax({
2880                    url: '/?action=easter2k17',
2881                    data: userData,
2882                    type: 'POST',
2883                    beforeSend: function() {
2884                        $('#formEaster2017')
2885                            .find('input, select, button, textarea')
2886                                .attr('disabled', 'disabled');
2887                    },
2888                    success: function(response) {
2889                        handleWarning([
2890                            { type: 'ok', msg: 'Participação enviada com sucesso!' }
2891                        ]);
2892
2893                        $('#formEaster2017')
2894                            .find('input, textarea')
2895                                .val('')
2896                                .removeAttr('disabled')
2897                                .end()
2898                            .find('button, select')
2899                                .removeAttr('disabled');
2900                    }
2901                });
2902            }});
2903        });
2904    }
2905
2906   	/* Cookie Law
2907     */
2908	(function() {
2909		var $cookielaw = $('#cookielaw');
2910		if( $cookielaw.length ) {
2911			var h = $cookielaw.height();
2912
2913			$cookielaw
2914                .css({                    display: 'block',
2915                    bottom: -h + 'px'
2916                })
2917                .animate({ 'bottom': '0' })
2918                .find('a')
2919                    .on('click', function(e) {
2920                        e.preventDefault();
2921                        var $a = $(this);
2922
2923                        switch( $a.get(0).hash ){
2924                            case '#more':
2925                                $cookielaw.animate({'bottom':-h+'px'},{'complete':function(){
2926                                    $cookielaw
2927                                        .css({'bottom': -500+'px'})
2928                                        .addClass('showMore');
2929
2930                                    h = $cookielaw.height();
2931                                    $cookielaw.css({'bottom': -h+'px'}).animate({'bottom':'0px'});
2932                                }});
2933                                break;
2934                            case '#ok':
2935                                createCookie('cookielaw',1,31);
2936                                $cookielaw.animate({'bottom':-h+'px'},{'complete':function(){
2937                                    $cookielaw.remove();
2938                                }});
2939                                break;
2940                            case '#ko':
2941                                createCookie('cookielaw',0);
2942                                $cookielaw.animate({'bottom':-h+'px'},{'complete':function(){
2943                                    $cookielaw.remove();
2944                                }});
2945                                break;
2946                            case '#closecookielaw':
2947                                $cookielaw.animate({'bottom':-h+'px'},{'complete':function(){
2948                                    $cookielaw.remove();
2949                                }});
2950                                break;
2951                        }
2952                        return false;
2953                    })
2954                    .end()
2955                .on('scroll touchmove mousewheel', function(e) {
2956                    e.preventDefault();
2957                    return false;
2958                });
2959		}
2960	})();
2961
2962    /* handles warning fade
2963     */
2964    if($.trim($('#warnings').find('.w-holder').html()) != '') {
2965        handleWarning();
2966    }
2967    function handleWarning(json) {
2968        if(json) {
2969            json.forEach(function(el) {
2970                $('#warnings')
2971                    .find('.w-holder')
2972                    .append('<div class="' + el.type + '">' + el.msg + '</div>');
2973            });
2974        }
2975        $('#warnings').fadeIn('fast', function() {
2976            setTimeout(function() {
2977                $('#warnings').fadeOut('slow', function() {
2978                    $(this).find('.w-holder').html('');
2979                });
2980            }, 5000);
2981        });
2982    }
2983
2984    /* handles required fields
2985     */
2986    if ( $('#formContact').length > 0 ) {
2987        $('#formContact').submit(function(e) {
2988            var hasErrors = false;
2989            var requiredFiels = $('#formContact').find('[data-required=true], #g-recaptcha-response');
2990            requiredFiels.removeClass('error').each(function() {
2991                if ( $(this).val() == '' ) {
2992                    hasErrors = true;
2993                    $(this).addClass('error');
2994                }
2995            });
2996            return ( hasErrors == false ? true : false );
2997        });
2998    }
2999    /* track file downloads
3000     */
3001    $('.resources .r_files a').click(function() {
3002        if ( typeof _gaq !== 'undefined' && _gaq !== null ) {
3003            _gaq.push(['_trackEvent','Download','PDF', $(this).attr('href')]);
3004        }
3005    });
3006
3007    if($('#calendarList').length > 0) {
3008        handleCalendarList();
3009    }
3010    function handleCalendarList() {
3011        var calItems = $('#calendarList').find('.element-item'),
3012            calToday = new Date().getDate(),
3013            i;
3014
3015        calItems.each(function(index) {
3016            var el = $(this),
3017                elImg = el.find('.resources li.rn1'),
3018                elThumb = elImg.find('> a'),
3019                i = index+1;
3020
3021            if(elImg.length === 0) { return; }
3022            elImg
3023                .siblings().remove();
3024            elThumb
3025                .closest('.resources')
3026                .css({
3027                    backgroundImage: 'url(' + elThumb.data('thumb') + ')'
3028                })
3029                .end()
3030                .closest('.r_images')
3031                    .remove();
3032
3033            if(i < calToday) {
3034                el.addClass('past');
3035            }
3036            if(i == calToday) {
3037                el.addClass('today');
3038            }
3039        });
3040    }
3041    if($('#view').is('.pg-calendar-selected') === true) {
3042        if($('#calNav').length > 0) {
3043            var calNav = $('#calNav'),
3044                calCurrent = calNav.data('current'),
3045                calToday = new Date().getDate(),
3046                calColor = [
3047                    '',
3048
3049                    'white-on-gold',
3050                    'gold-on-grey',
3051                    'grey-on-white',
3052                    'white-on-gold',
3053                    'gold-on-grey',
3054                    'grey-on-white',
3055
3056                    'grey-on-white',
3057                    'white-on-gold',
3058                    'gold-on-grey',
3059                    'grey-on-white',
3060                    'white-on-gold',
3061                    'gold-on-grey',
3062
3063                    'white-on-gold',
3064                    'grey-on-white',
3065                    'grey-on-gold',
3066                    'gold-on-grey',
3067                    'grey-on-white',
3068                    'white-on-gold',
3069
3070                    'grey-on-white',
3071                    'white-on-gold',
3072                    'gold-on-grey',
3073                    'grey-on-white',
3074                    'grey-on-gold',
3075                    'grey-on-white'
3076                ],
3077                i;
3078            for(i=1; i<=24; i++) {
3079                calNav.append('<li class="element-item col-md-2 col-sm-2 col-xs-2 ' + calColor[i] + ((i < calToday && i !== calCurrent) ? ' past' : '') + (i === calCurrent ? ' current' : '') + (i === calToday ? ' today' : '') + '"><a href="/calendario-advento/dia-' + i + '" title="Calendário do Advento"><span class="date-theme">' + i + '</span></a></li>');
3080            }
3081            // TMP
3082            calNav.find('a').on('click', function(e) {
3083                if(e) { e.preventDefault(); }
3084                var calLink = $(this).attr('href').split('/');
3085                calLink.pop();
3086                linkUrl = calLink.join('/');
3087                location.href=linkUrl;
3088            });
3089        }
3090
3091        if(sessionStorage.getItem('cart') == null) {
3092            initCart();
3093        }
3094        if($('.catalogOrderList').find('ul').length == 0) {
3095            updateCartList();
3096        }
3097
3098        $('#catalogAddCart').on('click', function(e) {
3099            if(e) { e.preventDefault(); }
3100            var itemQty = $('#id_qty'),
3101                itemQtyVal = Math.floor(itemQty.val());
3102
3103            if(itemQtyVal < 1 || Number.isInteger(itemQtyVal) == false) {
3104                return false;
3105            }
3106
3107            var cart = sessionStorage.getItem('cart'),
3108                cartObject = JSON.parse(cart),
3109                cartCopy = cartObject,
3110                items = cartCopy.items,
3111                item = {
3112                    sku: $(this).data('sku'),
3113                    name: $('h1 span.title').text(),
3114                    qty: itemQtyVal,
3115                    unit: itemQty.data('unit'),
3116                    pvp: $(this).data('pvp'),
3117                    promo: $(this).data('promo')
3118                };
3119
3120            items.push(item);
3121            itemQty.val('');
3122
3123            sessionStorage.setItem('cart', JSON.stringify(cartCopy));
3124            updateCartList();
3125        });
3126
3127        $('#catalogOrder').find('.catalogOrderList').on('click', 'a.close', function(e) {
3128            if(e) { e.preventDefault(); }
3129
3130            var el = $(e.target),
3131                item = el.closest('li'),
3132                itemSku = item.data('sku'),
3133                itemIndex = item.index(),
3134                listWrapper = el.closest('ul'),
3135
3136                cart = sessionStorage.getItem('cart'),
3137                cartObj = JSON.parse(cart),
3138                cartCopy = cartObj,
3139                items = cartCopy.items;
3140
3141            items.splice(itemIndex, 1);
3142
3143            if(items.length > 0) {
3144                sessionStorage.setItem('cart', JSON.stringify(cartCopy));
3145            } else {
3146                initCart();
3147            }
3148
3149            updateCartList();
3150
3151        });
3152        $('#catalogBuyCart').on('click', function(e) {
3153            if(e) { e.preventDefault(); }
3154            $('html').addClass('buyCart');
3155            $('#id_qty').removeAttr('required');
3156        });
3157        $('#orderCancel a, #catalogBuyCancel').on('click', function(e) {
3158            if(e) { e.preventDefault(); }
3159            $('html').removeClass('buyCart');
3160            $('#id_qty')
3161                .attr('required', 'required');
3162        });
3163
3164        $.getScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/jquery.validate.min.js', function() {
3165            $.getScript('//ajax.aspnetcdn.com/ajax/jquery.validate/1.15.0/localization/messages_pt_PT.js');
3166            $.getScript('//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js', function() {
3167                $.getScript('//cdnjs.cloudflare.com/ajax/libs/pikaday/1.5.1/pikad
3167ay.min.js', function() {
3168                    var style = document.getElementsByTagName('style')[0],
3169                        link = document.createElement('link');
3170                        link.rel = 'stylesheet';
3171                        link.type = 'text/css';
3172                        link.href = '//cdnjs.cloudflare.com/ajax/libs/pikaday/1.5.1/css/pikaday.min.css';
3173                        link.media = 'all';
3174
3175                    style.parentNode.insertBefore(link, style.nextSibling);
3176
3177                    if(window.i18n.en) {
3178                        window.i18n.en.picker = {
3179                            previousMonth : 'Previous Month',
3180                            nextMonth     : 'Next Month',
3181                            months        : ['January','February','March','April','May','June','July','August','September','October','November','December'],
3182                            weekdays      : ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
3183                            weekdaysShort : ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
3184                        }
3185                    }
3186                    if(window.i18n.pt) {
3187                        window.i18n.pt.picker = {
3188                            previousMonth : 'Anterior',
3189                            nextMonth     : 'Seguinte',
3190                            months        : ['janeiro','fevereiro','março','abril','maio','junho','julho','agosto','setembro','outubro','novembro','dezembro'],
3191                            weekdays      : ['domingo','segunda','terça','quarta','quinta','sexta','sábado'],
3192                            weekdaysShort : ['dom','seg','ter','qua','qui','sex','sáb']
3193                        }
3194                    }
3195
3196                    var pickDay = document.getElementById('id_date'),
3197                        pickDayMin = $(pickDay).attr('min'),
3198                        pickDayMax = $(pickDay).attr('max'),
3199                        pickerI18n = window.i18n[window.lang].picker,
3200                        picker = new Pikaday({
3201                            field: pickDay,
3202                            firstDay: 1,
3203                            format: 'YYYY-MM-DD',
3204                            minDate: new Date(pickDayMin),
3205                            maxDate: new Date(pickDayMax),
3206                            i18n: pickerI18n
3207                        });
3208                });
3209            });
3210
3211            $('#catalogOrder').validate({ submitHandler: function (form) {
3212                var cart = sessionStorage.getItem('cart'),
3213                    cartObj = JSON.parse(cart),
3214                    cartItems = cartObj.items,
3215
3216                    userData = {
3217                        date: $('#id_date').val(),
3218                        hour: $('#id_hour').val(),
3219                        name: $('#id_nickname').val(),
3220                        email: $('#id_email').val(),
3221                        phone: $('#id_phone').val(),
3222                        msg: $('#id_message').val(),
3223                        reservation: JSON.stringify(cartItems)
3224                    },
3225
3226                    dataString = JSON.stringify(userData);
3227
3228                ga('send', {
3229                    hitType: 'event',
3230                    eventCategory: 'Store',
3231                    eventAction: 'Reservation',
3232                    eventLabel: 'AdventCalendar2016',
3233                    eventCart: cartItems
3234                });
3235
3236                $.ajax({
3237                    url: '/?order=true',
3238                    data: userData,
3239                    type: 'POST',
3240                    beforeSend: function() {
3241                        $('#catalogOrder')
3242                            .find('input, select, button, textarea')
3243                                .attr('disabled', 'disabled');
3244                    },
3245                    success: function(response) {
3246                        initCart();
3247                        updateCartList();
3248
3249                        $('html').removeClass('buyCart');
3250
3251                        handleWarning([
3252                            { type: 'ok', msg: 'Pedido de reserva enviado com sucesso!' }
3253                        ]);
3254
3255                        $('#id_qty')
3256                            .attr('required','required');
3257
3258                        $('#catalogOrder')
3259                            .find('input, textarea')
3260                                .val('')
3261                                .removeAttr('disabled')
3262                                .end()
3263                            .find('button, select')
3264                                .removeAttr('disabled');
3265                    }
3266                });
3267            } });
3268        });
3269    }
3270    function initCart() {
3271        var cart = {};
3272            cart.items = [];
3273        sessionStorage.removeItem('cart');
3274        sessionStorage.setItem('cart', JSON.stringify(cart));
3275    }
3276    function updateCartList() {
3277        var placeHolder = $('.catalogOrderList'),
3278            cart = sessionStorage.getItem('cart');
3279
3280        cart = JSON.parse(cart);
3281
3282        if(cart && cart.items.length > 0) {
3283            if(placeHolder.find('ul').length == 0) {
3284                placeHolder.prepend('<ul />');
3285            }
3286            placeHolder.find('ul li').remove();
3287            $(cart.items).each(function(index) {
3288                placeHolder.find('ul').append('<li data-sku="' + this.sku + '">' + this.qty + ' un &times; ' + this.name + ' <a class="close">&times;</a></li>');
3289            });
3290        } else {
3291            placeHolder.find('ul').remove();
3292        }
3293    }
3294}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.