(function(){$.jQTouch=function(t){function e(t){"string"==typeof t.selector&&"string"==typeof t.name&&P.push(t)}function n(t){"string"==typeof t.name&&"function"==typeof t.isSupported&&"function"==typeof t.fn&&O.push(t)}function o(t,e){A.unshift({page:t,animation:e,hash:"#"+t.attr("id"),id:t.attr("id")})}function a(t){var e=$(t.target);e.is(q.join(", "))||(e=$(t.target).closest(q.join(", "))),e&&e.attr("href")&&!e.isExternalLink()&&t.preventDefault(),$.support.touch||$(t.target).trigger("tap",t)}function r(t,e,n,a){function r(){var o=H;$.support.animationEvents&&n&&M.useAnimations?(t.unbind("webkitAnimationEnd",r),t.removeClass(s+" out inmotion"),s&&e.removeClass(s),E.removeClass("animating animating3d"),M.trackScrollPositions===!0&&(e.css("top",-e.data("lastScroll")),setTimeout(function(){e.css("top",0),window.scroll(0,e.data("lastScroll")),$(".scroll",e).each(function(){this.scrollTop=-$(this).data("lastScroll")})},0))):(t.removeClass(s+" out inmotion"),s&&e.removeClass(s),o+=260),setTimeout(function(){e.removeClass("in"),window.scroll(0,0)},o),t.unselect(),e.trigger("pageAnimationEnd",{direction:"in",animation:n,back:a}),t.trigger("pageAnimationEnd",{direction:"out",animation:n,back:a})}if(a=a?a:!1,void 0===e||0===e.length)return $.fn.unselect(),!1;if(e.hasClass("current"))return $.fn.unselect(),!1;if($(":focus").trigger("blur"),t.trigger("pageAnimationStart",{direction:"out",back:a}),e.trigger("pageAnimationStart",{direction:"in",back:a}),$.support.animationEvents&&n&&M.useAnimations){!$.support.transform3d&&n.is3d&&(n.name=M.defaultAnimation);var s=n.name,u=n.is3d?"animating3d":"";a&&(s=s.replace(/left|right|up|down|in|out/,i)),t.bind("webkitAnimationEnd",r),E.addClass("animating "+u);var c=window.pageYOffset;M.trackScrollPositions===!0&&e.css("top",window.pageYOffset-(e.data("lastScroll")||0)),e.addClass(s+" in current"),t.removeClass("current").addClass(s+" out inmotion"),M.trackScrollPositions===!0&&(t.data("lastScroll",c),$(".scroll",t).each(function(){$(this).data("lastScroll",this.scrollTop)}))}else e.addClass("current in"),t.removeClass("current"),r();return Y=e,a?A.shift():o(Y,n),g(Y.attr("id")),!0}function i(t){var e={up:"down",down:"up",left:"right",right:"left","in":"out",out:"in"};return e[t]||t}function s(){return D}function u(){1>A.length,1===A.length&&window.history.go(-1);var t=A[0],e=A[1];return r(t.page,e.page,t.animation,!0)?X:!1}function c(t,e){var n=A[0].page;if("string"==typeof e)for(var o=0,a=P.length;a>o;o++)if(P[o].name===e){e=P[o];break}if("string"==typeof t){var i=$(t);if(1>i.length)return b(t,{animation:e}),void 0;t=i}return r(n,t,e)?X:!1}function l(){return location.hash===A[0].hash?!0:""===location.hash?(u(),!0):A[1]&&location.hash===A[1].hash?(u(),!0):(c($(location.hash),M.defaultAnimation),void 0)}function d(){if(M.preloadImages)for(var t=M.preloadImages.length-1;t>=0;t--)(new Image).src=M.preloadImages[t];var e=M.addGlossToIcon?"":"-precomposed";M.icon&&(B+='<link rel="apple-touch-icon'+e+'" href="'+M.icon+'" />'),M.icon4&&(B+='<link rel="apple-touch-icon'+e+'" sizes="114x114" href="'+M.icon4+'" />'),M.startupScreen&&(B+='<link rel="apple-touch-startup-image" href="'+M.startupScreen+'" />'),M.fixedViewport&&(B+='<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>'),M.fullScreen&&(B+='<meta name="apple-mobile-web-app-capable" content="yes" />',M.statusBar&&(B+='<meta name="apple-mobile-web-app-status-bar-style" content="'+M.statusBar+'" />')),B&&x.prepend(B)}function p(){$.fn.isExternalLink=function(){var t=$(this);return"_blank"===t.attr("target")||"external"===t.attr("rel")||t.is('a[href^="http://maps.google.com"], a[href^="mailto:"], a[href^="tel:"], a[href^="javascript:"], a[href*="youtube.com/v"], a[href*="youtube.com/watch"]')},$.fn.makeActive=function(){return $(this).addClass("active")},$.fn.unselect=function(t){t?t.removeClass("active"):$(".active").removeClass("active")}}function f(t){for(var e,n=0,o=P.length;o>n;n++)if(t.is(P[n].selector)){e=P[n];break}return e||(e=M.defaultAnimation),e}function h(t,e){var n=null,o=document.createElement("div");return o.innerHTML=t,$(o).children().each(function(){var t=$(this);t.attr("id")||t.attr("id","page-"+ ++Q),$("#"+t.attr("id")).remove(),E.append(t),E.trigger("pageInserted",{page:t}),(t.hasClass("current")||!n)&&(n=t)}),null!==n?(c(n,e),n):!1}function m(){scrollTo(0,0),D=90===Math.abs(window.orientation)?"landscape":"portrait",E.removeClass("portrait landscape").addClass(D).trigger("turn",{orientation:D})}function g(t){M.updateHash&&(location.hash="#"+t.replace(/^#/,""))}function v(){$.support||($.support={}),$.support.animationEvents=window.WebKitAnimationEvent!==void 0,$.support.touch=window.TouchEvent!==void 0&&window.navigator.userAgent.indexOf("Mobile")>-1&&M.useFastTouch,$.support.transform3d=S(),$.support.ios5=C(),!$.support.touch,!$.support.transform3d;for(var t=0,r=I.length;r>t;t++){var i=I[t];$.isFunction(i)&&$.extend(X,i(X))}for(var s=0,u=L.length;u>s;s++)n(L[s]);j();for(var d=0,p=G.animations.length;p>d;d++){var f=G.animations[d];void 0!==M[f.name+"Selector"]&&(f.selector=M[f.name+"Selector"]),e(f)}q.push(M.touchSelector),q.push(M.backSelector),q.push(M.submitSelector),$(q.join(", ")).css("-webkit-touch-callout","none"),E=$("#jqt");var h=[];0===E.length&&(E=$(document.body).attr("id","jqt")),$.support.transform3d&&h.push("supports3d"),M.useTouchScroll&&($.support.ios5?h.push("touchscroll"):h.push("autoscroll")),M.fullScreenClass&&window.navigator.standalone===!0&&h.push(M.fullScreenClass,M.statusBar),E.addClass(h.join(" ")).bind("click",a).bind("orientationchange",m).bind("submit",w).bind("tap",k).bind($.support.touch?"touchstart":"mousedown",y).trigger("orientationchange"),$(window).bind("hashchange",l);var v=location.hash;Y=0===$("#jqt > .current").length?$("#jqt > *:first-child").addClass("current"):$("#jqt > .current"),g(Y.attr("id")),o(Y),1===$(v).length&&c(v)}function b(t,e){var n={data:null,method:"GET",animation:null,callback:null,$referrer:null},o=$.extend({},n,e);"#"!==t?$.ajax({url:t,data:o.data,type:o.method,success:function(t){var e=h(t,o.animation);e&&("GET"===o.method&&M.cacheGetRequests===!0&&o.$referrer&&o.$referrer.attr("href","#"+e.attr("id")),o.callback&&o.callback(!0))},error:function(){o.$referrer&&o.$referrer.unselect(),o.callback&&o.callback(!1)}}):o.$referrer&&o.$referrer.unselect()}function w(t,e){$(":focus").trigger("blur"),t.preventDefault();var n="string"==typeof t?$(t).eq(0):t.target?$(t.target):$(t);return n.length&&n.is(M.formSelector)&&n.attr("action")?(b(n.attr("action"),{data:n.serialize(),method:n.attr("method")||"POST",animation:f(n),callback:e}),!1):!0}function T(t){var e=t.closest("form");return 0!==e.length?(e.trigger("submit"),!1):!0}function S(){var t,e,n,o,a;return t=document.getElementsByTagName("head")[0],e=document.body,n=document.createElement("style"),n.textContent="@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-webkit-transform-3d){#jqt-3dtest{height:3px}}",o=document.createElement("div"),o.id="jqt-3dtest",t.appendChild(n),e.appendChild(o),a=3===o.offsetHeight,n.parentNode.removeChild(n),o.parentNode.removeChild(o),a}function C(){var t=!1,e=/OS (\d+)(_\d+)* like Mac OS X/i,n=window.navigator.userAgent;return e.test(n)&&(t=e.exec(n)[1]>=5),t}function y(t){var e=$(t.target),n=q.join(", ");e.is(n)||(e=e.closest(n)),e.length&&e.attr("href")&&e.addClass("active"),e.on($.support.touch?"touchmove":"mousemove",function(){e.removeClass("active")}),e.on("touchend",function(){e.unbind("touchmove mousemove")})}function k(t){if(t.isDefaultPrevented())return!0;var e=$(t.target);if(e.is(q.join(", "))||(e=e.closest(q.join(", "))),!e.length||!e.attr("href"))return!0;for(var n=e.attr("target"),o=e.prop("hash"),a=e.attr("href"),r={e:t,$el:e,target:n,hash:o,href:a,jQTSettings:M},i=0,s=O.length;s>i;i++){var u=O[i],c=u.isSupported(t,r);if(c){var l=u.fn(t,r);return l}}}function j(){n({name:"external-link",isSupported:function(t,e){return e.$el.isExternalLink()},fn:function(t,e){return e.$el.unselect(),!0}}),n({name:"back-selector",isSupported:function(t,e){return e.$el.is(e.jQTSettings.backSelector)},fn:function(t,e){u(e.hash)}}),n({name:"submit-selector",isSupported:function(t,e){return e.$el.is(e.jQTSettings.submitSelector)},fn:function(t,e){T(e.$el)}}),n({name:"webapp",isSupported:function(t,e){return"_webapp"===e.target},fn:function(t,e){return window.location=e.href,!1}}),n({name:"no-op",isSupported:function(t,e){return"#"===e.href},fn:function(t,e){return e.$el.unselect(),!0}}),n({name:"standard",isSupported:function(t,e){return e.hash&&"#"!==e.hash},fn:function(t,e){var n=f(e.$el);return e.$el.addClass("active"),c($(e.hash).data("referrer",e.$el),n,e.$el.hasClass("reverse")),!1}}),n({name:"external",isSupported:function(){return!0},fn:function(t,e){var n=f(e.$el);return e.$el.addClass("loading active"),b(e.$el.attr("href"),{animation:n,callback:function(){e.$el.removeClass("loading"),setTimeout($.fn.unselect,250,e.$el)},$referrer:e.$el}),!1}})}var E,x=$("head"),A=[],Q=0,M={},Y="",D="portrait",q=[],X={},H=100,I=$.jQTouch.prototype.extensions,L=$.jQTouch.prototype.tapHandlers,O=[],P=[],B="",G={addGlossToIcon:!0,backSelector:".back, .cancel, .goback",cacheGetRequests:!0,debug:!0,defaultAnimation:"slideleft",fixedViewport:!0,formSelector:"form",fullScreen:!0,fullScreenClass:"fullscreen",icon:null,icon4:null,preloadImages:!1,starter:$(document).ready,startupScreen:null,statusBar:"default",submitSelector:".submit",touchSelector:"a, .touch",trackScrollPositions:!0,updateHash:!0,useAnimations:!0,useFastTouch:!0,useTouchScroll:!0,animations:[{name:"cubeleft",selector:".cubeleft, .cube",is3d:!0},{name:"cuberight",selector:".cuberight",is3d:!0},{name:"dissolve",selector:".dissolve"},{name:"fade",selector:".fade"},{name:"flipleft",selector:".flipleft, .flip",is3d:!0},{name:"flipright",selector:".flipright",is3d:!0},{name:"pop",selector:".pop",is3d:!0},{name:"swapleft",selector:".swapleft, .swap",is3d:!0},{name:"swapright",selector:".swapright",is3d:!0},{name:"slidedown",selector:".slidedown"},{name:"slideright",selector:".slideright"},{name:"slideup",selector:".slideup"},{name:"slideleft",selector:".slideleft, .slide, #jqt > * > ul li a"}]};return M=$.extend({},G,t),d(t),p(),X={addAnimation:e,animations:P,getOrientation:s,goBack:u,insertPages:h,goTo:c,history:A,settings:M,submitForm:w},M.starter(v),X},$.jQTouch.prototype.extensions=[],$.jQTouch.prototype.tapHandlers=[],$.jQTouch.addExtension=function(t){$.jQTouch.prototype.extensions.push(t)},$.jQTouch.addTapHandler=function(t){$.jQTouch.prototype.tapHandlers.push(t)}})();