
/*! jQuery Mobile v1.4.5 | Copyright 2010, 2014 jQuery Foundation, Inc. | jquery.org/license */

(function(e,t,n){typeof define=="function"&&define.amd?define(["jquery"],function(r){return n(r,e,t),r.mobile}):n(e.jQuery,e,t)})(this,document,function(e,t,n,r){(function(e,t,n,r){function T(e){while(e&&typeof e.originalEvent!="undefined")e=e.originalEvent;return e}function N(t,n){var i=t.type,s,o,a,l,c,h,p,d,v;t=e.Event(t),t.type=n,s=t.originalEvent,o=e.event.props,i.search(/^(mouse|click)/)>-1&&(o=f);if(s)for(p=o.length,l;p;)l=o[--p],t[l]=s[l];i.search(/mouse(down|up)|click/)>-1&&!t.which&&(t.which=1);if(i.search(/^touch/)!==-1){a=T(s),i=a.touches,c=a.changedTouches,h=i&&i.length?i[0]:c&&c.length?c[0]:r;if(h)for(d=0,v=u.length;d<v;d++)l=u[d],t[l]=h[l]}return t}function C(t){var n={},r,s;while(t){r=e.data(t,i);for(s in r)r[s]&&(n[s]=n.hasVirtualBinding=!0);t=t.parentNode}return n}function k(t,n){var r;while(t){r=e.data(t,i);if(r&&(!n||r[n]))return t;t=t.parentNode}return null}function L(){g=!1}function A(){g=!0}function O(){E=0,v.length=0,m=!1,A()}function M(){L()}function _(){D(),c=setTimeout(function(){c=0,O()},e.vmouse.resetTimerDuration)}function D(){c&&(clearTimeout(c),c=0)}function P(t,n,r){var i;if(r&&r[t]||!r&&k(n.target,t))i=N(n,t),e(n.target).trigger(i);return i}function H(t){var n=e.data(t.target,s),r;!m&&(!E||E!==n)&&(r=P("v"+t.type,t),r&&(r.isDefaultPrevented()&&t.preventDefault(),r.isPropagationStopped()&&t.stopPropagation(),r.isImmediatePropagationStopped()&&t.stopImmediatePropagation()))}function B(t){var n=T(t).touches,r,i,o;n&&n.length===1&&(r=t.target,i=C(r),i.hasVirtualBinding&&(E=w++,e.data(r,s,E),D(),M(),d=!1,o=T(t).touches[0],h=o.pageX,p=o.pageY,P("vmouseover",t,i),P("vmousedown",t,i)))}function j(e){if(g)return;d||P("vmousecancel",e,C(e.target)),d=!0,_()}function F(t){if(g)return;var n=T(t).touches[0],r=d,i=e.vmouse.moveDistanceThreshold,s=C(t.target);d=d||Math.abs(n.pageX-h)>i||Math.abs(n.pageY-p)>i,d&&!r&&P("vmousecancel",t,s),P("vmousemove",t,s),_()}function I(e){if(g)return;A();var t=C(e.target),n,r;P("vmouseup",e,t),d||(n=P("vclick",e,t),n&&n.isDefaultPrevented()&&(r=T(e).changedTouches[0],v.push({touchID:E,x:r.clientX,y:r.clientY}),m=!0)),P("vmouseout",e,t),d=!1,_()}function q(t){var n=e.data(t,i),r;if(n)for(r in n)if(n[r])return!0;return!1}function R(){}function U(t){var n=t.substr(1);return{setup:function(){q(this)||e.data(this,i,{});var r=e.data(this,i);r[t]=!0,l[t]=(l[t]||0)+1,l[t]===1&&b.bind(n,H),e(this).bind(n,R),y&&(l.touchstart=(l.touchstart||0)+1,l.touchstart===1&&b.bind("touchstart",B).bind("touchend",I).bind("touchmove",F).bind("scroll",j))},teardown:function(){--l[t],l[t]||b.unbind(n,H),y&&(--l.touchstart,l.touchstart||b.unbind("touchstart",B).unbind("touchmove",F).unbind("touchend",I).unbind("scroll",j));var r=e(this),s=e.data(this,i);s&&(s[t]=!1),r.unbind(n,R),q(this)||r.removeData(i)}}}var i="virtualMouseBindings",s="virtualTouchID",o="vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split(" "),u="clientX clientY pageX pageY screenX screenY".split(" "),a=e.event.mouseHooks?e.event.mouseHooks.props:[],f=e.event.props.concat(a),l={},c=0,h=0,p=0,d=!1,v=[],m=!1,g=!1,y="addEventListener"in n,b=e(n),w=1,E=0,S,x;e.vmouse={moveDistanceThreshold:10,clickDistanceThreshold:10,resetTimerDuration:1500};for(x=0;x<o.length;x++)e.event.special[o[x]]=U(o[x]);y&&n.addEventListener("click",function(t){var n=v.length,r=t.target,i,o,u,a,f,l;if(n){i=t.clientX,o=t.clientY,S=e.vmouse.clickDistanceThreshold,u=r;while(u){for(a=0;a<n;a++){f=v[a],l=0;if(u===r&&Math.abs(f.x-i)<S&&Math.abs(f.y-o)<S||e.data(u,s)===f.touchID){t.preventDefault(),t.stopPropagation();return}}u=u.parentNode}}},!0)})(e,t,n),function(e){e.mobile={}}(e),function(e,t){var r={touch:"ontouchend"in n};e.mobile.support=e.mobile.support||{},e.extend(e.support,r),e.extend(e.mobile.support,r)}(e),function(e,t,r){function l(t,n,i,s){var o=i.type;i.type=n,s?e.event.trigger(i,r,t):e.event.dispatch.call(t,i),i.type=o}var i=e(n),s=e.mobile.support.touch,o="touchmove scroll",u=s?"touchstart":"mousedown",a=s?"touchend":"mouseup",f=s?"touchmove":"mousemove";e.each("touchstart touchmove touchend tap taphold swipe swipeleft swiperight scrollstart scrollstop".split(" "),function(t,n){e.fn[n]=function(e){return e?this.bind(n,e):this.trigger(n)},e.attrFn&&(e.attrFn[n]=!0)}),e.event.special.scrollstart={enabled:!0,setup:function(){function s(e,n){r=n,l(t,r?"scrollstart":"scrollstop",e)}var t=this,n=e(t),r,i;n.bind(o,function(t){if(!e.event.special.scrollstart.enabled)return;r||s(t,!0),clearTimeout(i),i=setTimeout(function(){s(t,!1)},50)})},teardown:function(){e(this).unbind(o)}},e.event.special.tap={tapholdThreshold:750,emitTapOnTaphold:!0,setup:function(){var t=this,n=e(t),r=!1;n.bind("vmousedown",function(s){function a(){clearTimeout(u)}function f(){a(),n.unbind("vclick",c).unbind("vmouseup",a),i.unbind("vmousecancel",f)}function c(e){f(),!r&&o===e.target?l(t,"tap",e):r&&e.preventDefault()}r=!1;if(s.which&&s.which!==1)return!1;var o=s.target,u;n.bind("vmouseup",a).bind("vclick",c),i.bind("vmousecancel",f),u=setTimeout(function(){e.event.special.tap.emitTapOnTaphold||(r=!0),l(t,"taphold",e.Event("taphold",{target:o}))},e.event.special.tap.tapholdThreshold)})},teardown:function(){e(this).unbind("vmousedown").unbind("vclick").unbind("vmouseup"),i.unbind("vmousecancel")}},e.event.special.swipe={scrollSupressionThreshold:30,durationThreshold:1e3,horizontalDistanceThreshold:30,verticalDistanceThreshold:30,getLocation:function(e){var n=t.pageXOffset,r=t.pageYOffset,i=e.clientX,s=e.clientY;if(e.pageY===0&&Math.floor(s)>Math.floor(e.pageY)||e.pageX===0&&Math.floor(i)>Math.floor(e.pageX))i-=n,s-=r;else if(s<e.pageY-r||i<e.pageX-n)i=e.pageX-n,s=e.pageY-r;return{x:i,y:s}},start:function(t){var n=t.originalEvent.touches?t.originalEvent.touches[0]:t,r=e.event.special.swipe.getLocation(n);return{time:(new Date).getTime(),coords:[r.x,r.y],origin:e(t.target)}},stop:function(t){var n=t.originalEvent.touches?t.originalEvent.touches[0]:t,r=e.event.special.swipe.getLocation(n);return{time:(new Date).getTime(),coords:[r.x,r.y]}},handleSwipe:function(t,n,r,i){if(n.time-t.time<e.event.special.swipe.durationThreshold&&Math.abs(t.coords[0]-n.coords[0])>e.event.special.swipe.horizontalDistanceThreshold&&Math.abs(t.coords[1]-n.coords[1])<e.event.special.swipe.verticalDistanceThreshold){var s=t.coords[0]>n.coords[0]?"swipeleft":"swiperight";return l(r,"swipe",e.Event("swipe",{target:i,swipestart:t,swipestop:n}),!0),l(r,s,e.Event(s,{target:i,swipestart:t,swipestop:n}),!0),!0}return!1},eventInProgress:!1,setup:function(){var t,n=this,r=e(n),s={};t=e.data(this,"mobile-events"),t||(t={length:0},e.data(this,"mobile-events",t)),t.length++,t.swipe=s,s.start=function(t){if(e.event.special.swipe.eventInProgress)return;e.event.special.swipe.eventInProgress=!0;var r,o=e.event.special.swipe.start(t),u=t.target,l=!1;s.move=function(t){if(!o||t.isDefaultPrevented())return;r=e.event.special.swipe.stop(t),l||(l=e.event.special.swipe.handleSwipe(o,r,n,u),l&&(e.event.special.swipe.eventInProgress=!1)),Math.abs(o.coords[0]-r.coords[0])>e.event.special.swipe.scrollSupressionThreshold&&t.preventDefault()},s.stop=function(){l=!0,e.event.special.swipe.eventInProgress=!1,i.off(f,s.move),s.move=null},i.on(f,s.move).one(a,s.stop)},r.on(u,s.start)},teardown:function(){var t,n;t=e.data(this,"mobile-events"),t&&(n=t.swipe,delete t.swipe,t.length--,t.length===0&&e.removeData(this,"mobile-events")),n&&(n.start&&e(this).off(u,n.start),n.move&&i.off(f,n.move),n.stop&&i.off(a,n.stop))}},e.each({scrollstop:"scrollstart",taphold:"tap",swipeleft:"swipe.left",swiperight:"swipe.right"},function(t,n){e.event.special[t]={setup:function(){e(this).bind(n,e.noop)},teardown:function(){e(this).unbind(n)}}})}(e,this),function(e,t,n){e.extend(e.mobile,{version:"1.4.5",subPageUrlKey:"ui-page",hideUrlBar:!0,keepNative:":jqmData(role='none'), :jqmData(role='nojs')",activePageClass:"ui-page-active",activeBtnClass:"ui-btn-active",focusClass:"ui-focus",ajaxEnabled:!0,hashListeningEnabled:!0,linkBindingEnabled:!0,defaultPageTransition:"fade",maxTransitionWidth:!1,minScrollBack:0,defaultDialogTransition:"pop",pageLoadErrorMessage:"Error Loading Page",pageLoadErrorMessageTheme:"a",phonegapNavigationEnabled:!1,autoInitializePage:!0,pushStateEnabled:!0,ignoreContentEnabled:!1,buttonMarkup:{hoverDelay:200},dynamicBaseEnabled:!0,pageContainer:e(),allowCrossDomainPages:!1,dialogHashKey:"&ui-state=dialog"})}(e,this),function(e,t,n){var r={},i=e.find,s=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,o=/:jqmData\(([^)]*)\)/g;e.extend(e.mobile,{ns:"",getAttribute:function(t,n){var r;t=t.jquery?t[0]:t,t&&t.getAttribute&&(r=t.getAttribute("data-"+e.mobile.ns+n));try{r=r==="true"?!0:r==="false"?!1:r==="null"?null:+r+""===r?+r:s.test(r)?JSON.parse(r):r}catch(i){}return r},nsNormalizeDict:r,nsNormalize:function(t){return r[t]||(r[t]=e.camelCase(e.mobile.ns+t))},closestPageData:function(e){return e.closest(":jqmData(role='page'), :jqmData(role='dialog')").data("mobile-page")}}),e.fn.jqmData=function(t,r){var i;return typeof t!="undefined"&&(t&&(t=e.mobile.nsNormalize(t)),arguments.length<2||r===n?i=this.data(t):i=this.data(t,r)),i},e.jqmData=function(t,n,r){var i;return typeof n!="undefined"&&(i=e.data(t,n?e.mobile.nsNormalize(n):n,r)),i},e.fn.jqmRemoveData=function(t){return this.removeData(e.mobile.nsNormalize(t))},e.jqmRemoveData=function(t,n){return e.removeData(t,e.mobile.nsNormalize(n))},e.find=function(t,n,r,s){return t.indexOf(":jqmData")>-1&&(t=t.replace(o,"[data-"+(e.mobile.ns||"")+"$1]")),i.call(this,t,n,r,s)},e.extend(e.find,i)}(e,this),function(e,t){function s(t,n){var r,i,s,u=t.nodeName.toLowerCase();return"area"===u?(r=t.parentNode,i=r.name,!t.href||!i||r.nodeName.toLowerCase()!=="map"?!1:(s=e("img[usemap=#"+i+"]")[0],!!s&&o(s))):(/input|select|textarea|button|object/.test(u)?!t.disabled:"a"===u?t.href||n:n)&&o(t)}function o(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return e.css(this,"visibility")==="hidden"}).length}var r=0,i=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"c0ab71056b936627e8a7821f03c044aec6280a40",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(n,r){return typeof n=="number"?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),r&&r.call(t)},n)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?t=this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):t=this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(this[0].ownerDocument||n):t},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++r)})},removeUniqueId:function(){return this.each(function(){i.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,r){return!!e.data(t,r[3])},focusable:function(t){return s(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),r=isNaN(n);return(r||n>=0)&&s(t,!r)}}),e("<a>").outerWidth(1).jquery||e.each(["Width","Height"],function(n,r){function u(t,n,r,s){return e.each(i,function(){n-=parseFloat(e.css(t,"padding"+this))||0,r&&(n-=parseFloat(e.css(t,"border"+this+"Width"))||0),s&&(n-=parseFloat(e.css(t,"margin"+this))||0)}),n}var i=r==="Width"?["Left","Right"]:["Top","Bottom"],s=r.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+r]=function(n){return n===t?o["inner"+r].call(this):this.each(function(){e(this).css(s,u(this,n)+"px")})},e.fn["outer"+r]=function(t,n){return typeof t!="number"?o["outer"+r].call(this,t):this.each(function(){e(this).css(s,u(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(e==null?this.prevObject:this.prevObject.filter(e))}),e("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(n){return arguments.length?t.call(this,e.camelCase(n)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in n.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(r){if(r!==t)return this.css("zIndex",r);if(this.length){var i=e(this[0]),s,o;while(i.length&&i[0]!==n){s=i.css("position");if(s==="absolute"||s==="relative"||s==="fixed"){o=parseInt(i.css("zIndex"),10);if(!isNaN(o)&&o!==0)return o}i=i.parent()}}return 0}}),e.ui.plugin={add:function(t,n,r){var i,s=e.ui[t].prototype;for(i in r)s.plugins[i]=s.plugins[i]||[],s.plugins[i].push([n,r[i]])},call:function(e,t,n,r){var i,s=e.plugins[t];if(!s)return;if(!r&&(!e.element[0].parentNode||e.element[0].parentNode.nodeType===11))return;for(i=0;i<s.length;i++)e.options[s[i][0]]&&s[i][1].apply(e.element,n)}}}(e),function(e,t,r){var i=function(t,n){var r=t.parent(),i=[],s=function(){var t=e(this),n=e.mobile.toolbar&&t.data("mobile-toolbar")?t.toolbar("option"):{position:t.attr("data-"+e.mobile.ns+"position"),updatePagePadding:t.attr("data-"+e.mobile.ns+"update-page-padding")!==!1};return n.position!=="fixed"||n.updatePagePadding!==!0},o=r.children(":jqmData(role='header')").filter(s),u=t.children(":jqmData(role='header')"),a=r.children(":jqmData(role='footer')").filter(s),f=t.children(":jqmData(role='footer')");return u.length===0&&o.length>0&&(i=i.concat(o.toArray())),f.length===0&&a.length>0&&(i=i.concat(a.toArray())),e.each(i,function(t,r){n-=e(r).outerHeight()}),Math.max(0,n)};e.extend(e.mobile,{window:e(t),document:e(n),keyCode:e.ui.keyCode,behaviors:{},silentScroll:function(n){e.type(n)!=="number"&&(n=e.mobile.defaultHomeScroll),e.event.special.scrollstart.enabled=!1,setTimeout(function(){t.scrollTo(0,n),e.mobile.document.trigger("silentscroll",{x:0,y:n})},20),setTimeout(function(){e.event.special.scrollstart.enabled=!0},150)},getClosestBaseUrl:function(t){var n=e(t).closest(".ui-page").jqmData("url"),r=e.mobile.path.documentBase.hrefNoHash;if(!e.mobile.dynamicBaseEnabled||!n||!e.mobile.path.isPath(n))n=r;return e.mobile.path.makeUrlAbsolute(n,r)},removeActiveLinkClass:function(t){!!e.mobile.activeClickedLink&&(!e.mobile.activeClickedLink.closest("."+e.mobile.activePageClass).length||t)&&e.mobile.activeClickedLink.removeClass(e.mobile.activeBtnClass),e.mobile.activeClickedLink=null},getInheritedTheme:function(e,t){var n=e[0],r="",i=/ui-(bar|body|overlay)-([a-z])\b/,s,o;while(n){s=n.className||"";if(s&&(o=i.exec(s))&&(r=o[2]))break;n=n.parentNode}return r||t||"a"},enhanceable:function(e){return this.haveParents(e,"enhance")},hijackable:function(e){return this.haveParents(e,"ajax")},haveParents:function(t,n){if(!e.mobile.ignoreContentEnabled)return t;var r=t.length,i=e(),s,o,u,a,f;for(a=0;a<r;a++){o=t.eq(a),u=!1,s=t[a];while(s){f=s.getAttribute?s.getAttribute("data-"+e.mobile.ns+n):"";if(f==="false"){u=!0;break}s=s.parentNode}u||(i=i.add(o))}return i},getScreenHeight:function(){return t.innerHeight||e.mobile.window.height()},resetActivePageHeight:function(t){var n=e("."+e.mobile.activePageClass),r=n.height(),s=n.outerHeight(!0);t=i(n,typeof t=="number"?t:e.mobile.getScreenHeight()),n.css("min-height",""),n.height()<t&&n.css("min-height",t-(s-r))},loading:function(){var t=this.loading._widget||e(e.mobile.loader.prototype.defaultHtml).loader(),n=t.loader.apply(t,arguments);return this.loading._widget=t,n}}),e.addDependents=function(t,n){var r=e(t),i=r.jqmData("dependents")||e();r.jqmData("dependents",e(i).add(n))},e.fn.extend({removeWithDependents:function(){e.removeWithDependents(this)},enhanceWithin:function(){var t,n={},r=e.mobile.page.prototype.keepNativeSelector(),i=this;e.mobile.nojs&&e.mobile.nojs(this),e.mobile.links&&e.mobile.links(this),e.mobile.degradeInputsWithin&&e.mobile.degradeInputsWithin(this),e.fn.buttonMarkup&&this.find(e.fn.buttonMarkup.initSelector).not(r).jqmEnhanceable().buttonMarkup(),e.fn.fieldcontain&&this.find(":jqmData(role='fieldcontain')").not(r).jqmEnhanceable().fieldcontain(),e.each(e.mobile.widgets,function(t,s){if(s.initSelector){var o=e.mobile.enhanceable(i.find(s.initSelector));o.length>0&&(o=o.not(r)),o.length>0&&(n[s.prototype.widgetName]=o)}});for(t in n)n[t][t]();return this},addDependents:function(t){e.addDependents(this,t)},getEncodedText:function(){return e("<a>").text(this.text()).html()},jqmEnhanceable:function(){return e.mobile.enhanceable(this)},jqmHijackable:function(){return e.mobile.hijackable(this)}}),e.removeWithDependents=function(t){var n=e(t);(n.jqmData("dependents")||e()).remove(),n.remove()},e.addDependents=function(t,n){var r=e(t),i=r.jqmData("dependents")||e();r.jqmData("dependents",e(i).add(n))},e.find.matches=function(t,n){return e.find(t,null,null,n)},e.find.matchesSelector=function(t,n){return e.find(n,null,null,[t]).length>0}}(e,this),function(e,r){t.matchMedia=t.matchMedia||function(e,t){var n,r=e.documentElement,i=r.firstElementChild||r.firstChild,s=e.createElement("body"),o=e.createElement("div");return o.id="mq-test-1",o.style.cssText="position:absolute;top:-100em",s.style.background="none",s.appendChild(o),function(e){return o.innerHTML='&shy;<style media="'+e+'"> #mq-test-1 { width: 42px; }</style>',r.insertBefore(s,i),n=o.offsetWidth===42,r.removeChild(s),{matches:n,media:e}}}(n),e.mobile.media=function(e){return t.matchMedia(e).matches}}(e)});
/* *
 * global function to loading scripts
 */
var ScriptArray = []; // global array of urls
jQuery.cachedScript = function(url, options){
	options = $.extend(options || {},{
		dataType: 'script',
		cache: true,
		url: url
	});
	//console.log('loading: '+ url);
	// use $.ajax() since it is more flexible than $.getScript
	return jQuery.ajax(options);
};
$.loadScript = function(url, callback){
	if(ScriptArray.indexOf(url) === -1){
		// the global array doesn't have such url
		if(callback && (typeof callback === 'function')){
			return $.cachedScript(url).done(function(script, textStatus, jqXHR){
				ScriptArray.push(url);
				callback(script, textStatus, jqXHR);
			});
		} else {
			return $.cachedScript(url).done(function(){ ScriptArray.push(url); });
		}
	} else {
		// the file is already there, it does nothing, to support as of jQuery 1.5 methods .done().fail()
		return { done: function() { return { fail: function(){} }; } };
	}
};


jQuery(document).ready(function(){

	/* *
	 * include scripts
	 */
	/* ajax functions */
	if( $('a[href*="ajax=1"]').length || $('a[data-ajax="1"]').length || $('.ajax').length ){
		$.loadScript('/fileadmin/theme/global/js/ajaxContent.js');
	}
	/* csc-mailform */
	if( $('.csc-mailform').length ){
		$.loadScript('/fileadmin/theme/global/js/vendor/validation/jquery.validate.min.js', function(){
			if(! $('html[lang^="en"]').length){ $.loadScript('/fileadmin/theme/global/js/vendor/validation/localization/messages_'+ $('html').attr('lang').substring(0,2) +'.js'); }
			$('.csc-mailform form').each(function(){ $(this).validate(); }); // info: powermail_form has its own validation
			//console.log(textStatus);
		});
	}


	/* *
	 * globals
	 *
	 * functionality:
	 * 		add class "js" (for css)
	 * 		onclick a[href] -> no blur border
	 */
	if(typeof window.Modernizr === "undefined"){ $('html').removeClass('no-js').addClass('js'); }
	$('a').on('click',function(){ $(this).blur(); });


	/* *
	 * detect touch support
	 *
	 * functionality:
	 * 		check if it's possible to touch in device
	 * 		add class for css
	 * 		(!!! this is not a check for mobile devices, a desktop computer could also have "touch" features !!!)
	 */
	function detectTouchSupport(){
		msGesture = window.navigator && window.navigator.msPointerEnabled && window.MSGesture,
		touchSupport = (( 'ontouchstart' in window ) || msGesture || window.DocumentTouch && document instanceof DocumentTouch);
		if(touchSupport){ $('html').addClass('touch'); } else { $('html').addClass('no-touch'); }
	}
	detectTouchSupport();


	/* *
	 * detect mobile
	 */
	var isMobile = {
		Android: function(){ return navigator.userAgent.match(/Android/i); },
		BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); },
		iOS: function(){ return navigator.userAgent.match(/iPhone|iPad|iPod/i); },
		Opera: function(){ return navigator.userAgent.match(/Opera Mini/i); },
		Windows: function(){ return navigator.userAgent.match(/IEMobile/i); },
		any: function(){ return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); }
	};
	if(isMobile.any()){ $('html').addClass('mobile'); }


	/* *
	 * scroll to top
	 *
	 * functionality:
	 * 		animate Button show/hide
	 * 		onclick -> scroll to top
	 */
	if($('#ScrollToTop').length){
		var $ScrollToTop = $('#ScrollToTop');
		var $PosY, $WinHeight = ($(window).height() /2);
		$ScrollToTop.hide();
		$(window).on('scroll',function(){
			$PosY = $(window).scrollTop();
			if($PosY >= $WinHeight && $ScrollToTop.is(':hidden')){ $ScrollToTop.addClass('scroll-top-visible').stop(true, true).slideDown();
			} else if($PosY < $WinHeight && $ScrollToTop.hasClass('scroll-top-visible')){ $ScrollToTop.removeClass('scroll-top-visible').stop(true, true).slideUp(); }
		});
		/* change position of #ScrollToTop */
		if($ScrollToTop.attr('data-element').length && $ScrollToTop.hasClass('vpos-bottom')){
			function check_element_position() {
				var $element = $ScrollToTop.attr('data-element'),
					$windowPos = $(window).scrollTop() + $(window).height(),
					element_height = $(''+$element+'').outerHeight(),
					element_top_position = $(''+$element+'').offset().top;
				// check to see if this container is within viewport
				if( element_top_position <= $windowPos ){ $ScrollToTop.addClass('scroll-top-fixed').css({'bottom': ($windowPos - element_top_position) +'px'});
				} else { $ScrollToTop.removeClass('scroll-top-fixed').css({'bottom':''}); }
			}
			$(window).on('scroll resize', check_element_position);
			$(window).trigger('scroll');
		}
	}


	/* *
	 * smooth scrolling to anchor
	 */
	$('a[href*="#"]:not([href="#"])').on('click',function(){
		var $target = '';
		if($(this.hash).selector == '#top') { $target = '#top'; /* fix for stupid anchor */
		} else if( (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')) && (location.hostname == this.hostname) ){
			/* anchor not empty ( href="#" ) && not on other page or site ( href="page.html#anchor" ) */
			$target = $(this.hash);
			$target = $target.length ? $target : $(this.hash.slice(1));
		}
		if($target.length){ $(this).blur(); $('html,body').stop(true, true).animate({ scrollTop: $($target).offset().top -30 },'slow','swing'); return false; }
	});


	// if page loads with anchor
	$(window).load(function(){
		var $hash = location.hash.replace(/^#/,'');
		if($hash.length){ /* scroll to item */
			$('html,body').stop(true, true).animate({ scrollTop: $('#'+$hash).offset().top -30 },'slow','swing');
			if($('.accordion-container').length){ /* open the item */
				$('.accordion-container #'+$hash).find('.accordionHeader').click();
			}
			history.pushState('', document.title, window.location.pathname + window.location.search); /* delete the hash from the URL */
		}
	});


	/* *
	 * detect external links
	 */
	$('a[href^="http://"], a[href^="https://"]').filter(function(){ return this.hostname && this.hostname !== location.hostname; }).addClass('external');
	$('a.external > img').each(function(){ $(this).parent('a.external').removeClass('external'); });


	/* *
	 * animate navigation for mobile view
	 */
	if($('.navbar-toggler').length){
		if(! $('#overlay').length){ $('#outer-wrapper').after('<div id="overlay" class="overlay-bg" />'); }
		// click burger-menu
		$('.navbar-toggler').on('click',function(){ $('html').toggleClass('nav-open'); });
		// click overlay -> close burger-menu
		$('#overlay').on('click',function(){ $('.navbar-toggler').click(); });
		// mobile / touch devices can swipe
		$('.touch').on('swipe',function(){ if($('#mainNav').is(':visible') && $('.nav-open').length){ $('.navbar-toggler').click(); } });
	}


	/* *
	 * Aufklappbare Inhalte | Accordion
	 */
	if($('.accordion-container .accordionItems > div').length){
		$('.accordion-container').each(function(){
			var $num = 0;
			$(this).addClass('animated').find('.accordionItems > div').each(function(){
				$num++; $(this).attr('itemno', $num);
				$(this).addClass('closed').wrapInner('<div class="accordionContent" />');
				if(! $(this).find('header').length) {
					$(this).prepend('<div class="accordionHeader empty"><header class="header H3">'+ $num +'</header></div>');
				} else {
					$(this).find('header').each(function(){
						$(this).html( $.trim( $(this).html() ).replace(/\s\s+/g,'') ); // remove empty spaces
					});
					$(this).find('header').first().children().first().wrap('<div class="accordionHeader"><header /></div>');
					$(this).prepend($(this).find('.accordionHeader'));
					$(this).find('header:empty').remove();
				}
				$(this).find('.accordionHeader').append('<span class="toggleSubNav" />');
			});
			$(this).find('.accordionHeader').on('click', function(){
				$(this).toggleClass('open').parent().toggleClass('closed');
				//$(this).next('.accordionContent').stop(true,true).slideToggle('slow');
				return false;
			});
		});
	}


	/* *
	 * Inhalte in Tabs
	 */
	if($('.tab-container .tab-content > div').length){
		$('.tab-container').each(function(){
			var $tabContainer = $(this);
			var $num = 0;
			$tabContainer.prepend('<div class="tabs" />')
			$tabContainer.addClass('animated').find('.tab-content > div').addClass('tab-item').each(function(){;
				$num++; $(this).attr('data-tabcontent', $num);
				if(! $(this).find('header').length) {
					$tabContainer.find('.tabs').append('<div class="tab-link empty" data-tab="'+ $num +'">'+ $num +'</div>');
				} else {
					$(this).find('header').each(function(){
						$(this).html( $.trim( $(this).html() ).replace(/\s\s+/g,'') ); // remove empty spaces
					});
					$tabContainer.find('.tabs').append('<div class="tab-link" data-tab="'+ $num +'">'+ $(this).find('header').first().children().first().text() +'</div>');
				}
			});
			$tabContainer.find('.tab-link').on('click', function(){
				var tab_id = +$(this).attr('data-tab');
				$(this).siblings().removeClass('current');
				$(this).addClass('current');
				$tabContainer.find('.tab-item.current').removeClass('current');
				$tabContainer.find('[data-tabcontent="'+tab_id+'"]').addClass('current');
				return false;
			});
			$tabContainer.find('.tab-link').first().click(); // initial
		});
	}


	/* *
	 * iframe / video
	 */
	if($('#content iframe').length){
		$('#content iframe').each(function(){
			if(!( $(this).attr('src').toLowerCase().indexOf('maps.google') >= 0 || $(this).parents('.ce-gallery').length || ($(this).attr('name') && $(this).attr('name').toLowerCase().indexOf('widget') >= 0 ) )){ // if not map & not in gallery & not widget
				$(this).wrap('<div class="iframe-outer-wrapper"><div class="iframe-inner-wrapper" /></div>');
				$(this).parents('.iframe-outer-wrapper').width($(this).attr('width'));
				if(! $(this).parents('.news-img-wrap').length){
					var $iframeWidth = $(this).attr('width');
					if(! $iframeWidth){ $iframeWidth = '100%'; }
					if($iframeWidth.indexOf('%') >= 0){ $iframeWidth = $(this).parents('.iframe-outer-wrapper').parent().width() /100 * $iframeWidth.replace(/[^-\d\.]/g,''); } // if %
					var $iframeHeight;
					if($(this).attr('height')){ $iframeHeight = $(this).attr('height').replace(/[^-\d\.]/g,'');
					} else { $iframeHeight = $(this).height(); }
					$('<style type="text/css" id="ID'+ $(this).closest('div[id]').attr('id') +'Css">#'+ $(this).closest('div[id]').attr('id') +' .iframe-inner-wrapper { padding-top: '+ 100 / $iframeWidth * $iframeHeight +'%; }</style>').appendTo('head');
				}
			}
		});
	}


});
/* eof: global functions */

jQuery(document).ready(function(){

	/* *
	 * cookie hint
	 */
	if( $('#cookieconsent').length ){
		$.loadScript('/fileadmin/theme/global/js/jquery.cookie.js', function(){
			/* check cookie */
			if($.getCookie('cookieconsent_dismissed')){
				$('html').addClass('cookie-accepted');
				$('#cookieconsent').remove();
			} else {

				/* add nescessary spacer element */
				if( $('#cookieconsent .cc_banner-position-top').length ){
					$('#root').prepend('<div class="cc_spacer" />');
				} else {
					$('#mainFooter').append('<div class="cc_spacer" />');
				}

				/* show */
				$('#cookieconsent .cc_banner-wrapper').show();

				/* accept cookie */
				$('#cookieconsent .cc_btn').on('click',function(){
					$.setCookie('cookieconsent_dismissed', 'yes', $('#cookieconsent .cc_btn').attr('data-expiryDays'));
					$('html').addClass('cookie-accepted');
					$('#cookieconsent, .cc_spacer').stop(true, true).fadeOut('slow','linear').delay(500).hide();
					$('#cookieconsent').addClass('cc-invisible');
					return false;
				});

				/* get height of cookie hint */
				function getCookieConsentHeight(){
					$('.cc_spacer').css('height',$('.cc_container').outerHeight());
				}
				getCookieConsentHeight();

				/* resize function */
				$(window).on('resize',function(){
					clearTimeout(window.resizedWindowFinished);
					window.resizedWindowFinished = setTimeout(function(){
						getCookieConsentHeight();
					}, 250);
				});

			}
		});
	}


});
/* eof: cookie functions */
