/**
 *
 *    /$$
 *   | $$
 *   | $$       /$$   /$$ /$$$$$$$   /$$$$$$   /$$$$$$
 *   | $$      | $$  | $$| $$__  $$ /$$__  $$ /$$__  $$
 *   | $$      | $$  | $$| $$  \ $$| $$  \ $$| $$  \ $$
 *   | $$      | $$  | $$| $$  | $$| $$  | $$| $$  | $$
 *   | $$$$$$$$|  $$$$$$/| $$  | $$|  $$$$$$$|  $$$$$$/
 *   |________/ \______/ |__/  |__/ \____  $$ \______/
 *                                  /$$  \ $$
 *                                 |  $$$$$$/
 *                                  \______/
 *
 * @copyright 2011 TapQuo Inc (c)
 * @license   http://www.github.com/tapquo/lungo/blob/master/LICENSE.txt
 * @version   1.0.0
 * @link      https://github.com/TapQuo/Lungo.js
 *
 * @author   Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
 * @author   Guillermo Pascual <pasku@tapquo.com> || @pasku1
 */

(function(b){if(String.prototype.trim===b)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")};if(Array.prototype.reduce===b)Array.prototype.reduce=function(g){if(this===void 0||this===null)throw new TypeError;var f=Object(this),j=f.length>>>0,h=0,k;if(typeof g!="function")throw new TypeError;if(j==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)k=arguments[1];else{do{if(h in f){k=f[h++];break}if(++h>=j)throw new TypeError;}while(1)}for(;h<j;){if(h in
f)k=g.call(b,k,f[h],h,f);h++}return k}})();
var Zepto=function(){function b(d){return{}.toString.call(d)=="[object Function]"}function g(d){return d instanceof Object}function f(d){return d instanceof Array}function j(d){return typeof d.length=="number"}function h(d){return d.filter(function(p){return p!==C&&p!==null})}function k(d){return d.replace(/-+(.)?/g,function(p,q){return q?q.toUpperCase():""})}function m(d){return d.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}
function o(d){return d.filter(function(p,q,y){return y.indexOf(p)==q})}function n(d){return d in z?z[d]:z[d]=RegExp("(^|\\s)"+d+"(\\s|$)")}function v(d,p){p===C&&G.test(d);p in O||(p="*");var q=O[p];q.innerHTML=""+d;return e.call(q.childNodes)}function x(d,p){d=d||a;d.__proto__=x.prototype;d.selector=p||"";return d}function t(d,p){if(!d)return x();if(p!==C)return t(p).find(d);else if(b(d))return t(r).ready(d);else if(d instanceof x)return d;else{var q;if(f(d))q=h(d);else if(I.indexOf(d.nodeType)>=
0||d===window){q=[d];d=null}else if(G.test(d)){q=v(d,RegExp.$1);d=null}else q=d.nodeType&&d.nodeType==3?[d]:E(r,d);return x(q,d)}}function s(d,p){return p===C?t(d):t(d).filter(p)}function w(d,p,q,y){return b(p)?p.call(d,q,y):p}function B(d,p,q){var y=!d||d==3?p:p.parentNode;y.insertBefore(q,!d?y.firstChild:d==1?p.nextSibling:d==2?p:null)}function F(d,p){p(d);for(A in d.childNodes)F(d.childNodes[A],p)}var C,A,E,c,a=[],e=a.slice,r=window.document,u={},z={},D=r.defaultView.getComputedStyle,H={"column-count":1,
columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},G=/^\s*<(\w+)[^>]*>/,I=[1,9,11],M=r.createElement("table"),P=r.createElement("tr"),O={tr:r.createElement("tbody"),tbody:M,thead:M,tfoot:M,td:P,th:P,"*":r.createElement("div")};t.extend=function(d){e.call(arguments,1).forEach(function(p){for(A in p)d[A]=p[A]});return d};t.qsa=E=function(d,p){return e.call(d.querySelectorAll(p))};t.isFunction=b;t.isObject=g;t.isArray=f;t.map=function(d,p){var q,y=[],J;if(j(d))for(J=0;J<d.length;J++){q=
p(d[J],J);q!=null&&y.push(q)}else for(J in d){q=p(d[J],J);q!=null&&y.push(q)}return y.length>0?[].concat.apply([],y):y};t.each=function(d,p){var q;if(j(d))for(q=0;q<d.length;q++){if(p(q,d[q])===false)break}else for(q in d)if(p(q,d[q])===false)break;return d};t.fn={forEach:a.forEach,reduce:a.reduce,push:a.push,indexOf:a.indexOf,concat:a.concat,map:function(d){return t.map(this,function(p,q){return d.call(p,q,p)})},slice:function(){return t(e.apply(this,arguments))},ready:function(d){if(r.readyState==
"complete"||r.readyState=="loaded")d();r.addEventListener("DOMContentLoaded",d,false);return this},get:function(d){return d===C?this:this[d]},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(d){this.forEach(function(p,q){d.call(p,q,p)});return this},filter:function(d){return t([].filter.call(this,function(p){return E(p.parentNode,d).indexOf(p)>=0}))},end:function(){return this.prevObject||t()},
add:function(d,p){return t(o(this.concat(t(d,p))))},is:function(d){return this.length>0&&t(this[0]).filter(d).length>0},not:function(d){var p=[];if(b(d)&&d.call!==C)this.each(function(y){d.call(this,y)||p.push(this)});else{var q=typeof d=="string"?this.filter(d):j(d)&&b(d.item)?e.call(d):t(d);this.forEach(function(y){q.indexOf(y)<0&&p.push(y)})}return t(p)},eq:function(d){return d===-1?this.slice(d):this.slice(d,+d+1)},first:function(){return t(this[0])},last:function(){return t(this[this.length-
1])},find:function(d){var p;p=this.length==1?E(this[0],d):this.map(function(){return E(this,d)});return t(p)},closest:function(d,p){var q=this[0],y=E(p!==C?p:r,d);if(y.length===0)q=null;for(;q&&q!==r&&y.indexOf(q)<0;)q=q.parentNode;return t(q!==r&&q)},parents:function(d){for(var p=[],q=this;q.length>0;)q=t.map(q,function(y){if((y=y.parentNode)&&y!==r&&p.indexOf(y)<0){p.push(y);return y}});return s(p,d)},parent:function(d){return s(o(this.pluck("parentNode")),d)},children:function(d){return s(this.map(function(){return e.call(this.children)}),
d)},siblings:function(d){return s(this.map(function(p,q){return e.call(q.parentNode.children).filter(function(y){return y!==q})}),d)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(d){return this.map(function(){return this[d]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null);if(D(this,"").getPropertyValue("display")=="none"){var d=this.style,p=this.nodeName,q,y;if(!u[p]){q=r.createElement(p);r.body.appendChild(q);
y=D(q,"").getPropertyValue("display");q.parentNode.removeChild(q);y=="none"&&(y="block");u[p]=y}d.display=u[p]}})},replaceWith:function(d){return this.each(function(){var p=this.parentNode,q=this.nextSibling;t(this).remove();q?t(q).before(d):t(p).append(d)})},wrap:function(d){return this.each(function(){t(this).wrapAll(t(d)[0].cloneNode(false))})},wrapAll:function(d){if(this[0]){t(this[0]).before(d=t(d));d.append(this)}return this},unwrap:function(){this.parent().each(function(){t(this).replaceWith(t(this).children())});
return this},hide:function(){return this.css("display","none")},toggle:function(d){return(d===C?this.css("display")=="none":d)?this.show():this.hide()},prev:function(){return t(this.pluck("previousElementSibling"))},next:function(){return t(this.pluck("nextElementSibling"))},html:function(d){return d===C?this.length>0?this[0].innerHTML:null:this.each(function(p){var q=this.innerHTML;t(this).empty().append(w(this,d,p,q))})},text:function(d){return d===C?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=
d})},attr:function(d,p){return typeof d=="string"&&p===C?this.length>0&&this[0].nodeName=="INPUT"&&this[0].type=="text"&&d=="value"?this.val():this.length>0?this[0].getAttribute(d)||(d in this[0]?this[0][d]:C):C:this.each(function(q){if(g(d))for(A in d)this.setAttribute(A,d[A]);else this.setAttribute(d,w(this,p,q,this.getAttribute(d)))})},removeAttr:function(d){return this.each(function(){this.removeAttribute(d)})},data:function(d,p){return this.attr("data-"+d,p)},val:function(d){return d===C?this.length>
0?this[0].value:null:this.each(function(){this.value=d})},offset:function(){if(this.length==0)return null;var d=this[0].getBoundingClientRect();return{left:d.left+r.body.scrollLeft,top:d.top+r.body.scrollTop,width:d.width,height:d.height}},css:function(d,p){if(p===C&&typeof d=="string")return this[0].style[k(d)]||D(this[0],"").getPropertyValue(d);var q="";for(A in d)q+=m(A)+":"+(typeof d[A]=="number"&&!H[m(A)]?d[A]+"px":d[A])+";";if(typeof d=="string")q=m(d)+":"+(typeof p=="number"&&!H[m(d)]?p+"px":
p);return this.each(function(){this.style.cssText+=";"+q})},index:function(d){return d?this.indexOf(t(d)[0]):this.parent().children().indexOf(this[0])},hasClass:function(d){return this.length<1?false:n(d).test(this[0].className)},addClass:function(d){return this.each(function(p){c=[];var q=this.className;w(this,d,p,q).split(/\s+/g).forEach(function(y){t(this).hasClass(y)||c.push(y)},this);c.length&&(this.className+=(q?" ":"")+c.join(" "))})},removeClass:function(d){return this.each(function(p){if(d===
C)return this.className="";c=this.className;w(this,d,p,c).split(/\s+/g).forEach(function(q){c=c.replace(n(q)," ")});this.className=c.trim()})},toggleClass:function(d,p){return this.each(function(q){q=w(this,d,q,this.className);p!==C&&!p||t(this).hasClass(q)?t(this).removeClass(q):t(this).addClass(q)})}};"filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings".split(",").forEach(function(d){var p=t.fn[d];t.fn[d]=function(){var q=p.apply(this,arguments);q.prevObject=this;return q}});
["width","height"].forEach(function(d){t.fn[d]=function(p){var q;return p===C?(q=this.offset())&&q[d]:this.css(d,p)}});["prepend","after","before","append"].forEach(function(d,p){t.fn[d]=function(q){var y=typeof q=="object"?q:v(q);"length"in y||(y=[y]);if(y.length<1)return this;var J=this.length,Q=J>1,R=p<2;return this.each(function(S,T){for(var K=0;K<y.length;K++){var L=y[R?y.length-K-1:K];F(L,function(N){N.nodeName!=null&&N.nodeName.toUpperCase()==="SCRIPT"&&window.eval.call(window,N.innerHTML)});
if(Q&&S<J-1)L=L.cloneNode(true);B(p,T,L)}})}});["append","prepend"].forEach(function(d){t.fn[d+"To"]=function(p){if(typeof p!="object")p=t(p);p[d](this);return this}});x.prototype=t.fn;return t}();"$"in window||(window.$=Zepto);
(function(b){function g(s,w,B,F){w=f(w);if(w.ns)var C=RegExp("(?:^| )"+w.ns.replace(" "," .* ?")+"(?: |$)");return(o[s._zid||(s._zid=n++)]||[]).filter(function(A){return A&&(!w.e||A.e==w.e)&&(!w.ns||C.test(A.ns))&&(!B||A.fn==B)&&(!F||A.sel==F)})}function f(s){s=(""+s).split(".");return{e:s[0],ns:s.slice(1).sort().join(" ")}}function j(s,w,B,F,C){var A=s._zid||(s._zid=n++),E=o[A]||(o[A]=[]);w.split(/\s/).forEach(function(c){var a=C||B,e=function(r){var u=a.apply(s,[r].concat(r.data));u===false&&r.preventDefault();
return u};c=b.extend(f(c),{fn:B,proxy:e,sel:F,del:C,i:E.length});E.push(c);s.addEventListener(c.e,e,false)})}function h(s,w,B,F){var C=s._zid||(s._zid=n++);(w||"").split(/\s/).forEach(function(A){g(s,A,B,F).forEach(function(E){delete o[C][E.i];s.removeEventListener(E.e,E.proxy,false)})})}function k(s){var w=b.extend({originalEvent:s},s);b.each(t,function(B,F){w[B]=function(){this[F]=v;return s[B].apply(s,arguments)};w[F]=x});return w}var m=b.qsa,o={},n=1;b.event={add:j,remove:h};b.fn.bind=function(s,
w){return this.each(function(){j(this,s,w)})};b.fn.unbind=function(s,w){return this.each(function(){h(this,s,w)})};b.fn.one=function(s,w){return this.each(function(){var B=this;j(this,s,function(F){w.call(B,F);h(B,s,arguments.callee)})})};var v=function(){return true},x=function(){return false},t={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};b.fn.delegate=function(s,w,B){return this.each(function(F,C){j(C,w,B,
s,function(A,E){for(var c=A.target,a=m(C,s);c&&a.indexOf(c)<0;)c=c.parentNode;c&&c!==C&&c!==document&&B.call(c,b.extend(k(A),{currentTarget:c,liveFired:C}),E)})})};b.fn.undelegate=function(s,w,B){return this.each(function(){h(this,w,B,s)})};b.fn.live=function(s,w){b(document.body).delegate(this.selector,s,w);return this};b.fn.die=function(s,w){b(document.body).undelegate(this.selector,s,w);return this};b.fn.trigger=function(s,w){if(typeof s=="string")s=b.Event(s);s.data=w;return this.each(function(){this.dispatchEvent(s)})};
b.fn.triggerHandler=function(s,w){var B,F;this.each(function(C,A){B=k(typeof s=="string"?b.Event(s):s);B.data=w;B.target=A;b.each(g(A,s.type||s),function(E,c){F=c.proxy(B);if(B.isImmediatePropagationStopped())return false})});return F};"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout change select keydown keypress keyup error".split(" ").forEach(function(s){b.fn[s]=function(w){return this.bind(s,w)}});["focus","blur"].forEach(function(s){b.fn[s]=
function(w){if(w)this.bind(s,w);else if(this.length)try{this.get(0)[s]()}catch(B){}return this}});b.Event=function(s,w){var B=document.createEvent("Events");w&&b.extend(B,w);B.initEvent(s,!(w&&w.bubbles===false),true);return B}})(Zepto);
(function(b){function g(j){var h={},k=j.match(/(Android)\s+([\d.]+)/),m=j.match(/(iPad).*OS\s([\d_]+)/),o=!m&&j.match(/(iPhone\sOS)\s([\d_]+)/),n=j.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),v=n&&j.match(/TouchPad/);j=j.match(/(BlackBerry).*Version\/([\d.]+)/);if(k){h.android=true;h.version=k[2]}if(o){h.ios=true;h.version=o[2].replace(/_/g,".");h.iphone=true}if(m){h.ios=true;h.version=m[2].replace(/_/g,".");h.ipad=true}if(n){h.webos=true;h.version=n[2]}if(v)h.touchpad=true;if(j){h.blackberry=true;h.version=
j[2]}return h}b.os=g(navigator.userAgent);b.__detect=g;var f=navigator.userAgent.match(/WebKit\/([\d.]+)/);b.browser=f?{webkit:true,version:f[1]}:{webkit:false}})(Zepto);
(function(b,g){var f=["scale","scaleX","scaleY","translate","translateX","translateY","translate3d","skew","skewX","skewY","rotate","rotateX","rotateY","rotateZ","rotate3d","matrix"];b.fn.anim=function(j,h,k,m){var o=[],n={},v,x=this;for(v in j)if(f.indexOf(v)>=0)o.push(v+"("+j[v]+")");else n[v]=j[v];j=function(){x.css({"-webkit-transition":"none"});m&&m()};h>0?this.one("webkitTransitionEnd",j):setTimeout(j,0);if(o.length>0)n["-webkit-transform"]=o.join(" ");n["-webkit-transition"]="all "+(h!==g?
h:0.5)+"s "+(k||"");setTimeout(function(){x.css(n)},0);return this}})(Zepto);
(function(b){function g(){}var f=0,j=b.isObject,h;b.ajaxJSONP=function(k){var m="jsonp"+ ++f,o=document.createElement("script");window[m]=function(n){k.success(n);delete window[m]};o.src=k.url.replace(/=\?/,"="+m);b("head").append(o)};b.ajaxSettings={type:"GET",beforeSend:g,success:g,error:g,complete:g,accepts:{script:"text/javascript, application/javascript",json:"application/json",xml:"application/xml, text/xml",html:"text/html",text:"text/plain"}};b.ajax=function(k){k=k||{};var m=b.extend({},k);
for(h in b.ajaxSettings)m[h]||(m[h]=b.ajaxSettings[h]);if(/=\?/.test(m.url))return b.ajaxJSONP(m);if(!m.url)m.url=window.location.toString();if(m.data&&!m.contentType)m.contentType="application/x-www-form-urlencoded";if(j(m.data))m.data=b.param(m.data);if(m.type.match(/get/i)&&m.data){k=m.data;if(m.url.match(/\?.*=/))k="&"+k;else if(k[0]!="?")k="?"+k;m.url+=k}var o=m.accepts[m.dataType],n=new XMLHttpRequest;m.headers=b.extend({"X-Requested-With":"XMLHttpRequest"},m.headers||{});if(o)m.headers.Accept=
o;n.onreadystatechange=function(){if(n.readyState==4){var v,x=false;if(n.status>=200&&n.status<300||n.status==0){if(o=="application/json"&&n.responseText!="")try{v=JSON.parse(n.responseText)}catch(t){x=t}else v=n.responseText;x?m.error(n,"parsererror",x):m.success(v,"success",n)}else{x=true;m.error(n,"error")}m.complete(n,x?"error":"success")}};n.open(m.type,m.url,true);if(m.beforeSend(n,m)===false){n.abort();return false}if(m.contentType)m.headers["Content-Type"]=m.contentType;for(name in m.headers)n.setRequestHeader(name,
m.headers[name]);n.send(m.data);return n};b.get=function(k,m){b.ajax({url:k,success:m})};b.post=function(k,m,o,n){if(b.isFunction(m)){n=n||o;o=m;m=null}b.ajax({type:"POST",url:k,data:m,success:o,dataType:n})};b.getJSON=function(k,m){b.ajax({url:k,success:m,dataType:"json"})};b.fn.load=function(k,m){if(!this.length)return this;var o=this,n=k.split(/\s/),v;if(n.length>1){k=n[0];v=n[1]}b.get(k,function(x){o.html(v?b(document.createElement("div")).html(x).find(v).html():x);m&&m()});return this};b.param=
function(k,m){var o=[],n=function(x,t){o.push(encodeURIComponent(m?m+"["+x+"]":x)+"="+encodeURIComponent(t))},v=b.isArray(k);for(h in k)j(k[h])?o.push(b.param(k[h],m?m+"["+h+"]":h)):n(v?"":h,k[h]);return o.join("&").replace("%20","+")}})(Zepto);
(function(b){b.fn.serializeArray=function(){var g=[],f;b(Array.prototype.slice.call(this.get(0).elements)).each(function(){f=b(this);if((f.attr("type")!=="radio"||f.is(":checked"))&&!(f.attr("type")==="checkbox"&&!f.is(":checked")))g.push({name:f.attr("name"),value:f.val()})});return g};b.fn.serialize=function(){var g=[];this.serializeArray().forEach(function(f){g.push(encodeURIComponent(f.name)+"="+encodeURIComponent(f.value))});return g.join("&")};b.fn.submit=function(g){if(g)this.bind("submit",
g);else if(this.length){g=b.Event("submit");this.eq(0).trigger(g);g.defaultPrevented||this.get(0).submit()}return this}})(Zepto);
(function(b){function g(){if(f.last&&Date.now()-f.last>=h){b(f.target).trigger("longTap");f={}}}var f={},j,h=750;b(document).ready(function(){b(document.body).bind("touchstart",function(k){var m=Date.now(),o=m-(f.last||m);f.target="tagName"in k.touches[0].target?k.touches[0].target:k.touches[0].target.parentNode;j&&clearTimeout(j);f.x1=k.touches[0].pageX;f.y1=k.touches[0].pageY;if(o>0&&o<=250)f.isDoubleTap=true;f.last=m;setTimeout(g,h)}).bind("touchmove",function(k){f.x2=k.touches[0].pageX;f.y2=k.touches[0].pageY}).bind("touchend",
function(){if(f.isDoubleTap){b(f.target).trigger("doubleTap");f={}}else if(f.x2>0||f.y2>0){(Math.abs(f.x1-f.x2)>30||Math.abs(f.y1-f.y2)>30)&&b(f.target).trigger("swipe")&&b(f.target).trigger("swipe"+(Math.abs(f.x1-f.x2)>=Math.abs(f.y1-f.y2)?f.x1-f.x2>0?"Left":"Right":f.y1-f.y2>0?"Up":"Down"));f.x1=f.x2=f.y1=f.y2=f.last=0}else if("last"in f)j=setTimeout(function(){j=null;b(f.target).trigger("tap");f={}},250)}).bind("touchcancel",function(){f={}})});["swipe","swipeLeft","swipeRight","swipeUp","swipeDown",
"doubleTap","tap","longTap"].forEach(function(k){b.fn[k]=function(m){return this.bind(k,m)}})})(Zepto);(function(){var b=Math,g=/webkit/i.test(navigator.appVersion)?"webkit":/firefox/i.test(navigator.userAgent)?"Moz":"opera"in window?"O":"",f="WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix,j="ontouchstart"in window,h=g+"Transform"in document.documentElement.style,k=/android/gi.test(navigator.appVersion),m=/iphone|ipad/gi.test(navigator.appVersion),o=/playbook/gi.test(navigator.appVersion),n=m||o,v=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||
window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(c){return setTimeout(c,1)}}(),x=window.cancelRequestAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout,t="onorientationchange"in window?"orientationchange":"resize",s=j?"touchstart":"mousedown",w=j?"touchmove":"mousemove",B=j?"touchend":"mouseup",F=j?"touchcancel":"mouseup",C=g=="Moz"?"DOMMouseScroll":
"mousewheel",A="translate"+(f?"3d(":"("),E=f?",0)":")";o=function(c,a){var e=this,r=document,u;e.wrapper=typeof c=="object"?c:r.getElementById(c);e.wrapper.style.overflow="hidden";e.scroller=e.wrapper.children[0];e.options={hScroll:true,vScroll:true,bounce:true,bounceLock:false,momentum:true,lockDirection:true,useTransform:true,useTransition:false,topOffset:0,checkDOMChanges:false,hScrollbar:true,vScrollbar:true,fixedScrollbar:k,hideScrollbar:m,fadeScrollbar:m&&f,scrollbarClass:"",zoom:false,zoomMin:1,
zoomMax:4,doubleTapZoom:2,wheelAction:"scroll",snap:false,snapThreshold:1,onRefresh:null,onBeforeScrollStart:function(z){z.preventDefault()},onScrollStart:null,onBeforeScrollMove:null,onScrollMove:null,onBeforeScrollEnd:null,onScrollEnd:null,onTouchEnd:null,onDestroy:null,onZoomStart:null,onZoom:null,onZoomEnd:null};for(u in a)e.options[u]=a[u];e.options.useTransform=h?e.options.useTransform:false;e.options.hScrollbar=e.options.hScroll&&e.options.hScrollbar;e.options.vScrollbar=e.options.vScroll&&
e.options.vScrollbar;e.options.zoom=e.options.useTransform&&e.options.zoom;e.options.useTransition=n&&e.options.useTransition;e.scroller.style[g+"TransitionProperty"]=e.options.useTransform?"-"+g.toLowerCase()+"-transform":"top left";e.scroller.style[g+"TransitionDuration"]="0";e.scroller.style[g+"TransformOrigin"]="0 0";if(e.options.useTransition)e.scroller.style[g+"TransitionTimingFunction"]="cubic-bezier(0.33,0.66,0.66,1)";if(e.options.useTransform)e.scroller.style[g+"Transform"]=A+"0,0"+E;else e.scroller.style.cssText+=
";position:absolute;top:0;left:0";if(e.options.useTransition)e.options.fixedScrollbar=true;e.refresh();e._bind(t,window);e._bind(s);if(!j){e._bind("mouseout",e.wrapper);e._bind(C)}if(e.options.checkDOMChanges)e.checkDOMTime=setInterval(function(){e._checkDOMChanges()},500)};o.prototype={enabled:true,x:0,y:0,steps:[],scale:1,currPageX:0,currPageY:0,pagesX:[],pagesY:[],aniTime:null,wheelZoomCount:0,handleEvent:function(c){switch(c.type){case s:if(!j&&c.button!==0)break;this._start(c);break;case w:this._move(c);
break;case B:case F:this._end(c);break;case t:this._resize();break;case C:this._wheel(c);break;case "mouseout":this._mouseout(c);break;case "webkitTransitionEnd":this._transitionEnd(c)}},_checkDOMChanges:function(){this.moved||this.zoomed||this.animating||this.scrollerW==this.scroller.offsetWidth*this.scale&&this.scrollerH==this.scroller.offsetHeight*this.scale||this.refresh()},_scrollbar:function(c){var a=document,e;if(this[c+"Scrollbar"]){if(!this[c+"ScrollbarWrapper"]){e=a.createElement("div");
if(this.options.scrollbarClass)e.className=this.options.scrollbarClass+c.toUpperCase();else e.style.cssText="position:absolute;z-index:100;"+(c=="h"?"height:7px;bottom:1px;left:2px;right:"+(this.vScrollbar?"7":"2")+"px":"width:7px;bottom:"+(this.hScrollbar?"7":"2")+"px;top:2px;right:1px");e.style.cssText+=";pointer-events:none;-"+g+"-transition-property:opacity;-"+g+"-transition-duration:"+(this.options.fadeScrollbar?"350ms":"0")+";overflow:hidden;opacity:"+(this.options.hideScrollbar?"0":"1");this.wrapper.appendChild(e);
this[c+"ScrollbarWrapper"]=e;e=a.createElement("div");if(!this.options.scrollbarClass)e.style.cssText="position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);-"+g+"-background-clip:padding-box;-"+g+"-box-sizing:border-box;"+(c=="h"?"height:100%":"width:100%")+";-"+g+"-border-radius:3px;border-radius:3px";e.style.cssText+=";pointer-events:none;-"+g+"-transition-property:-"+g+"-transform;-"+g+"-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);-"+g+"-transition-duration:0;-"+
g+"-transform:"+A+"0,0"+E;if(this.options.useTransition)e.style.cssText+=";-"+g+"-transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)";this[c+"ScrollbarWrapper"].appendChild(e);this[c+"ScrollbarIndicator"]=e}if(c=="h"){this.hScrollbarSize=this.hScrollbarWrapper.clientWidth;this.hScrollbarIndicatorSize=b.max(b.round(this.hScrollbarSize*this.hScrollbarSize/this.scrollerW),8);this.hScrollbarIndicator.style.width=this.hScrollbarIndicatorSize+"px";this.hScrollbarMaxScroll=this.hScrollbarSize-this.hScrollbarIndicatorSize;
this.hScrollbarProp=this.hScrollbarMaxScroll/this.maxScrollX}else{this.vScrollbarSize=this.vScrollbarWrapper.clientHeight;this.vScrollbarIndicatorSize=b.max(b.round(this.vScrollbarSize*this.vScrollbarSize/this.scrollerH),8);this.vScrollbarIndicator.style.height=this.vScrollbarIndicatorSize+"px";this.vScrollbarMaxScroll=this.vScrollbarSize-this.vScrollbarIndicatorSize;this.vScrollbarProp=this.vScrollbarMaxScroll/this.maxScrollY}this._scrollbarPos(c,true)}else if(this[c+"ScrollbarWrapper"]){if(h)this[c+
"ScrollbarIndicator"].style[g+"Transform"]="";this[c+"ScrollbarWrapper"].parentNode.removeChild(this[c+"ScrollbarWrapper"]);this[c+"ScrollbarWrapper"]=null;this[c+"ScrollbarIndicator"]=null}},_resize:function(){var c=this;setTimeout(function(){c.refresh()},k?200:0)},_pos:function(c,a){c=this.hScroll?c:0;a=this.vScroll?a:0;if(this.options.useTransform)this.scroller.style[g+"Transform"]=A+c+"px,"+a+"px"+E+" scale("+this.scale+")";else{c=b.round(c);a=b.round(a);this.scroller.style.left=c+"px";this.scroller.style.top=
a+"px"}this.x=c;this.y=a;this._scrollbarPos("h");this._scrollbarPos("v")},_scrollbarPos:function(c,a){var e=c=="h"?this.x:this.y;if(this[c+"Scrollbar"]){e=this[c+"ScrollbarProp"]*e;if(e<0){if(!this.options.fixedScrollbar){e=this[c+"ScrollbarIndicatorSize"]+b.round(e*3);if(e<8)e=8;this[c+"ScrollbarIndicator"].style[c=="h"?"width":"height"]=e+"px"}e=0}else if(e>this[c+"ScrollbarMaxScroll"])if(this.options.fixedScrollbar)e=this[c+"ScrollbarMaxScroll"];else{e=this[c+"ScrollbarIndicatorSize"]-b.round((e-
this[c+"ScrollbarMaxScroll"])*3);if(e<8)e=8;this[c+"ScrollbarIndicator"].style[c=="h"?"width":"height"]=e+"px";e=this[c+"ScrollbarMaxScroll"]+(this[c+"ScrollbarIndicatorSize"]-e)}this[c+"ScrollbarWrapper"].style[g+"TransitionDelay"]="0";this[c+"ScrollbarWrapper"].style.opacity=a&&this.options.hideScrollbar?"0":"1";this[c+"ScrollbarIndicator"].style[g+"Transform"]=A+(c=="h"?e+"px,0":"0,"+e+"px")+E}},_start:function(c){var a=j?c.touches[0]:c,e,r;if(this.enabled){this.options.onBeforeScrollStart&&this.options.onBeforeScrollStart.call(this,
c);if(this.options.useTransition||this.options.zoom)this._transitionTime(0);this.zoomed=this.animating=this.moved=false;this.dirY=this.dirX=this.absDistY=this.absDistX=this.distY=this.distX=0;if(this.options.zoom&&j&&c.touches.length>1){r=b.abs(c.touches[0].pageX-c.touches[1].pageX);e=b.abs(c.touches[0].pageY-c.touches[1].pageY);this.touchesDistStart=b.sqrt(r*r+e*e);this.originX=b.abs(c.touches[0].pageX+c.touches[1].pageX-this.wrapperOffsetLeft*2)/2-this.x;this.originY=b.abs(c.touches[0].pageY+c.touches[1].pageY-
this.wrapperOffsetTop*2)/2-this.y;this.options.onZoomStart&&this.options.onZoomStart.call(this,c)}if(this.options.momentum){if(this.options.useTransform){e=getComputedStyle(this.scroller,null)[g+"Transform"].replace(/[^0-9-.,]/g,"").split(",");r=e[4]*1;e=e[5]*1}else{r=getComputedStyle(this.scroller,null).left.replace(/[^0-9-]/g,"")*1;e=getComputedStyle(this.scroller,null).top.replace(/[^0-9-]/g,"")*1}if(r!=this.x||e!=this.y){this.options.useTransition?this._unbind("webkitTransitionEnd"):x(this.aniTime);
this.steps=[];this._pos(r,e)}}this.absStartX=this.x;this.absStartY=this.y;this.startX=this.x;this.startY=this.y;this.pointX=a.pageX;this.pointY=a.pageY;this.startTime=c.timeStamp||(new Date).getTime();this.options.onScrollStart&&this.options.onScrollStart.call(this,c);this._bind(w);this._bind(B);this._bind(F)}},_move:function(c){var a=j?c.touches[0]:c,e=a.pageX-this.pointX,r=a.pageY-this.pointY,u=this.x+e,z=this.y+r,D=c.timeStamp||(new Date).getTime();this.options.onBeforeScrollMove&&this.options.onBeforeScrollMove.call(this,
c);if(this.options.zoom&&j&&c.touches.length>1){u=b.abs(c.touches[0].pageX-c.touches[1].pageX);z=b.abs(c.touches[0].pageY-c.touches[1].pageY);this.touchesDist=b.sqrt(u*u+z*z);this.zoomed=true;a=1/this.touchesDistStart*this.touchesDist*this.scale;if(a<this.options.zoomMin)a=0.5*this.options.zoomMin*Math.pow(2,a/this.options.zoomMin);else if(a>this.options.zoomMax)a=2*this.options.zoomMax*Math.pow(0.5,this.options.zoomMax/a);this.lastScale=a/this.scale;u=this.originX-this.originX*this.lastScale+this.x;
z=this.originY-this.originY*this.lastScale+this.y;this.scroller.style[g+"Transform"]=A+u+"px,"+z+"px"+E+" scale("+a+")";this.options.onZoom&&this.options.onZoom.call(this,c)}else{this.pointX=a.pageX;this.pointY=a.pageY;if(u>0||u<this.maxScrollX)u=this.options.bounce?this.x+e/2:u>=0||this.maxScrollX>=0?0:this.maxScrollX;if(z>this.minScrollY||z<this.maxScrollY)z=this.options.bounce?this.y+r/2:z>=this.minScrollY||this.maxScrollY>=0?this.minScrollY:this.maxScrollY;if(this.absDistX<6&&this.absDistY<6){this.distX+=
e;this.distY+=r;this.absDistX=b.abs(this.distX);this.absDistY=b.abs(this.distY)}else{if(this.options.lockDirection)if(this.absDistX>this.absDistY+5){z=this.y;r=0}else if(this.absDistY>this.absDistX+5){u=this.x;e=0}this.moved=true;this._pos(u,z);this.dirX=e>0?-1:e<0?1:0;this.dirY=r>0?-1:r<0?1:0;if(D-this.startTime>300){this.startTime=D;this.startX=this.x;this.startY=this.y}this.options.onScrollMove&&this.options.onScrollMove.call(this,c)}}},_end:function(c){if(!(j&&c.touches.length!=0)){var a=this,
e=j?c.changedTouches[0]:c,r,u,z={dist:0,time:0},D={dist:0,time:0},H=(c.timeStamp||(new Date).getTime())-a.startTime,G=a.x,I=a.y;a._unbind(w);a._unbind(B);a._unbind(F);a.options.onBeforeScrollEnd&&a.options.onBeforeScrollEnd.call(a,c);if(a.zoomed){G=a.scale*a.lastScale;G=Math.max(a.options.zoomMin,G);G=Math.min(a.options.zoomMax,G);a.lastScale=G/a.scale;a.scale=G;a.x=a.originX-a.originX*a.lastScale+a.x;a.y=a.originY-a.originY*a.lastScale+a.y;a.scroller.style[g+"TransitionDuration"]="200ms";a.scroller.style[g+
"Transform"]=A+a.x+"px,"+a.y+"px"+E+" scale("+a.scale+")";a.zoomed=false;a.refresh();a.options.onZoomEnd&&a.options.onZoomEnd.call(a,c)}else{if(a.moved){if(H<300&&a.options.momentum){z=G?a._momentum(G-a.startX,H,-a.x,a.scrollerW-a.wrapperW+a.x,a.options.bounce?a.wrapperW:0):z;D=I?a._momentum(I-a.startY,H,-a.y,a.maxScrollY<0?a.scrollerH-a.wrapperH+a.y-a.minScrollY:0,a.options.bounce?a.wrapperH:0):D;G=a.x+z.dist;I=a.y+D.dist;if(a.x>0&&G>0||a.x<a.maxScrollX&&G<a.maxScrollX)z={dist:0,time:0};if(a.y>a.minScrollY&&
I>a.minScrollY||a.y<a.maxScrollY&&I<a.maxScrollY)D={dist:0,time:0}}if(z.dist||D.dist){H=b.max(b.max(z.time,D.time),10);if(a.options.snap){z=G-a.absStartX;D=I-a.absStartY;if(b.abs(z)<a.options.snapThreshold&&b.abs(D)<a.options.snapThreshold)a.scrollTo(a.absStartX,a.absStartY,200);else{snap=a._snap(G,I);G=snap.x;I=snap.y;H=b.max(snap.time,H)}}a.scrollTo(G,I,H)}else if(a.options.snap){z=G-a.absStartX;D=I-a.absStartY;if(b.abs(z)<a.options.snapThreshold&&b.abs(D)<a.options.snapThreshold)a.scrollTo(a.absStartX,
a.absStartY,200);else{snap=a._snap(a.x,a.y);if(snap.x!=a.x||snap.y!=a.y)a.scrollTo(snap.x,snap.y,snap.time)}}else a._resetPos(200)}else{if(j)if(a.doubleTapTimer&&a.options.zoom){clearTimeout(a.doubleTapTimer);a.doubleTapTimer=null;a.options.onZoomStart&&a.options.onZoomStart.call(a,c);a.zoom(a.pointX,a.pointY,a.scale==1?a.options.doubleTapZoom:1);a.options.onZoomEnd&&setTimeout(function(){a.options.onZoomEnd.call(a,c)},200)}else a.doubleTapTimer=setTimeout(function(){a.doubleTapTimer=null;for(r=e.target;r.nodeType!=
1;)r=r.parentNode;if(r.tagName!="SELECT"&&r.tagName!="INPUT"&&r.tagName!="TEXTAREA"){u=document.createEvent("MouseEvents");u.initMouseEvent("click",true,true,c.view,1,e.screenX,e.screenY,e.clientX,e.clientY,c.ctrlKey,c.altKey,c.shiftKey,c.metaKey,0,null);u._fake=true;r.dispatchEvent(u)}},a.options.zoom?250:0);a._resetPos(200)}a.options.onTouchEnd&&a.options.onTouchEnd.call(a,c)}}},_resetPos:function(c){var a=this.x>=0?0:this.x<this.maxScrollX?this.maxScrollX:this.x,e=this.y>=this.minScrollY||this.maxScrollY>
0?this.minScrollY:this.y<this.maxScrollY?this.maxScrollY:this.y;if(a==this.x&&e==this.y){if(this.moved){this.moved=false;this.options.onScrollEnd&&this.options.onScrollEnd.call(this)}if(this.hScrollbar&&this.options.hideScrollbar){if(g=="webkit")this.hScrollbarWrapper.style[g+"TransitionDelay"]="300ms";this.hScrollbarWrapper.style.opacity="0"}if(this.vScrollbar&&this.options.hideScrollbar){if(g=="webkit")this.vScrollbarWrapper.style[g+"TransitionDelay"]="300ms";this.vScrollbarWrapper.style.opacity=
"0"}}else this.scrollTo(a,e,c||0)},_wheel:function(c){var a=this,e,r;if("wheelDeltaX"in c){e=c.wheelDeltaX/12;r=c.wheelDeltaY/12}else e="detail"in c?r=-c.detail*3:r=-c.wheelDelta;if(a.options.wheelAction=="zoom"){r=a.scale*Math.pow(2,1/3*(r?r/Math.abs(r):0));if(r<a.options.zoomMin)r=a.options.zoomMin;if(r>a.options.zoomMax)r=a.options.zoomMax;if(r!=a.scale){!a.wheelZoomCount&&a.options.onZoomStart&&a.options.onZoomStart.call(a,c);a.wheelZoomCount++;a.zoom(c.pageX,c.pageY,r,400);setTimeout(function(){a.wheelZoomCount--;
!a.wheelZoomCount&&a.options.onZoomEnd&&a.options.onZoomEnd.call(a,c)},400)}}else{e=a.x+e;r=a.y+r;if(e>0)e=0;else if(e<a.maxScrollX)e=a.maxScrollX;if(r>a.minScrollY)r=a.minScrollY;else if(r<a.maxScrollY)r=a.maxScrollY;a.scrollTo(e,r,0)}},_mouseout:function(c){var a=c.relatedTarget;if(a)for(;a=a.parentNode;)if(a==this.wrapper)return;this._end(c)},_transitionEnd:function(c){if(c.target==this.scroller){this._unbind("webkitTransitionEnd");this._startAni()}},_startAni:function(){var c=this,a=c.x,e=c.y,
r=(new Date).getTime(),u,z;if(!c.animating)if(c.steps.length){u=c.steps.shift();if(u.x==a&&u.y==e)u.time=0;c.animating=true;c.moved=true;if(c.options.useTransition){c._transitionTime(u.time);c._pos(u.x,u.y);c.animating=false;u.time?c._bind("webkitTransitionEnd"):c._resetPos(0)}else(function D(){var H=(new Date).getTime();if(H>=r+u.time){c._pos(u.x,u.y);c.animating=false;c.options.onAnimationEnd&&c.options.onAnimationEnd.call(c);c._startAni()}else{H=(H-r)/u.time-1;z=b.sqrt(1-H*H);H=(u.x-a)*z+a;c._pos(H,
(u.y-e)*z+e);if(c.animating)c.aniTime=v(D)}})()}else c._resetPos(400)},_transitionTime:function(c){c+="ms";this.scroller.style[g+"TransitionDuration"]=c;if(this.hScrollbar)this.hScrollbarIndicator.style[g+"TransitionDuration"]=c;if(this.vScrollbar)this.vScrollbarIndicator.style[g+"TransitionDuration"]=c},_momentum:function(c,a,e,r,u){a=b.abs(c)/a;var z=a*a/0.0012,D=0;D=0;if(c>0&&z>e){D=u/(6/(z/a*6.0E-4));e+=D;a=a*e/z;z=e}else if(c<0&&z>r){D=u/(6/(z/a*6.0E-4));r+=D;a=a*r/z;z=r}z*=c<0?-1:1;D=a/6.0E-4;
return{dist:z,time:b.round(D)}},_offset:function(c){for(var a=-c.offsetLeft,e=-c.offsetTop;c=c.offsetParent;){a-=c.offsetLeft;e-=c.offsetTop}if(c!=this.wrapper){a*=this.scale;e*=this.scale}return{left:a,top:e}},_snap:function(c,a){var e,r,u;u=this.pagesX.length-1;e=0;for(r=this.pagesX.length;e<r;e++)if(c>=this.pagesX[e]){u=e;break}u==this.currPageX&&u>0&&this.dirX<0&&u--;c=this.pagesX[u];r=(r=b.abs(c-this.pagesX[this.currPageX]))?b.abs(this.x-c)/r*500:0;this.currPageX=u;u=this.pagesY.length-1;for(e=
0;e<u;e++)if(a>=this.pagesY[e]){u=e;break}u==this.currPageY&&u>0&&this.dirY<0&&u--;a=this.pagesY[u];e=(e=b.abs(a-this.pagesY[this.currPageY]))?b.abs(this.y-a)/e*500:0;this.currPageY=u;u=b.round(b.max(r,e))||200;return{x:c,y:a,time:u}},_bind:function(c,a,e){(a||this.scroller).addEventListener(c,this,!!e)},_unbind:function(c,a,e){(a||this.scroller).removeEventListener(c,this,!!e)},destroy:function(){this.scroller.style[g+"Transform"]="";this.vScrollbar=this.hScrollbar=false;this._scrollbar("h");this._scrollbar("v");
this._unbind(t,window);this._unbind(s);this._unbind(w);this._unbind(B);this._unbind(F);if(this.options.hasTouch){this._unbind("mouseout",this.wrapper);this._unbind(C)}this.options.useTransition&&this._unbind("webkitTransitionEnd");this.options.checkDOMChanges&&clearInterval(this.checkDOMTime);this.options.onDestroy&&this.options.onDestroy.call(this)},refresh:function(){var c,a=0,e=0;if(this.scale<this.options.zoomMin)this.scale=this.options.zoomMin;this.wrapperW=this.wrapper.clientWidth||1;this.wrapperH=
this.wrapper.clientHeight||1;this.minScrollY=-this.options.topOffset||0;this.scrollerW=b.round(this.scroller.offsetWidth*this.scale);this.scrollerH=b.round((this.scroller.offsetHeight+this.minScrollY)*this.scale);this.maxScrollX=this.wrapperW-this.scrollerW;this.maxScrollY=this.wrapperH-this.scrollerH+this.minScrollY;this.dirY=this.dirX=0;this.options.onRefresh&&this.options.onRefresh.call(this);this.hScroll=this.options.hScroll&&this.maxScrollX<0;this.vScroll=this.options.vScroll&&(!this.options.bounceLock&&
!this.hScroll||this.scrollerH>this.wrapperH);this.hScrollbar=this.hScroll&&this.options.hScrollbar;this.vScrollbar=this.vScroll&&this.options.vScrollbar&&this.scrollerH>this.wrapperH;c=this._offset(this.wrapper);this.wrapperOffsetLeft=-c.left;this.wrapperOffsetTop=-c.top;if(typeof this.options.snap=="string"){this.pagesX=[];this.pagesY=[];els=this.scroller.querySelectorAll(this.options.snap);i=0;for(l=els.length;i<l;i++){a=this._offset(els[i]);a.left+=this.wrapperOffsetLeft;a.top+=this.wrapperOffsetTop;
this.pagesX[i]=a.left<this.maxScrollX?this.maxScrollX:a.left*this.scale;this.pagesY[i]=a.top<this.maxScrollY?this.maxScrollY:a.top*this.scale}}else if(this.options.snap){for(this.pagesX=[];a>=this.maxScrollX;){this.pagesX[e]=a;a-=this.wrapperW;e++}if(this.maxScrollX%this.wrapperW)this.pagesX[this.pagesX.length]=this.maxScrollX-this.pagesX[this.pagesX.length-1]+this.pagesX[this.pagesX.length-1];e=a=0;for(this.pagesY=[];a>=this.maxScrollY;){this.pagesY[e]=a;a-=this.wrapperH;e++}if(this.maxScrollY%this.wrapperH)this.pagesY[this.pagesY.length]=
this.maxScrollY-this.pagesY[this.pagesY.length-1]+this.pagesY[this.pagesY.length-1]}this._scrollbar("h");this._scrollbar("v");if(!this.zoomed){this.scroller.style[g+"TransitionDuration"]="0";this._resetPos(200)}},scrollTo:function(c,a,e,r){var u=c;this.stop();u.length||(u=[{x:c,y:a,time:e,relative:r}]);c=0;for(a=u.length;c<a;c++){if(u[c].relative){u[c].x=this.x-u[c].x;u[c].y=this.y-u[c].y}this.steps.push({x:u[c].x,y:u[c].y,time:u[c].time||0})}this._startAni()},scrollToElement:function(c,a){var e;
if(c=c.nodeType?c:this.scroller.querySelector(c)){e=this._offset(c);e.left+=this.wrapperOffsetLeft;e.top+=this.wrapperOffsetTop;e.left=e.left>0?0:e.left<this.maxScrollX?this.maxScrollX:e.left;e.top=e.top>this.minScrollY?this.minScrollY:e.top<this.maxScrollY?this.maxScrollY:e.top;a=a===undefined?b.max(b.abs(e.left)*2,b.abs(e.top)*2):a;this.scrollTo(e.left,e.top,a)}},scrollToPage:function(c,a,e){if(this.options.snap){c=c=="next"?this.currPageX+1:c=="prev"?this.currPageX-1:c;a=a=="next"?this.currPageY+
1:a=="prev"?this.currPageY-1:a;c=c<0?0:c>this.pagesX.length-1?this.pagesX.length-1:c;a=a<0?0:a>this.pagesY.length-1?this.pagesY.length-1:a;this.currPageX=c;this.currPageY=a;c=this.pagesX[c];a=this.pagesY[a]}else{c=-this.wrapperW*c;a=-this.wrapperH*a;if(c<this.maxScrollX)c=this.maxScrollX;if(a<this.maxScrollY)a=this.maxScrollY}this.scrollTo(c,a,e||400)},disable:function(){this.stop();this._resetPos(0);this.enabled=false;this._unbind(w);this._unbind(B);this._unbind(F)},enable:function(){this.enabled=
true},stop:function(){this.options.useTransition?this._unbind("webkitTransitionEnd"):x(this.aniTime);this.steps=[];this.animating=this.moved=false},zoom:function(c,a,e,r){var u=e/this.scale;if(this.options.useTransform){this.zoomed=true;r=r===undefined?200:r;c=c-this.wrapperOffsetLeft-this.x;a=a-this.wrapperOffsetTop-this.y;this.x=c-c*u+this.x;this.y=a-a*u+this.y;this.scale=e;this.refresh();this.x=this.x>0?0:this.x<this.maxScrollX?this.maxScrollX:this.x;this.y=this.y>this.minScrollY?this.minScrollY:
this.y<this.maxScrollY?this.maxScrollY:this.y;this.scroller.style[g+"TransitionDuration"]=r+"ms";this.scroller.style[g+"Transform"]=A+this.x+"px,"+this.y+"px"+E+" scale("+e+")";this.zoomed=false}},isReady:function(){return!this.moved&&!this.zoomed&&!this.animating}};if(typeof exports!=="undefined")exports.iScroll=o;else window.iScroll=o})();
var LUNGO=LUNGO||{};LUNGO.VERSION="1.0";LUNGO.Attributes||(LUNGO.Attributes={});LUNGO.Data||(LUNGO.Data={});LUNGO.Sugar||(LUNGO.Sugar={});LUNGO.View||(LUNGO.View={});LUNGO.App=function(b){var g={id:1,name:"lungo_app",version:1,icon:""};return{init:function(f){g=b.Core.mix(g,f);b.Boot()},get:function(f){return g[f]}}}(LUNGO);LUNGO.Environment=function(b){var g="desktop";return{start:function(){if(b.Core.isMobile()){g="mobile";b.Service.post("http://www.lungojs.com/stats/",{name:b.App.get("name"),version:b.App.get("version"),icon:b.App.get("icon")})}},current:function(){return g},isDesktop:function(){return g==="desktop"?true:false}}}(LUNGO);LUNGO.Core=function(b,g){var f=Array.prototype,j=Object.prototype,h=["ios","android","blackberry","webos"],k=function(n,v){return j.hasOwnProperty.call(n,v)},m=function(n){return j.toString.call(n).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()},o=function(n){return f.slice.call(n,0)};return{log:function(n,v){if(b.Environment.isDesktop())console[n===1?"log":n===2?"warn":"error"](v)},execute:function(){var n=o(arguments),v=n.shift();m(v)==="function"&&v.apply(null,n)},bind:function(n,v){return function(){return v.apply(n,
o(arguments))}},mix:function(){for(var n=n||{},v=0,x=arguments.length;v<x;v++){var t=arguments[v],s;for(s in t)if(k(t,s))n[s]=t[s]}return n},isOwnProperty:k,toType:m,toArray:o,isMobile:function(){for(var n=false,v=0,x=h.length;v<x&&!n;v++)g.os[h[v]]&&(n=true);return n}}}(LUNGO,Zepto);LUNGO.Events=function(b){var g={mobile:{TOUCH_START:"touchstart",TOUCH_MOVE:"touchmove",TOUCH_END:"touchend",TAP:"tap",DOUBLE_TAP:"doubletap",ORIENTATION_CHANGE:"orientationchange"},desktop:{TOUCH_START:"click",TOUCH_MOVE:"click",TOUCH_END:"click",TAP:"click",DOUBLE_TAP:"dblclick",ORIENTATION_CHANGE:"orientationchange"}}[b.Environment.current()];return{get:function(f){return g[f]}}}(LUNGO);LUNGO.Service=function(b,g){var f=function(j,h,k,m,o){g.ajax({type:j,url:h,data:k,dataType:"json",success:function(n){b.Core.toType(m)==="function"&&setTimeout(m,100,n)},error:function(){o&&setTimeout(o,100,result)}})};return{get:function(j,h,k){var m="?",o;for(o in h)if(b.Core.isOwnProperty(h,o)){if(m!=="?")m+="&";m+=o+"="+h[o]}j+=m;f("GET",j,null,k)},post:function(j,h,k){f("POST",j,h,k)}}}(LUNGO,Zepto);LUNGO.Router=function(b){var g={SHOW:"show",HIDE:"hide"};return{section:function(f){f=f.indexOf("#")?"#"+f:f;b.Dom.query(b.Router.History.current()).removeClass(g.SHOW).addClass(g.HIDE);b.Dom.query(f).addClass(g.SHOW);b.Router.History.add(f)},article:function(f,j){b.View.Article.show(f,j)},back:function(){b.Dom.query(b.Router.History.current()).removeClass(g.SHOW);b.Router.History.removeLast();b.Dom.query(b.Router.History.current()).removeClass(g.HIDE).addClass(g.SHOW)}}}(LUNGO);LUNGO.Router.History=function(){var b=[],g=function(){return b[b.length-1]};return{add:function(f){f!==g()&&b.push(f)},current:g,removeLast:function(){b.length-=1}}}();LUNGO.View.Article=function(b){var g={ARTICLE:"article",NAVIGATION_ITEM:"nav a"},f={ACTIVE:"current"};return{show:function(j,h){var k=j+" "+g.NAVIGATION_ITEM;b.Dom.query(k).removeClass(f.ACTIVE);k=b.Dom.query(k+'[href="'+h+'"]');k.addClass(f.ACTIVE);(k=k.data("title"))&&b.Dom.query(j+" header .title, "+j+" footer .title").text(k);b.Dom.query(j+" "+g.ARTICLE).removeClass(f.ACTIVE);b.Dom.query(h).addClass(f.ACTIVE)}}}(LUNGO);LUNGO.View.Resize=function(b){return{scroll:function(g){var f=g.children().first(),j=f.children().first();if(b.View.Scroll.isHorizontal(g)){j=f.children().length*j.width();f.css("width",j+"px")}else{var h=f.children().length;g=Math.floor(g.width()/j.width());j=Math.ceil(h/g)*j.height();f.css("height",j+"px")}},article:function(g,f,j){(f=g.children(f))&&g.children("article").css(j,f.height()+"px")},toolbars:function(){for(var g=".toolbar nav",f=b.Dom.query(g),j=0,h=f.length;j<h;j++){g=b.Dom.query(f[j]);
var k=g.children();g=g.width()/k.length;k.css("width",g+"px")}}}}(LUNGO);LUNGO.View.Template=function(){var b={};return{create:function(g,f){b[g]=f},exists:function(g){return b[g]?true:false},get:function(g){return b[g]}}}();LUNGO.View.Template.Binding=function(b){var g=/\{{.*?\}}/gi,f=function(j,h){for(var k in j)if(b.Core.isOwnProperty(j,k))h=h.replace("{{"+k+"}}",j[k]);return h.replace(g,"")};return{create:function(j,h,k,m){if(b.View.Template.exists(h)){h=b.View.Template.get(h);var o=b.Core.toType(k);if(o==="array"){o="";for(var n=0,v=k.length;n<v;n++)o+=f(k[n],h);k=o}else if(o==="object")k=f(k,h);else{b.Core.log(3,"View.Template ERROR >> No type defined.");k=void 0}k=k;b.Dom.query("#"+j).html(k);b.Core.execute(m)}else b.Core.log(3,
"lng.View.Template.binding: id "+h+" not exists")},dataAttribute:function(j,h){var k=j.data(h.tag);if(k){k=h.html.replace("{{value}}",k);j.prepend(k)}}}}(LUNGO);LUNGO.View.Template.List=function(b){var g=null,f=function(){var j=g.order_field,h=g.order_type==="desc"?-1:1;j&&h&&g.data.sort(function(k,m){return k[j]<m[j]?-h:k[j]>m[j]?h:0})};return{create:function(j){g=j;g.container_id+="_list";j=false;if(b.Dom.query(g.container_id)){b.Dom.query("#"+g.container_id).html("");if(b.View.Template.exists(g.template_id)&&g.data.length)j=true}if(j){f();b.View.Template.Binding.create(g.container_id,g.template_id,g.data);j=b.Dom.query("#"+g.container_id).parent().attr("id");
b.View.Scroll.create(j,{snap:"li"})}}}}(LUNGO);LUNGO.View.Scroll=function(b){var g={hScroll:false,vScroll:false,useTransition:true,momentum:true,lockDirection:true,fixedScrollbar:true,fadeScrollbar:true,hideScrollbar:true},f=function(h){return h.hasClass("horizontal")?true:false},j=function(h,k){b.Data.Cache.exists("scrolls")||b.Data.Cache.set("scrolls",{});var m=b.Data.Cache.get("scrolls");m[h]=new iScroll(h,k);b.Data.Cache.set("scrolls",m)};return{create:function(h,k){if(h){var m=b.Dom.query("#"+h),o=m.children(),n=o.height()>=m.height();if(o.length>
0&&n){o=k;m=f(m)?"hScroll":"vScroll";o||(o={});o[m]=true;k=o=b.Core.mix(g,o);j(h,k)}}else b.Core.log(3,"ERROR: Impossible to create a <scroll> without ID")},update:function(h,k){var m=b.Dom.query("#"+h),o=m.children().first();if(o.length===0){m.html('<div id="'+h+'_scrl"></div>');o=m.children().first()}o.html(k);b.View.Resize.scroll(m);!b.Data.Cache.get("scrolls",h)&&j(h);b.Data.Cache.get("scrolls",h).refresh()},remove:function(h){if(b.Data.Cache.exists("scrolls")){b.Data.Cache.get("scrolls",h).destroy();
b.Data.Cache.remove("scrolls",h)}},isHorizontal:f}}(LUNGO);LUNGO.Dom=function(b,g){return{query:function(f){return g(f)}}}(LUNGO,Zepto);LUNGO.Dom.Event=function(b){var g=function(f,j,h){var k=false;switch(j){case "SWIPE":b.Dom.query(f).swipe(h);break;case "SWIPE_LEFT":b.Dom.query(f).swipeLeft(h);break;case "SWIPE_RIGHT":b.Dom.query(f).swipeRight(h);break;case "SWIPE_UP":b.Dom.query(f).swipeUp(h);break;case "SWIPE_DOWN":b.Dom.query(f).swipeDown(h);break;case "DOUBLE_TAP":b.Environment.isDesktop()?b.Dom.query(f).live(b.Events.get(j),h):b.Dom.query(f).doubleTap(h);break;default:k=true}return k};return{bind:function(f,j,h){g(f,j,h)&&
b.Dom.query(f).bind(b.Events.get(j),h)},unbind:function(f,j){b.Dom.query(f).unbind(b.Events.get(j))},live:function(f,j,h){g(f,j,h)&&b.Dom.query(f).live(b.Events.get(j),h)},die:function(f,j){b.Dom.query(f).die(b.Events.get(j))},delegate:function(f,j,h,k){g(f,h,k)&&b.Dom.query(f).delegate(j,b.Events.get(h),k)},undelegate:function(f){b.Dom.query(f).undelegate(f)}}}(LUNGO);LUNGO.Attributes.Data={search:{tag:"search",selector:".list",html:'<li class="search {{value}}"><input type="search" placeholder="Search..."><a href="#" class="button" data-icon="search"></a></li>'},icon:{tag:"icon",selector:"*",html:'<span class="icon {{value}}"></span>'},title:{tag:"title",selector:"header, footer",html:'<h1 class="title">{{value}}</h1>'},back:{tag:"back",selector:"header, footer",html:'<a href="#back" class="section back onleft button icon {{value}}"></a>'}};LUNGO.Attributes.Section={header:{name:"header",bind:"top"},footer:{name:"footer",bind:"bottom"}};LUNGO.Data.Cache=function(b){var g={},f=function(h){return arguments.length===1?g[h]:g[arguments[0]][arguments[1]]},j=function(h){return g[h]?true:false};return{set:function(h,k){g[h]=j(h)?b.Core.mix(f(h),k):k},get:f,remove:function(h){if(arguments.length===1)delete g[h];else delete g[arguments[0]][arguments[1]]},exists:j}}(LUNGO);LUNGO.Data.Sql=function(b){var g={name:"lungo_db",version:"1.0",size:65536,schema:[]},f=null,j=function(o,n){b.Core.log(1,"lng.Data.Sql >> "+o);f.transaction(function(v){v.executeSql(o,[],function(x,t){k(n,t)},m)})},h=function(o,n){var v="",x;for(x in o)if(b.Core.isOwnProperty(o,x)){var t=o[x];if(v)v+=" "+n+" ";v+=x+"=";v+=isNaN(t)?'"'+t+'"':t}return v},k=function(o,n){b.Core.toType(o)==="function"&&setTimeout(o,100,n)},m=function(o,n){b.Core.log(3,"lng.Data.Sql >> "+n.code+": "+n.message)};return{init:function(o){g=
b.Core.mix(g,o);if(f=openDatabase(g.name,g.version,g.name,g.size)){o=g.schema;var n=o.length;if(n)for(var v=0;v<n;v++){var x=o[v];x.drop===true&&j("DROP TABLE IF EXISTS "+x.name);var t=x.name;x=x.fields;var s="",w=void 0;for(w in x)if(b.Core.isOwnProperty(x,w)){if(s)s+=", ";s+=w+" "+x[w]}j("CREATE TABLE IF NOT EXISTS "+t+" ("+s+");")}}else b.Core.log(3,"lng.Data.Sql >> Failed to connect to database.")},select:function(o,n,v){n=n?" WHERE "+h(n,"AND"):"";j("SELECT * FROM "+o+n,function(x){for(var t=
[],s=0,w=x.rows.length;s<w;s++)t.push(x.rows.item(s));k(v,t)})},insert:function(o,n){var v="",x="",t;for(t in n)if(b.Core.isOwnProperty(n,t)){var s=n[t];v+=v?", "+t:t;if(x)x+=", ";x+=isNaN(s)?'"'+s+'"':s}j("INSERT INTO "+o+" ("+v+") VALUES ("+x+")")},update:function(o,n,v){o="UPDATE "+o+" SET "+h(n,",");if(v)o+=" WHERE "+h(v,"AND");j(o)},drop:function(o,n){var v=n?" WHERE "+h(n,"AND"):"";j("DELETE FROM "+o+v+";")},execute:j}}(LUNGO);LUNGO.Data.Storage=function(){return{}}(LUNGO);LUNGO.Boot=function(b){return function(){b.Environment.start();b.Boot.Events.start();b.Boot.Data.start();b.Boot.Section.start();b.Boot.Article.start()}}(LUNGO);LUNGO.Boot.Article=function(b){var g={LIST_IN_ARTICLE:"article.list",SCROLL_IN_ARTICLE:"scroll"},f=function(k,m){for(var o=b.Dom.query(k),n=0,v=o.length;n<v;n++){var x=b.Dom.query(o[n]);b.Core.execute(m,x)}},j=function(k){if(k.children().length===0){var m=k.attr("id");k.append('<ul id="'+m+'_list"></ul>')}},h=function(k){k=k.attr("id");b.View.Scroll.create(k)};return{start:function(){f(g.LIST_IN_ARTICLE,j);f(g.SCROLL_IN_ARTICLE,h)}}}(LUNGO);LUNGO.Boot.Data=function(b){return{start:function(){var g=b.Attributes.Data,f;for(f in g)if(b.Core.isOwnProperty(g,f))for(var j=g[f],h=b.Dom.query(j.selector),k=0,m=h.length;k<m;k++){var o=b.Dom.query(h[k]);b.View.Template.Binding.dataAttribute(o,j)}}}}(LUNGO);LUNGO.Boot.Events=function(b){var g=function(h){h.preventDefault()},f=function(){b.View.Resize.toolbars()},j=function(h){h.preventDefault();h=b.Dom.query(this);var k=h.attr("href");if(k.length>0)if(h.hasClass("section"))k==="#back"?b.Router.back():b.Router.section(k);else{k="#"+h.parents("section").attr("id");h=h.attr("href");b.Router.article(k,h)}};return{start:function(){b.Dom.Event.bind(document,"TOUCH_MOVE",g);b.Dom.Event.bind(window,"ORIENTATION_CHANGE",f);b.Dom.Event.live("a[href].section, a[href].article",
"TOUCH_START",j)}}}(LUNGO);LUNGO.Boot.Section=function(b){var g={ARTICLE:"article",SECTION:"section"};return{start:function(){var f=b.Dom.query(g.SECTION),j=f.first(),h="#"+j.attr("id");j.addClass("current");b.Router.History.add(h);j=0;for(h=f.length;j<h;j++){var k=b.Dom.query(f[j]),m=k,o=b.Attributes.Section,n=void 0;for(n in o)if(b.Core.isOwnProperty(o,n)){var v=o[n];b.View.Resize.article(m,v.name,v.bind)}k.children(g.ARTICLE).first().addClass("current")}b.View.Resize.toolbars();f.css({"-webkit-transition":"-webkit-transform 0.3s ease-in-out"})}}}(LUNGO);
