/* Minification failed. Returning unminified contents.
(4434,9-10): run-time error JS1010: Expected identifier: .
(4434,9-10): run-time error JS1195: Expected expression: .
 */
/*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
(function(r,G,f,v){var J=f("html"),n=f(r),p=f(G),b=f.fancybox=function(){b.open.apply(this,arguments)},I=navigator.userAgent.match(/msie/i),B=null,s=G.createTouch!==v,t=function(a){return a&&a.hasOwnProperty&&a instanceof f},q=function(a){return a&&"string"===f.type(a)},E=function(a){return q(a)&&0<a.indexOf("%")},l=function(a,d){var e=parseInt(a,10)||0;d&&E(a)&&(e*=b.getViewport()[d]/100);return Math.ceil(e)},w=function(a,b){return l(a,b)+"px"};f.extend(b,{version:"2.1.5",defaults:{padding:15,margin:20,
width:800,height:600,minWidth:100,minHeight:100,maxWidth:9999,maxHeight:9999,pixelRatio:1,autoSize:!0,autoHeight:!1,autoWidth:!1,autoResize:!0,autoCenter:!s,fitToView:!0,aspectRatio:!1,topRatio:0.5,leftRatio:0.5,scrolling:"auto",wrapCSS:"",arrows:!0,closeBtn:!0,closeClick:!1,nextClick:!1,mouseWheel:!0,autoPlay:!1,playSpeed:3E3,preload:3,modal:!1,loop:!0,ajax:{dataType:"html",headers:{"X-fancyBox":!0}},iframe:{scrolling:"auto",preload:!0},swf:{wmode:"transparent",allowfullscreen:"true",allowscriptaccess:"always"},
keys:{next:{13:"left",34:"up",39:"left",40:"up"},prev:{8:"right",33:"down",37:"right",38:"down"},close:[27],play:[32],toggle:[70]},direction:{next:"left",prev:"right"},scrollOutside:!0,index:0,type:null,href:null,content:null,title:null,tpl:{wrap:'<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',image:'<img class="fancybox-image" src="{href}" alt="" />',iframe:'<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen'+
(I?' allowtransparency="true"':"")+"></iframe>",error:'<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',closeBtn:'<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',next:'<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',prev:'<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'},openEffect:"fade",openSpeed:250,openEasing:"swing",openOpacity:!0,
openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:!0,title:!0},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop},group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,
isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,d){if(a&&(f.isPlainObject(d)||(d={}),!1!==b.close(!0)))return f.isArray(a)||(a=t(a)?f(a).get():[a]),f.each(a,function(e,c){var k={},g,h,j,m,l;"object"===f.type(c)&&(c.nodeType&&(c=f(c)),t(c)?(k={href:c.data("fancybox-href")||c.attr("href"),title:c.data("fancybox-title")||c.attr("title"),isDom:!0,element:c},f.metadata&&f.extend(!0,k,
c.metadata())):k=c);g=d.href||k.href||(q(c)?c:null);h=d.title!==v?d.title:k.title||"";m=(j=d.content||k.content)?"html":d.type||k.type;!m&&k.isDom&&(m=c.data("fancybox-type"),m||(m=(m=c.prop("class").match(/fancybox\.(\w+)/))?m[1]:null));q(g)&&(m||(b.isImage(g)?m="image":b.isSWF(g)?m="swf":"#"===g.charAt(0)?m="inline":q(c)&&(m="html",j=c)),"ajax"===m&&(l=g.split(/\s+/,2),g=l.shift(),l=l.shift()));j||("inline"===m?g?j=f(q(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):k.isDom&&(j=c):"html"===m?j=g:!m&&(!g&&
k.isDom)&&(m="inline",j=c));f.extend(k,{href:g,type:m,content:j,title:h,selector:l});a[e]=k}),b.opts=f.extend(!0,{},b.defaults,d),d.keys!==v&&(b.opts.keys=d.keys?f.extend({},b.defaults.keys,d.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0,!0).trigger("onReset").remove(),b.coming=null,b.current||
b._afterZoomOut(a))},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),b.isActive&&(!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),b.transitions[b.current.closeMethod]())))},play:function(a){var d=function(){clearTimeout(b.player.timer)},e=function(){d();b.current&&b.player.isActive&&(b.player.timer=
setTimeout(b.next,b.current.playSpeed))},c=function(){d();p.unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index<b.group.length-1))b.player.isActive=!0,p.bind({"onCancel.player beforeClose.player":c,"onUpdate.player":e,"beforeLoad.player":d}),e(),b.trigger("onPlayStart")}else c()},next:function(a){var d=b.current;d&&(q(a)||(a=d.direction.next),b.jumpto(d.index+1,a,"next"))},prev:function(a){var d=b.current;
d&&(q(a)||(a=d.direction.prev),b.jumpto(d.index-1,a,"prev"))},jumpto:function(a,d,e){var c=b.current;c&&(a=l(a),b.direction=d||c.direction[a>=c.index?"next":"prev"],b.router=e||"jumpto",c.loop&&(0>a&&(a=c.group.length+a%c.group.length),a%=c.group.length),c.group[a]!==v&&(b.cancel(),b._start(a)))},reposition:function(a,d){var e=b.current,c=e?e.wrap:null,k;c&&(k=b._getPosition(d),a&&"scroll"===a.type?(delete k.position,c.stop(!0,!0).animate(k,200)):(c.css(k),e.pos=f.extend({},e.dim,k)))},update:function(a){var d=
a&&a.type,e=!d||"orientationchange"===d;e&&(clearTimeout(B),B=null);b.isOpen&&!B&&(B=setTimeout(function(){var c=b.current;c&&!b.isClosing&&(b.wrap.removeClass("fancybox-tmp"),(e||"load"===d||"resize"===d&&c.autoResize)&&b._setDimension(),"scroll"===d&&c.canShrink||b.reposition(a),b.trigger("onUpdate"),B=null)},e&&!s?0:300))},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)?a:!b.current.fitToView,s&&(b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate")),
b.update())},hideLoading:function(){p.unbind(".loading");f("#fancybox-loading").remove()},showLoading:function(){var a,d;b.hideLoading();a=f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");p.bind("keydown.loading",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});b.defaults.fixed||(d=b.getViewport(),a.css({position:"absolute",top:0.5*d.h+d.y,left:0.5*d.w+d.x}))},getViewport:function(){var a=b.current&&b.current.locked||!1,d={x:n.scrollLeft(),
y:n.scrollTop()};a?(d.w=a[0].clientWidth,d.h=a[0].clientHeight):(d.w=s&&r.innerWidth?r.innerWidth:n.width(),d.h=s&&r.innerHeight?r.innerHeight:n.height());return d},unbindEvents:function(){b.wrap&&t(b.wrap)&&b.wrap.unbind(".fb");p.unbind(".fb");n.unbind(".fb")},bindEvents:function(){var a=b.current,d;a&&(n.bind("orientationchange.fb"+(s?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(d=a.keys)&&p.bind("keydown.fb",function(e){var c=e.which||e.keyCode,k=e.target||e.srcElement;
if(27===c&&b.coming)return!1;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!k||!k.type&&!f(k).is("[contenteditable]")))&&f.each(d,function(d,k){if(1<a.group.length&&k[c]!==v)return b[d](k[c]),e.preventDefault(),!1;if(-1<f.inArray(c,k))return b[d](),e.preventDefault(),!1})}),f.fn.mousewheel&&a.mouseWheel&&b.wrap.bind("mousewheel.fb",function(d,c,k,g){for(var h=f(d.target||null),j=!1;h.length&&!j&&!h.is(".fancybox-skin")&&!h.is(".fancybox-wrap");)j=h[0]&&!(h[0].style.overflow&&"hidden"===h[0].style.overflow)&&
(h[0].clientWidth&&h[0].scrollWidth>h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==c&&!j&&1<b.group.length&&!a.canShrink){if(0<g||0<k)b.prev(0<g?"down":"left");else if(0>g||0>k)b.next(0>g?"up":"right");d.preventDefault()}}))},trigger:function(a,d){var e,c=d||b.coming||b.current;if(c){f.isFunction(c[a])&&(e=c[a].apply(c,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;c.helpers&&f.each(c.helpers,function(d,e){if(e&&b.helpers[d]&&f.isFunction(b.helpers[d][a]))b.helpers[d][a](f.extend(!0,
{},b.helpers[d].defaults,e),c)});p.trigger(a)}},isImage:function(a){return q(a)&&a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i)},isSWF:function(a){return q(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var d={},e,c;a=l(a);e=b.group[a]||null;if(!e)return!1;d=f.extend(!0,{},b.opts,e);e=d.margin;c=d.padding;"number"===f.type(e)&&(d.margin=[e,e,e,e]);"number"===f.type(c)&&(d.padding=[c,c,c,c]);d.modal&&f.extend(!0,d,{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,
mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});d.autoSize&&(d.autoWidth=d.autoHeight=!0);"auto"===d.width&&(d.autoWidth=!0);"auto"===d.height&&(d.autoHeight=!0);d.group=b.group;d.index=a;b.coming=d;if(!1===b.trigger("beforeLoad"))b.coming=null;else{c=d.type;e=d.href;if(!c)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===c||"swf"===c)d.autoHeight=d.autoWidth=!1,d.scrolling="visible";"image"===c&&(d.aspectRatio=
!0);"iframe"===c&&s&&(d.scrolling="scroll");d.wrap=f(d.tpl.wrap).addClass("fancybox-"+(s?"mobile":"desktop")+" fancybox-type-"+c+" fancybox-tmp "+d.wrapCSS).appendTo(d.parent||"body");f.extend(d,{skin:f(".fancybox-skin",d.wrap),outer:f(".fancybox-outer",d.wrap),inner:f(".fancybox-inner",d.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){d.skin.css("padding"+b,w(d.padding[a]))});b.trigger("onReady");if("inline"===c||"html"===c){if(!d.content||!d.content.length)return b._error("content")}else if(!e)return b._error("href");
"image"===c?b._loadImage():"ajax"===c?b._loadAjax():"iframe"===c?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width/b.opts.pixelRatio;b.coming.height=this.height/b.opts.pixelRatio;b._afterLoad()};a.onerror=function(){this.onload=
this.onerror=null;b._error("image")};a.src=b.coming.href;!0!==a.complete&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(d,e){"success"===e&&(a.content=d,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,d=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling",s?"auto":a.iframe.scrolling).attr("src",a.href);
f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),d.one("load",function(){f(this).data("ready",1);s||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=d.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,d=b.current,e=a.length,c=d.preload?Math.min(d.preload,
e-1):0,f,g;for(g=1;g<=c;g+=1)f=a[(d.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,d=b.current,e,c,k,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,d))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{d&&(b.trigger("beforeChange",d),d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());b.unbindEvents();e=a.content;c=a.type;k=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,
outer:a.outer,inner:a.inner,current:a,previous:d});g=a.href;switch(c){case "inline":case "ajax":case "html":a.selector?e=f("<div>").html(e).find(a.selector):t(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",!1)}));break;case "image":e=a.tpl.image.replace("{href}",
g);break;case "swf":e='<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="'+g+'"></param>',h="",f.each(a.swf,function(a,b){e+='<param name="'+a+'" value="'+b+'"></param>';h+=" "+a+'="'+b+'"'}),e+='<embed src="'+g+'" type="application/x-shockwave-flash" width="100%" height="100%"'+h+"></embed></object>"}(!t(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow");a.inner.css("overflow","yes"===k?"scroll":
"no"===k?"hidden":k);b._setDimension();b.reposition();b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(d.prevMethod)b.transitions[d.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),d=0,e=!1,c=!1,e=b.wrap,k=b.skin,g=b.inner,h=b.current,c=h.width,j=h.height,m=h.minWidth,u=h.minHeight,n=h.maxWidth,p=h.maxHeight,s=h.scrolling,q=h.scrollOutside?
h.scrollbarWidth:0,x=h.margin,y=l(x[1]+x[3]),r=l(x[0]+x[2]),v,z,t,C,A,F,B,D,H;e.add(k).add(g).width("auto").height("auto").removeClass("fancybox-tmp");x=l(k.outerWidth(!0)-k.width());v=l(k.outerHeight(!0)-k.height());z=y+x;t=r+v;C=E(c)?(a.w-z)*l(c)/100:c;A=E(j)?(a.h-t)*l(j)/100:j;if("iframe"===h.type){if(H=h.content,h.autoHeight&&1===H.data("ready"))try{H[0].contentWindow.document.location&&(g.width(C).height(9999),F=H.contents().find("body"),q&&F.css("overflow-x","hidden"),A=F.outerHeight(!0))}catch(G){}}else if(h.autoWidth||
h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(C),h.autoHeight||g.height(A),h.autoWidth&&(C=g.width()),h.autoHeight&&(A=g.height()),g.removeClass("fancybox-tmp");c=l(C);j=l(A);D=C/A;m=l(E(m)?l(m,"w")-z:m);n=l(E(n)?l(n,"w")-z:n);u=l(E(u)?l(u,"h")-t:u);p=l(E(p)?l(p,"h")-t:p);F=n;B=p;h.fitToView&&(n=Math.min(a.w-z,n),p=Math.min(a.h-t,p));z=a.w-y;r=a.h-r;h.aspectRatio?(c>n&&(c=n,j=l(c/D)),j>p&&(j=p,c=l(j*D)),c<m&&(c=m,j=l(c/D)),j<u&&(j=u,c=l(j*D))):(c=Math.max(m,Math.min(c,n)),h.autoHeight&&
"iframe"!==h.type&&(g.width(c),j=g.height()),j=Math.max(u,Math.min(j,p)));if(h.fitToView)if(g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height(),h.aspectRatio)for(;(a>z||y>r)&&(c>m&&j>u)&&!(19<d++);)j=Math.max(u,Math.min(p,j-10)),c=l(j*D),c<m&&(c=m,j=l(c/D)),c>n&&(c=n,j=l(c/D)),g.width(c).height(j),e.width(c+x),a=e.width(),y=e.height();else c=Math.max(m,Math.min(c,c-(a-z))),j=Math.max(u,Math.min(j,j-(y-r)));q&&("auto"===s&&j<A&&c+x+q<z)&&(c+=q);g.width(c).height(j);e.width(c+x);a=e.width();
y=e.height();e=(a>z||y>r)&&c>m&&j>u;c=h.aspectRatio?c<F&&j<B&&c<C&&j<A:(c<F||j<B)&&(c<C||j<A);f.extend(h,{dim:{width:w(a),height:w(y)},origWidth:C,origHeight:A,canShrink:e,canExpand:c,wPadding:x,hPadding:v,wrapSpace:y-k.outerHeight(!0),skinSpace:k.height()-j});!H&&(h.autoHeight&&j>u&&j<p&&!c)&&g.height("auto")},_getPosition:function(a){var d=b.current,e=b.getViewport(),c=d.margin,f=b.wrap.width()+c[1]+c[3],g=b.wrap.height()+c[0]+c[2],c={position:"absolute",top:c[0],left:c[3]};d.autoCenter&&d.fixed&&
!a&&g<=e.h&&f<=e.w?c.position="fixed":d.locked||(c.top+=e.y,c.left+=e.x);c.top=w(Math.max(c.top,c.top+(e.h-g)*d.topRatio));c.left=w(Math.max(c.left,c.left+(e.w-f)*d.leftRatio));return c},_afterZoomIn:function(){var a=b.current;a&&(b.isOpen=b.isOpened=!0,b.wrap.css("overflow","visible").addClass("fancybox-opened"),b.update(),(a.closeClick||a.nextClick&&1<b.group.length)&&b.inner.css("cursor","pointer").bind("click.fb",function(d){!f(d.target).is("a")&&!f(d.target).parent().is("a")&&(d.preventDefault(),
b[a.closeClick?"close":"next"]())}),a.closeBtn&&f(a.tpl.closeBtn).appendTo(b.skin).bind("click.fb",function(a){a.preventDefault();b.close()}),a.arrows&&1<b.group.length&&((a.loop||0<a.index)&&f(a.tpl.prev).appendTo(b.outer).bind("click.fb",b.prev),(a.loop||a.index<b.group.length-1)&&f(a.tpl.next).appendTo(b.outer).bind("click.fb",b.next)),b.trigger("afterShow"),!a.loop&&a.index===a.group.length-1?b.play(!1):b.opts.autoPlay&&!b.player.isActive&&(b.opts.autoPlay=!1,b.play()))},_afterZoomOut:function(a){a=
a||b.current;f(".fancybox-wrap").trigger("onReset").remove();f.extend(b,{group:{},opts:{},router:!1,current:null,isActive:!1,isOpened:!1,isOpen:!1,isClosing:!1,wrap:null,skin:null,outer:null,inner:null});b.trigger("afterClose",a)}});b.transitions={getOrigPosition:function(){var a=b.current,d=a.element,e=a.orig,c={},f=50,g=50,h=a.hPadding,j=a.wPadding,m=b.getViewport();!e&&(a.isDom&&d.is(":visible"))&&(e=d.find("img:first"),e.length||(e=d));t(e)?(c=e.offset(),e.is("img")&&(f=e.outerWidth(),g=e.outerHeight())):
(c.top=m.y+(m.h-g)*a.topRatio,c.left=m.x+(m.w-f)*a.leftRatio);if("fixed"===b.wrap.css("position")||a.locked)c.top-=m.y,c.left-=m.x;return c={top:w(c.top-h*a.topRatio),left:w(c.left-j*a.leftRatio),width:w(f+j),height:w(g+h)}},step:function(a,d){var e,c,f=d.prop;c=b.current;var g=c.wrapSpace,h=c.skinSpace;if("width"===f||"height"===f)e=d.end===d.start?1:(a-d.start)/(d.end-d.start),b.isClosing&&(e=1-e),c="width"===f?c.wPadding:c.hPadding,c=a-c,b.skin[f](l("width"===f?c:c-g*e)),b.inner[f](l("width"===
f?c:c-g*e-h*e))},zoomIn:function(){var a=b.current,d=a.pos,e=a.openEffect,c="elastic"===e,k=f.extend({opacity:1},d);delete k.position;c?(d=this.getOrigPosition(),a.openOpacity&&(d.opacity=0.1)):"fade"===e&&(d.opacity=0.1);b.wrap.css(d).animate(k,{duration:"none"===e?0:a.openSpeed,easing:a.openEasing,step:c?this.step:null,complete:b._afterZoomIn})},zoomOut:function(){var a=b.current,d=a.closeEffect,e="elastic"===d,c={opacity:0.1};e&&(c=this.getOrigPosition(),a.closeOpacity&&(c.opacity=0.1));b.wrap.animate(c,
{duration:"none"===d?0:a.closeSpeed,easing:a.closeEasing,step:e?this.step:null,complete:b._afterZoomOut})},changeIn:function(){var a=b.current,d=a.nextEffect,e=a.pos,c={opacity:1},f=b.direction,g;e.opacity=0.1;"elastic"===d&&(g="down"===f||"up"===f?"top":"left","down"===f||"right"===f?(e[g]=w(l(e[g])-200),c[g]="+=200px"):(e[g]=w(l(e[g])+200),c[g]="-=200px"));"none"===d?b._afterZoomIn():b.wrap.css(e).animate(c,{duration:a.nextSpeed,easing:a.nextEasing,complete:b._afterZoomIn})},changeOut:function(){var a=
b.previous,d=a.prevEffect,e={opacity:0.1},c=b.direction;"elastic"===d&&(e["down"===c||"up"===c?"top":"left"]=("up"===c||"left"===c?"-":"+")+"=200px");a.wrap.animate(e,{duration:"none"===d?0:a.prevSpeed,easing:a.prevEasing,complete:function(){f(this).trigger("onReset").remove()}})}};b.helpers.overlay={defaults:{closeClick:!0,speedOut:200,showEarly:!0,css:{},locked:!s,fixed:!0},overlay:null,fixed:!1,el:f("html"),create:function(a){a=f.extend({},this.defaults,a);this.overlay&&this.close();this.overlay=
f('<div class="fancybox-overlay"></div>').appendTo(b.coming?b.coming.parent:a.parent);this.fixed=!1;a.fixed&&b.defaults.fixed&&(this.overlay.addClass("fancybox-overlay-fixed"),this.fixed=!0)},open:function(a){var d=this;a=f.extend({},this.defaults,a);this.overlay?this.overlay.unbind(".overlay").width("auto").height("auto"):this.create(a);this.fixed||(n.bind("resize.overlay",f.proxy(this.update,this)),this.update());a.closeClick&&this.overlay.bind("click.overlay",function(a){if(f(a.target).hasClass("fancybox-overlay"))return b.isActive?
b.close():d.close(),!1});this.overlay.css(a.css).show()},close:function(){var a,b;n.unbind("resize.overlay");this.el.hasClass("fancybox-lock")&&(f(".fancybox-margin").removeClass("fancybox-margin"),a=n.scrollTop(),b=n.scrollLeft(),this.el.removeClass("fancybox-lock"),n.scrollTop(a).scrollLeft(b));f(".fancybox-overlay").remove().hide();f.extend(this,{overlay:null,fixed:!1})},update:function(){var a="100%",b;this.overlay.width(a).height("100%");I?(b=Math.max(G.documentElement.offsetWidth,G.body.offsetWidth),
p.width()>b&&(a=p.width())):p.width()>n.width()&&(a=p.width());this.overlay.width(a).height(p.height())},onReady:function(a,b){var e=this.overlay;f(".fancybox-overlay").stop(!0,!0);e||this.create(a);a.locked&&(this.fixed&&b.fixed)&&(e||(this.margin=p.height()>n.height()?f("html").css("margin-right").replace("px",""):!1),b.locked=this.overlay.append(b.wrap),b.fixed=!1);!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,b){var e,c;b.locked&&(!1!==this.margin&&(f("*").filter(function(){return"fixed"===
f(this).css("position")&&!f(this).hasClass("fancybox-overlay")&&!f(this).hasClass("fancybox-wrap")}).addClass("fancybox-margin"),this.el.addClass("fancybox-margin")),e=n.scrollTop(),c=n.scrollLeft(),this.el.addClass("fancybox-lock"),n.scrollTop(e).scrollLeft(c));this.open(a)},onUpdate:function(){this.fixed||this.update()},afterClose:function(a){this.overlay&&!b.coming&&this.overlay.fadeOut(a.speedOut,f.proxy(this.close,this))}};b.helpers.title={defaults:{type:"float",position:"bottom"},beforeShow:function(a){var d=
b.current,e=d.title,c=a.type;f.isFunction(e)&&(e=e.call(d.element,d));if(q(e)&&""!==f.trim(e)){d=f('<div class="fancybox-title fancybox-title-'+c+'-wrap">'+e+"</div>");switch(c){case "inside":c=b.skin;break;case "outside":c=b.wrap;break;case "over":c=b.inner;break;default:c=b.skin,d.appendTo("body"),I&&d.width(d.width()),d.wrapInner('<span class="child"></span>'),b.current.margin[2]+=Math.abs(l(d.css("margin-bottom")))}d["top"===a.position?"prependTo":"appendTo"](c)}}};f.fn.fancybox=function(a){var d,
e=f(this),c=this.selector||"",k=function(g){var h=f(this).blur(),j=d,k,l;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(k=a.groupAttr||"data-fancybox-group",l=h.attr(k),l||(k="rel",l=h.get(0)[k]),l&&(""!==l&&"nofollow"!==l)&&(h=c.length?f(c):e,h=h.filter("["+k+'="'+l+'"]'),j=h.index(this)),a.index=j,!1!==b.open(h,a)&&g.preventDefault())};a=a||{};d=a.index||0;!c||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start",k):p.undelegate(c,"click.fb-start").delegate(c+
":not('.fancybox-item, .fancybox-nav')","click.fb-start",k);this.filter("[data-fancybox-start=1]").trigger("click");return this};p.ready(function(){var a,d;f.scrollbarWidth===v&&(f.scrollbarWidth=function(){var a=f('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===v){a=f.support;d=f('<div style="position:fixed;top:20px;"></div>').appendTo("body");var e=20===
d[0].offsetTop||15===d[0].offsetTop;d.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")});a=f(r).width();J.addClass("fancybox-lock-test");d=f(r).width();J.removeClass("fancybox-lock-test");f("<style type='text/css'>.fancybox-margin{margin-right:"+(d-a)+"px;}</style>").appendTo("head")})})(window,document,jQuery);;
$.fn.isOnScreen = function(){
    
    var win = $(window);
    
    var viewport = {
        top : win.scrollTop(),
        left : win.scrollLeft()
    };
    viewport.right = viewport.left + win.width();
    viewport.bottom = viewport.top + win.height();
    
    var bounds = this.offset();
    bounds.right = bounds.left + this.outerWidth();
    bounds.bottom = bounds.top + this.outerHeight();
    
    return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
    
};;
if (jQuery)
{
	jQuery.fn.WaitOverlay = function (options)
	{
		switch (options)
		{
			case 'hide':
				$('.waitOverlay').remove();
				$('.waitLoader').remove();
				break;
			default:
				var docWidth = $(document).width();
				var docHeight = $(document).height();
				var windowHeight = $(window).height();

				var overLay = $('<div>').attr('class', 'waitOverlay').css({
					width: docWidth,
					height: docHeight
				});

				var loaderImage = $('<div>').addClass('waitLoader');
				var leftCenter = (docWidth / 2) - (loaderImage.width() / 2);
				var topCenter = (windowHeight / 2) - (loaderImage.height() / 2);
				loaderImage.css({
					left: leftCenter + "px",
					top: topCenter + "px"
				});

				if (options !== undefined)
				{
					if (options.size !== undefined)
					{
						loaderImage.css("width", options.size);
						loaderImage.css("height", options.size);
						//Adjust border width according to size 100 = 5 | 80 = 4 | 60 = 3 | 40 = 2 | 20 = 1
						var borderWidth = (options.size > 0 && options.size < 30) ? 1 : (options.size > 30 && options.size < 50) ? 2 : (options.size > 50 && options.size < 70) ? 3 : (options.size > 70 && options.size < 90) ? 4 : (options.size > 90) ? 5 : 1;
						loaderImage.css("border-width", borderWidth + "px");
						loaderImage.css("box-shadow", "0 0 " + borderWidth + "px " + borderWidth + "px #DCDCDC");
					}
					if (options.opacity !== undefined)
						overLay.css("opacity", options.opacity);
					if (options.bgcolor !== undefined)
						overLay.css("background-color", options.bgcolor);
				}

				if ($('.waitOverlay').length === 0)
				{
					this.append(overLay);
					this.append(loaderImage);
				}
				break;
		}
	}
}
;
/**
 * Copyright (C) 2010-2014 Graham Breach
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * jQuery.tagcanvas 2.5.1
 * For more information, please contact <graham@goat1000.com>
 */
(function (ak) { var K, I, J = Math.abs, ad = Math.sin, v = Math.cos, q = Math.max, ay = Math.min, al = Math.ceil, C = Math.sqrt, an = Math.pow, f = {}, h = {}, k = { 0: "0,", 1: "17,", 2: "34,", 3: "51,", 4: "68,", 5: "85,", 6: "102,", 7: "119,", 8: "136,", 9: "153,", a: "170,", A: "170,", b: "187,", B: "187,", c: "204,", C: "204,", d: "221,", D: "221,", e: "238,", E: "238,", f: "255,", F: "255," }, w, b, O, aA, F, aB, B = document, n, a = {}; for (K = 0; K < 256; ++K) { I = K.toString(16); if (K < 16) { I = "0" + I } h[I] = h[I.toUpperCase()] = K.toString() + "," } function ae(i) { return typeof i != "undefined" } function G(i) { return typeof i == "object" && i != null } function ap(i, j, aC) { return isNaN(i) ? aC : ay(aC, q(j, i)) } function av() { return false } function E() { return new Date().valueOf() } function z(aC, aF) { var j = [], aD = aC.length, aE; for (aE = 0; aE < aD; ++aE) { j.push(aC[aE]) } j.sort(aF); return j } function aj(j) { var aD = j.length - 1, aC, aE; while (aD) { aE = ~~(Math.random() * aD); aC = j[aD]; j[aD] = j[aE]; j[aE] = aC; --aD } } function aa(i, aC, j) { this.x = i; this.y = aC; this.z = j } F = aa.prototype; F.length = function () { return C(this.x * this.x + this.y * this.y + this.z * this.z) }; F.dot = function (i) { return this.x * i.x + this.y * i.y + this.z * i.z }; F.cross = function (j) { var i = this.y * j.z - this.z * j.y, aD = this.z * j.x - this.x * j.z, aC = this.x * j.y - this.y * j.x; return new aa(i, aD, aC) }; F.angle = function (j) { var i = this.dot(j), aC; if (i == 0) { return Math.PI / 2 } aC = i / (this.length() * j.length()); if (aC >= 1) { return 0 } if (aC <= -1) { return Math.PI } return Math.acos(aC) }; F.unit = function () { var i = this.length(); return new aa(this.x / i, this.y / i, this.z / i) }; function af(aC, j) { j = j * Math.PI / 180; aC = aC * Math.PI / 180; var i = ad(aC) * v(j), aE = -ad(j), aD = -v(aC) * v(j); return new aa(i, aE, aD) } function P(i) { this[1] = { 1: i[0], 2: i[1], 3: i[2] }; this[2] = { 1: i[3], 2: i[4], 3: i[5] }; this[3] = { 1: i[6], 2: i[7], 3: i[8] } } aA = P.prototype; P.Identity = function () { return new P([1, 0, 0, 0, 1, 0, 0, 0, 1]) }; P.Rotation = function (aD, i) { var j = ad(aD), aC = v(aD), aE = 1 - aC; return new P([aC + an(i.x, 2) * aE, i.x * i.y * aE - i.z * j, i.x * i.z * aE + i.y * j, i.y * i.x * aE + i.z * j, aC + an(i.y, 2) * aE, i.y * i.z * aE - i.x * j, i.z * i.x * aE - i.y * j, i.z * i.y * aE + i.x * j, aC + an(i.z, 2) * aE]) }; aA.mul = function (aC) { var aD = [], aG, aF, aE = (aC.xform ? 1 : 0); for (aG = 1; aG <= 3; ++aG) { for (aF = 1; aF <= 3; ++aF) { if (aE) { aD.push(this[aG][1] * aC[1][aF] + this[aG][2] * aC[2][aF] + this[aG][3] * aC[3][aF]) } else { aD.push(this[aG][aF] * aC) } } } return new P(aD) }; aA.xform = function (aC) { var j = {}, i = aC.x, aE = aC.y, aD = aC.z; j.x = i * this[1][1] + aE * this[2][1] + aD * this[3][1]; j.y = i * this[1][2] + aE * this[2][2] + aD * this[3][2]; j.z = i * this[1][3] + aE * this[2][3] + aD * this[3][3]; return j }; function o(aD, aF, aK, aH) { var aG, aJ, j, aI, aL = [], aE = Math.PI * (3 - C(5)), aC = 2 / aD; for (aG = 0; aG < aD; ++aG) { aJ = aG * aC - 1 + (aC / 2); j = C(1 - aJ * aJ); aI = aG * aE; aL.push([v(aI) * j * aF, aJ * aK, ad(aI) * j * aH]) } return aL } function U(aE, aC, aH, aN, aL) { var aM, aO = [], aF = Math.PI * (3 - C(5)), aD = 2 / aE, aK, aJ, aI, aG; for (aK = 0; aK < aE; ++aK) { aJ = aK * aD - 1 + (aD / 2); aM = aK * aF; aI = v(aM); aG = ad(aM); aO.push(aC ? [aJ * aH, aI * aN, aG * aL] : [aI * aH, aJ * aN, aG * aL]) } return aO } function L(aC, aD, aG, aM, aK, aI) { var aL, aN = [], aE = Math.PI * 2 / aD, aJ, aH, aF; for (aJ = 0; aJ < aD; ++aJ) { aL = aJ * aE; aH = v(aL); aF = ad(aL); aN.push(aC ? [aI * aG, aH * aM, aF * aK] : [aH * aG, aI * aM, aF * aK]) } return aN } function ai(aD, i, j, aC) { return U(aD, 0, i, j, aC) } function ao(aD, i, j, aC) { return U(aD, 1, i, j, aC) } function c(aE, i, j, aC, aD) { aD = isNaN(aD) ? 0 : aD * 1; return L(0, aE, i, j, aC, aD) } function l(aE, i, j, aC, aD) { aD = isNaN(aD) ? 0 : aD * 1; return L(1, aE, i, j, aC, aD) } function S(aF, i) { var aE = aF, aD, aC, j = (i * 1).toPrecision(3) + ")"; if (aF[0] === "#") { if (!f[aF]) { if (aF.length === 4) { f[aF] = "rgba(" + k[aF[1]] + k[aF[2]] + k[aF[3]] } else { f[aF] = "rgba(" + h[aF.substr(1, 2)] + h[aF.substr(3, 2)] + h[aF.substr(5, 2)] } } aE = f[aF] + j } else { if (aF.substr(0, 4) === "rgb(" || aF.substr(0, 4) === "hsl(") { aE = (aF.replace("(", "a(").replace(")", "," + j)) } else { if (aF.substr(0, 5) === "rgba(" || aF.substr(0, 5) === "hsla(") { aD = aF.lastIndexOf(",") + 1, aC = aF.indexOf(")"); i *= parseFloat(aF.substring(aD, aC)); aE = aF.substr(0, aD) + i.toPrecision(3) + ")" } } } return aE } function N(i, j) { if (window.G_vmlCanvasManager) { return null } var aC = B.createElement("canvas"); aC.width = i; aC.height = j; return aC } function ah() { var j = N(3, 3), aD, aC; if (!j) { return false } aD = j.getContext("2d"); aD.strokeStyle = "#000"; aD.shadowColor = "#fff"; aD.shadowBlur = 3; aD.globalAlpha = 0; aD.strokeRect(2, 2, 2, 2); aD.globalAlpha = 1; aC = aD.getImageData(2, 2, 1, 1); j = null; return (aC.data[0] > 0) } function ag(aG, j, aF, aE) { var aD = aG.createLinearGradient(0, 0, j, 0), aC; for (aC in aE) { aD.addColorStop(1 - aC, aE[aC]) } aG.fillStyle = aD; aG.fillRect(0, aF, j, 1) } function g(aE, aC, j) { var aD = 1024, aI = 1, aH = aE.weightGradient, aG, aK, aF, aJ; if (aE.gCanvas) { aK = aE.gCanvas.getContext("2d"); aI = aE.gCanvas.height } else { if (G(aH[0])) { aI = aH.length } else { aH = [aH] } aE.gCanvas = aG = N(aD, aI); if (!aG) { return null } aK = aG.getContext("2d"); for (aF = 0; aF < aI; ++aF) { ag(aK, aD, aF, aH[aF]) } } j = q(ay(j || 0, aI - 1), 0); aJ = aK.getImageData(~~((aD - 1) * aC), j, 1, 1).data; return "rgba(" + aJ[0] + "," + aJ[1] + "," + aJ[2] + "," + (aJ[3] / 255) + ")" } function V(aL, aE, j, aN, aF, aK, aG, aD, aJ, aM) { var aI = aF + (aG || 0) + (aD.length && aD[0] < 0 ? J(aD[0]) : 0), aC = aF + (aG || 0) + (aD.length && aD[1] < 0 ? J(aD[1]) : 0), aH, aO; aL.font = aE; aL.textBaseline = "top"; aL.fillStyle = j; aK && (aL.shadowColor = aK); aG && (aL.shadowBlur = aG); aD.length && (aL.shadowOffsetX = aD[0], aL.shadowOffsetY = aD[1]); for (aH = 0; aH < aN.length; ++aH) { aO = aM ? (aJ - aM[aH]) / 2 : 0; aL.fillText(aN[aH], aI + aO, aC); aC += parseInt(aE) } } function am(aG, i, aF, j, aD, aE, aC) { if (aE) { aG.beginPath(); aG.moveTo(i, aF + aD - aE); aG.arcTo(i, aF, i + aE, aF, aE); aG.arcTo(i + j, aF, i + j, aF + aE, aE); aG.arcTo(i + j, aF + aD, i + j - aE, aF + aD, aE); aG.arcTo(i, aF + aD, i, aF + aD - aE, aE); aG.closePath(); aG[aC ? "stroke" : "fill"]() } else { aG[aC ? "strokeRect" : "fillRect"](i, aF, j, aD) } } function t(aG, aO, aI, aT, aJ, aQ, aH, aR, aP, aN, i, aL, aF, aM, aV) { var aD = aI + J(i[0]) + 2 * (aN + aL) + aR, aK = aT + J(i[1]) + 2 * (aN + aL) + aR, aE, aW, aU, aS, aC, j; aE = N(aD, aK); if (!aE) { return null } aU = aC = aR / 2; aS = aD - aR; j = aK - aR; aL += aU; aW = aE.getContext("2d"); if (aQ) { aW.fillStyle = aQ; am(aW, aU, aC, aS, j, aF) } if (aR) { aW.strokeStyle = aH; aW.lineWidth = aR; am(aW, aU, aC, aS, j, aF, true) } V(aW, aO, aJ, aG, aL, aP, aN, i, aM, aV); return aE } function u(aD, j, aE) { var aC = N(j, aE), aF; if (!aC) { return null } aF = aC.getContext("2d"); aF.drawImage(aD, (j - aD.width) / 2, (aE - aD.height) / 2); return aC } function ar(aD, j, aE) { var aC = N(j, aE), aF; if (!aC) { return null } aF = aC.getContext("2d"); aF.drawImage(aD, 0, 0, j, aE); return aC } function ax(aO, aJ, aP, aT, aK, aI, aH, aM, aF, aG) { var aD = aJ + ((2 * aM) + aI) * aT, aL = aP + ((2 * aM) + aI) * aT, aE = N(aD, aL), aS, aR, aC, aQ, j, aU, aN; if (!aE) { return null } aI *= aT; aF *= aT; aR = aC = aI / 2; aQ = aD - aI; j = aL - aI; aM = (aM * aT) + aR; aS = aE.getContext("2d"); if (aK) { aS.fillStyle = aK; am(aS, aR, aC, aQ, j, aF) } if (aI) { aS.strokeStyle = aH; aS.lineWidth = aI; am(aS, aR, aC, aQ, j, aF, true) } if (aG) { aU = N(aD, aL); aN = aU.getContext("2d"); aN.drawImage(aO, aM, aM, aJ, aP); aN.globalCompositeOperation = "source-in"; aN.fillStyle = aH; aN.fillRect(0, 0, aD, aL); aN.globalCompositeOperation = "destination-over"; aN.drawImage(aE, 0, 0); aN.globalCompositeOperation = "source-over"; aS.drawImage(aU, 0, 0) } else { aS.drawImage(aO, aM, aM, aO.width, aO.height) } return { image: aE, width: aD / aT, height: aL / aT } } function X(aI, aO, aK, aE, aM, aN, aD) { var aP = J(aD[0]), aJ = J(aD[1]), aF = aO + (aP > aN ? aP + aN : aN * 2) * aE, j = aK + (aJ > aN ? aJ + aN : aN * 2) * aE, aH = aE * ((aN || 0) + (aD[0] < 0 ? aP : 0)), aC = aE * ((aN || 0) + (aD[1] < 0 ? aJ : 0)), aG, aL; aG = N(aF, j); if (!aG) { return null } aL = aG.getContext("2d"); aM && (aL.shadowColor = aM); aN && (aL.shadowBlur = aN * aE); aD && (aL.shadowOffsetX = aD[0] * aE, aL.shadowOffsetY = aD[1] * aE); aL.drawImage(aI, aH, aC, aO, aK); return { image: aG, width: aF / aE, height: j / aE } } function r(aO, aG, aM) { var aN = parseInt(aO.toString().length * aM), aF = parseInt(aM * 2 * aO.length), aD = N(aN, aF), aJ, j, aE, aI, aL, aK, aC, aH; if (!aD) { return null } aJ = aD.getContext("2d"); aJ.fillStyle = "#000"; aJ.fillRect(0, 0, aN, aF); V(aJ, aM + "px " + aG, "#fff", aO, 0, 0, 0, []); j = aJ.getImageData(0, 0, aN, aF); aE = j.width; aI = j.height; aH = { min: { x: aE, y: aI }, max: { x: -1, y: -1 } }; for (aK = 0; aK < aI; ++aK) { for (aL = 0; aL < aE; ++aL) { aC = (aK * aE + aL) * 4; if (j.data[aC + 1] > 0) { if (aL < aH.min.x) { aH.min.x = aL } if (aL > aH.max.x) { aH.max.x = aL } if (aK < aH.min.y) { aH.min.y = aK } if (aK > aH.max.y) { aH.max.y = aK } } } } if (aE != aN) { aH.min.x *= (aN / aE); aH.max.x *= (aN / aE) } if (aI != aF) { aH.min.y *= (aN / aI); aH.max.y *= (aN / aI) } aD = null; return aH } function m(i) { return "'" + i.replace(/(\'|\")/g, "").replace(/\s*,\s*/g, "', '") + "'" } function Z(i, j, aC) { aC = aC || B; if (aC.addEventListener) { aC.addEventListener(i, j, false) } else { aC.attachEvent("on" + i, j) } } function aq(aG, aC, aK, aF) { var aL = aF.imageScale, aI, aD, aH, j, aE, aJ; if (!aC.complete) { return Z("load", function () { aq(aG, aC, aK, aF) }, aC) } if (!aG.complete) { return Z("load", function () { aq(aG, aC, aK, aF) }, aG) } aC.width = aC.width; aC.height = aC.height; if (aL) { aG.width = aC.width * aL; aG.height = aC.height * aL } aK.w = aG.width; aK.h = aG.height; if (aF.txtOpt) { aD = aG; aI = aF.zoomMax * aF.txtScale; aE = aK.w * aI; aJ = aK.h * aI; if (aE < aC.naturalWidth || aJ < aC.naturalHeight) { aD = ar(aG, aE, aJ); if (aD) { aK.image = aD } } else { aE = aK.w; aJ = aK.h; aI = 1 } if (aF.shadow) { aD = X(aK.image, aE, aJ, aI, aF.shadow, aF.shadowBlur, aF.shadowOffset); if (aD) { aK.image = aD.image; aK.w = aD.width; aK.h = aD.height } } if (aF.bgColour || aF.bgOutlineThickness) { aH = aF.bgColour == "tag" ? W(aK.a, "background-color") : aF.bgColour; j = aF.bgOutline == "tag" ? W(aK.a, "color") : (aF.bgOutline || aF.textColour); aE = aK.image.width; aJ = aK.image.height; if (aF.outlineMethod == "colour") { aD = ax(aK.image, aE, aJ, aI, aH, aF.bgOutlineThickness, aF.outlineColour, aF.padding, aF.bgRadius, 1); if (aD) { aK.oimage = aD.image } } aD = ax(aK.image, aE, aJ, aI, aH, aF.bgOutlineThickness, j, aF.padding, aF.bgRadius); if (aD) { aK.image = aD.image; aK.w = aD.width; aK.h = aD.height } } if (aF.outlineMethod == "size") { if (aF.outlineIncrease > 0) { aK.w += 2 * aF.outlineIncrease; aK.h += 2 * aF.outlineIncrease; aE = aI * aK.w; aJ = aI * aK.h; aD = ar(aK.image, aE, aJ); aK.oimage = aD; aK.image = u(aK.image, aK.oimage.width, aK.oimage.height) } else { aE = aI * (aK.w + (2 * aF.outlineIncrease)); aJ = aI * (aK.h + (2 * aF.outlineIncrease)); aD = ar(aK.image, aE, aJ); aK.oimage = u(aD, aK.image.width, aK.image.height) } } } } function W(aD, aC) { var j = B.defaultView, i = aC.replace(/\-([a-z])/g, function (aE) { return aE.charAt(1).toUpperCase() }); return (j && j.getComputedStyle && j.getComputedStyle(aD, null).getPropertyValue(aC)) || (aD.currentStyle && aD.currentStyle[i]) } function s(j, aD, aC) { var i = 1, aE; if (aD) { i = 1 * (j.getAttribute(aD) || aC) } else { if (aE = W(j, "font-size")) { i = (aE.indexOf("px") > -1 && aE.replace("px", "") * 1) || (aE.indexOf("pt") > -1 && aE.replace("pt", "") * 1.25) || aE * 3.3 } } return i } function e(i) { return i.target && ae(i.target.id) ? i.target.id : i.srcElement.parentNode.id } function Q(aE, aF) { var aD, aC, i = parseInt(W(aF, "width")) / aF.width, j = parseInt(W(aF, "height")) / aF.height; if (ae(aE.offsetX)) { aD = { x: aE.offsetX, y: aE.offsetY } } else { aC = Y(aF.id); if (ae(aE.changedTouches)) { aE = aE.changedTouches[0] } if (aE.pageX) { aD = { x: aE.pageX - aC.x, y: aE.pageY - aC.y } } } if (aD && i && j) { aD.x /= i; aD.y /= j } return aD } function A(aC) { var j = aC.target || aC.fromElement.parentNode, i = x.tc[j.id]; if (i) { i.mx = i.my = -1; i.UnFreeze(); i.EndDrag() } } function ab(aG) { var aD, aC = x, j, aF, aE = e(aG); for (aD in aC.tc) { j = aC.tc[aD]; if (j.tttimer) { clearTimeout(j.tttimer); j.tttimer = null } } if (aE && aC.tc[aE]) { j = aC.tc[aE]; if (aF = Q(aG, j.canvas)) { j.mx = aF.x; j.my = aF.y; j.Drag(aG, aF) } j.drawn = 0 } } function y(aD) { var j = x, i = B.addEventListener ? 0 : 1, aC = e(aD); if (aC && aD.button == i && j.tc[aC]) { j.tc[aC].BeginDrag(aD) } } function az(aE) { var aC = x, j = B.addEventListener ? 0 : 1, aD = e(aE), i; if (aD && aE.button == j && aC.tc[aD]) { i = aC.tc[aD]; ab(aE); if (!i.EndDrag() && !i.touched) { i.Clicked(aE) } } } function R(aC) { var i = x, j = e(aC); if (j && aC.changedTouches && i.tc[j]) { i.tc[j].touched = 1; i.tc[j].BeginDrag(aC) } } function p(aC) { var i = x, j = e(aC); if (j && aC.changedTouches && i.tc[j]) { au(aC); if (!i.tc[j].EndDrag()) { i.tc[j].Draw(); i.tc[j].Clicked(aC) } } } function au(aG) { var aD, aC = x, j, aF, aE = e(aG); for (aD in aC.tc) { j = aC.tc[aD]; if (j.tttimer) { clearTimeout(j.tttimer); j.tttimer = null } } if (aE && aC.tc[aE] && aG.changedTouches) { j = aC.tc[aE]; if (aF = Q(aG, j.canvas)) { j.mx = aF.x; j.my = aF.y; j.Drag(aG, aF) } j.drawn = 0 } } function ac(aC) { var i = x, j = e(aC); if (j && i.tc[j]) { aC.cancelBubble = true; aC.returnValue = false; aC.preventDefault && aC.preventDefault(); i.tc[j].Wheel((aC.wheelDelta || aC.detail) > 0) } } function M() { D(E()) } function D(aD) { var j = x.tc, aC; x.NextFrame(x.interval); aD = aD || E(); for (aC in j) { j[aC].Draw(aD) } } function Y(aC) { var aF = B.getElementById(aC), i = aF.getBoundingClientRect(), aI = B.documentElement, aG = B.body, aH = window, aD = aH.pageXOffset || aI.scrollLeft, aJ = aH.pageYOffset || aI.scrollTop, aE = aI.clientLeft || aG.clientLeft, j = aI.clientTop || aG.clientTop; return { x: i.left + aD - aE, y: i.top + aJ - j } } function T(j, aD, aE, aC) { var i = j.radius * j.z1 / (j.z1 + j.z2 + aD.z); return { x: aD.x * i * aE, y: aD.y * i * aC, z: aD.z, w: (j.z1 - aD.z) / j.z2 } } function aw(i) { this.e = i; this.br = 0; this.line = []; this.text = []; this.original = i.innerText || i.textContent } aB = aw.prototype; aB.Lines = function (aE) { var aD = aE ? 1 : 0, aF, j, aC; aE = aE || this.e; aF = aE.childNodes; j = aF.length; for (aC = 0; aC < j; ++aC) { if (aF[aC].nodeName == "BR") { this.text.push(this.line.join(" ")); this.br = 1 } else { if (aF[aC].nodeType == 3) { if (this.br) { this.line = [aF[aC].nodeValue]; this.br = 0 } else { this.line.push(aF[aC].nodeValue) } } else { this.Lines(aF[aC]) } } } aD || this.br || this.text.push(this.line.join(" ")); return this.text }; aB.SplitWidth = function (aC, aJ, aG, aF) { var aE, aD, aI, aH = []; aJ.font = aF + "px " + aG; for (aE = 0; aE < this.text.length; ++aE) { aI = this.text[aE].split(/\s+/); this.line = [aI[0]]; for (aD = 1; aD < aI.length; ++aD) { if (aJ.measureText(this.line.join(" ") + " " + aI[aD]).width > aC) { aH.push(this.line.join(" ")); this.line = [aI[aD]] } else { this.line.push(aI[aD]) } } aH.push(this.line.join(" ")) } return this.text = aH }; function H(i, j) { this.ts = E(); this.tc = i; this.tag = j; this.x = this.y = this.w = this.h = this.sc = 1; this.z = 0; this.Draw = i.pulsateTo < 1 && i.outlineMethod != "colour" ? this.DrawPulsate : this.DrawSimple; this.radius = i.outlineRadius | 0; this.SetMethod(i.outlineMethod) } w = H.prototype; w.SetMethod = function (aC) { var j = { block: ["PreDraw", "DrawBlock"], colour: ["PreDraw", "DrawColour"], outline: ["PostDraw", "DrawOutline"], classic: ["LastDraw", "DrawOutline"], size: ["PreDraw", "DrawColour"], none: ["LastDraw"] }, i = j[aC] || j.outline; if (aC == "none") { this.Draw = function () { return 1 } } else { this.drawFunc = this[i[1]] } this[i[0]] = this.Draw }; w.Update = function (aI, aH, aJ, aE, aF, aG, aD, i) { var j = this.tc.outlineOffset, aC = 2 * j; this.x = aF * aI + aD - j; this.y = aF * aH + i - j; this.w = aF * aJ + aC; this.h = aF * aE + aC; this.sc = aF; this.z = aG }; w.DrawOutline = function (aF, i, aE, j, aC, aD) { aF.strokeStyle = aD; am(aF, i, aE, j, aC, this.radius, true) }; w.DrawColour = function (aD, aG, aE, aH, aC, i, aI, j, aF) { if (aI.oimage) { aI.alpha = 1; aI.Draw(aD, j, aF, aI.oimage); return 1 } return this[aI.image ? "DrawColourImage" : "DrawColourText"](aD, aG, aE, aH, aC, i, aI, j, aF) }; w.DrawColourText = function (aE, aH, aF, aI, aC, i, aJ, j, aG) { var aD = aJ.colour; aJ.colour = i; aJ.alpha = 1; aJ.Draw(aE, j, aG); aJ.colour = aD; return 1 }; w.DrawColourImage = function (aH, aK, aI, aL, aG, i, aO, j, aJ) { var aM = aH.canvas, aE = ~~q(aK, 0), aD = ~~q(aI, 0), aF = ay(aM.width - aE, aL) + 0.5 | 0, aN = ay(aM.height - aD, aG) + 0.5 | 0, aC; if (n) { n.width = aF, n.height = aN } else { n = N(aF, aN) } if (!n) { return this.SetMethod("outline") } aC = n.getContext("2d"); aC.drawImage(aM, aE, aD, aF, aN, 0, 0, aF, aN); aH.clearRect(aE, aD, aF, aN); aO.alpha = 1; aO.Draw(aH, j, aJ); aH.setTransform(1, 0, 0, 1, 0, 0); aH.save(); aH.beginPath(); aH.rect(aE, aD, aF, aN); aH.clip(); aH.globalCompositeOperation = "source-in"; aH.fillStyle = i; aH.fillRect(aE, aD, aF, aN); aH.restore(); aH.globalCompositeOperation = "destination-over"; aH.drawImage(n, 0, 0, aF, aN, aE, aD, aF, aN); aH.globalCompositeOperation = "source-over"; return 1 }; w.DrawBlock = function (aF, i, aE, j, aC, aD) { aF.fillStyle = aD; am(aF, i, aE, j, aC, this.radius) }; w.DrawSimple = function (aE, i, j, aD) { var aC = this.tc; aE.setTransform(1, 0, 0, 1, 0, 0); aE.strokeStyle = aC.outlineColour; aE.lineWidth = aC.outlineThickness; aE.shadowBlur = aE.shadowOffsetX = aE.shadowOffsetY = 0; aE.globalAlpha = 1; return this.drawFunc(aE, this.x, this.y, this.w, this.h, aC.outlineColour, i, j, aD) }; w.DrawPulsate = function (aF, i, j, aD) { var aE = E() - this.ts, aC = this.tc; aF.setTransform(1, 0, 0, 1, 0, 0); aF.strokeStyle = aC.outlineColour; aF.lineWidth = aC.outlineThickness; aF.shadowBlur = aF.shadowOffsetX = aF.shadowOffsetY = 0; aF.globalAlpha = aC.pulsateTo + ((1 - aC.pulsateTo) * (0.5 + (v(2 * Math.PI * aE / (1000 * aC.pulsateTime)) / 2))); return this.drawFunc(aF, this.x, this.y, this.w, this.h, aC.outlineColour, i, j, aD) }; w.Active = function (aC, i, j) { return (i >= this.x && j >= this.y && i <= this.x + this.w && j <= this.y + this.h) }; w.PreDraw = w.PostDraw = w.LastDraw = av; function d(aD, aO, aK, aN, aL, aE, aC, aG, aM, aF, aJ, j, aI, i) { var aH = aD.ctxt; this.tc = aD; this.image = aO.src ? aO : null; this.text = aO.src ? [] : aO; this.text_original = i; this.line_widths = []; this.title = aK.title || null; this.a = aK; this.position = new aa(aN[0], aN[1], aN[2]); this.x = this.y = this.z = 0; this.w = aL; this.h = aE; this.colour = aC || aD.textColour; this.bgColour = aG || aD.bgColour; this.bgRadius = aM | 0; this.bgOutline = aF || this.colour; this.bgOutlineThickness = aJ | 0; this.textFont = j || aD.textFont; this.padding = aI | 0; this.sc = this.alpha = 1; this.weighted = !aD.weight; this.outline = new H(aD, this); if (!this.image) { this.textHeight = aD.textHeight; this.Measure(aH, aD) } this.SetShadowColour = aD.shadowAlpha ? this.SetShadowColourAlpha : this.SetShadowColourFixed; this.SetDraw(aD) } b = d.prototype; b.EqualTo = function (aC) { var j = aC.getElementsByTagName("img"); if (this.a.href != aC.href) { return 0 } if (j.length) { return this.image.src == j[0].src } return (aC.innerText || aC.textContent) == this.text_original }; b.SetDraw = function (i) { this.Draw = this.image ? (i.ie > 7 ? this.DrawImageIE : this.DrawImage) : this.DrawText; i.noSelect && (this.CheckActive = av) }; b.MeasureText = function (aF) { var aD, aC = this.text.length, j = 0, aE; for (aD = 0; aD < aC; ++aD) { this.line_widths[aD] = aE = aF.measureText(this.text[aD]).width; j = q(j, aE) } return j }; b.Measure = function (aH, j) { var aF = r(this.text, this.textFont, this.textHeight), aD, aE, aG, aC, i; this.h = aF ? aF.max.y + aF.min.y : this.textHeight; aH.font = this.font = this.textHeight + "px " + this.textFont; this.w = this.MeasureText(aH); if (j.txtOpt) { aD = j.txtScale; aE = aD * this.textHeight; aG = aE + "px " + this.textFont; aC = [aD * j.shadowOffset[0], aD * j.shadowOffset[1]]; aH.font = aG; i = this.MeasureText(aH); this.image = t(this.text, aG, i + aD, (aD * this.h) + aD, this.colour, this.bgColour, this.bgOutline, aD * this.bgOutlineThickness, j.shadow, aD * j.shadowBlur, aC, aD * this.padding, aD * this.bgRadius, i, this.line_widths); if (j.outlineMethod == "colour") { this.oimage = t(this.text, aG, i + aD, (aD * this.h) + aD, j.outlineColour, this.bgColour, j.outlineColour, aD * this.bgOutlineThickness, j.shadow, aD * j.shadowBlur, aC, aD * this.padding, aD * this.bgRadius, i, this.line_widths) } else { if (j.outlineMethod == "size") { aF = r(this.text, this.textFont, this.textHeight + j.outlineIncrease); aE = aF.max.y + aF.min.y; aG = (aD * (this.textHeight + j.outlineIncrease)) + "px " + this.textFont; aH.font = aG; i = this.MeasureText(aH); this.oimage = t(this.text, aG, i + aD, (aD * aE) + aD, this.colour, this.bgColour, this.bgOutline, aD * this.bgOutlineThickness, j.shadow, aD * j.shadowBlur, aC, aD * this.padding, aD * this.bgRadius, i, this.line_widths); if (j.outlineIncrease > 0) { this.image = u(this.image, this.oimage.width, this.oimage.height) } else { this.oimage = u(this.oimage, this.image.width, this.image.height) } } } if (this.image) { this.w = this.image.width / aD; this.h = this.image.height / aD } this.SetDraw(j); j.txtOpt = !!this.image } }; b.SetFont = function (j, aD, aC, i) { this.textFont = j; this.colour = aD; this.bgColour = aC; this.bgOutline = i; this.Measure(this.tc.ctxt, this.tc) }; b.SetWeight = function (aC) { var j = this.tc, aE = j.weightMode.split(/[, ]/), i, aD, aF = aC.length; if (!this.text.length) { return } this.weighted = true; for (aD = 0; aD < aF; ++aD) { i = aE[aD] || "size"; if ("both" == i) { this.Weight(aC[aD], j.ctxt, j, "size", j.min_weight[aD], j.max_weight[aD], aD); this.Weight(aC[aD], j.ctxt, j, "colour", j.min_weight[aD], j.max_weight[aD], aD) } else { this.Weight(aC[aD], j.ctxt, j, i, j.min_weight[aD], j.max_weight[aD], aD) } } this.Measure(j.ctxt, j) }; b.Weight = function (aC, aH, aD, j, aG, aE, aF) { aC = isNaN(aC) ? 1 : aC; var i = (aC - aG) / (aE - aG); if ("colour" == j) { this.colour = g(aD, i, aF) } else { if ("bgcolour" == j) { this.bgColour = g(aD, i, aF) } else { if ("bgoutline" == j) { this.bgOutline = g(aD, i, aF) } else { if ("size" == j) { if (aD.weightSizeMin > 0 && aD.weightSizeMax > aD.weightSizeMin) { this.textHeight = aD.weightSize * (aD.weightSizeMin + (aD.weightSizeMax - aD.weightSizeMin) * i) } else { this.textHeight = q(1, aC * aD.weightSize) } } } } } }; b.SetShadowColourFixed = function (aC, j, i) { aC.shadowColor = j }; b.SetShadowColourAlpha = function (aC, j, i) { aC.shadowColor = S(j, i) }; b.DrawText = function (aE, aH, aD) { var aI = this.tc, aG = this.x, aF = this.y, aJ = this.sc, j, aC; aE.globalAlpha = this.alpha; aE.fillStyle = this.colour; aI.shadow && this.SetShadowColour(aE, aI.shadow, this.alpha); aE.font = this.font; aG += aH / aJ; aF += (aD / aJ) - (this.h / 2); for (j = 0; j < this.text.length; ++j) { aC = aG - (this.line_widths[j] / 2); aE.setTransform(aJ, 0, 0, aJ, aJ * aC, aJ * aF); aE.fillText(this.text[j], 0, 0); aF += this.textHeight } }; b.DrawImage = function (aE, aL, aD, aG) { var aI = this.x, aF = this.y, aM = this.sc, j = aG || this.image, aJ = this.w, aC = this.h, aH = this.alpha, aK = this.shadow; aE.globalAlpha = aH; aK && this.SetShadowColour(aE, aK, aH); aI += (aL / aM) - (aJ / 2); aF += (aD / aM) - (aC / 2); aE.setTransform(aM, 0, 0, aM, aM * aI, aM * aF); aE.drawImage(j, 0, 0, aJ, aC) }; b.DrawImageIE = function (aE, aI, aD) { var j = this.image, aJ = this.sc, aH = j.width = this.w * aJ, aC = j.height = this.h * aJ, aG = (this.x * aJ) + aI - (aH / 2), aF = (this.y * aJ) + aD - (aC / 2); aE.setTransform(1, 0, 0, 1, 0, 0); aE.globalAlpha = this.alpha; aE.drawImage(j, aG, aF) }; b.Calc = function (i, aC) { var j, aF = this.tc, aE = aF.minBrightness, aD = aF.maxBrightness, aG = aF.max_radius; j = i.xform(this.position); this.xformed = j; j = T(aF, j, aF.stretchX, aF.stretchY); this.x = j.x; this.y = j.y; this.z = j.z; this.sc = j.w; this.alpha = aC * ap(aE + (aD - aE) * (aG - this.z) / (2 * aG), 0, 1) }; b.UpdateActive = function (aH, aC, aF) { var aE = this.outline, j = this.w, aD = this.h, i = this.x - j / 2, aG = this.y - aD / 2; aE.Update(i, aG, j, aD, this.sc, this.z, aC, aF); return aE }; b.CheckActive = function (aE, i, aD) { var j = this.tc, aC = this.UpdateActive(aE, i, aD); return aC.Active(aE, j.mx, j.my) ? aC : null }; b.Clicked = function (aF) { var j = this.a, aC = j.target, aD = j.href, i; if (aC != "" && aC != "_self") { if (self.frames[aC]) { self.frames[aC].document.location = aD } else { try { if (top.frames[aC]) { top.frames[aC].document.location = aD; return } } catch (aE) { } window.open(aD, aC) } return } if (B.createEvent) { i = B.createEvent("MouseEvents"); i.initMouseEvent("click", 1, 1, window, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null); if (!j.dispatchEvent(i)) { return } } else { if (j.fireEvent) { if (!j.fireEvent("onclick")) { return } } } B.location = aD }; function x(aI, j, aD) { var aC, aF, aH = B.getElementById(aI), aE = ["id", "class", "innerHTML"], aG; if (!aH) { throw 0 } if (ae(window.G_vmlCanvasManager)) { aH = window.G_vmlCanvasManager.initElement(aH); this.ie = parseFloat(navigator.appVersion.split("MSIE")[1]) } if (aH && (!aH.getContext || !aH.getContext("2d").fillText)) { aF = B.createElement("DIV"); for (aC = 0; aC < aE.length; ++aC) { aF[aE[aC]] = aH[aE[aC]] } aH.parentNode.insertBefore(aF, aH); aH.parentNode.removeChild(aH); throw 0 } for (aC in x.options) { this[aC] = aD && ae(aD[aC]) ? aD[aC] : (ae(x[aC]) ? x[aC] : x.options[aC]) } this.canvas = aH; this.ctxt = aH.getContext("2d"); this.z1 = 250 / this.depth; this.z2 = this.z1 / this.zoom; this.radius = ay(aH.height, aH.width) * 0.0075; this.max_weight = []; this.min_weight = []; this.textFont = this.textFont && m(this.textFont); this.textHeight *= 1; this.pulsateTo = ap(this.pulsateTo, 0, 1); this.minBrightness = ap(this.minBrightness, 0, 1); this.maxBrightness = ap(this.maxBrightness, this.minBrightness, 1); this.ctxt.textBaseline = "top"; this.lx = (this.lock + "").indexOf("x") + 1; this.ly = (this.lock + "").indexOf("y") + 1; this.frozen = this.dx = this.dy = this.fixedAnim = this.touched = 0; this.fixedAlpha = 1; this.source = j || aI; this.transform = P.Identity(); this.startTime = this.time = E(); this.Animate = this.dragControl ? this.AnimateDrag : this.AnimatePosition; this.animTiming = (typeof x[this.animTiming] == "function" ? x[this.animTiming] : x.Smooth); if (this.shadowBlur || this.shadowOffset[0] || this.shadowOffset[1]) { this.ctxt.shadowColor = this.shadow; this.shadow = this.ctxt.shadowColor; this.shadowAlpha = ah() } else { delete this.shadow } this.Load(); if (j && this.hideTags) { (function (i) { if (x.loaded) { i.HideTags() } else { Z("load", function () { i.HideTags() }, window) } })(this) } this.yaw = this.initial ? this.initial[0] * this.maxSpeed : 0; this.pitch = this.initial ? this.initial[1] * this.maxSpeed : 0; if (this.tooltip) { if (this.tooltip == "native") { this.Tooltip = this.TooltipNative } else { this.Tooltip = this.TooltipDiv; if (!this.ttdiv) { this.ttdiv = B.createElement("div"); this.ttdiv.className = this.tooltipClass; this.ttdiv.style.position = "absolute"; this.ttdiv.style.zIndex = aH.style.zIndex + 1; Z("mouseover", function (i) { i.target.style.display = "none" }, this.ttdiv); B.body.appendChild(this.ttdiv) } } } else { this.Tooltip = this.TooltipNone } if (!this.noMouse && !a[aI]) { Z("mousemove", ab, aH); Z("mouseout", A, aH); Z("mouseup", az, aH); Z("touchstart", R, aH); Z("touchend", p, aH); Z("touchcancel", p, aH); Z("touchmove", au, aH); if (this.dragControl) { Z("mousedown", y, aH); Z("selectstart", av, aH) } if (this.wheelZoom) { Z("mousewheel", ac, aH); Z("DOMMouseScroll", ac, aH) } a[aI] = 1 } if (!x.started) { aG = window.requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame; x.NextFrame = aG ? x.NextFrameRAF : x.NextFrameTimeout; x.interval = this.interval; x.NextFrame(this.interval); x.started = 1 } } O = x.prototype; O.SourceElements = function () { if (B.querySelectorAll) { return B.querySelectorAll("#" + this.source) } return [B.getElementById(this.source)] }; O.HideTags = function () { var aC = this.SourceElements(), j; for (j = 0; j < aC.length; ++j) { aC[j].style.display = "none" } }; O.GetTags = function () { var aG = this.SourceElements(), aF, aC = [], aE, aD; for (aE = 0; aE < aG.length; ++aE) { aF = aG[aE].getElementsByTagName("a"); for (aD = 0; aD < aF.length; ++aD) { aC.push(aF[aD]) } } return aC }; O.CreateTag = function (aF, j) { var aI = aF.getElementsByTagName("img"), aE, aJ, aH, aC, aG, aD; j = j || [0, 0, 0]; if (aI.length) { aE = new Image; aE.src = aI[0].src; aJ = new d(this, aE, aF, j, 0, 0); aq(aE, aI[0], aJ, this); return aJ } aH = new aw(aF); aJ = aH.Lines(); aC = this.textFont || m(W(aF, "font-family")); if (this.splitWidth) { aJ = aH.SplitWidth(this.splitWidth, this.ctxt, aC, this.textHeight) } aG = this.bgColour == "tag" ? W(aF, "background-color") : this.bgColour; aD = this.bgOutline == "tag" ? W(aF, "color") : this.bgOutline; return new d(this, aJ, aF, j, 2, this.textHeight + 2, this.textColour || W(aF, "color"), aG, this.bgRadius, aD, this.bgOutlineThickness, aC, this.padding, aH.original) }; O.UpdateTag = function (aC, i) { var aF = this.textColour || W(i, "color"), j = this.textFont || m(W(i, "font-family")), aE = this.bgColour == "tag" ? W(i, "background-color") : this.bgColour, aD = this.bgOutline == "tag" ? W(i, "color") : this.bgOutline; aC.a = i; aC.title = i.title; if (aC.colour != aF || aC.textFont != j || aC.bgColour != aE || aC.bgOutline != aD) { aC.SetFont(j, aF, aE, aD) } }; O.Weight = function (aI) { var aE = aI.length, aG, aC, aJ, aF = [], j, aD = this.weightFrom ? this.weightFrom.split(/[, ]/) : [null], aH = aD.length; for (aC = 0; aC < aE; ++aC) { aF[aC] = []; for (aJ = 0; aJ < aH; ++aJ) { aG = s(aI[aC].a, aD[aJ], this.textHeight); if (!this.max_weight[aJ] || aG > this.max_weight[aJ]) { this.max_weight[aJ] = aG } if (!this.min_weight[aJ] || aG < this.min_weight[aJ]) { this.min_weight[aJ] = aG } aF[aC][aJ] = aG } } for (aJ = 0; aJ < aH; ++aJ) { if (this.max_weight[aJ] > this.min_weight[aJ]) { j = 1 } } if (j) { for (aC = 0; aC < aE; ++aC) { aI[aC].SetWeight(aF[aC]) } } }; O.Load = function () { var aL = this.GetTags(), aH = [], aK, aG, aD, aC, j, aE, aJ, aF = [], aI = { sphere: o, vcylinder: ai, hcylinder: ao, vring: c, hring: l }; if (aL.length) { aF.length = aL.length; for (aJ = 0; aJ < aL.length; ++aJ) { aF[aJ] = aJ } this.shuffleTags && aj(aF); aD = 100 * this.radiusX; aC = 100 * this.radiusY; j = 100 * this.radiusZ; this.max_radius = q(aD, q(aC, j)); if (this.shapeArgs) { this.shapeArgs[0] = aL.length } else { aG = this.shape.toString().split(/[(),]/); aK = aG.shift(); this.shape = aI[aK] || aI.sphere; this.shapeArgs = [aL.length, aD, aC, j].concat(aG) } aE = this.shape.apply(this, this.shapeArgs); this.listLength = aL.length; for (aJ = 0; aJ < aL.length; ++aJ) { aH.push(this.CreateTag(aL[aF[aJ]], aE[aJ])) } this.weight && this.Weight(aH, true) } this.taglist = aH }; O.Update = function () { var aL = this.GetTags(), aK = [], aF = this.taglist, aM, aJ = [], aH = [], aD, aI, aC, aG, aE; if (!this.shapeArgs) { return this.Load() } if (aL.length) { aC = this.listLength = aL.length; aI = aF.length; for (aG = 0; aG < aI; ++aG) { aK.push(aF[aG]); aH.push(aG) } for (aG = 0; aG < aC; ++aG) { for (aE = 0, aM = 0; aE < aI; ++aE) { if (aF[aE].EqualTo(aL[aG])) { this.UpdateTag(aK[aE], aL[aG]); aM = aH[aE] = -1 } } if (!aM) { aJ.push(aG) } } for (aG = 0, aE = 0; aG < aI; ++aG) { if (aH[aE] == -1) { aH.splice(aE, 1) } else { ++aE } } if (aH.length) { aj(aH); while (aH.length && aJ.length) { aG = aH.shift(); aE = aJ.shift(); aK[aG] = this.CreateTag(aL[aE]) } aH.sort(function (j, i) { return j - i }); while (aH.length) { aK.splice(aH.pop(), 1) } } aE = aK.length / (aJ.length + 1); aG = 0; while (aJ.length) { aK.splice(al(++aG * aE), 0, this.CreateTag(aL[aJ.shift()])) } this.shapeArgs[0] = aC = aK.length; aD = this.shape.apply(this, this.shapeArgs); for (aG = 0; aG < aC; ++aG) { aK[aG].position = new aa(aD[aG][0], aD[aG][1], aD[aG][2]) } this.weight && this.Weight(aK) } this.taglist = aK }; O.SetShadow = function (i) { i.shadowBlur = this.shadowBlur; i.shadowOffsetX = this.shadowOffset[0]; i.shadowOffsetY = this.shadowOffset[1] }; O.Draw = function (aM) { if (this.paused) { return } var aG = this.canvas, aE = aG.width, aL = aG.height, aO = 0, aD = (aM - this.time) * x.interval / 1000, aK = aE / 2 + this.offsetX, aJ = aL / 2 + this.offsetY, aS = this.ctxt, aI, aT, aQ, aC = -1, aF = this.taglist, aP = aF.length, j = this.frontSelect, aN = (this.centreFunc == av), aH; this.time = aM; if (this.frozen && this.drawn) { return this.Animate(aE, aL, aD) } aH = this.AnimateFixed(); aS.setTransform(1, 0, 0, 1, 0, 0); for (aQ = 0; aQ < aP; ++aQ) { aF[aQ].Calc(this.transform, this.fixedAlpha) } aF = z(aF, function (aU, i) { return i.z - aU.z }); if (aH && this.fixedAnim.active) { aI = this.fixedAnim.tag.UpdateActive(aS, aK, aJ) } else { this.active = null; for (aQ = 0; aQ < aP; ++aQ) { aT = this.mx >= 0 && this.my >= 0 && this.taglist[aQ].CheckActive(aS, aK, aJ); if (aT && aT.sc > aO && (!j || aT.z <= 0)) { aI = aT; aC = aQ; aI.tag = this.taglist[aQ]; aO = aT.sc } } this.active = aI } this.txtOpt || (this.shadow && this.SetShadow(aS)); aS.clearRect(0, 0, aE, aL); for (aQ = 0; aQ < aP; ++aQ) { if (!aN && aF[aQ].z <= 0) { try { this.centreFunc(aS, aE, aL, aK, aJ) } catch (aR) { alert(aR); this.centreFunc = av } aN = true } if (!(aI && aI.tag == aF[aQ] && aI.PreDraw(aS, aF[aQ], aK, aJ))) { aF[aQ].Draw(aS, aK, aJ) } aI && aI.tag == aF[aQ] && aI.PostDraw(aS) } if (this.freezeActive && aI) { this.Freeze() } else { this.UnFreeze(); this.drawn = (aP == this.listLength) } if (this.fixedCallback) { this.fixedCallback(this, this.fixedCallbackTag); this.fixedCallback = null } aH || this.Animate(aE, aL, aD); aI && aI.LastDraw(aS); aG.style.cursor = aI ? this.activeCursor : ""; this.Tooltip(aI, this.taglist[aC]) }; O.TooltipNone = function () { }; O.TooltipNative = function (j, i) { this.canvas.title = j && i && i.title ? i.title : "" }; O.TooltipDiv = function (aE, j) { var i = this, aD = i.ttdiv.style, aF = i.canvas.id, aC = "none"; if (aE && j && j.title) { if (j.title != i.ttdiv.innerHTML) { aD.display = aC } i.ttdiv.innerHTML = j.title; j.title = i.ttdiv.innerHTML; if (aD.display == aC && !i.tttimer) { i.tttimer = setTimeout(function () { var aG = Y(aF); aD.display = "block"; aD.left = aG.x + i.mx + "px"; aD.top = aG.y + i.my + 24 + "px"; i.tttimer = null }, i.tooltipDelay) } } else { aD.display = aC } }; O.Transform = function (aF, i, aH) { if (i || aH) { var j = ad(i), aG = v(i), aI = ad(aH), aE = v(aH), aC = new P([aE, 0, aI, 0, 1, 0, -aI, 0, aE]), aD = new P([1, 0, 0, 0, aG, -j, 0, j, aG]); aF.transform = aF.transform.mul(aC.mul(aD)) } }; O.AnimateFixed = function () { var aC, j, aE, i, aD; if (this.fadeIn) { j = E() - this.startTime; if (j >= this.fadeIn) { this.fadeIn = 0; this.fixedAlpha = 1 } else { this.fixedAlpha = j / this.fadeIn } } if (this.fixedAnim) { if (!this.fixedAnim.transform) { this.fixedAnim.transform = this.transform } aC = this.fixedAnim, j = E() - aC.t0, aE = aC.angle, i, aD = this.animTiming(aC.t, j); this.transform = aC.transform; if (j >= aC.t) { this.fixedCallbackTag = aC.tag; this.fixedCallback = aC.cb; this.fixedAnim = this.yaw = this.pitch = 0 } else { aE *= aD } i = P.Rotation(aE, aC.axis); this.transform = this.transform.mul(i); return (this.fixedAnim != 0) } return false }; O.AnimatePosition = function (aC, aF, aD) { var j = this, i = j.mx, aH = j.my, aE, aG; if (!j.frozen && i >= 0 && aH >= 0 && i < aC && aH < aF) { aE = j.maxSpeed, aG = j.reverse ? -1 : 1; j.lx || (j.yaw = ((i * 2 * aE / aC) - aE) * aG * aD); j.ly || (j.pitch = ((aH * 2 * aE / aF) - aE) * -aG * aD); j.initial = null } else { if (!j.initial) { if (j.frozen && !j.freezeDecel) { j.yaw = j.pitch = 0 } else { j.Decel(j) } } } this.Transform(j, j.pitch, j.yaw) }; O.AnimateDrag = function (j, aE, aD) { var i = this, aC = 100 * aD * i.maxSpeed / i.max_radius / i.zoom; if (i.dx || i.dy) { i.lx || (i.yaw = i.dx * aC / i.stretchX); i.ly || (i.pitch = i.dy * -aC / i.stretchY); i.dx = i.dy = 0; i.initial = null } else { if (!i.initial) { i.Decel(i) } } this.Transform(i, i.pitch, i.yaw) }; O.Freeze = function () { if (!this.frozen) { this.preFreeze = [this.yaw, this.pitch]; this.frozen = 1; this.drawn = 0 } }; O.UnFreeze = function () { if (this.frozen) { this.yaw = this.preFreeze[0]; this.pitch = this.preFreeze[1]; this.frozen = 0 } }; O.Decel = function (i) { var aC = i.minSpeed, aD = J(i.yaw), j = J(i.pitch); if (!i.lx && aD > aC) { i.yaw = aD > i.z0 ? i.yaw * i.decel : 0 } if (!i.ly && j > aC) { i.pitch = j > i.z0 ? i.pitch * i.decel : 0 } }; O.Zoom = function (i) { this.z2 = this.z1 * (1 / i); this.drawn = 0 }; O.Clicked = function (aC) { var i = this.active; try { if (i && i.tag) { if (this.clickToFront === false || this.clickToFront === null) { i.tag.Clicked(aC) } else { this.TagToFront(i.tag, this.clickToFront, function () { i.tag.Clicked(aC) }, true) } } } catch (j) { } }; O.Wheel = function (j) { var aC = this.zoom + this.zoomStep * (j ? 1 : -1); this.zoom = ay(this.zoomMax, q(this.zoomMin, aC)); this.Zoom(this.zoom) }; O.BeginDrag = function (i) { this.down = Q(i, this.canvas); i.cancelBubble = true; i.returnValue = false; i.preventDefault && i.preventDefault() }; O.Drag = function (aE, aD) { if (this.dragControl && this.down) { var aC = this.dragThreshold * this.dragThreshold, j = aD.x - this.down.x, i = aD.y - this.down.y; if (this.dragging || j * j + i * i > aC) { this.dx = j; this.dy = i; this.dragging = 1; this.down = aD } } }; O.EndDrag = function () { var i = this.dragging; this.dragging = this.down = null; return i }; O.Pause = function () { this.paused = true }; O.Resume = function () { this.paused = false }; O.SetSpeed = function (j) { this.initial = j; this.yaw = j[0] * this.maxSpeed; this.pitch = j[1] * this.maxSpeed }; O.FindTag = function (aC) { if (!ae(aC)) { return null } ae(aC.index) && (aC = aC.index); if (!G(aC)) { return this.taglist[aC] } var aD, aE, j; if (ae(aC.id)) { aD = "id", aE = aC.id } else { if (ae(aC.text)) { aD = "innerText", aE = aC.text } } for (j = 0; j < this.taglist.length; ++j) { if (this.taglist[j].a[aD] == aE) { return this.taglist[j] } } }; O.RotateTag = function (aK, aD, aJ, i, aH, aC) { var aI = aK.xformed, aF = new aa(aI.x, aI.y, aI.z), aE = af(aJ, aD), j = aF.angle(aE), aG = aF.cross(aE).unit(); if (j == 0) { this.fixedCallbackTag = aK; this.fixedCallback = aH } else { this.fixedAnim = { angle: -j, axis: aG, t: i, t0: E(), cb: aH, tag: aK, active: aC } } }; O.TagToFront = function (i, aC, aD, j) { this.RotateTag(i, 0, 0, aC, aD, j) }; x.Start = function (aC, i, j) { x.tc[aC] = new x(aC, i, j) }; function at(i, j) { x.tc[j] && x.tc[j][i]() } x.Linear = function (i, j) { return j / i }; x.Smooth = function (i, j) { return 0.5 - v(j * Math.PI / i) / 2 }; x.Pause = function (i) { at("Pause", i) }; x.Resume = function (i) { at("Resume", i) }; x.Reload = function (i) { at("Load", i) }; x.Update = function (i) { at("Update", i) }; x.SetSpeed = function (j, i) { if (G(i) && x.tc[j] && !isNaN(i[0]) && !isNaN(i[1])) { x.tc[j].SetSpeed(i); return true } return false }; x.TagToFront = function (j, i) { if (!G(i)) { return false } i.lat = i.lng = 0; return x.RotateTag(j, i) }; x.RotateTag = function (aC, i) { if (G(i) && x.tc[aC]) { if (isNaN(i.time)) { i.time = 500 } var j = x.tc[aC].FindTag(i); if (j) { x.tc[aC].RotateTag(j, i.lat, i.lng, i.time, i.callback, i.active); return true } } return false }; x.Delete = function (i) { delete a[i]; delete x.tc[i] }; x.NextFrameRAF = function () { requestAnimationFrame(D) }; x.NextFrameTimeout = function (i) { setTimeout(M, i) }; x.tc = {}; x.options = { z1: 20000, z2: 20000, z0: 0.0002, freezeActive: false, freezeDecel: false, activeCursor: "pointer", pulsateTo: 1, pulsateTime: 3, reverse: false, depth: 0.5, maxSpeed: 0.05, minSpeed: 0, decel: 0.95, interval: 20, minBrightness: 0.1, maxBrightness: 1, outlineColour: "#ffff99", outlineThickness: 2, outlineOffset: 5, outlineMethod: "outline", outlineRadius: 0, textColour: "#ff99ff", textHeight: 15, textFont: "Helvetica, Arial, sans-serif", shadow: "#000", shadowBlur: 0, shadowOffset: [0, 0], initial: null, hideTags: true, zoom: 1, weight: false, weightMode: "size", weightFrom: null, weightSize: 1, weightSizeMin: null, weightSizeMax: null, weightGradient: { 0: "#f00", 0.33: "#ff0", 0.66: "#0f0", 1: "#00f" }, txtOpt: true, txtScale: 2, frontSelect: false, wheelZoom: true, zoomMin: 0.3, zoomMax: 3, zoomStep: 0.05, shape: "sphere", lock: null, tooltip: null, tooltipDelay: 300, tooltipClass: "tctooltip", radiusX: 1, radiusY: 1, radiusZ: 1, stretchX: 1, stretchY: 1, offsetX: 0, offsetY: 0, shuffleTags: false, noSelect: false, noMouse: false, imageScale: 1, paused: false, dragControl: false, dragThreshold: 4, centreFunc: av, splitWidth: 0, animTiming: "Smooth", clickToFront: false, fadeIn: 0, padding: 0, bgColour: null, bgRadius: 0, bgOutline: null, bgOutlineThickness: 0, outlineIncrease: 4 }; for (K in x.options) { x[K] = x.options[K] } window.TagCanvas = x; jQuery.fn.tagcanvas = function (j, i) { var aC = { pause: function () { ak(this).each(function () { at("Pause", ak(this)[0].id) }) }, resume: function () { ak(this).each(function () { at("Resume", ak(this)[0].id) }) }, reload: function () { ak(this).each(function () { at("Load", ak(this)[0].id) }) }, update: function () { ak(this).each(function () { at("Update", ak(this)[0].id) }) }, tagtofront: function () { ak(this).each(function () { x.TagToFront(ak(this)[0].id, i) }) }, rotatetag: function () { ak(this).each(function () { x.RotateTag(ak(this)[0].id, i) }) }, "delete": function () { ak(this).each(function () { x.Delete(ak(this)[0].id) }) }, setspeed: function () { ak(this).each(function () { x.SetSpeed(ak(this)[0].id, i) }) } }; if (typeof j == "string" && aC[j]) { aC[j].apply(this); return this } else { x.jquery = 1; ak(this).each(function () { x.Start(ak(this)[0].id, i, j) }); return x.started } }; Z("load", function () { x.loaded = 1 }, window) })(jQuery);
;
/* easing functions */
jQuery.easing.jswing = jQuery.easing.swing; jQuery.extend(jQuery.easing, { def: "easeOutQuad", swing: function (e, f, a, h, g) { return jQuery.easing[jQuery.easing.def](e, f, a, h, g) }, easeInQuad: function (e, f, a, h, g) { return h * (f /= g) * f + a }, easeOutQuad: function (e, f, a, h, g) { return -h * (f /= g) * (f - 2) + a }, easeInOutQuad: function (e, f, a, h, g) { if ((f /= g / 2) < 1) { return h / 2 * f * f + a } return -h / 2 * ((--f) * (f - 2) - 1) + a }, easeInCubic: function (e, f, a, h, g) { return h * (f /= g) * f * f + a }, easeOutCubic: function (e, f, a, h, g) { return h * ((f = f / g - 1) * f * f + 1) + a }, easeInOutCubic: function (e, f, a, h, g) { if ((f /= g / 2) < 1) { return h / 2 * f * f * f + a } return h / 2 * ((f -= 2) * f * f + 2) + a }, easeInQuart: function (e, f, a, h, g) { return h * (f /= g) * f * f * f + a }, easeOutQuart: function (e, f, a, h, g) { return -h * ((f = f / g - 1) * f * f * f - 1) + a }, easeInOutQuart: function (e, f, a, h, g) { if ((f /= g / 2) < 1) { return h / 2 * f * f * f * f + a } return -h / 2 * ((f -= 2) * f * f * f - 2) + a }, easeInQuint: function (e, f, a, h, g) { return h * (f /= g) * f * f * f * f + a }, easeOutQuint: function (e, f, a, h, g) { return h * ((f = f / g - 1) * f * f * f * f + 1) + a }, easeInOutQuint: function (e, f, a, h, g) { if ((f /= g / 2) < 1) { return h / 2 * f * f * f * f * f + a } return h / 2 * ((f -= 2) * f * f * f * f + 2) + a }, easeInSine: function (e, f, a, h, g) { return -h * Math.cos(f / g * (Math.PI / 2)) + h + a }, easeOutSine: function (e, f, a, h, g) { return h * Math.sin(f / g * (Math.PI / 2)) + a }, easeInOutSine: function (e, f, a, h, g) { return -h / 2 * (Math.cos(Math.PI * f / g) - 1) + a }, easeInExpo: function (e, f, a, h, g) { return (f == 0) ? a : h * Math.pow(2, 10 * (f / g - 1)) + a }, easeOutExpo: function (e, f, a, h, g) { return (f == g) ? a + h : h * (-Math.pow(2, -10 * f / g) + 1) + a }, easeInOutExpo: function (e, f, a, h, g) { if (f == 0) { return a } if (f == g) { return a + h } if ((f /= g / 2) < 1) { return h / 2 * Math.pow(2, 10 * (f - 1)) + a } return h / 2 * (-Math.pow(2, -10 * --f) + 2) + a }, easeInCirc: function (e, f, a, h, g) { return -h * (Math.sqrt(1 - (f /= g) * f) - 1) + a }, easeOutCirc: function (e, f, a, h, g) { return h * Math.sqrt(1 - (f = f / g - 1) * f) + a }, easeInOutCirc: function (e, f, a, h, g) { if ((f /= g / 2) < 1) { return -h / 2 * (Math.sqrt(1 - f * f) - 1) + a } return h / 2 * (Math.sqrt(1 - (f -= 2) * f) + 1) + a }, easeInElastic: function (f, h, e, l, k) { var i = 1.70158; var j = 0; var g = l; if (h == 0) { return e } if ((h /= k) == 1) { return e + l } if (!j) { j = k * 0.3 } if (g < Math.abs(l)) { g = l; var i = j / 4 } else { var i = j / (2 * Math.PI) * Math.asin(l / g) } return -(g * Math.pow(2, 10 * (h -= 1)) * Math.sin((h * k - i) * (2 * Math.PI) / j)) + e }, easeOutElastic: function (f, h, e, l, k) { var i = 1.70158; var j = 0; var g = l; if (h == 0) { return e } if ((h /= k) == 1) { return e + l } if (!j) { j = k * 0.3 } if (g < Math.abs(l)) { g = l; var i = j / 4 } else { var i = j / (2 * Math.PI) * Math.asin(l / g) } return g * Math.pow(2, -10 * h) * Math.sin((h * k - i) * (2 * Math.PI) / j) + l + e }, easeInOutElastic: function (f, h, e, l, k) { var i = 1.70158; var j = 0; var g = l; if (h == 0) { return e } if ((h /= k / 2) == 2) { return e + l } if (!j) { j = k * (0.3 * 1.5) } if (g < Math.abs(l)) { g = l; var i = j / 4 } else { var i = j / (2 * Math.PI) * Math.asin(l / g) } if (h < 1) { return -0.5 * (g * Math.pow(2, 10 * (h -= 1)) * Math.sin((h * k - i) * (2 * Math.PI) / j)) + e } return g * Math.pow(2, -10 * (h -= 1)) * Math.sin((h * k - i) * (2 * Math.PI) / j) * 0.5 + l + e }, easeInBack: function (e, f, a, i, h, g) { if (g == undefined) { g = 1.70158 } return i * (f /= h) * f * ((g + 1) * f - g) + a }, easeOutBack: function (e, f, a, i, h, g) { if (g == undefined) { g = 1.70158 } return i * ((f = f / h - 1) * f * ((g + 1) * f + g) + 1) + a }, easeInOutBack: function (e, f, a, i, h, g) { if (g == undefined) { g = 1.70158 } if ((f /= h / 2) < 1) { return i / 2 * (f * f * (((g *= (1.525)) + 1) * f - g)) + a } return i / 2 * ((f -= 2) * f * (((g *= (1.525)) + 1) * f + g) + 2) + a }, easeInBounce: function (e, f, a, h, g) { return h - jQuery.easing.easeOutBounce(e, g - f, 0, h, g) + a }, easeOutBounce: function (e, f, a, h, g) { if ((f /= g) < (1 / 2.75)) { return h * (7.5625 * f * f) + a } else { if (f < (2 / 2.75)) { return h * (7.5625 * (f -= (1.5 / 2.75)) * f + 0.75) + a } else { if (f < (2.5 / 2.75)) { return h * (7.5625 * (f -= (2.25 / 2.75)) * f + 0.9375) + a } else { return h * (7.5625 * (f -= (2.625 / 2.75)) * f + 0.984375) + a } } } }, easeInOutBounce: function (e, f, a, h, g) { if (f < g / 2) { return jQuery.easing.easeInBounce(e, f * 2, 0, h, g) * 0.5 + a } return jQuery.easing.easeOutBounce(e, f * 2 - g, 0, h, g) * 0.5 + h * 0.5 + a } });

//Evident SwipeMenu
/*jslint browser: true, plusplus: true, vars: true, white: true, indent: 2 */
; (function ($, window, document)
{
    "use strict";

    $.fn.swipemenu = function (options)
    {
        var publicfunctions, command = typeof options === "string" ? options : false;
        if (command)
        {
            publicfunctions = this.data("swipemenu");
            if ($.isPlainObject(publicfunctions) && $.isFunction(publicfunctions[command]))
            {
                publicfunctions[command]();
            }
            return this;
        }

        options = $.extend({
            trigger: ".menutrigger",  //Trigger that causes the menu to show/hide
            menuclass: "active",      //Class to set/uset on the menu in order to show/hide it
            contexts: "small"         //Mediaquery context in which to setup the menu (otherwise be torn down)
        }, options);

        options.trigger = $(options.trigger);
        options.menuclass = $.trim(options.menuclass || "");
        if (typeof options.contexts === "string")
        {
            options.contexts = options.contexts.split(",");
        }
        else
        {
            options.contexts = $.makeArray(options.contexts || undefined);
        }

        var menu = this, body = $("body"),
            menuevents = "touchend.swipemenu pointerup.swipemenu MSPointerUp.swipemenu click.swipemenu",
            bodyevents = "click.swipemenu touchstart.swipemenu pointerdown.swipemenu MSPointerDown.swipemenu touchmove.swipemenu pointermove.swipemenu MSPointerMove.swipemenu touchend.swipemenu pointerup.swipemenu MSPointerUp.swipemenu";

        var isshowing = function ()
        {
            return menu.hasClass(options.menuclass);
        };

        var ismenu = function (target)
        {
            return $(target).parents().is(menu);
        };

        var istrigger = function (target)
        {
            return $(target).parents().is(options.trigger);
        };

        var buttonclick = (function ()
        {
            var lastevent = "", resethandle = 0,
                resetfunc = function () { lastevent = ""; };

            var event = function (show)
            {
                return function (e)
                {
                    var classok = show ? !isshowing() : isshowing();
                    if ((lastevent === "" || e.type === lastevent) && classok)
                    {
                        publicfunctions[show ? "show" : "hide"]();
                        lastevent = e.type;
                        window.clearTimeout(resethandle);
                        resethandle = window.setTimeout(resetfunc, 2000);
                    }
                    e.stopPropagation();
                    e.stopImmediatePropagation();
                    return false;
                };
            };
            return {
                show: event(true),
                hide: event(false)
            };
        }());

        publicfunctions = {
            hide: function ()
            {
                menu.removeClass(options.menuclass);
                options.trigger.off(".swipemenu").on(menuevents, buttonclick.show);
            },
            show: function ()
            {
                menu.addClass(options.menuclass);
                options.trigger.off(".swipemenu").on(menuevents, buttonclick.hide);
            }
        };

        var bodytouch = (function ()
        {
            var swipestart, swipedelta,
                lastevent = "", resethandle = 0,
                touchingresult;

            var setlast = function (type)
            {
                lastevent = type;
                window.clearTimeout(resethandle);
                resethandle = window.setTimeout(function () { lastevent = ""; }, 2000);
            };

            return function (e)
            {
                if (e.type == "click")
                {
                    if (istrigger(e.target) || ismenu(e.target))
                    {
                        return true;
                    }
                    touchingresult = undefined;
                    if ((isshowing() && lastevent === "") || (!isshowing() && lastevent === "hidemenu"))
                    {
                        setlast("hidemenu");
                        publicfunctions.hide();
                        e.stopImmediatePropagation();
                        setlast(e.type);
                        return false;
                    }
                }
            };
        }());

        var setup = function ()
        {
            options.trigger.css("-ms-touch-action", "none");
            options.trigger.on(menuevents, buttonclick.show);
            body.on(bodyevents, bodytouch);
        };

        var teardown = function ()
        {
            publicfunctions.hide();
            options.trigger.css("-ms-touch-action", "");
            options.trigger.off(".swipemenu");
            body.off(".swipemenu");
        };

        this.data("swipemenu", publicfunctions);
        if ($.mediaqueries && options.contexts.length)
        {
            $(document).on("mediaquery", function (e, data)
            {
                var oldok = $.inArray(data.previousContext, options.contexts) >= 0,
                    newok = $.inArray(data.context, options.contexts) >= 0;
                if (oldok !== newok)
                {
                    if (newok)
                    {
                        setup();
                    }
                    else
                    {
                        teardown();
                    }
                }
            });
        }
        else
        {
            setup();
        }

        return this;
    };

}(this.jQuery, this, this.document));

// Evident mediaqueries
(function (c, b, a) { c.mediaqueries = (function () { var g, d = "", f = ""; var e = function () { c(a).trigger("mediaquery", { context: d, previousContext: f }) }; var i = function () { var k; if (a.documentElement.currentStyle) { k = a.documentElement.currentStyle.fontFamily } else { if (b.getComputedStyle) { k = b.getComputedStyle(a.documentElement, null).getPropertyValue("font-family") } } return String(k || "").replace(/['",]/g, "") }; var h = function () { var l = arguments[0] === "fire", k = i(); if (!k) { return } if ((k !== d || l) && c.inArray(k, g) >= 0) { f = d; d = k; e() } }; var j = (function () { var l = {}; if (b.addEventListener && b.removeEventListener) { l.attach = function (m, o, n) { m.addEventListener(o, n, false) }; l.detach = function (m, o, n) { m.removeEventListener(o, n, false) } } else { if (b.attachEvent && b.detachEvent) { l.attach = function (m, o, n) { m.attachEvent("on" + o, n) }; l.detach = function (m, o, n) { m.detachEvent("on" + o, n) } } } var k = function (m) { if (!l.attach || !l.detach) { return function () { } } return function (o, n, p) { o = o || b; if (!p) { return } c.each(String(n || "").split(" "), function (q, r) { r = c.trim(r); if (r !== "") { l[m](o, r, p) } }) } }; return { attach: k("attach"), detach: k("detach") } }()); return { setup: function () { var k = c.isArray(g); if (!k) { g = c.makeArray(c.isArray(arguments[0]) ? arguments[0] : arguments); c.mediaqueries.attachResize(h); h() } }, context: function (k) { if (k === false) { return i() } return d }, fire: function () { h("fire") }, attachResize: function (k) { j.attach(b, "resize deviceorientation", k) }, detachResize: function (k) { j.detach(b, "resize deviceorientation", k) } } }()) }(this.jQuery, this, this.document));


(function ($, window, document)
{

	var init = function ()
	{

	    $.setupSearchPanel($("#searchtrigger"), $("body"), "searchpanel-active", $("#site-search-text"));
	    $.setupSearchPanel($("#searchtrigger-webshop"), $("#webshop-header"), "searchpanel-active", $("#s"));

		//init sliding panels for Small screens
		$(document).on("mediaquery", function (e, data)
		{

			if (data.context === "small")
			{
				$.shortenlist(".linklist > ul", 6, "meer populaire links");
			}

			if (data.context === "small" || data.context === "medium")
			{
				//init Hamburger Menu Control
				$.hamburgerControl(".mainnav");
				//init search panel
				//form/detail switch
				setupPageSwitch();
			}
			else
			{
				//$(".step-image-thumb > a").fancybox({
				//  loop:false,
				//  helpers: {title: false}
				//});
				//undo Hamburger Menu Control
				//$(".searchpanel > input").attr("placeholder", "Typ hier wat u zoekt op onze website");
				$.removeHamburgerControl(".mainnav");
			}

		});

		// WE DON'T WANT THE MENU TO BE SWIPEABLE
		$(".mainnav").swipemenu({
			trigger: "#menutrigger",
			menuclass: "slideIn",
			contexts: "small,medium"
		});

		$.mediaqueries.setup("small", "medium", "large");

		//init share buttons
		if ($.fn.ghostshare)
		{
			$(".ghostshare").ghostshare();
		}

		//naar boven link instellen
		$(".totop").click(function (e)
		{
			e.preventDefault();
			$('body,html').animate({
				scrollTop: 0
			}, 800);
			return false;
		});

		//$(document).on("click", ".listing:not(.reactions) > .clickable", function (e) {
		//    // indien het geklikte element een link is, die gewoon volgen.
		//    if ($(e.target).is("a")) {
		//        return true;
		//    }

		//    e.preventDefault();

		//	var href = $(this).find("h2 > a").attr("href");
		//	if (typeof href === "undefined")
		//		return;
		//	else
		//		document.location.href = href;
		//});
		
		//page toggle 
		function setupPageSwitch()
		{
			$('.togglepage').not(":first").hide();
			$(".switchpage").each(function ()
			{
				$(this).show().click(function (e)
				{
					e.preventDefault();
					var target = ($(this).closest('.togglepage'));
					$(target).fadeOut();
					$('.togglepage').not(target).fadeIn();
					$('body,html').animate({
						scrollTop: 0
					}, 200);

				})
			})
		}

		$('.subsubmenu-header').on('click', function (event) {
		    $('.subsubmenu').toggleClass('active');
		});

	    //open overlay
		$('.btn-open-overlay').click(function (e) {
		    e.preventDefault();
		    OVERLAY.Open();
		});

		$("#btn-close-overlay").click(function (e) {
		    e.preventDefault();
		    OVERLAY.Close();
		});
	    //#endregion
	};

	$.setupSearchPanel = function ($trigger, $target, enabledClass, searchInput)
	{
		$($trigger).click(function (e)
		{
		    e.preventDefault();
		    if ($target.hasClass(enabledClass)) {
		        $target.removeClass(enabledClass);
		    } else {
		        $target.addClass(enabledClass);
		        searchInput.focus();
            }
		})
	}

	$.shortenlist = function (list, max, label)
	{
		$(list).each(function ()
		{

			var toomany = $("> li:nth-child(n+" + max + ")", this);
			if ($(toomany).length)
			{
				$(toomany).hide();
				$(this).after(
                  $('<a href="javascript:void(0)" class="loadmore">' + label + '</a>').click(function ()
                  {
                  	$(this).addClass("loading");
                  	$(toomany).slideDown();
                  	$(this).remove();
                  })
                );
			}
		});

	};

	$.hamburgerControl = function (mainnav)
	{
		if ($(mainnav).hasClass("hamburger"))
		{
			return false
		}

		$(mainnav).addClass("hamburger");
		$("li", mainnav).each(function ()
		{
			if ($(this).children('ul').length)
			{
				//make it possible to expand tab
				$("> a", this).addClass('icon expandable after').click(function (e)
				{
					e.preventDefault();

					//toggle open/close
					$(this).toggleClass('foldable');

					//close others in case they are open
					if ($(this).hasClass('foldable'))
					{
						$('.foldable', mainnav).not(this).not($(this).parents('li.hassubmenu').children('a.foldable')).removeClass('foldable');
					}
				});
			}
		});

		// Give the 'word lid' link a class 'duplicate' and move it after the 'webshop' li element.
		var $li = $(mainnav).find(".standout");
		$li.removeClass("standout").addClass("duplicate set-standout");
		$(mainnav).find(".webshop").after($li);
	};

	$.removeHamburgerControl = function (mainnav)
	{
		$(mainnav).removeClass("hamburger");
		$(mainnav).find("a").removeClass("expandable foldable").unbind("click");
		$(mainnav).find(".set-standout").removeClass("duplicate").addClass("standout");
	}

	init();
}(jQuery, this, this.document));

var OVERLAY = {
    Open: function () {
        //open overlay
        $('#overlay').addClass('active');
        $('body').addClass('overlay-open');
    },
    Close: function () {
        //close overlay
        $('#overlay').removeClass('active');
        $('body').removeClass('overlay-open');
    }
}

var urlParams;
(window.onpopstate = function()
{
	var match,
        pl = /\+/g,  // Regex for replacing addition symbol with a space
        search = /([^&=]+)=?([^&]*)/g,
        decode = function(s) { return decodeURIComponent(s.replace(pl, " ")); },
        query = window.location.search.substring(1);

	urlParams = {};
	while (match = search.exec(query))
		urlParams[decode(match[1])] = decode(match[2]);
})();;
$(document).ready(function()
{
	LOG.Init();
});

var LOG =
{
	SUPPORTED: false,

	Init: function()
	{
		this.SUPPORTED = typeof console === "object";
	},

	TimeStamp: function()
	{
		var today = new Date();
		var dd    = today.getDate();
		var MM    = today.getMonth() + 1; //January is 0!
		var yyyy  = today.getFullYear();
		var HH    = today.getHours();
		var mm    = today.getMinutes();
		var ss    = today.getSeconds();
		var ms    = today.getMilliseconds();

		dd = ("0" + dd).slice(-2);
		MM = ("0" + MM).slice(-2);
		HH = ("0" + HH).slice(-2);
		mm = ("0" + mm).slice(-2);
		ss = ("0" + ss).slice(-2);
		ms = ("00" + ms).slice(-3);

		return dd + "-" + MM + "-" + yyyy + " " + HH + ":" + mm + ":" + ss + "." + ms;
	},

	Write: function(message)
	{
		if (this.SUPPORTED)
			console.log(this.TimeStamp() + " " + message);
	},

	WriteInfo: function(message)
	{
		if (this.SUPPORTED)
			console.info(this.TimeStamp() + " " + message);
	},

	WriteError: function(message)
	{
		if (this.SUPPORTED)
			console.error(this.TimeStamp() + " " + message);
	},

	WriteWarning: function(message)
	{
		if (this.SUPPORTED)
			console.warn(this.TimeStamp() + " " + message);
	},

	WriteObject: function(object)
	{
		if (this.SUPPORTED)
		{
			var prefix = this.TimeStamp() + " ";
			console.log(prefix, object);
		}
	}
};
;
$(document).ready(function ()
{
    BAR.Init();
});

var BAR =
{
    BAR: $("#notification-bar"),
    DELAY: 5000,
    FADE_SPEED: "slow",

    Init: function ()
    {
        this.BAR.empty();
    },

    Add: function ($element, $replace, delay)
    {
        if (typeof $replace !== "undefined" && $replace !== null)
            return this.Replace($element, $replace, delay);
        else
            return this.AddElement($element, delay);
    },

    AddInfo: function (text, $replace, delay)
    {
        var $element = $("<div class='notification icon info'>" + text + "</div>");
        return this.Add($element, $replace, delay);
    },

    AddSuccess: function (text, $replace, delay)
    {
        var $element = $("<div class='notification icon success'>" + text + "</div>");
        return this.Add($element, $replace, delay);
    },

    AddError: function (text, $replace, delay)
    {
        var $element = $("<div class='notification icon error'>" + text + "</div>");
        return this.Add($element, $replace, delay);
    },

    AddLoading: function (text, $replace, delay)
    {
        var $element = $("<div class='notification loading spinner-white'>" + text + "</div>");
        return this.Add($element, $replace, delay);
    },

    AddElement: function($element, delay)
    {
        var _this = this;
        var $wrapper = $("<div />").append($element).hide();
        _this.BAR.append($wrapper);
        $wrapper.fadeIn(_this.FADE_SPEED);

        if (delay === 0)
            return $wrapper;

        setTimeout(function ()
        {
            _this.Remove($wrapper);
        }, delay || _this.DELAY);
        
        return $wrapper;
    },

    Remove: function ($element)
    {
        var _this = this;
        $element.slideUp(_this.FADE_SPEED, function ()
        {
            $(this).remove();
        });
    },

    Replace: function ($element, $replace, delay)
    {
        var _this = this;
        $replace.slideUp(_this.FADE_SPEED, function ()
        {
            $(this).remove();
            return _this.AddElement($element, delay);
        });
    }
};
;
String.prototype.escape = function ()
{
    var tagsToReplace = {
        '&': '&amp;',
        '<': '&lt;',
        '>': '&gt;'
    };
    return this.replace(/[&<>]/g, function (tag)
    {
        return tagsToReplace[tag] || tag;
    });
};

String.prototype.format = function ()
{
    var args = arguments;
    return this.replace(/{(\d+)}/g, function (match, number)
    {
        return typeof args[number] != "undefined" ? args[number] : match;
    });
};

String.prototype.endsWith = function (suffix)
{
	return this.indexOf(suffix, this.length - suffix.length) !== -1;
}

// CASE INSENSITIVE CONTAINS
$.expr[":"].Contains = $.expr.createPseudo(function (arg)
{
	return function (elem)
	{
		return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
	};
});

/*#region POLYFILLS*/
if (!String.prototype.includes)
{
	String.prototype.includes = function(search, start)
	{
		'use strict';
		if (typeof start !== 'number')
		{
			start = 0;
		}

		if (start + search.length > this.length)
		{
			return false;
		}
		else
		{
			return this.indexOf(search, start) !== -1;
		}
	};
}
/*#endregion POLYFILLS*/;
$(document).ready(function ()
{
	COOKIEINFO.Init();
	PROPERTIES.Init();
	CLIENT.Init();
	DATALAYERADDITIONS.Init();

	$(window).on("resize", function ()
	{
		PROPERTIES.Init();
	});
});

var PROPERTIES =
{
	WIDTH: "large",
	PIXELS: 0,
	VIDEOS: [],
	VIDEODIVS: [],

	Init: function ()
	{
		var width = window.innerWidth;
		if (width <= 900 && width >= 650)
			this.WIDTH = "medium";
		else if (width < 650)
			this.WIDTH = "small";
		else
			this.WIDTH = "large";

		this.PIXELS = window.innerWidth;

		//In case a user has search suggestion open we should remove the container.
		if ($(".suggestion-list").length > 0) {
			$(".suggestion-list").remove();
		}
	}
};

var COOKIEINFO =
{
	$doc: $(document),
	Cookies: {
		//Notification: "cookie-show-notification",
		Settings: ".sw-cookie"
	},
	CookieSettings: "1", //1 = Functional only | 2 = Adverts for YouTube movies allowed || 3 = All adverts allowed
	Init: function ()
	{
		var _this = this;

		if ($.cookie(_this.Cookies.Settings) !== undefined) //IF COOKIESETTINGS COOKIE IS PRESENT, TAKE ITS VALUE
			COOKIEINFO.CookieSettings = $.cookie(_this.Cookies.Settings);

		_this.$doc.on("click", ".cookie-info-agree", function () //User clicked on Cookie Agree button
		{
			var cookielevel = "3";

			if (typeof dataLayer !== 'undefined')
				dataLayer.push({ 'event': 'Cookies Agreed' });

			// Set cookie so the info-bar will not be displayed in the future.
			$.cookie(_this.Cookies.Settings, cookielevel, { expires: 365 * 10, path: "/" });

			if ($.cookie(_this.Cookies.Settings) !== undefined)
			{
				_this.CookieSettings = cookielevel;
				_this.SaveCookieConsent();
				_this.ShowOrHideExternalMedia();

				// Remove info-bar.
				$("#cookie-info").remove();
			}
			else
				BAR.AddError("Uw browser accepteert mogelijk geen cookies, u kunt daardoor deze melding niet sluiten.", null, 8000);
		}).on("click", ".cookie-info-disagree", function () //User clicked on Cookie Agree button
		{
			var cookielevel = "1";

			if (typeof dataLayer !== 'undefined')
				dataLayer.push({ 'event': 'Cookies Disagreed' });

			// Set cookie so the info-bar will not be displayed in the future.
			$.cookie(_this.Cookies.Settings, cookielevel, { expires: 365 * 10, path: "/" });

			if ($.cookie(_this.Cookies.Settings) !== undefined)
			{
				_this.CookieSettings = cookielevel;
				_this.ShowOrHideExternalMedia();

				// Remove info-bar.
				$("#cookie-info").remove();
			}
			else
				BAR.AddError("Uw browser accepteert mogelijk geen cookies, u kunt daardoor deze melding niet sluiten.", null, 8000);
        }).on("click", ".cookie-allow-video", function (e) //User clicked on Allow Video cookies button
		{
            e.preventDefault();
            var cookielevel = "2";

            if (typeof dataLayer !== 'undefined')
                dataLayer.push({ 'event': 'Allow Video' });

            // Set cookie so the info-bar will not be displayed in the future.
            $.cookie(_this.Cookies.Settings, cookielevel, { expires: 365 * 10, path: "/" });

            if ($.cookie(_this.Cookies.Settings) !== undefined) {
                _this.CookieSettings = cookielevel;
                _this.ShowOrHideExternalMedia();

                // Remove info-bar.
                $("#cookie-info").remove();
            }
            else {
                BAR.AddError("Uw browser accepteert mogelijk geen cookies, u kunt daardoor deze melding niet sluiten.", null, 8000);
            }
        }).on("click", "#cookie-settings-save", function () //User clicked on Cookie Settings Save button
		{
			var cookielevel = _this.CookieSettings;
            if ($("#adverts-cookies-3").is(":checked"))
			{
                cookielevel = "3";
                _this.SaveCookieConsent();
            }

            else if ($("#adverts-cookies-2").is(":checked"))
            {
                cookielevel = "2";
                _this.SaveCookieConsent();
            }
			else
				cookielevel = "1";

			if (typeof dataLayer !== 'undefined')
			{
				dataLayer.push({
					'event': 'Cookies Settings Saved',
					'settings': cookielevel === "1" ? 'Functional' : cookielevel === "2" ? 'Youtube Adverts' : 'All Adverts'
				});
			}

			$.cookie(_this.Cookies.Settings, cookielevel, { expires: 365 * 10, path: "/" });

			if ($.cookie(_this.Cookies.Settings) !== undefined)
			{
				var referrer = $('#cookie-referrer').length > 0 ? $('#cookie-referrer').val() : "";
				if (referrer !== "")
					window.location.href = referrer;
				else if ($('.cookie-settings-url').length > 0)
					window.location.href = "/";
				else
				{
					_this.CookieSettings = cookielevel;
					_this.ShowOrHideExternalMedia();

					// Remove info-bar.
					$("#cookie-info").remove();
				}
			}
			else
				BAR.AddError("Uw browser accepteert mogelijk geen cookies, u kunt daardoor uw instellingen niet opslaan.", null, 8000);
		}).on("click", ".why-cookies", function (e) //User clicked on More info about cookies button
		{
			$(this).toggleClass('expand').toggleClass('collapse');

			if (typeof dataLayer !== 'undefined')
			{
				if ($('.extendedInfo').hasClass('hide'))
					dataLayer.push({ 'event': 'Cookies MoreInfo Opened' });
				else
					dataLayer.push({ 'event': 'Cookies MoreInfo Closed' });
			}

			$('.changeCookieSettings').addClass('hide');
			$('.extendedInfo').toggleClass('hide');
		}).on("click", ".cookie-settings-video", function (e)
		{
			if (typeof dataLayer !== 'undefined')
				dataLayer.push({ 'event': 'Cookies Settings Opened via blocked video' });
		});

		//Disable YouTube video's if advert cookies are disabled
		_this.ShowOrHideExternalMedia();
	},

	SaveCookieConsent: function ()
	{
		$.ajax({
			url: "/_Base/SaveCookieConsent",
			type: "POST",
			error: function ()
			{
				console.log("error in _Base/SaveCookieConsent");
			}
		});
	},

	ShowOrHideExternalMedia: function ()
	{
		var _this = this;
		if (_this.CookieSettings === "1")
		{
			// At this point the media can NOT be shown, instead we need to show a placeholder
			try
			{
				let getCookieContent = false;
				let cookieHtml;
				$.post("/home/getcookiecontent", function (data)
				{
					if (data.success)
					{
						getCookieContent = true;
						cookieHtml = data.html;
					}
				}, "json").done(function ()
				{
					try
					{
						$(".video:not(.icon), .video-left:not(.icon), .video-right:not(.icon)").each(function ()
						{
							var $this = $(this);
							var objClass = $this.hasClass("video-left") ? "video-left" : $this.hasClass("video-right") ? "video-right" : "video";
							if (getCookieContent)
							{
								var placeholder = $("<div>");
								placeholder.addClass(objClass + ' cookies-blocked-movie clear');
								placeholder.html(cookieHtml);
								placeholder.attr('data-youtubeid', $this.data('youtubeid'));
								$this.replaceWith(placeholder);
							}
						});
						$(".spotify:not(.icon), .spotify-left:not(.icon), .spotify-right:not(.icon)").each(function ()
						{
							var $this = $(this);
							var objClass = $this.hasClass("spotify-left") ? "spotify-left" : $this.hasClass("spotify-right") ? "spotify-right" : "spotify";
							if (getCookieContent)
							{
								var placeholder = $("<div>");
								placeholder.addClass(objClass + ' cookies-blocked-movie clear');
								placeholder.html(cookieHtml);
								placeholder.attr('data-spotifyid', $this.data('spotifyid'));
								$this.replaceWith(placeholder);
							}
						});
					} catch (e)
					{
						return null;
					}
				});
			} catch (ex)
			{
				LOG.WriteError(ex);
			}
		}
		else
		{
			// At this point the media can be shown
			try
			{
				$(".video:not(.icon), .video-left:not(.icon), .video-right:not(.icon)").each(function (index)
				{
					var youtubeId = $(this).attr("data-youtubeID");
					if (youtubeId !== undefined)
					{
						var vidClass = $(this).hasClass("video-left") ? "video-left" : $(this).hasClass("video-right") ? "video-right" : "video";
						try
						{
							var video = $("<div>");
							video.addClass(vidClass);
							var videoDiv = $('<div>');
							videoDiv.attr('id', 'video-placeholder-' + index);
							videoDiv.attr('data-id', youtubeId);
							video.html(videoDiv);
							$(this).replaceWith(video);

							PROPERTIES.VIDEODIVS.push(videoDiv);
						} catch (ex)
						{
							return null;
						}
					}
					if (PROPERTIES.VIDEODIVS.length > 0)
					{
						var tag = document.createElement('script');

						tag.src = "https://www.youtube.com/iframe_api";
						var firstScriptTag = document.getElementsByTagName('script')[0];
						firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
					}
				});
				$(".spotify:not(.icon), .spotify-left:not(.icon), .spotify-right:not(.icon)").each(function (index)
				{
					var spotifyId = $(this).attr("data-spotifyid");
					if (spotifyId !== undefined)
					{
						var objClass = $(this).hasClass("spotify-left") ? "spotify-left" : $(this).hasClass("spotify-right") ? "spotify-right" : "spotify";
						try
						{
							var wrapper = $("<div>");
							wrapper.addClass(objClass);
							var spotifyFrame = $('<iframe>');
							spotifyFrame.attr('id', 'spotify-placeholder-' + index)
								.attr('src', "https://open.spotify.com/embed-podcast/episode/" + spotifyId)
								.attr("frameborder", 0)
								.attr("allowtransparency", true)
								.attr("allow", "encrypted-media")
								.width("100%").height(232);
							wrapper.html(spotifyFrame);
							$(this).replaceWith(wrapper);

						} catch (ex)
						{
							return null;
						}
					}
				});
			} catch (e)
			{
				return null;
			}
		}
	}
};

function onYouTubeIframeAPIReady()
{
	$.each(PROPERTIES.VIDEODIVS, function (i, div)
	{
		var player = new YT.Player('video-placeholder-' + i, {
			width: 420,
			height: 315,
			videoId: div.data('id'),
			playerVars: {
				allowfullscreen: 'true',
				suggestedQuality: 'hd1080',
				rel: 0,
				wmode: 'transparent'
			}
		});
		PROPERTIES.VIDEOS.push(player);
	});
}

var CLIENT =
{
	COOKIE: ".sw-client",
	IP: null,
	UserAgent: null,
	Browser: null,
	Device: null,
	IsMobile: false,
	Loading: true,

	Init: function ()
	{
		var _this = this;
		if (!$.cookie(_this.COOKIE))
			_this.SetCookie();
		else
			_this.LoadCookie();
	},

	SetCookie: function ()
	{
		var _this = this;

		$.get("/getclient", function (data)
		{
			$.cookie(_this.COOKIE, JSON.stringify(data), { path: "/" });
			_this.IP = data.ip;
			_this.UserAgent = data.useragent;
			_this.Browser = data.browser;
			_this.Device = _this.SetDevice(data.useragent);
			_this.IsMobile = data.browser.mobile || _this.Device !== "Other";
		}).done(function ()
		{
			_this.Loading = false;
		});
	},

	LoadCookie: function()
	{
		var _this = this;
		var data = JSON.parse($.cookie(_this.COOKIE));

		_this.IP        = data.ip;
		_this.UserAgent = data.useragent;
		_this.Browser   = data.browser;
		_this.Device    = _this.SetDevice(data.useragent);
		_this.IsMobile  = data.browser.mobile || _this.Device !== "Other";
		_this.Loading   = false;
	},

	SetDevice: function(useragent)
	{
		//NOTE: vanaf v13 heeft iPad eigen OS, hierin staat geen 'iPad' meer in de useragent maar 'Macintosh'.
		//hierdoor is het alleen nog van MacOS te onderscheiden door detectie van multi-touch.
		var match =
			{
				android: useragent.match(/Android/),
				iphone: useragent.match(/iPhone/),
				ipad: useragent.match(/iPad/) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1),
				macos: useragent.match(/Macintosh/),
				windows: useragent.match(/Windows/)
			};

		if (match.android)
			return "Android";
		else if (match.iphone)
			return "iPhone";
		else if (match.ipad)
			return "iPad";
		else if (match.macos)
			return "macOS";
		else if (match.windows)
			return "Windows";
		else
			return "Other";
	},

	IsAndroid: function()
	{
		return this.Device === "Android";
	},

	IsApple: function ()
	{
		return this.Device === "iPhone" || this.Device === "iPad" || this.Device === "macOS";
	}
};

var XURL =
{
	QueryString: function (key)
	{
		var vars = [];
		var hash;
		var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

		for (var i = 0; i < hashes.length; i++)
		{
			hash = hashes[i].split('=');
			vars.push(hash[0]);
			vars[hash[0]] = hash[1];
		}

		if (key !== undefined && key !== null)
			return vars[key];
		else
			return vars;
	},

	GetQueryString: function ()
	{
		var match;
		var pl = /\+/g;  // Regex for replacing addition symbol with a space
		var search = /([^&=]+)=?([^&]*)/g;
		var decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); };
		var query = window.location.search.substring(1);

		var urlParams = {};
		while (match = search.exec(query))
			urlParams[decode(match[1])] = decode(match[2]);

		return urlParams;
	}
};

var DATALAYERADDITIONS =
{
	DL_AVAILABLE: typeof dataLayer !== "undefined",

	Init: function ()
	{
		var _this = this;
		_this.RegisterIfUserIsLoggedIn();
		_this.TrackButtons();
		if (_this.DL_AVAILABLE)
			_this.RegisterLoginResults();
	},

	RegisterIfUserIsLoggedIn: function ()
	{
		var _this = this;
		if (_this.DL_AVAILABLE)
			dataLayer.push({ "lid": $("body").data("registered") === "true" });
	},

	RegisterLoginResults: function() //(this function is not for inline-logins; these are registered by code in another file)
	{
		if ($("[data-valmsg-for='LoginFailed']").length)
			dataLayer.push({ 'event': 'inloggen', 'status': 'mislukt' });
		else if (document.referrer.includes("seniorweb.nl/inloggen"))
			dataLayer.push({ 'event': 'inloggen', 'status': 'geslaagd' });
	},

	TrackButtons: function ()
	{
		var $toTrack = $(".track-button");
		var _this = this;

		if (_this.DL_AVAILABLE)
		{
			$toTrack.on("click", function ()
			{
				var action = $(this).data("trackaction");
				if (action !== "")
				{
					dataLayer.push(
					{
						event: "buttonClick",
						categorie: "button",
						actie: action
					});
				}
			});
		}
	}
};;
var DATETIME =
{
    DaysInMonth: function (month, year)
    {
        switch (month)
        {
            case 1:
                return (year % 4 == 0 && year % 100) || year % 400 == 0 ? 29 : 28;
            case 3: case 5: case 8: case 10:
                return 30;
            default:
                return 31
        }
    },

    FirstWeekDayInMonth: function (month, year)
    {
        return new Date(year, month, 1).getDay();
    },

    GetFormattedTime: function (datetime)
    {
        var HH = datetime.getHours();
        var mm = datetime.getMinutes();

        HH = ("0" + HH).slice(-2);
        mm = ("0" + mm).slice(-2);

        return HH + ":" + mm;
    },

    GetFormattedAjaxDateTime: function (datetime)
    {
        try
        {
            var dd = datetime.getDate();
            var MM = datetime.getMonth() + 1;
            var yy = datetime.getFullYear();
            var HH = datetime.getHours();
            var mm = datetime.getMinutes();
            var ss = datetime.getSeconds();

            dd = ("0" + dd).slice(-2);
            MM = ("0" + MM).slice(-2);
            HH = ("0" + HH).slice(-2);
            mm = ("0" + mm).slice(-2);
            ss = ("0" + ss).slice(-2);

            return dd + "-" + MM + "-" + yy + " " + HH + ":" + mm + ":" + ss;
        } catch (e)
        {
            return datetime;
        }
    }
};;
$(document).ready(function ()
{
	// use html5 History API
	Backbone.history.start();

	TABS.Init();
});

var TABS =
{
	ActiveTab: {},
	ActiveTabPane: {},
	AjaxUrl: "",
	ContentType: "",
	ContentTypeDescr: "",
	Page: ("_escaped_fragment" in urlParams) ? parseInt(urlParams["_escaped_fragment"].split("/").filter(Number), 10) : 1,
	ContinuedPaged: false,

	Init: function () {
	    this.SetupTabNav();
	},

	SetupTabNav: function()
	{
	    //tabs event for mobile devices
	    $(document).on("click", ".tabnav a", function (event) {
	        var $el = $(this),
                $tab = $el.parent(),
                $navTabs = $el.closest('.tabnav');

	        //toggleclass active
	        if ($tab.hasClass('tab-xs')) {
	            $navTabs.addClass('active');
	        } else {
	            $navTabs.removeClass('active');
	        }
	    });
	},

	ShowActiveTab: function()
	{
		var $this = this;
		//Check if a hashtag is active
		var activeHash = this.ContentTypeDescr;
		if (activeHash === "")
		{
			//Select active tab by finding the active tabbutton
			this.ActiveTab = $(".tabnav").find(".active");
		}
		else
		{
			var tabs = $(".tabnav").find("a");
			$.each(tabs, function(k, v)
			{
				if ($(this).attr("href") === "#" + activeHash)
				{
					$this.ActiveTab = $(this).parent();
					return false;
				}
			});
		}

		if (this.ActiveTab !== null)
		{
			//Call ChangeTabs function
			this.ChangeTabs();
		}
	},

	ChangeTabs: function()
	{
		//Define variables
		this.ActiveTabPane = $('#' + this.ContentType + '-tab');

	    //Set all tabbuttons inactive
		$('.tabnav .active').removeClass('active');

		//Set active tabbutton active
		this.ActiveTab.addClass('active');

		//Set all lists inactive (hidden)
		$('#tab-wrapper > div').addClass('hide');

		//Set matching list active (shown)
		this.ActiveTabPane.removeClass('hide');

		//Move to top if tabbutton is not visible in screen
		if (this.Page === 1)
		{
			$('.pagedItem').remove();
		}
		this.ChangePaging();
	},

	ChangePaging: function()
	{
		//Define paging variables
		$this = this;
		var recordsPerPage = parseInt(this.ActiveTabPane.data('recordsperpage'), 10);
		var loadedPage = parseInt(this.ActiveTabPane.attr('data-loadedpage'), 10);

		//move to record of page
		if (this.Page > 1 && this.Page != loadedPage && ("_escaped_fragment" in urlParams) == false)
		{
			var iStart = loadedPage + 1;
			this.LoadPage(iStart);
		}
		else
		{
			this.UpdatePagingButton();
		}
	},

	LoadPage: function(page)
	{
		var $this = this;
		var target = this.ActiveTabPane.find('li:last-of-type');
		var continuePaging = false;

		if (page < this.Page)
		{
			continuePaging = true;
		}

		//Set loading status to pagingbutton
		var pagingButton = $("#" + this.ContentType + "ToNext");
		pagingButton.addClass('loading').addClass('spinner-white');

		//Set possible theme details
		var themeId = pagingButton.data('themeid');
		var urlTheme ="";
		if (themeId != null && themeId != "")
			urlTheme = "/" + themeId;

		this.RemoveListItems();
		$.get(this.AjaxUrl.toLowerCase() + this.ContentType.toLowerCase() + "/" + page + urlTheme).done(function(data)
		{
			$this.ActiveTabPane.attr('data-loadedpage', page);
			target.parent().append(data.html);

			if (continuePaging)
			{
				$this.ContinuedPaged = true;
				$this.ChangePaging();
			}
			else
			{
				//Set new values in pagingbutton
				$this.UpdatePagingButton(data);

				//Remove loading status from pagingbutton
				pagingButton.removeClass('loading').removeClass('spinner-white');
			}
		});
	},

	RemoveListItems: function()
	{
		var $this = this;
		$.each($('.pagedItem'), function(k, v)
		{
			var belongsToPage = parseInt($(this).data('page'), 10);
			if (belongsToPage > $this.Page)
			{
				$(this).addClass('deletedItem');
			}
		});
		$('.deletedItem').remove();
	},

	UpdatePagingButton: function(data)
	{
		//Define paging variables
		var pagingButton = $("#" + this.ContentType + "ToNext");
		if (pagingButton.data('contenttypeurl') !== null)
		{
			var currentUrl = pagingButton.attr('href') !== undefined ? pagingButton.attr('href') : "";
			var remaining = parseInt(this.ActiveTabPane.data('recordsperpage'), 10);

			if (data !== undefined && data !== null)
			{
				remaining = data.remaining < remaining ? data.remaining : remaining;
				fromPage = data.records.Paging.Page;
			}
			$(pagingButton).find('.remainingRecords').html(remaining);

			if (remaining > 0)
			{
				pagingButton.removeClass('disabled');
				if (currentUrl.match(/\\$/))
				{
					pagingButton.attr('href', currentUrl + (this.Page + 1));
				}
				else
				{
					pagingButton.attr('href', '#/' + pagingButton.data('contenttypeurl').toLowerCase() + '/' + (this.Page + 1));
				}
			}
			else
			{
				pagingButton.addClass('disabled');
			}
		}
	},

	ScrollWindowToTarget: function(target)
	{
		if ($(target).offset() !== undefined)
		{
			var speed = 1800 * this.Page;
			$('html, body').animate({
				scrollTop: $(target).offset().top
			}, speed);
		}
	}
};

var interval;
var AppRouter = {
	AjaxUrl: "",
	Paging: Backbone.Router.extend({
		routes: {
			"": "index",
			":tab(/:page)": "showTab"
		},
		index: function(){
			tab = $(".tabnav").find(".active");
			if (tab === null)
				tab = $(".tabnav").find("a:first-of-type");
			TABS.Page = 1;
			TABS.ActiveTab = tab;
			TABS.ContentType = tab.data("contenttype") != undefined ? tab.data("contenttype") : "";
			TABS.ContentTypeDescr = tab.attr("href") != undefined ? tab.attr("href").replace("#", "") : "";
			TABS.ShowActiveTab();
		},
		showTab: function(tab, page)
		{
			var loadPage = 1;
			if (page !== null)
				loadPage = parseInt(page, 10);
			else
			{
				//Need to reset the TABS object
				if (!(Object.keys(TABS.ActiveTabPane).length === 0 && JSON.stringify(TABS.ActiveTabPane) === JSON.stringify({})))
					TABS.ActiveTabPane.attr('data-loadedpage', 1);

				TABS.ActiveTab = {};
				TABS.ActiveTabPane = {};
				TABS.AjaxUrl = "";
				TABS.ContentType = "";
				TABS.ContentTypeDescr = "";
				TABS.Page = 1;
				TABS.ContinuedPaged = false;
			}

			if (TABS.Page !== null && (page === null || loadPage != TABS.Page))
			{
				if (tab === null)
				{
					tab = $(".tabnav").find(".active");
					if (tab === null)
						tab = $(".tabnav").find("a:first-of-type");
				}
				else
					tab = $("#" + tab);

				if (tab !== undefined && tab !== null)
				{
					TABS.Page = loadPage;
					TABS.ActiveTab = tab;
					TABS.AjaxUrl = AppRouter.AjaxUrl;
					TABS.ContentType = tab.data("contenttype") != undefined ? tab.data("contenttype") : "";
					TABS.ContentTypeDescr = tab.attr("href") != undefined ? tab.attr("href").replace("#", "") : "";
				}

				TABS.ShowActiveTab();
			}
		}
	})
};
new AppRouter.Paging();;
var _small = false;

$(document).ready(function ()
{
    TOGGLE.InitText();
    TOGGLE.InitTextToggle();
    TOGGLE.InitHelpInfo();
});

var updateLayout = _.debounce(function (e)
{
    // Does all the layout updating here
    TOGGLE.InitText();

}, 10); // Maximum run of once per 500 milliseconds

window.addEventListener("resize", updateLayout);

TOGGLE = {
	Triggered: false,
    InitText: function ()
    {
        if (PROPERTIES.WIDTH != "large")
        {
            if (!_small)
            {
                _small = true;
            }
            if (!TOGGLE.Triggered)
            {
            	$("#read-more").addClass("show").removeClass("hide");
            	$(".rest").addClass("hide").removeClass("show");
            	if ($(".rest").hasClass('hide'))
            		$("#read-more").html("Lees meer").removeClass("collapse").addClass("expand");
            	else
            		$("#read-more").html("Lees minder").removeClass("expand").addClass("collapse");
            }
        }
        else
        {
        	TOGGLE.Triggered = false;

            $("#read-more").addClass("hide").removeClass("show");
            $(".rest").removeClass("hide");
        }
    },

    InitTextToggle: function ()
    {
    	$(document).on("click", "#read-more", function ()
        {
            if ($(this).hasClass('expand'))
            {
            	TOGGLE.Triggered = true;
                $(".rest").removeClass("hide").addClass("show");
                $(this).html("Lees minder").removeClass("expand").addClass("collapse");
            }
            else if ($(this).hasClass('collapse'))
            {
                $(".rest").addClass("hide").removeClass("show");
                $(this).html("Lees meer").removeClass("collapse").addClass("expand");
            }
        });
    },

    InitHelpInfo: function()
    {
        $(document).on("click", ".icon.info.clickable, .icon.help.clickable", function ()
    	{
    		if ($(this).hasClass('active'))
                $(this).removeClass("active");
            else
                $(this).addClass("active");

            var showTarget = $(this).data("show");
            if (showTarget === undefined || showTarget === '')
                showTarget = $(this).closest(".item-wrapper").next();
            else
                showTarget = "#" + showTarget;

            $(showTarget).slideToggle("fast");
        });
    }
};
$(document).ready(function ()
{
	if ($(".faq").length > 0)
		FAQ.Init();
});

var FAQ =
	{
		AUTOSCROLL: true,

		Init: function ()
		{
			var _this = this;

			_this.SetupShow();
			_this.SetupPermalinks();
		},

		SetupShow: function ()
		{
			var $this = this;
			$(document).on("click", ".faq > .faq-item > .faq-item-head > a:first-of-type", function (e)
			{
				e.preventDefault();

				var $link = $(this);
				var $faqItem = $link.parent().parent();
				var $div = $faqItem.children(".faq-item-content");
				var show = !$faqItem.hasClass("active");

				$this.ShowFaqItem($link, $faqItem, $div, show);

				if (window.location.hash !== undefined && window.location.hash !== "")
				{
					history.pushState("", document.title, window.location.pathname + window.location.search);
				}
			});

			if (window.location.hash !== undefined)
			{
				var faqId = window.location.hash.replace(/\D/g, "");

				var $faqItem = $(".faq-item[data-faqid=" + faqId + "]");
				if ($faqItem !== undefined) {
					var $link = $faqItem.find(".faq-item-title");
					var $div = $faqItem.children(".faq-item-content");
					var show = !$faqItem.hasClass("active");

					$this.ShowFaqItem($link, $faqItem, $div, show);
				}
			}
		},

		ShowFaqItem: function ($link, $faqItem, $div, show)
		{
			var _this = this;

			if ($faqItem.length !== undefined && $faqItem.length > 0)
			{
				$faqItem.removeClass("active");
				$link.removeClass("point-up").addClass("point-down");
				$div.slideUp("slow");

				if (show) {
					$faqItem.addClass("active");
					$link.removeClass("point-down").addClass("point-up");
					$div.slideDown("slow");

					var easingDistance = PROPERTIES.WIDTH === "large" ? 100 : 25;
					if (_this.AUTOSCROLL)
					{
						$('html, body').animate({
							scrollTop: $faqItem.offset().top - easingDistance
						}, 1500);
					}
				}
			}
		},

		SetupPermalinks: function ()
		{
			$(document).on("click", ".permalink a", function (e)
			{
				e.preventDefault();
				var $this = $(this);
				var $input = $this.next("input");

				$input.on("focus", function ()
				{
					$(this).select();
				});
				$input.show();
				$this.remove();
			});
		}
	};
;
$(document).ready(function ()
{
	if (typeof CKEDITOR !== "undefined")
		SWEDITOR.Init();
});

var SWEDITOR =
{
	NoCKEDITOR: typeof CKEDITOR === "undefined",

	AUTOSAVE_TIME: 300,

	TOOLBAR:
		{
			DEFAULT:
			[
				{ items: ["Bold", "Italic", "Underline"] },
				{ items: ["SWSimpleLink", "SWSimpleUnlink", "Unlink"] },
				{ items: ["SWSimpleImage", "SWSimpleVideo"] }
			],
			SIMPLE:
			[
				{ items: ["Bold", "Italic", "Underline"] },
				{ items: ["SWSimpleLink", "SWSimpleUnlink", "Unlink"] },
				{ items: ["Scayt"] }
			],
			SIMPLE_PLUS:
			[
				{ items: ["Bold", "Italic", "Underline"] },
				{ items: ["SWSimpleLink", "SWSimpleUnlink", "Unlink"] },
				{ items: ["NumberedList", "BulletedList"]},
				{ items: ["Scayt"] }
			],
			EXTENDED:
			[
				{ items: ["Bold", "Italic", "Underline"] },
				{ items: ["SWSimpleLink", "SWSimpleUnlink", "Unlink"] },
				{ items: ["SWSimpleImage", "SWSimpleVideo"] },
				{ items: ["NumberedList", "BulletedList", "Outdent", "Indent", "JustifyLeft", "JustifyCenter", "JustifyRight", "JustifyBlock"] }
			]
		},

	Init: function ()
	{
		var _this = this;

		if (_this.NoCKEDITOR)
			return;

		_this.SetupEditor();
		_this.SetupButtons();
		_this.SetupDateTimePicker();
		_this.ApplyEditors();
		_this.SetupInlineDefaults();
	},

	SetupInlineDefaults: function()
	{
		if (this.NoCKEDITOR)
			return;

		var config = this.GetConfig();
		config.SWSimpleCharCount =
			{
				showCharCount: false,
				maxCharCount: 0,
				minCharCount: 0,
				errorCSS: ""
			};
		CKEDITOR.config.language                  = config.language;
		CKEDITOR.config.disableNativeSpellChecker = config.disableNativeSpellChecker;
		CKEDITOR.config.dialog_noConfirmCancel    = config.dialog_noConfirmCancel;
		CKEDITOR.config.title                     = config.title;
		CKEDITOR.config.ignoreEmptyParagraph      = config.ignoreEmptyParagraph;
		CKEDITOR.config.HtmlEncodeOutput          = config.HtmlEncodeOutput;
		CKEDITOR.config.allowedContent            = config.allowedContent;
		CKEDITOR.config.forcePasteAsPlainText     = config.forcePasteAsPlainText;
		CKEDITOR.config.enterMode                 = config.enterMode;
		CKEDITOR.config.shiftEnterMode            = config.shiftEnterMode;
		CKEDITOR.config.coreStyles_bold           = config.coreStyles_bold;
		CKEDITOR.config.coreStyles_italic         = config.coreStyles_italic;
		CKEDITOR.config.extraPlugins              = config.extraPlugins;
		CKEDITOR.config.removePlugins             = config.removePlugins;
		CKEDITOR.config.SWSimpleCharCount         = config.SWSimpleCharCount;
		CKEDITOR.config.toolbar					  = this.TOOLBAR.DEFAULT;
	},

	GetConfig: function ()
	{
		if (this.NoCKEDITOR)
			return;

		var config =
			{
				language: "nl",
				disableNativeSpellChecker: false,
				dialog_noConfirmCancel: true,
				title: false,
				ignoreEmptyParagraph: true,
				HtmlEncodeOutput: true,
				allowedContent: true,
				forcePasteAsPlainText: true,
				enterMode: CKEDITOR.ENTER_BR,
				shiftEnterMode: CKEDITOR.ENTER_BR,
				coreStyles_bold:
					{
						element: "span",
						attributes: { "class": "bold" }
					},
				coreStyles_italic:
					{
						element: "span",
						attributes: { "class": "italic" }
					},
				coreStyles_underline:
					{
						element: "span",
						attributes: { "class" : "underline" }
					},
				extraPlugins: "divarea,SWSimpleLink,SWSimpleUnlink,SWSimpleImage,SWSimpleVideo,confighelper,SWSimpleCharCount,undo,image2",
				removePlugins: "link,elementspath,iframe,scayt,liststyle,magicline,image",
				removeButtons: "",
				uploadUrl: "/upload/uploadimagefromeditor"
			};

		return config;
	},

	GetConfigDefaultStyle: function()
	{
		var config = this.GetConfig();
		config.coreStyles_bold =
					{
						element: "b",
						overrides: "strong"
					};
		config.coreStyles_italic =
				{
					element: "i",
					overrides: "em"
				};
		config.coreStyles_underline =
			{
				element: "u"
			};
		return config;
	},

	SetupEditor: function ()
	{
		if (this.NoCKEDITOR)
			return;

		CKEDITOR.plugins.addExternal("SWSimpleLink", "/Content/JavaScripts/CKEditor/PlugIns/", "SWSimpleLink.js");
		CKEDITOR.plugins.addExternal("SWSimpleUnlink", "/Content/JavaScripts/CKEditor/PlugIns/", "SWSimpleUnlink.js");
		CKEDITOR.plugins.addExternal("SWSimpleImage", "/Content/JavaScripts/CKEditor/PlugIns/", "SWSimpleImage.js");
		CKEDITOR.plugins.addExternal("SWSimpleVideo", "/Content/JavaScripts/CKEditor/PlugIns/", "SWSimpleVideo.js");
		CKEDITOR.plugins.addExternal("confighelper", "/Content/JavaScripts/CKEditor/PlugIns/", "confighelper.js");
		CKEDITOR.plugins.addExternal("SWSimpleCharCount", "/Content/JavaScripts/CKEditor/PlugIns/", "SWSimpleCharCount.js");
		CKEDITOR.plugins.addExternal("tabletools", "/Content/JavaScripts/CKEditor/PlugIns/tabletools/", "plugin.js");
	},

	ApplyEditors: function ()
	{
		var _this = this;

		if (_this.NoCKEDITOR)
			return;

		var config = _this.GetConfig();
		var defconfig = _this.GetConfigDefaultStyle();

		$(".editor-form").each(function ()
		{
			var $this = $(this);

			if ($this.hasClass("editor-attached"))
				return;

			if ($this.data("lazyload").toLowerCase() === "true")
			{
				_this.SetupLazyLoad($this);
				return;
			}

			var $text = $this.find(".editor");
			if ($text.hasClass("simple")) {
				config.toolbar = _this.TOOLBAR.SIMPLE;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); a[*](*)";
			}
			else if ($text.hasClass("simple-plus")) {
				config.toolbar = _this.TOOLBAR.SIMPLE_PLUS;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); ul ol li a[*](*)";
			}
			else if ($text.hasClass("extended"))
				config.toolbar = _this.TOOLBAR.EXTENDED;
			else
				config.toolbar = _this.TOOLBAR.DEFAULT;
			if ($text.hasClass("disallow-word"))
				config.allowedContent = false;

			config.SWSimpleCharCount =
			{
				showCharCount: $text.hasClass("charcount"),
				maxCharCount: parseInt($text.data("swsccmax"), 10),
				minCharCount: parseInt($text.data("swsccmin"), 10),
				errorCSS: $this.data("swsccerror")
			};

			try
			{
				if ($text.hasClass("editor-default-style"))
					$text.ckeditor(defconfig);
				else
					$text.ckeditor(config);

				_this.ApplyAutoSave($text);
			}
			catch (e)
			{
				LOG.WriteError("Unknown error while initializing CKEditor: " + e);
				$text[0].innerHTML = $text[0].innerHTML.trim();
			}

			$this.addClass("editor-attached");
		});

		$(".editor-only").each(function ()
		{
			var $this = $(this);

			if ($this.hasClass("editor-attached"))
				return;

			if ($this.hasClass("simple"))
			{
				config.toolbar = _this.TOOLBAR.SIMPLE;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); a[*](*)";
			}
			else if ($this.hasClass("simple-plus")) {
				config.toolbar = _this.TOOLBAR.SIMPLE_PLUS;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); ul ol li a[*](*)";
			}
			else if ($this.hasClass("extended"))
				config.toolbar = _this.TOOLBAR.EXTENDED;
			else
				config.toolbar = _this.TOOLBAR.DEFAULT;
			if ($this.hasClass("disallow-word"))
				config.allowedContent = false;

			config.SWSimpleCharCount =
			{
				showCharCount: $this.hasClass("charcount"),
				countUnstripped: $this.hasClass("countwithhtml"),
				maxCharCount: parseInt($this.data("swsccmax"), 10),
				minCharCount: parseInt($this.data("swsccmin"), 10),
				errorCSS: $this.data("swsccerror")
			};

			try
			{
				if ($this.hasClass("editor-default-style"))
					$this.ckeditor(defconfig);
				else
					$this.ckeditor(config);

				_this.ApplyAutoSave($this);
			}
			catch (e)
			{
				LOG.WriteError("Unknown error while initializing CKEditor: " + e);
				$this[0].innerHTML = $this[0].innerHTML.trim();
			}

			$this.addClass("editor-attached");
		});
	},

	SetupLazyLoad: function ($form)
	{
		var _this = this;
		var config = _this.GetConfig();
		var defconfig = _this.GetConfigDefaultStyle();
		var toggle = $form.data("loadtoggle");

		$(document).on("click", toggle, function ()
		{
			if ($form.hasClass("editor-attached"))
				return;

			var $this = $(this);

			config.toolbar = _this.TOOLBAR.DEFAULT;
			var $text = $form.find(".editor");
			if ($text.hasClass("simple")) {
				config.toolbar = _this.TOOLBAR.SIMPLE;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); a[*](*)";
			}
			else if ($text.hasClass("simple-plus")) {
				config.toolbar = _this.TOOLBAR.SIMPLE_PLUS;
				config.allowedContent = "span(!underline); span(!italic); span(!bold); ul ol li a[*](*)";
			}
			else if ($text.hasClass("extended"))
				config.toolbar = _this.TOOLBAR.EXTENDED;
			if ($text.hasClass("disallow-word"))
				config.allowedContent = false;

			try
			{
				if ($text.hasClass("editor-default-style"))
					$text.ckeditor(defconfig, function () { $(this).focus(); });
				else
					$text.ckeditor(config, function () { $(this).focus(); });
			}
			catch (e)
			{
				LOG.WriteError("Unknown error while initializing CKEditor: " + e);
				if (_this.WARNING === null || !_this.WARNING.is(":visible"))
					_this.WARNING = BAR.AddInfo("De editor kan niet geladen worden in deze browser.");
			}

			$form.addClass("editor-attached");
		});
	},

	ApplyAutoSave: function($textarea)
	{
		var _this = this;

		if ($textarea.hasClass("autosave"))
		{
			var editor = $textarea.ckeditor().editor;

			if (editor.name === "")
				LOG.WriteInfo("Editor autosave can only be applied when a unique name attribute is specified for the textarea.");
			else
			{
				var keyprefix = window.location.href + "#";
				var key = keyprefix + editor.name;

				$textarea.data("autosave-key", key);

				editor.on("change", function ()
				{
					var object = { value: editor.getData(), timestamp: new Date() };
					if (object.value === "")
						localStorage.removeItem(key);
					else
						localStorage.setItem(key, JSON.stringify(object));
				});

				var stored = localStorage.getItem(key);
				if (stored !== null)
				{
					var parsed    = JSON.parse(stored);
					var storedate = new Date(parsed.timestamp);
					var now       = new Date();
					var diff      = (now - storedate) / 1000;

					if (diff <= _this.AUTOSAVE_TIME)
						editor.setData(parsed.value);
					else
						localStorage.removeItem(key);
				}
			}
		}
	},

	ClearAutoSave: function ($textarea)
	{
		var key = $textarea.data("autosave-key");
		if (key !== "")
			localStorage.removeItem(key);
	},

	SetupButtons: function ()
	{
		var _this = this;

		if (_this.NoCKEDITOR)
			return;

		$(document).on("click", ".editor-submit", function ()
		{
			// SAVE ALL EDITOR INSTANCES TO THE UNDERLYING TEXTAREAS
			for (var instance in CKEDITOR.instances)
				CKEDITOR.instances[instance].updateElement();

			var $btn = $(this);
			if ($btn.hasClass("disabled"))
				return;

			var $form           = $btn.closest("form");
			var $title          = $form.find(".editor-title");
			var $editor_content = $form.find(".editor-content");
			var $content        = $editor_content.parent().find(".cke_wysiwyg_div").first().html();
			var $attachment     = $form.find(".editor-attachment");
			var $span           = $form.find(".editor-attachments-list span");
			var $del            = $form.find(".editor-attachments-list a");
			var $start          = $form.find(".editor-start");
			var $end            = $form.find(".editor-end");

			var savingText    = $form.find(".editor-saving-text").val();
			var savingSuccess = $form.find(".editor-saving-success").val();
			var savingError   = $form.find(".editor-saving-error").val();
			var noAttachmentT = $form.find(".editor-no-attachment-text").val();

			var title         = $.trim($title.val());
			var content       = $.trim($content);
			var sticky        = $form.find(".editor-sticky-button input[type=checkbox]").is(":checked");
			var start         = $start.data("date");
			var end           = $end.data("date");
			var contentHidden = $form.find(".editor-content-text");

			var onCompleteHtml = "";
			var clean          = _this.GetCleanContent($editor_content.val());
			var hasAttachment  = !($attachment.val() === undefined || $attachment.val() === "");

			if (contentHidden !== null && content !== null)
				contentHidden.val(content);

			// SET CLEAN CONTENT TO EDITOR AND TEXTAREA
			$editor_content.val(clean);
			$editor_content.ckeditorGet().updateElement();

			// DISABLE ALL BUTTONS FOR SUBMIT
			$form.find("a, .btn").addClass("disabled");
			$form.find("input[type=checkbox]").prop("disabled", true);

			if (typeof FormData === "undefined") // FORMDATA IS NOT AVAILABLE ON <= IE9, SO WE NEED TO PROCESS A FULL POSTBACK
			{
				BAR.AddLoading(savingText, null, 0);
				$form.attr("action", $form.attr("action") + "?ajax=false");
				$form.submit();
				return;
			}

			var progressId = "editor-progress-" + new Date().getTime();
			var url = $form.attr("action");

			var $loading;
			if (!hasAttachment)
				$loading = BAR.AddLoading(savingText, null, 0);
			else
				$loading = BAR.AddLoading(savingText + "<div class='editor-progress-wrapper'><div class='editor-progress' id='" + progressId + "' /></div>", null, 0);

			$.ajax({
				url: url,
				type: "POST",
				xhr: function()
				{
					var myXhr = $.ajaxSettings.xhr();
					if (myXhr.upload)
					{
						myXhr.upload.addEventListener("progress", function(e)
						{
							var progress = parseInt(e.loaded / e.total * 100, 10);
							$("#" + progressId).css("width", progress + "%");
						}, false);
						return myXhr;
					}
				},
				success: function(result)
				{
					if (result.success)
					{
						BAR.AddSuccess(savingSuccess, $loading);
						if (result.html !== null)
							onCompleteHtml = result.html;
						_this.ClearForm($form);
						_this.FireCallback($form.data("onsuccess"), result);
					}
					else
					{
						if (result.show)
							BAR.AddError(result.error, $loading, 10000);
						else
							BAR.AddError(savingError, $loading);
						LOG.WriteError(result.error);

						_this.FireCallback($form.data("onerror"), result);
					}
				},
				error: function(jqXHR, status, error)
				{
					BAR.AddError(savingError, $loading);
					_this.FireCallback($form.data("onservererror"), error);
				},
				complete: function()
				{
					$form.find("a, .btn").removeClass("disabled");
					$form.find("input[type=checkbox]").prop("disabled", false);
					$form.find("textarea").attr("name", "content");
					if ($form.data("executechangesoncomplete") === 'True')
						ChangesOnComplete($form, onCompleteHtml);
					_this.FireCallback($form.data("oncomplete"));
				},
				data: hasAttachment ? new FormData($form[0]) : $form.serialize(), // IOS 11.3 FIX WHEN SENDING ONLY TEXT
				processData: !hasAttachment,
				contentType: hasAttachment ? false : "application/x-www-form-urlencoded; charset=UTF-8",
				cache: false
			});
		}).on("click", ".editor-cancel", function ()
		{
			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			var $form = $this.closest("form");

			_this.CancelForm($this.closest("form"));
			_this.FireCallback($form.data("oncancel"));
		}).on("click", ".editor-attachment-button", function ()
		{
			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			var $form = $this.closest("form");
			$form.find(".editor-attachment").trigger("click");
		}).on("change", ".editor-attachment", function ()
		{
			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			var $form = $this.closest("form");
			$form.find(".editor-attachments-list span").text($this.val());
			$form.find(".editor-attachment-delete").show();
		}).on("click", ".editor-attachment-delete", function ()
		{
			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			var $form = $this.closest("form");
			var noAttachmentT = $form.find(".editor-no-attachment-text").val();
			$form.find(".editor-attachments-list span").text(noAttachmentT);
			$form.find("[name=attachment-removed]").val("true");
			$form.find(".editor-attachment").val("");
			$this.hide();
		}).on("click", ".editor-sticky-button", function (e)
		{
			var $btn, $chk;

			if (!$(e.target).hasClass("btn")) // CLICK DIRECTLY ON CHECKBOX
			{
				$chk = $(e.target);
				$btn = $chk.closest(".editor-sticky-button");
				if ($btn.hasClass("disabled"))
					return;
			}
			else
			{
				$btn = $(this);
				if ($btn.hasClass("disabled"))
					return;

				$chk = $btn.find("input[type=checkbox]");
				$chk.prop("checked", !$chk.prop("checked"));
			}

			$chk.next("input[type='hidden']").val($chk.prop("checked"));
		}).on("change", ".editor-attachment", function () {
			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			var $form = $this.closest("form");
			
			$form.find(".editor-attachments-list span").text($this.val().replace(/^.*[\\\/]/, ''));
			$form.find(".editor-attachment-delete").show();
		}).on("keypress", ".editor-title", function(e) // DISABLE TRIGGERING A POST OF THE FORM ON ENTER IN TITLE FIELD
		{
			var key = e.keyCode || e.which || e.charCode;
			if (key === 13)
				e.preventDefault();
		});
	},

	FireCallback: function (callback, param)
	{
		if (callback !== undefined)
		{
			if (param !== undefined && param !== null)
				callback(param);
			else
				callback();
		}
	},

	CancelForm: function ($form)
	{
		var $title = $form.find(".editor-title");
		var $content = $form.find("textarea");
		var $span = $form.find(".editor-attachments-list span");

		$title.val($title.data("default"));
		$form.find(".editor").val($content.data("default"));
		$span.text($span.data("default"));
		$form.find(".datetime").val("").removeData("date");
		$form.find("[name=attachment-removed]").val("false");

		var noAttachmentT = $.trim($form.find(".editor-no-attachment-text").val());
		if ($.trim($span.text()) !== $.trim(noAttachmentT))
			$form.find(".editor-attachment-delete").show();
	},

	ClearForm: function ($form)
	{
		var clear = $.trim($form.find(".editor-clear-form-on-success").val().toUpperCase()) === "TRUE";
		if (!clear)
			return;

		$form.find(".editor-title").val("");
		$form.find(".editor").val("");
		$form.find(".editor-attachment").val("");
		$form.find(".editor-attachment-delete").hide();
		$form.find(".editor-sticky-button input[type=checkbox]").prop("checked", false);
		$form.find(".datetime").val("").removeData("date");
		$form.find("[name=attachment-removed]").val("false");

		var $span = $form.find(".editor-attachments-list span");
		$span.text($span.data("default"));
	},

	SetupDateTimePicker: function ()
	{
		$(".editor-wrapper .datetime").each(function ()
		{
			var $input = $(this);
			$input.datetimepicker({
				lang: "nl",
				step: 30,
				format: "d-m-Y H:i",
				dayOfWeekStart: 1,
				onShow: function (ct)
				{
					ct.setHours(0, 0, 0, 0);
					this.setOptions({ minDate: false, minTime: false, maxDate: false, maxTime: false });
					var compare = $input.siblings(".datetime").data("date");

					if (compare !== undefined && $input.hasClass("edit-event-start"))
					{
						this.setOptions({ maxDate: compare });
						if (compare.getDate() === ct.getDate() &&
							compare.getMonth() === ct.getMonth() &&
							compare.getFullYear() === ct.getFullYear())
						{
							this.setOptions({ maxTime: DATETIME.GetFormattedTime(compare) });
						}
					}
					else if (compare !== undefined)
					{
						this.setOptions({ minDate: compare });
						if (compare.getDate() === ct.getDate() &&
							compare.getMonth() === ct.getMonth() &&
							compare.getFullYear() === ct.getFullYear())
						{
							this.setOptions({ minTime: DATETIME.GetFormattedTime(compare) });
						}
					}
				},
				onSelectDate: function (ct)
				{
					var compare = $input.siblings(".datetime").data("date");
					this.setOptions({ minTime: false, maxTime: false });

					if (compare !== undefined && $input.hasClass("editor-start"))
					{
						if (compare.getDate() === ct.getDate() &&
							compare.getMonth() === ct.getMonth() &&
							compare.getFullYear() === ct.getFullYear())
						{
							this.setOptions({ maxTime: DATETIME.GetFormattedTime(compare) });
						}
					}
					else if (compare !== undefined)
					{
						if (compare.getDate() === ct.getDate() &&
							compare.getMonth() === ct.getMonth() &&
							compare.getFullYear() === ct.getFullYear())
						{
							this.setOptions({ minTime: DATETIME.GetFormattedTime(compare) });
						}
					}

					$input.data("date", ct);
				},
				onSelectTime: function (ct)
				{
					$input.data("date", ct);
				}
			});

			$input.on("blur", function ()
			{
				if ($.trim($(this).val()) === "")
					$(this).removeData("date");
			});
		});
	},

	GetCleanContent: function (content)
	{
		content = content.replace(/&nbsp;/g, " "); // REPLACE NON BREAKING SPACE CHARACTERS WITH NORMAL SPACES
		content = content.replace(/\n/g, ""); // REMOVE NEW LINE CHARACTERS

		var $div = $("<div />");
		$div.append(content);

		// REMOVE ALL LEADING BREAKS FROM THE FIRST PARAGRAPH
		$div.find("p:first-of-type").contents().each(function ()
		{
			if ($(this).is("br"))
				$(this).remove();
			else
				return false;
		});

		// REMOVE ALL TRAILING BREAKS FROM THE LAST PARAGRAPH
		var arr = [];
		$div.find("p:last-of-type").contents().each(function ()
		{
			arr.push($(this));
		});
		$.each(arr.reverse(), function ()
		{
			if ($(this).is("br"))
				$(this).remove();
			else
				return false;
		});

		// REMOVE ALL LEADING AND TRAILING BREAKS IF NO PARAGRAPH IS PRESENT
		$div.contents().each(function ()
		{
			if ($(this).is("br"))
				$(this).remove();
			else
				return false;
		});

		arr = [];
		$div.contents().each(function()
		{
			arr.push($(this));
		});
		$.each(arr.reverse(), function ()
		{
			if ($(this).is("br"))
				$(this).remove();
			else
				return false;
		});

		content = $.trim($div.html());
		content = content.replace(/<br>/g, "<br />");

		return content;
	}
};;
$(document).ready(function ()
{
    DICTIONARY.Init();
});

var DICTIONARY =
{
    ALPHABET: "123ABCDEFGHIJKLMNOPQRSTUVWXYZ",

    URL:
        {
            WORD: "/Dictionary/GetWord",
            MODEL: "/Dictionary/GetModel",
            CATEGORY: "/Dictionary/GetCategory"
        },

    TIMEOUT: null,

    Init: function ()
    {
    	// STANDALONE PAGE ONLY NEEDS WORD CLOUD FUNCTIONALITY
        if ($("#dictionary-standalone").length) 
            this.SetupStandAloneSound(); // ATTACH ONLY SOUND PLAYING EVENT ON STANDALONE PAGE
        else
            this.SetupEvents();

        this.SetupWordCloud();
    },

    SetupStandAloneSound: function()
    {
    	$("#dictionary-play-sound").on("click", function ()
    	{
    		try
    		{
    			$("#dictionary-audio")[0].play();
    		}
    		catch (e)
    		{
    			// If playing the sound fails, offer the file for download.
    			window.location = $("#dictionary-mp3").attr("src");
    		}
    	});
    },

    SetupEvents: function ()
    {
        var _this = this;

        $(document).on("click", "#dictionary-tab", function ()
        {
            _this.OpenDictionary();

        }).on("click", "#dictionary-close", function (e)
        {

            e.preventDefault();
            _this.CloseDictionary();
        }).on("click", "#overlay-dictionary", function (e) {

            if ($('#overlay-dictionary').is(e.target)) {
                _this.CloseDictionary();
            }

        }).on("click", ".uitleg, .word", function (e)
        {
        	// ONLY OPEN DICTIONARY WHEN DICTIONARY DIV EXISTS, ELSE JUST OPEN LINK TO DICTIONARY
        	if ($("#dictionary").length)
        	{
        		e.preventDefault();
        		var $this = $(this);

        		_this.OpenDictionary();

        		var word = $this.text();
        		if (typeof $this.data("word") !== typeof undefined)
        			word = $this.data("word");

        		var data = { word: JSON.stringify($.trim(word)) };
        		_this.SetupGetData(_this.URL.WORD, data);
        	}

        }).on("click", "#dictionary-content-text a", function (e)
        {
        	//indien externe link return true
        	var href = $(this).attr('href');
        	if (href.indexOf('computerwoordenboek') > 0)
        	{
        		e.preventDefault();
        		var $this = $(this);

        		_this.OpenDictionary();

        		var word = $this.text();
        		if (typeof $this.data("word") !== typeof undefined)
        			word = $this.data("word");

        		var data = { word: JSON.stringify($.trim(word)) };
        		_this.SetupGetData(_this.URL.WORD, data);

        	}
        	return true;
        }).on("click", "#dictionary-play-sound", function ()
        {
            try
            {
                $("#dictionary-audio")[0].play();
            }
            catch (e)
            {
                // If playing the sound fails, offer the file for download.
                window.location = $("#dictionary-mp3").attr("src");
            }
        }).on("click", "#dictionary-search-button", function()
        {
            var $text = $("#dictionary-search-text");
            var word = $.trim($text.val());

            if (word !== "")
            {
                if ((word.length === 1 || word.length === 3) && _this.ALPHABET.indexOf(word.toUpperCase()) > -1)
                {
                    var data = { cat: JSON.stringify(word.toUpperCase()) };
                    _this.SetupGetData(_this.URL.CATEGORY, data);
                }
                else
                {
                    var data = { word: JSON.stringify(word) };
                    _this.SetupGetData(_this.URL.WORD, data);
                }
            }
        }).on("keyup", "#dictionary-search-text", function(e)
        {
            if (e.keyCode === 13) // Enter triggers search
                $("#dictionary-search-button").trigger("click");
        }).on("click", "#dictionary-home", function (e)
        {
            e.preventDefault();
            _this.SetupGetData(_this.URL.MODEL, null);
        }).on("click", ".letter", function(e)
        {
            e.preventDefault();
            var $this = $(this);

            _this.OpenDictionary();

            // IE 11 takes content in pseudo elements as text as well, so this way we will counter that.
            var letter = $this.text();
            if (typeof $this.data("word") !== typeof undefined)
                letter = $this.data("word");

            var data = { cat: JSON.stringify($.trim(letter)) };
            _this.SetupGetData(_this.URL.CATEGORY, data);
        });
    },

    SetupWordCloud: function ()
    {
    	$("#tag-cloud").tagcanvas({
    		textColour: "#F68B28",
    		outlineColour: "#00A892",
    		outlineMethod: "colour",
    		frontSelect: true,
    		freezeActive: true,
    		reverse: true,
    		shuffleTags: true,
    		initial: [0.5, -0.3],
    		minSpeed: 0.005,
    		maxSpeed: 0.01,
    		weight: true,
    		weightMode: "size",
    		weightFrom: "data-weight"
    	}, "tags");
    },
    
    SetupGetData: function (url, data)
    {
        var _this = this;
        // We need to kill the tag canvas before appending it again later on.

        $("#tag-cloud").tagcanvas("delete");

        $("#dictionary-title").addClass("loading spinner-teal").text("Een ogenblik geduld a.u.b...");
        $("#dictionary-content-text").empty().html("Bezig met zoeken in het computerwoordenboek...");
        $("#dictionary-content-image").hide();
        $("#dictionary-word-list").hide();
        $("#dictionary-play-sound").hide();
        $("#dictionary-navigation").hide();

        _this.FetchData(url, data);
    },

    FetchData: function(url, data)
    {
        var _this = this;

        $.ajax({
            type: "POST",
            url: url,
            data: data,
            dataType: "json",
            cache: true,
            success: function (result)
            {
                if (result.success)
                    $("#dictionary").replaceWith(result.html);
                else
                    LOG.WriteError(result.error);
            },
            complete: function ()
            {
                clearTimeout(_this.TIMEOUT);
                setTimeout(function ()
                {
                    _this.SetupWordCloud();
                }, 100);
            }
        });
    },
    OpenDictionary: function () {
        //open overlay
        $('#overlay-dictionary').addClass('active');
        $('body').addClass('overlay-open');
    },
    CloseDictionary: function () {
        //close overlay
        $('#overlay-dictionary').removeClass('active');
        $('body').removeClass('overlay-open');
    }
};
;
/*
* jQuery Mobile v1.4.5
* http://jquerymobile.com
*
* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
*/

(function ( root, doc, factory ) {
	if ( typeof define === "function" && define.amd ) {
		// AMD. Register as an anonymous module.
		define( [ "jquery" ], function ( $ ) {
			factory( $, root, doc );
			return $.mobile;
		});
	} else {
		// Browser globals
		factory( root.jQuery, root, doc );
	}
}( this, document, function ( jQuery, window, document, undefined ) {// This plugin is an experiment for abstracting away the touch and mouse
// events so that developers don't have to worry about which method of input
// the device their document is loaded on supports.
//
// The idea here is to allow the developer to register listeners for the
// basic mouse events, such as mousedown, mousemove, mouseup, and click,
// and the plugin will take care of registering the correct listeners
// behind the scenes to invoke the listener at the fastest possible time
// for that device, while still retaining the order of event firing in
// the traditional mouse environment, should multiple handlers be registered
// on the same element for different events.
//
// The current version exposes the following virtual events to jQuery bind methods:
// "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel"

(function( $, window, document, undefined ) {

var dataPropertyName = "virtualMouseBindings",
	touchTargetPropertyName = "virtualTouchID",
	virtualEventNames = "vmouseover vmousedown vmousemove vmouseup vclick vmouseout vmousecancel".split( " " ),
	touchEventProps = "clientX clientY pageX pageY screenX screenY".split( " " ),
	mouseHookProps = $.event.mouseHooks ? $.event.mouseHooks.props : [],
	mouseEventProps = $.event.props.concat( mouseHookProps ),
	activeDocHandlers = {},
	resetTimerID = 0,
	startX = 0,
	startY = 0,
	didScroll = false,
	clickBlockList = [],
	blockMouseTriggers = false,
	blockTouchTriggers = false,
	eventCaptureSupported = "addEventListener" in document,
	$document = $( document ),
	nextTouchID = 1,
	lastTouchID = 0, threshold,
	i;

$.vmouse = {
	moveDistanceThreshold: 10,
	clickDistanceThreshold: 10,
	resetTimerDuration: 1500
};

function getNativeEvent( event ) {

	while ( event && typeof event.originalEvent !== "undefined" ) {
		event = event.originalEvent;
	}
	return event;
}

function createVirtualEvent( event, eventType ) {

	var t = event.type,
		oe, props, ne, prop, ct, touch, i, j, len;

	event = $.Event( event );
	event.type = eventType;

	oe = event.originalEvent;
	props = $.event.props;

	// addresses separation of $.event.props in to $.event.mouseHook.props and Issue 3280
	// https://github.com/jquery/jquery-mobile/issues/3280
	if ( t.search( /^(mouse|click)/ ) > -1 ) {
		props = mouseEventProps;
	}

	// copy original event properties over to the new event
	// this would happen if we could call $.event.fix instead of $.Event
	// but we don't have a way to force an event to be fixed multiple times
	if ( oe ) {
		for ( i = props.length, prop; i; ) {
			prop = props[ --i ];
			event[ prop ] = oe[ prop ];
		}
	}

	// make sure that if the mouse and click virtual events are generated
	// without a .which one is defined
	if ( t.search(/mouse(down|up)|click/) > -1 && !event.which ) {
		event.which = 1;
	}

	if ( t.search(/^touch/) !== -1 ) {
		ne = getNativeEvent( oe );
		t = ne.touches;
		ct = ne.changedTouches;
		touch = ( t && t.length ) ? t[0] : ( ( ct && ct.length ) ? ct[ 0 ] : undefined );

		if ( touch ) {
			for ( j = 0, len = touchEventProps.length; j < len; j++) {
				prop = touchEventProps[ j ];
				event[ prop ] = touch[ prop ];
			}
		}
	}

	return event;
}

function getVirtualBindingFlags( element ) {

	var flags = {},
		b, k;

	while ( element ) {

		b = $.data( element, dataPropertyName );

		for (  k in b ) {
			if ( b[ k ] ) {
				flags[ k ] = flags.hasVirtualBinding = true;
			}
		}
		element = element.parentNode;
	}
	return flags;
}

function getClosestElementWithVirtualBinding( element, eventType ) {
	var b;
	while ( element ) {

		b = $.data( element, dataPropertyName );

		if ( b && ( !eventType || b[ eventType ] ) ) {
			return element;
		}
		element = element.parentNode;
	}
	return null;
}

function enableTouchBindings() {
	blockTouchTriggers = false;
}

function disableTouchBindings() {
	blockTouchTriggers = true;
}

function enableMouseBindings() {
	lastTouchID = 0;
	clickBlockList.length = 0;
	blockMouseTriggers = false;

	// When mouse bindings are enabled, our
	// touch bindings are disabled.
	disableTouchBindings();
}

function disableMouseBindings() {
	// When mouse bindings are disabled, our
	// touch bindings are enabled.
	enableTouchBindings();
}

function startResetTimer() {
	clearResetTimer();
	resetTimerID = setTimeout( function() {
		resetTimerID = 0;
		enableMouseBindings();
	}, $.vmouse.resetTimerDuration );
}

function clearResetTimer() {
	if ( resetTimerID ) {
		clearTimeout( resetTimerID );
		resetTimerID = 0;
	}
}

function triggerVirtualEvent( eventType, event, flags ) {
	var ve;

	if ( ( flags && flags[ eventType ] ) ||
				( !flags && getClosestElementWithVirtualBinding( event.target, eventType ) ) ) {

		ve = createVirtualEvent( event, eventType );

		$( event.target).trigger( ve );
	}

	return ve;
}

function mouseEventCallback( event ) {
	var touchID = $.data( event.target, touchTargetPropertyName ),
		ve;

	if ( !blockMouseTriggers && ( !lastTouchID || lastTouchID !== touchID ) ) {
		ve = triggerVirtualEvent( "v" + event.type, event );
		if ( ve ) {
			if ( ve.isDefaultPrevented() ) {
				event.preventDefault();
			}
			if ( ve.isPropagationStopped() ) {
				event.stopPropagation();
			}
			if ( ve.isImmediatePropagationStopped() ) {
				event.stopImmediatePropagation();
			}
		}
	}
}

function handleTouchStart( event ) {

	var touches = getNativeEvent( event ).touches,
		target, flags, t;

	if ( touches && touches.length === 1 ) {

		target = event.target;
		flags = getVirtualBindingFlags( target );

		if ( flags.hasVirtualBinding ) {

			lastTouchID = nextTouchID++;
			$.data( target, touchTargetPropertyName, lastTouchID );

			clearResetTimer();

			disableMouseBindings();
			didScroll = false;

			t = getNativeEvent( event ).touches[ 0 ];
			startX = t.pageX;
			startY = t.pageY;

			triggerVirtualEvent( "vmouseover", event, flags );
			triggerVirtualEvent( "vmousedown", event, flags );
		}
	}
}

function handleScroll( event ) {
	if ( blockTouchTriggers ) {
		return;
	}

	if ( !didScroll ) {
		triggerVirtualEvent( "vmousecancel", event, getVirtualBindingFlags( event.target ) );
	}

	didScroll = true;
	startResetTimer();
}

function handleTouchMove( event ) {
	if ( blockTouchTriggers ) {
		return;
	}

	var t = getNativeEvent( event ).touches[ 0 ],
		didCancel = didScroll,
		moveThreshold = $.vmouse.moveDistanceThreshold,
		flags = getVirtualBindingFlags( event.target );

		didScroll = didScroll ||
			( Math.abs( t.pageX - startX ) > moveThreshold ||
				Math.abs( t.pageY - startY ) > moveThreshold );

	if ( didScroll && !didCancel ) {
		triggerVirtualEvent( "vmousecancel", event, flags );
	}

	triggerVirtualEvent( "vmousemove", event, flags );
	startResetTimer();
}

function handleTouchEnd( event ) {
	if ( blockTouchTriggers ) {
		return;
	}

	disableTouchBindings();

	var flags = getVirtualBindingFlags( event.target ),
		ve, t;
	triggerVirtualEvent( "vmouseup", event, flags );

	if ( !didScroll ) {
		ve = triggerVirtualEvent( "vclick", event, flags );
		if ( ve && ve.isDefaultPrevented() ) {
			// The target of the mouse events that follow the touchend
			// event don't necessarily match the target used during the
			// touch. This means we need to rely on coordinates for blocking
			// any click that is generated.
			t = getNativeEvent( event ).changedTouches[ 0 ];
			clickBlockList.push({
				touchID: lastTouchID,
				x: t.clientX,
				y: t.clientY
			});

			// Prevent any mouse events that follow from triggering
			// virtual event notifications.
			blockMouseTriggers = true;
		}
	}
	triggerVirtualEvent( "vmouseout", event, flags);
	didScroll = false;

	startResetTimer();
}

function hasVirtualBindings( ele ) {
	var bindings = $.data( ele, dataPropertyName ),
		k;

	if ( bindings ) {
		for ( k in bindings ) {
			if ( bindings[ k ] ) {
				return true;
			}
		}
	}
	return false;
}

function dummyMouseHandler() {}

function getSpecialEventObject( eventType ) {
	var realType = eventType.substr( 1 );

	return {
		setup: function(/* data, namespace */) {
			// If this is the first virtual mouse binding for this element,
			// add a bindings object to its data.

			if ( !hasVirtualBindings( this ) ) {
				$.data( this, dataPropertyName, {} );
			}

			// If setup is called, we know it is the first binding for this
			// eventType, so initialize the count for the eventType to zero.
			var bindings = $.data( this, dataPropertyName );
			bindings[ eventType ] = true;

			// If this is the first virtual mouse event for this type,
			// register a global handler on the document.

			activeDocHandlers[ eventType ] = ( activeDocHandlers[ eventType ] || 0 ) + 1;

			if ( activeDocHandlers[ eventType ] === 1 ) {
				$document.bind( realType, mouseEventCallback );
			}

			// Some browsers, like Opera Mini, won't dispatch mouse/click events
			// for elements unless they actually have handlers registered on them.
			// To get around this, we register dummy handlers on the elements.

			$( this ).bind( realType, dummyMouseHandler );

			// For now, if event capture is not supported, we rely on mouse handlers.
			if ( eventCaptureSupported ) {
				// If this is the first virtual mouse binding for the document,
				// register our touchstart handler on the document.

				activeDocHandlers[ "touchstart" ] = ( activeDocHandlers[ "touchstart" ] || 0) + 1;

				if ( activeDocHandlers[ "touchstart" ] === 1 ) {
					$document.bind( "touchstart", handleTouchStart )
						.bind( "touchend", handleTouchEnd )

						// On touch platforms, touching the screen and then dragging your finger
						// causes the window content to scroll after some distance threshold is
						// exceeded. On these platforms, a scroll prevents a click event from being
						// dispatched, and on some platforms, even the touchend is suppressed. To
						// mimic the suppression of the click event, we need to watch for a scroll
						// event. Unfortunately, some platforms like iOS don't dispatch scroll
						// events until *AFTER* the user lifts their finger (touchend). This means
						// we need to watch both scroll and touchmove events to figure out whether
						// or not a scroll happenens before the touchend event is fired.

						.bind( "touchmove", handleTouchMove )
						.bind( "scroll", handleScroll );
				}
			}
		},

		teardown: function(/* data, namespace */) {
			// If this is the last virtual binding for this eventType,
			// remove its global handler from the document.

			--activeDocHandlers[ eventType ];

			if ( !activeDocHandlers[ eventType ] ) {
				$document.unbind( realType, mouseEventCallback );
			}

			if ( eventCaptureSupported ) {
				// If this is the last virtual mouse binding in existence,
				// remove our document touchstart listener.

				--activeDocHandlers[ "touchstart" ];

				if ( !activeDocHandlers[ "touchstart" ] ) {
					$document.unbind( "touchstart", handleTouchStart )
						.unbind( "touchmove", handleTouchMove )
						.unbind( "touchend", handleTouchEnd )
						.unbind( "scroll", handleScroll );
				}
			}

			var $this = $( this ),
				bindings = $.data( this, dataPropertyName );

			// teardown may be called when an element was
			// removed from the DOM. If this is the case,
			// jQuery core may have already stripped the element
			// of any data bindings so we need to check it before
			// using it.
			if ( bindings ) {
				bindings[ eventType ] = false;
			}

			// Unregister the dummy event handler.

			$this.unbind( realType, dummyMouseHandler );

			// If this is the last virtual mouse binding on the
			// element, remove the binding data from the element.

			if ( !hasVirtualBindings( this ) ) {
				$this.removeData( dataPropertyName );
			}
		}
	};
}

// Expose our custom events to the jQuery bind/unbind mechanism.

for ( i = 0; i < virtualEventNames.length; i++ ) {
	$.event.special[ virtualEventNames[ i ] ] = getSpecialEventObject( virtualEventNames[ i ] );
}

// Add a capture click handler to block clicks.
// Note that we require event capture support for this so if the device
// doesn't support it, we punt for now and rely solely on mouse events.
if ( eventCaptureSupported ) {
	document.addEventListener( "click", function( e ) {
		var cnt = clickBlockList.length,
			target = e.target,
			x, y, ele, i, o, touchID;

		if ( cnt ) {
			x = e.clientX;
			y = e.clientY;
			threshold = $.vmouse.clickDistanceThreshold;

			// The idea here is to run through the clickBlockList to see if
			// the current click event is in the proximity of one of our
			// vclick events that had preventDefault() called on it. If we find
			// one, then we block the click.
			//
			// Why do we have to rely on proximity?
			//
			// Because the target of the touch event that triggered the vclick
			// can be different from the target of the click event synthesized
			// by the browser. The target of a mouse/click event that is synthesized
			// from a touch event seems to be implementation specific. For example,
			// some browsers will fire mouse/click events for a link that is near
			// a touch event, even though the target of the touchstart/touchend event
			// says the user touched outside the link. Also, it seems that with most
			// browsers, the target of the mouse/click event is not calculated until the
			// time it is dispatched, so if you replace an element that you touched
			// with another element, the target of the mouse/click will be the new
			// element underneath that point.
			//
			// Aside from proximity, we also check to see if the target and any
			// of its ancestors were the ones that blocked a click. This is necessary
			// because of the strange mouse/click target calculation done in the
			// Android 2.1 browser, where if you click on an element, and there is a
			// mouse/click handler on one of its ancestors, the target will be the
			// innermost child of the touched element, even if that child is no where
			// near the point of touch.

			ele = target;

			while ( ele ) {
				for ( i = 0; i < cnt; i++ ) {
					o = clickBlockList[ i ];
					touchID = 0;

					if ( ( ele === target && Math.abs( o.x - x ) < threshold && Math.abs( o.y - y ) < threshold ) ||
								$.data( ele, touchTargetPropertyName ) === o.touchID ) {
						// XXX: We may want to consider removing matches from the block list
						//      instead of waiting for the reset timer to fire.
						e.preventDefault();
						e.stopPropagation();
						return;
					}
				}
				ele = ele.parentNode;
			}
		}
	}, true);
}
})( jQuery, window, document );

(function( $ ) {
	$.mobile = {};
}( jQuery ));

	(function( $, undefined ) {
		var support = {
			touch: "ontouchend" in document
		};

		$.mobile.support = $.mobile.support || {};
		$.extend( $.support, support );
		$.extend( $.mobile.support, support );
	}( jQuery ));


(function( $, window, undefined ) {
	var $document = $( document ),
		supportTouch = $.mobile.support.touch,
		scrollEvent = "touchmove scroll",
		touchStartEvent = supportTouch ? "touchstart" : "mousedown",
		touchStopEvent = supportTouch ? "touchend" : "mouseup",
		touchMoveEvent = supportTouch ? "touchmove" : "mousemove";

	// setup new event shortcuts
	$.each( ( "touchstart touchmove touchend " +
		"tap taphold " +
		"swipe swipeleft swiperight " +
		"scrollstart scrollstop" ).split( " " ), function( i, name ) {

		$.fn[ name ] = function( fn ) {
			return fn ? this.bind( name, fn ) : this.trigger( name );
		};

		// jQuery < 1.8
		if ( $.attrFn ) {
			$.attrFn[ name ] = true;
		}
	});

	function triggerCustomEvent( obj, eventType, event, bubble ) {
		var originalType = event.type;
		event.type = eventType;
		if ( bubble ) {
			$.event.trigger( event, undefined, obj );
		} else {
			$.event.dispatch.call( obj, event );
		}
		event.type = originalType;
	}

	// also handles scrollstop
	$.event.special.scrollstart = {

		enabled: true,
		setup: function() {

			var thisObject = this,
				$this = $( thisObject ),
				scrolling,
				timer;

			function trigger( event, state ) {
				scrolling = state;
				triggerCustomEvent( thisObject, scrolling ? "scrollstart" : "scrollstop", event );
			}

			// iPhone triggers scroll after a small delay; use touchmove instead
			$this.bind( scrollEvent, function( event ) {

				if ( !$.event.special.scrollstart.enabled ) {
					return;
				}

				if ( !scrolling ) {
					trigger( event, true );
				}

				clearTimeout( timer );
				timer = setTimeout( function() {
					trigger( event, false );
				}, 50 );
			});
		},
		teardown: function() {
			$( this ).unbind( scrollEvent );
		}
	};

	// also handles taphold
	$.event.special.tap = {
		tapholdThreshold: 750,
		emitTapOnTaphold: true,
		setup: function() {
			var thisObject = this,
				$this = $( thisObject ),
				isTaphold = false;

			$this.bind( "vmousedown", function( event ) {
				isTaphold = false;
				if ( event.which && event.which !== 1 ) {
					return false;
				}

				var origTarget = event.target,
					timer;

				function clearTapTimer() {
					clearTimeout( timer );
				}

				function clearTapHandlers() {
					clearTapTimer();

					$this.unbind( "vclick", clickHandler )
						.unbind( "vmouseup", clearTapTimer );
					$document.unbind( "vmousecancel", clearTapHandlers );
				}

				function clickHandler( event ) {
					clearTapHandlers();

					// ONLY trigger a 'tap' event if the start target is
					// the same as the stop target.
					if ( !isTaphold && origTarget === event.target ) {
						triggerCustomEvent( thisObject, "tap", event );
					} else if ( isTaphold ) {
						event.preventDefault();
					}
				}

				$this.bind( "vmouseup", clearTapTimer )
					.bind( "vclick", clickHandler );
				$document.bind( "vmousecancel", clearTapHandlers );

				timer = setTimeout( function() {
					if ( !$.event.special.tap.emitTapOnTaphold ) {
						isTaphold = true;
					}
					triggerCustomEvent( thisObject, "taphold", $.Event( "taphold", { target: origTarget } ) );
				}, $.event.special.tap.tapholdThreshold );
			});
		},
		teardown: function() {
			$( this ).unbind( "vmousedown" ).unbind( "vclick" ).unbind( "vmouseup" );
			$document.unbind( "vmousecancel" );
		}
	};

	// Also handles swipeleft, swiperight
	$.event.special.swipe = {

		// More than this horizontal displacement, and we will suppress scrolling.
		scrollSupressionThreshold: 30,

		// More time than this, and it isn't a swipe.
		durationThreshold: 1000,

		// Swipe horizontal displacement must be more than this.
		horizontalDistanceThreshold: 30,

		// Swipe vertical displacement must be less than this.
		verticalDistanceThreshold: 30,

		getLocation: function ( event ) {
			var winPageX = window.pageXOffset,
				winPageY = window.pageYOffset,
				x = event.clientX,
				y = event.clientY;

			if ( event.pageY === 0 && Math.floor( y ) > Math.floor( event.pageY ) ||
				event.pageX === 0 && Math.floor( x ) > Math.floor( event.pageX ) ) {

				// iOS4 clientX/clientY have the value that should have been
				// in pageX/pageY. While pageX/page/ have the value 0
				x = x - winPageX;
				y = y - winPageY;
			} else if ( y < ( event.pageY - winPageY) || x < ( event.pageX - winPageX ) ) {

				// Some Android browsers have totally bogus values for clientX/Y
				// when scrolling/zooming a page. Detectable since clientX/clientY
				// should never be smaller than pageX/pageY minus page scroll
				x = event.pageX - winPageX;
				y = event.pageY - winPageY;
			}

			return {
				x: x,
				y: y
			};
		},

		start: function( event ) {
			var data = event.originalEvent.touches ?
					event.originalEvent.touches[ 0 ] : event,
				location = $.event.special.swipe.getLocation( data );
			return {
						time: ( new Date() ).getTime(),
						coords: [ location.x, location.y ],
						origin: $( event.target )
					};
		},

		stop: function( event ) {
			var data = event.originalEvent.touches ?
					event.originalEvent.touches[ 0 ] : event,
				location = $.event.special.swipe.getLocation( data );
			return {
						time: ( new Date() ).getTime(),
						coords: [ location.x, location.y ]
					};
		},

		handleSwipe: function( start, stop, thisObject, origTarget ) {
			if ( stop.time - start.time < $.event.special.swipe.durationThreshold &&
				Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.horizontalDistanceThreshold &&
				Math.abs( start.coords[ 1 ] - stop.coords[ 1 ] ) < $.event.special.swipe.verticalDistanceThreshold ) {
				var direction = start.coords[0] > stop.coords[ 0 ] ? "swipeleft" : "swiperight";

				triggerCustomEvent( thisObject, "swipe", $.Event( "swipe", { target: origTarget, swipestart: start, swipestop: stop }), true );
				triggerCustomEvent( thisObject, direction,$.Event( direction, { target: origTarget, swipestart: start, swipestop: stop } ), true );
				return true;
			}
			return false;

		},

		// This serves as a flag to ensure that at most one swipe event event is
		// in work at any given time
		eventInProgress: false,

		setup: function() {
			var events,
				thisObject = this,
				$this = $( thisObject ),
				context = {};

			// Retrieve the events data for this element and add the swipe context
			events = $.data( this, "mobile-events" );
			if ( !events ) {
				events = { length: 0 };
				$.data( this, "mobile-events", events );
			}
			events.length++;
			events.swipe = context;

			context.start = function( event ) {

				// Bail if we're already working on a swipe event
				if ( $.event.special.swipe.eventInProgress ) {
					return;
				}
				$.event.special.swipe.eventInProgress = true;

				var stop,
					start = $.event.special.swipe.start( event ),
					origTarget = event.target,
					emitted = false;

				context.move = function( event ) {
					if ( !start || event.isDefaultPrevented() ) {
						return;
					}

					stop = $.event.special.swipe.stop( event );
					if ( !emitted ) {
						emitted = $.event.special.swipe.handleSwipe( start, stop, thisObject, origTarget );
						if ( emitted ) {

							// Reset the context to make way for the next swipe event
							$.event.special.swipe.eventInProgress = false;
						}
					}
					// prevent scrolling
					if ( Math.abs( start.coords[ 0 ] - stop.coords[ 0 ] ) > $.event.special.swipe.scrollSupressionThreshold ) {
						event.preventDefault();
					}
				};

				context.stop = function() {
						emitted = true;

						// Reset the context to make way for the next swipe event
						$.event.special.swipe.eventInProgress = false;
						$document.off( touchMoveEvent, context.move );
						context.move = null;
				};

				$document.on( touchMoveEvent, context.move )
					.one( touchStopEvent, context.stop );
			};
			$this.on( touchStartEvent, context.start );
		},

		teardown: function() {
			var events, context;

			events = $.data( this, "mobile-events" );
			if ( events ) {
				context = events.swipe;
				delete events.swipe;
				events.length--;
				if ( events.length === 0 ) {
					$.removeData( this, "mobile-events" );
				}
			}

			if ( context ) {
				if ( context.start ) {
					$( this ).off( touchStartEvent, context.start );
				}
				if ( context.move ) {
					$document.off( touchMoveEvent, context.move );
				}
				if ( context.stop ) {
					$document.off( touchStopEvent, context.stop );
				}
			}
		}
	};
	$.each({
		scrollstop: "scrollstart",
		taphold: "tap",
		swipeleft: "swipe.left",
		swiperight: "swipe.right"
	}, function( event, sourceEvent ) {

		$.event.special[ event ] = {
			setup: function() {
				$( this ).bind( sourceEvent, $.noop );
			},
			teardown: function() {
				$( this ).unbind( sourceEvent );
			}
		};
	});

})( jQuery, this );


}));
;
/*!
 * jQuery Color Animations v2.0pre
 * http://jquery.org/
 *
 * Copyright 2011 John Resig
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 */

(function (jQuery, undefined)
{
	var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color outlineColor".split(" "),

		// plusequals test for += 100 -= 100
		rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
		// a set of RE's that can match strings and generate color tuples.
		stringParsers = [{
			re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
			parse: function (execResult)
			{
				return [
					execResult[1],
					execResult[2],
					execResult[3],
					execResult[4]
				];
			}
		}, {
			re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
			parse: function (execResult)
			{
				return [
					2.55 * execResult[1],
					2.55 * execResult[2],
					2.55 * execResult[3],
					execResult[4]
				];
			}
		}, {
			re: /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/,
			parse: function (execResult)
			{
				return [
					parseInt(execResult[1], 16),
					parseInt(execResult[2], 16),
					parseInt(execResult[3], 16)
				];
			}
		}, {
			re: /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/,
			parse: function (execResult)
			{
				return [
					parseInt(execResult[1] + execResult[1], 16),
					parseInt(execResult[2] + execResult[2], 16),
					parseInt(execResult[3] + execResult[3], 16)
				];
			}
		}, {
			re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
			space: "hsla",
			parse: function (execResult)
			{
				return [
					execResult[1],
					execResult[2] / 100,
					execResult[3] / 100,
					execResult[4]
				];
			}
		}],

		// jQuery.Color( )
		color = jQuery.Color = function (color, green, blue, alpha)
		{
			return new jQuery.Color.fn.parse(color, green, blue, alpha);
		},
		spaces = {
			rgba: {
				cache: "_rgba",
				props: {
					red: {
						idx: 0,
						type: "byte",
						empty: true
					},
					green: {
						idx: 1,
						type: "byte",
						empty: true
					},
					blue: {
						idx: 2,
						type: "byte",
						empty: true
					},
					alpha: {
						idx: 3,
						type: "percent",
						def: 1
					}
				}
			},
			hsla: {
				cache: "_hsla",
				props: {
					hue: {
						idx: 0,
						type: "degrees",
						empty: true
					},
					saturation: {
						idx: 1,
						type: "percent",
						empty: true
					},
					lightness: {
						idx: 2,
						type: "percent",
						empty: true
					}
				}
			}
		},
		propTypes = {
			"byte": {
				floor: true,
				min: 0,
				max: 255
			},
			"percent": {
				min: 0,
				max: 1
			},
			"degrees": {
				mod: 360,
				floor: true
			}
		},
		rgbaspace = spaces.rgba.props,
		support = color.support = {},

		// colors = jQuery.Color.names
		colors,

		// local aliases of functions called often
		each = jQuery.each;

	spaces.hsla.props.alpha = rgbaspace.alpha;

	function clamp(value, prop, alwaysAllowEmpty)
	{
		var type = propTypes[prop.type] || {},
			allowEmpty = prop.empty || alwaysAllowEmpty;

		if (allowEmpty && value == null)
		{
			return null;
		}
		if (prop.def && value == null)
		{
			return prop.def;
		}
		if (type.floor)
		{
			value = ~~value;
		} else
		{
			value = parseFloat(value);
		}
		if (value == null || isNaN(value))
		{
			return prop.def;
		}
		if (type.mod)
		{
			value = value % type.mod;
			// -10 -> 350
			return value < 0 ? type.mod + value : value;
		}

		// for now all property types without mod have min and max
		return type.min > value ? type.min : type.max < value ? type.max : value;
	}

	function stringParse(string)
	{
		var inst = color(),
			rgba = inst._rgba = [];

		string = string.toLowerCase();

		each(stringParsers, function (i, parser)
		{
			var match = parser.re.exec(string),
				values = match && parser.parse(match),
				parsed,
				spaceName = parser.space || "rgba",
				cache = spaces[spaceName].cache;


			if (values)
			{
				parsed = inst[spaceName](values);

				// if this was an rgba parse the assignment might happen twice
				// oh well....
				inst[cache] = parsed[cache];
				rgba = inst._rgba = parsed._rgba;

				// exit each( stringParsers ) here because we matched
				return false;
			}
		});

		// Found a stringParser that handled it
		if (rgba.length !== 0)
		{

			// if this came from a parsed string, force "transparent" when alpha is 0
			// chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
			if (Math.max.apply(Math, rgba) === 0)
			{
				jQuery.extend(rgba, colors.transparent);
			}
			return inst;
		}

		// named colors / default - filter back through parse function
		if (string = colors[string])
		{
			return string;
		}
	}

	color.fn = color.prototype = {
		constructor: color,
		parse: function (red, green, blue, alpha)
		{
			if (red === undefined)
			{
				this._rgba = [null, null, null, null];
				return this;
			}
			if (red instanceof jQuery || red.nodeType)
			{
				red = red instanceof jQuery ? red.css(green) : jQuery(red).css(green);
				green = undefined;
			}

			var inst = this,
				type = jQuery.type(red),
				rgba = this._rgba = [],
				source;

			// more than 1 argument specified - assume ( red, green, blue, alpha )
			if (green !== undefined)
			{
				red = [red, green, blue, alpha];
				type = "array";
			}

			if (type === "string")
			{
				return this.parse(stringParse(red) || colors._default);
			}

			if (type === "array")
			{
				each(rgbaspace, function (key, prop)
				{
					rgba[prop.idx] = clamp(red[prop.idx], prop);
				});
				return this;
			}

			if (type === "object")
			{
				if (red instanceof color)
				{
					each(spaces, function (spaceName, space)
					{
						if (red[space.cache])
						{
							inst[space.cache] = red[space.cache].slice();
						}
					});
				} else
				{
					each(spaces, function (spaceName, space)
					{
						each(space.props, function (key, prop)
						{
							var cache = space.cache;

							// if the cache doesn't exist, and we know how to convert
							if (!inst[cache] && space.to)
							{

								// if the value was null, we don't need to copy it
								// if the key was alpha, we don't need to copy it either
								if (red[key] == null || key === "alpha")
								{
									return;
								}
								inst[cache] = space.to(inst._rgba);
							}

							// this is the only case where we allow nulls for ALL properties.
							// call clamp with alwaysAllowEmpty
							inst[cache][prop.idx] = clamp(red[key], prop, true);
						});
					});
				}
				return this;
			}
		},
		is: function (compare)
		{
			var is = color(compare),
				same = true,
				myself = this;

			each(spaces, function (_, space)
			{
				var isCache = is[space.cache],
					localCache;
				if (isCache)
				{
					localCache = myself[space.cache] || space.to && space.to(myself._rgba) || [];
					each(space.props, function (_, prop)
					{
						if (isCache[prop.idx] != null)
						{
							same = (isCache[prop.idx] === localCache[prop.idx]);
							return same;
						}
					});
				}
				return same;
			});
			return same;
		},
		_space: function ()
		{
			var used = [],
				inst = this;
			each(spaces, function (spaceName, space)
			{
				if (inst[space.cache])
				{
					used.push(spaceName);
				}
			});
			return used.pop();
		},
		transition: function (other, distance)
		{
			var end = color(other),
				spaceName = end._space(),
				space = spaces[spaceName],
				start = this[space.cache] || space.to(this._rgba),
				result = start.slice();

			end = end[space.cache];
			each(space.props, function (key, prop)
			{
				var index = prop.idx,
					startValue = start[index],
					endValue = end[index],
					type = propTypes[prop.type] || {};

				// if null, don't override start value
				if (endValue === null)
				{
					return;
				}
				// if null - use end
				if (startValue === null)
				{
					result[index] = endValue;
				} else
				{
					if (type.mod)
					{
						if (endValue - startValue > type.mod / 2)
						{
							startValue += type.mod;
						} else if (startValue - endValue > type.mod / 2)
						{
							startValue -= type.mod;
						}
					}
					result[prop.idx] = clamp((endValue - startValue) * distance + startValue, prop);
				}
			});
			return this[spaceName](result);
		},
		blend: function (opaque)
		{
			// if we are already opaque - return ourself
			if (this._rgba[3] === 1)
			{
				return this;
			}

			var rgb = this._rgba.slice(),
				a = rgb.pop(),
				blend = color(opaque)._rgba;

			return color(jQuery.map(rgb, function (v, i)
			{
				return (1 - a) * blend[i] + a * v;
			}));
		},
		toRgbaString: function ()
		{
			var prefix = "rgba(",
				rgba = jQuery.map(this._rgba, function (v, i)
				{
					return v == null ? (i > 2 ? 1 : 0) : v;
				});

			if (rgba[3] === 1)
			{
				rgba.pop();
				prefix = "rgb(";
			}

			return prefix + rgba.join(",") + ")";
		},
		toHslaString: function ()
		{
			var prefix = "hsla(",
				hsla = jQuery.map(this.hsla(), function (v, i)
				{
					if (v == null)
					{
						v = i > 2 ? 1 : 0;
					}

					// catch 1 and 2
					if (i && i < 3)
					{
						v = Math.round(v * 100) + "%";
					}
					return v;
				});

			if (hsla[3] === 1)
			{
				hsla.pop();
				prefix = "hsl(";
			}
			return prefix + hsla.join(",") + ")";
		},
		toHexString: function (includeAlpha)
		{
			var rgba = this._rgba.slice(),
				alpha = rgba.pop();

			if (includeAlpha)
			{
				rgba.push(~~(alpha * 255));
			}

			return "#" + jQuery.map(rgba, function (v, i)
			{

				// default to 0 when nulls exist
				v = (v || 0).toString(16);
				return v.length === 1 ? "0" + v : v;
			}).join("");
		},
		toString: function ()
		{
			return this._rgba[3] === 0 ? "transparent" : this.toRgbaString();
		}
	};
	color.fn.parse.prototype = color.fn;

	// hsla conversions adapted from:
	// http://www.google.com/codesearch/p#OAMlx_jo-ck/src/third_party/WebKit/Source/WebCore/inspector/front-end/Color.js&d=7&l=193

	function hue2rgb(p, q, h)
	{
		h = (h + 1) % 1;
		if (h * 6 < 1)
		{
			return p + (q - p) * 6 * h;
		}
		if (h * 2 < 1)
		{
			return q;
		}
		if (h * 3 < 2)
		{
			return p + (q - p) * ((2 / 3) - h) * 6;
		}
		return p;
	}

	spaces.hsla.to = function (rgba)
	{
		if (rgba[0] == null || rgba[1] == null || rgba[2] == null)
		{
			return [null, null, null, rgba[3]];
		}
		var r = rgba[0] / 255,
			g = rgba[1] / 255,
			b = rgba[2] / 255,
			a = rgba[3],
			max = Math.max(r, g, b),
			min = Math.min(r, g, b),
			diff = max - min,
			add = max + min,
			l = add * 0.5,
			h, s;

		if (min === max)
		{
			h = 0;
		} else if (r === max)
		{
			h = (60 * (g - b) / diff) + 360;
		} else if (g === max)
		{
			h = (60 * (b - r) / diff) + 120;
		} else
		{
			h = (60 * (r - g) / diff) + 240;
		}

		if (l === 0 || l === 1)
		{
			s = l;
		} else if (l <= 0.5)
		{
			s = diff / add;
		} else
		{
			s = diff / (2 - add);
		}
		return [Math.round(h) % 360, s, l, a == null ? 1 : a];
	};

	spaces.hsla.from = function (hsla)
	{
		if (hsla[0] == null || hsla[1] == null || hsla[2] == null)
		{
			return [null, null, null, hsla[3]];
		}
		var h = hsla[0] / 360,
			s = hsla[1],
			l = hsla[2],
			a = hsla[3],
			q = l <= 0.5 ? l * (1 + s) : l + s - l * s,
			p = 2 * l - q,
			r, g, b;

		return [
			Math.round(hue2rgb(p, q, h + (1 / 3)) * 255),
			Math.round(hue2rgb(p, q, h) * 255),
			Math.round(hue2rgb(p, q, h - (1 / 3)) * 255),
			a
		];
	};


	each(spaces, function (spaceName, space)
	{
		var props = space.props,
			cache = space.cache,
			to = space.to,
			from = space.from;

		// makes rgba() and hsla()
		color.fn[spaceName] = function (value)
		{

			// generate a cache for this space if it doesn't exist
			if (to && !this[cache])
			{
				this[cache] = to(this._rgba);
			}
			if (value === undefined)
			{
				return this[cache].slice();
			}

			var type = jQuery.type(value),
				arr = (type === "array" || type === "object") ? value : arguments,
				local = this[cache].slice(),
				ret;

			each(props, function (key, prop)
			{
				var val = arr[type === "object" ? key : prop.idx];
				if (val == null)
				{
					val = local[prop.idx];
				}
				local[prop.idx] = clamp(val, prop);
			});

			if (from)
			{
				ret = color(from(local));
				ret[cache] = local;
				return ret;
			} else
			{
				return color(local);
			}
		};

		// makes red() green() blue() alpha() hue() saturation() lightness()
		each(props, function (key, prop)
		{
			// alpha is included in more than one space
			if (color.fn[key])
			{
				return;
			}
			color.fn[key] = function (value)
			{
				var vtype = jQuery.type(value),
					fn = (key === 'alpha' ? (this._hsla ? 'hsla' : 'rgba') : spaceName),
					local = this[fn](),
					cur = local[prop.idx],
					match;

				if (vtype === "undefined")
				{
					return cur;
				}

				if (vtype === "function")
				{
					value = value.call(this, cur);
					vtype = jQuery.type(value);
				}
				if (value == null && prop.empty)
				{
					return this;
				}
				if (vtype === "string")
				{
					match = rplusequals.exec(value);
					if (match)
					{
						value = cur + parseFloat(match[2]) * (match[1] === "+" ? 1 : -1);
					}
				}
				local[prop.idx] = value;
				return this[fn](local);
			};
		});
	});

	// add .fx.step functions
	each(stepHooks, function (i, hook)
	{
		jQuery.cssHooks[hook] = {
			set: function (elem, value)
			{
				var parsed, backgroundColor, curElem;

				if (jQuery.type(value) !== 'string' || (parsed = stringParse(value)))
{
					value = color(parsed || value);
					if (!support.rgba && value._rgba[3] !== 1)
					{
						curElem = hook === "backgroundColor" ? elem.parentNode : elem;
						do
						{
							backgroundColor = jQuery.curCSS(curElem, "backgroundColor");
						} while (
							(backgroundColor === "" || backgroundColor === "transparent") &&
							(curElem = curElem.parentNode) &&
							curElem.style
						);

						value = value.blend(backgroundColor && backgroundColor !== "transparent" ?
							backgroundColor :
							"_default");
					}

					value = value.toRgbaString();
				}
				elem.style[hook] = value;
			}
		};
		jQuery.fx.step[hook] = function (fx)
		{
			if (!fx.colorInit)
			{
				fx.start = color(fx.elem, hook);
				fx.end = color(fx.end);
				fx.colorInit = true;
			}
			jQuery.cssHooks[hook].set(fx.elem, fx.start.transition(fx.end, fx.pos));
		};
	});

	// detect rgba support
	jQuery(function ()
	{
		var div = document.createElement("div"),
			div_style = div.style;

		div_style.cssText = "background-color:rgba(1,1,1,.5)";
		support.rgba = div_style.backgroundColor.indexOf("rgba") > -1;
	});

	// Some named colors to work with
	// From Interface by Stefan Petre
	// http://interface.eyecon.ro/
	colors = jQuery.Color.names = {
		aqua: "#00ffff",
		azure: "#f0ffff",
		beige: "#f5f5dc",
		black: "#000000",
		blue: "#0000ff",
		brown: "#a52a2a",
		cyan: "#00ffff",
		darkblue: "#00008b",
		darkcyan: "#008b8b",
		darkgrey: "#a9a9a9",
		darkgreen: "#006400",
		darkkhaki: "#bdb76b",
		darkmagenta: "#8b008b",
		darkolivegreen: "#556b2f",
		darkorange: "#ff8c00",
		darkorchid: "#9932cc",
		darkred: "#8b0000",
		darksalmon: "#e9967a",
		darkviolet: "#9400d3",
		fuchsia: "#ff00ff",
		gold: "#ffd700",
		green: "#008000",
		indigo: "#4b0082",
		khaki: "#f0e68c",
		lightblue: "#add8e6",
		lightcyan: "#e0ffff",
		lightgreen: "#90ee90",
		lightgrey: "#d3d3d3",
		lightpink: "#ffb6c1",
		lightyellow: "#ffffe0",
		lime: "#00ff00",
		magenta: "#ff00ff",
		maroon: "#800000",
		navy: "#000080",
		olive: "#808000",
		orange: "#ffa500",
		pink: "#ffc0cb",
		purple: "#800080",
		violet: "#800080",
		red: "#ff0000",
		silver: "#c0c0c0",
		white: "#ffffff",
		yellow: "#ffff00",
		transparent: [null, null, null, 0],
		_default: "#ffffff"
	};
})(jQuery);
;
/*!
 * jQuery Cookie Plugin v1.4.1
 * https://github.com/carhartl/jquery-cookie
 *
 * Copyright 2006, 2014 Klaus Hartl
 * Released under the MIT license
 */
(function (factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD (Register as an anonymous module)
		define(['jquery'], factory);
	} else if (typeof exports === 'object') {
		// Node/CommonJS
		module.exports = factory(require('jquery'));
	} else {
		// Browser globals
		factory(jQuery);
	}
}(function ($) {

	var pluses = /\+/g;

	function encode(s) {
		return config.raw ? s : encodeURIComponent(s);
	}

	function decode(s) {
		return config.raw ? s : decodeURIComponent(s);
	}

	function stringifyCookieValue(value) {
		return encode(config.json ? JSON.stringify(value) : String(value));
	}

	function parseCookieValue(s) {
		if (s.indexOf('"') === 0) {
			// This is a quoted cookie as according to RFC2068, unescape...
			s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
		}

		try {
			// Replace server-side written pluses with spaces.
			// If we can't decode the cookie, ignore it, it's unusable.
			// If we can't parse the cookie, ignore it, it's unusable.
			s = decodeURIComponent(s.replace(pluses, ' '));
			return config.json ? JSON.parse(s) : s;
		} catch(e) {}
	}

	function read(s, converter) {
		var value = config.raw ? s : parseCookieValue(s);
		return $.isFunction(converter) ? converter(value) : value;
	}

	var config = $.cookie = function (key, value, options) {

		// Write

		if (arguments.length > 1 && !$.isFunction(value)) {
			options = $.extend({}, config.defaults, options);

			if (typeof options.expires === 'number') {
				var days = options.expires, t = options.expires = new Date();
				t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
			}

			return (document.cookie = [
				encode(key), '=', stringifyCookieValue(value),
				options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
				options.path    ? '; path=' + options.path : '',
				options.domain  ? '; domain=' + options.domain : '',
				options.secure  ? '; secure' : ''
			].join(''));
		}

		// Read

		var result = key ? undefined : {},
			// To prevent the for loop in the first place assign an empty array
			// in case there are no cookies at all. Also prevents odd result when
			// calling $.cookie().
			cookies = document.cookie ? document.cookie.split('; ') : [],
			i = 0,
			l = cookies.length;

		for (; i < l; i++) {
			var parts = cookies[i].split('='),
				name = decode(parts.shift()),
				cookie = parts.join('=');

			if (key === name) {
				// If second argument (value) is a function it's a converter...
				result = read(cookie, value);
				break;
			}

			// Prevent storing a cookie that we couldn't decode.
			if (!key && (cookie = read(cookie)) !== undefined) {
				result[name] = cookie;
			}
		}

		return result;
	};

	config.defaults = {};

	$.removeCookie = function (key, options) {
		// Must not alter options, thus extending a fresh object...
		$.cookie(key, '', $.extend({}, options, { expires: -1 }));
		return !$.cookie(key);
	};

}));
;
/*! modernizr 3.6.0 (Custom Build) | MIT *
 * https://modernizr.com/download/?-cssfilters-flexbox-setclasses !*/
!function(e, n, t) { function r(e, n) { return typeof e === n } function s() { var e, n, t, s, o, i, l; for (var a in S) if (S.hasOwnProperty(a)) { if (e = [], n = S[a], n.name && (e.push(n.name.toLowerCase()), n.options && n.options.aliases && n.options.aliases.length)) for (t = 0; t < n.options.aliases.length; t++)e.push(n.options.aliases[t].toLowerCase()); for (s = r(n.fn, "function") ? n.fn() : n.fn, o = 0; o < e.length; o++)i = e[o], l = i.split("."), 1 === l.length ? Modernizr[l[0]] = s : (!Modernizr[l[0]] || Modernizr[l[0]] instanceof Boolean || (Modernizr[l[0]] = new Boolean(Modernizr[l[0]])), Modernizr[l[0]][l[1]] = s), C.push((s ? "" : "no-") + l.join("-")) } } function o(e) { var n = w.className, t = Modernizr._config.classPrefix || ""; if (_ && (n = n.baseVal), Modernizr._config.enableJSClass) { var r = new RegExp("(^|\\s)" + t + "no-js(\\s|$)"); n = n.replace(r, "$1" + t + "js$2") } Modernizr._config.enableClasses && (n += " " + t + e.join(" " + t), _ ? w.className.baseVal = n : w.className = n) } function i() { return "function" != typeof n.createElement ? n.createElement(arguments[0]) : _ ? n.createElementNS.call(n, "http://www.w3.org/2000/svg", arguments[0]) : n.createElement.apply(n, arguments) } function l(e, n) { return !!~("" + e).indexOf(n) } function a(e) { return e.replace(/([a-z])-([a-z])/g, function(e, n, t) { return n + t.toUpperCase() }).replace(/^-/, "") } function u(e, n) { return function() { return e.apply(n, arguments) } } function f(e, n, t) { var s; for (var o in e) if (e[o] in n) return t === !1 ? e[o] : (s = n[e[o]], r(s, "function") ? u(s, t || n) : s); return !1 } function p(e) { return e.replace(/([A-Z])/g, function(e, n) { return "-" + n.toLowerCase() }).replace(/^ms-/, "-ms-") } function c(n, t, r) { var s; if ("getComputedStyle" in e) { s = getComputedStyle.call(e, n, t); var o = e.console; if (null !== s) r && (s = s.getPropertyValue(r)); else if (o) { var i = o.error ? "error" : "log"; o[i].call(o, "getComputedStyle returning null, its possible modernizr test results are inaccurate") } } else s = !t && n.currentStyle && n.currentStyle[r]; return s } function d() { var e = n.body; return e || (e = i(_ ? "svg" : "body"), e.fake = !0), e } function m(e, t, r, s) { var o, l, a, u, f = "modernizr", p = i("div"), c = d(); if (parseInt(r, 10)) for (; r--;)a = i("div"), a.id = s ? s[r] : f + (r + 1), p.appendChild(a); return o = i("style"), o.type = "text/css", o.id = "s" + f, (c.fake ? c : p).appendChild(o), c.appendChild(p), o.styleSheet ? o.styleSheet.cssText = e : o.appendChild(n.createTextNode(e)), p.id = f, c.fake && (c.style.background = "", c.style.overflow = "hidden", u = w.style.overflow, w.style.overflow = "hidden", w.appendChild(c)), l = t(p, e), c.fake ? (c.parentNode.removeChild(c), w.style.overflow = u, w.offsetHeight) : p.parentNode.removeChild(p), !!l } function y(n, r) { var s = n.length; if ("CSS" in e && "supports" in e.CSS) { for (; s--;)if (e.CSS.supports(p(n[s]), r)) return !0; return !1 } if ("CSSSupportsRule" in e) { for (var o = []; s--;)o.push("(" + p(n[s]) + ":" + r + ")"); return o = o.join(" or "), m("@supports (" + o + ") { #modernizr { position: absolute; } }", function(e) { return "absolute" == c(e, null, "position") }) } return t } function v(e, n, s, o) { function u() { p && (delete k.style, delete k.modElem) } if (o = r(o, "undefined") ? !1 : o, !r(s, "undefined")) { var f = y(e, s); if (!r(f, "undefined")) return f } for (var p, c, d, m, v, g = ["modernizr", "tspan", "samp"]; !k.style && g.length;)p = !0, k.modElem = i(g.shift()), k.style = k.modElem.style; for (d = e.length, c = 0; d > c; c++)if (m = e[c], v = k.style[m], l(m, "-") && (m = a(m)), k.style[m] !== t) { if (o || r(s, "undefined")) return u(), "pfx" == n ? m : !0; try { k.style[m] = s } catch (h) { } if (k.style[m] != v) return u(), "pfx" == n ? m : !0 } return u(), !1 } function g(e, n, t, s, o) { var i = e.charAt(0).toUpperCase() + e.slice(1), l = (e + " " + E.join(i + " ") + i).split(" "); return r(n, "string") || r(n, "undefined") ? v(l, n, s, o) : (l = (e + " " + N.join(i + " ") + i).split(" "), f(l, n, t)) } function h(e, n, r) { return g(e, t, t, n, r) } var C = [], S = [], x = { _version: "3.6.0", _config: { classPrefix: "", enableClasses: !0, enableJSClass: !0, usePrefixes: !0 }, _q: [], on: function(e, n) { var t = this; setTimeout(function() { n(t[e]) }, 0) }, addTest: function(e, n, t) { S.push({ name: e, fn: n, options: t }) }, addAsyncTest: function(e) { S.push({ name: null, fn: e }) } }, Modernizr = function() { }; Modernizr.prototype = x, Modernizr = new Modernizr; var w = n.documentElement, _ = "svg" === w.nodeName.toLowerCase(), b = x._config.usePrefixes ? " -webkit- -moz- -o- -ms- ".split(" ") : ["", ""]; x._prefixes = b; var P = "CSS" in e && "supports" in e.CSS, z = "supportsCSS" in e; Modernizr.addTest("supports", P || z); var T = "Moz O ms Webkit", E = x._config.usePrefixes ? T.split(" ") : []; x._cssomPrefixes = E; var N = x._config.usePrefixes ? T.toLowerCase().split(" ") : []; x._domPrefixes = N; var j = { elem: i("modernizr") }; Modernizr._q.push(function() { delete j.elem }); var k = { style: j.elem.style }; Modernizr._q.unshift(function() { delete k.style }), x.testAllProps = g, x.testAllProps = h, Modernizr.addTest("cssfilters", function() { if (Modernizr.supports) return h("filter", "blur(2px)"); var e = i("a"); return e.style.cssText = b.join("filter:blur(2px); "), !!e.style.length && (n.documentMode === t || n.documentMode > 9) }), Modernizr.addTest("flexbox", h("flexBasis", "1px", !0)), s(), o(C), delete x.addTest, delete x.addAsyncTest; for (var A = 0; A < Modernizr._q.length; A++)Modernizr._q[A](); e.Modernizr = Modernizr }(window, document);;
$(document).ready(function ()
{
	SITE_SEARCH.Init();
	//SEARCH_PAGE_RESULTS.Init();
});

var SITE_SEARCH =
	{
		$BUTTON: $("#site-search-btn"),
		$TEXT: $("#site-search-text"),

		Init: function ()
		{
			if (SITE_SEARCH.$BUTTON.size()) {
				this.SetupSearch();
				this.SetupRemoveErrorClass();
				this.SetupAutoComplete();
			}
		},

		SetupSearch: function ()
		{
			var _this = this;

			$(document).on("click", "#" + _this.$BUTTON[0].id, function (e)
			{
				e.preventDefault();
				_this.PerformSearch();
			});

			$(document).on("keypress", "#" + _this.$TEXT[0].id, function (e)
			{
				if (e.which === 13) {
					e.preventDefault();
					_this.PerformSearch();
				}
			});
		},
		AutoComplete: {
			OldQuery: "",
			NewQuery: "",
			TimeOut: null,
			Call: null
		},
		SetupAutoComplete: function ()
		{
			var _this = this;

			if ($(_this.$TEXT).length > 0) {
				$(document).on("keyup", "#" + _this.$TEXT[0].id, function ()
				{
					var searchbox = $(this);
					//Change apostrophe to single quote
					var cleanText = $(this).val();
					cleantText = cleanText.replace("’", "'");

					_this.AutoComplete.NewQuery = cleanText;

					if (_this.AutoComplete.Call !== null)
						_this.AutoComplete.Call.abort();

					if (_this.AutoComplete.NewQuery !== "" && _this.AutoComplete.NewQuery !== _this.AutoComplete.OldQuery) {
						if (_this.AutoComplete.TimeOut)
							clearTimeout(_this.AutoComplete.TimeOut);

						_this.AutoComplete.TimeOut = setTimeout(function ()
						{
							_this.ShowAutoComplete(searchbox);
						}, 100);
					}
					else {
						$(".suggestion-list").remove();
					}
				});
			}
			$(document).on("click", function (e)
			{
				var $tgt = $(e.target);
				if ($tgt.closest(".searchpanel").length === 0) {
					$(".suggestion-list").remove();
					if ($(_this.$TEXT).length > 0) {
						$("#" + _this.$TEXT[0].id).val("");
					}
				}
			});
		},
		ShowAutoComplete: function (searchbox)
		{
			var _this = this;
			if (_this.AutoComplete.NewQuery !== "" && _this.AutoComplete.NewQuery !== _this.AutoComplete.OldQuery)
			{
				var searchpanel = searchbox.closest(".searchpanel");
				var environment = $(searchpanel).data('environment');
				var panellocation = searchpanel.offset();
				var panelheight = searchpanel.outerHeight();
				var panelwidth = searchpanel.outerWidth();

				_this.AutoComplete.Call = $.ajax({
					method: "POST",
					url: "/AzureSearch/Suggest",
					data: { term: _this.AutoComplete.NewQuery, fuzzy: true, environment: environment },
					success: function (data)
					{
						if (data !== null) {
							$(".suggestion-list").remove();
							if (searchbox.is(":focus")) {
								$("body").append(data);
								$(".suggestion-list").css({
									left: panellocation.left,
									top: panellocation.top + panelheight,
									width: panelwidth
								}).show();
							}
						}
						_this.AutoComplete.OldQuery = _this.AutoComplete.NewQuery;
					},
					error: function ()
					{
						$(".suggestion-list").remove();
					}
				});
			}
		},
		PerformSearch: function ()
		{
			var _this = this;
			var text = _this.$TEXT.val();
			//Change apostrophe to single quote
			text = text.replace("’", "'");
			//Filter all non-relevant characters from the string
			text = text.replace(/[^-'a-zA-Z0-9]+/g, ' ');
			//Replace possible excessive whitespace to single whitespace
			text = text.replace(/\s+/g, ' ');
			//Trim the string to remove whitespaces at the start or end
			text = $.trim(text);

			var environment = "";
			if (window.location.href.indexOf("ambassade") > -1)
			{
				environment = "/ambassade";
			}

			if (!_this.CheckInput(text))
				return;
			else
				window.location.href = environment + "/zoeken/term/" + encodeURI(text) + "/pagina/1/periode/nofilter/soort/nofilter";
		},

		CheckInput: function (text)
		{
			var _this = this;

			if (text.length === 0) {
				_this.$TEXT.addClass("no-input");
				_this.$TEXT.val("");
				return false;
			}

			return true;
		},

		SetupRemoveErrorClass: function ()
		{
			var _this = this;

			$(document).on("animationend webkitAnimationEnd MSAnimationEnd oAnimationEnd", "#" + _this.$TEXT[0].id, function ()
			{
				$(this).removeClass("no-input");
			});
		},

		TruncateWatermarkText: function ()
		{
			var width = window.innerWidth;
			var _this = this;

			if (width >= 900 && width < 1090)
				_this.$TEXT.attr('placeholder', 'Typ hier wat u zoekt');
			else if (width >= 1090)
				_this.$TEXT.attr('placeholder', 'Typ hier wat u zoekt op onze website');
		}
	};

var SEARCH_PAGE_RESULTS =
	{
		$WRAPPER: $("#search-page-wrapper"),
		$ROUTER: null,

		Init: function ()
		{
			if (this.$WRAPPER.length === 0) // Initializing is only needed on the search results page.
				return;

			this.SetupFilters();
			this.SetupPaging();
			this.MoveFiltersOnResize();
			this.SetupRouter();

			this.$ROUTER.navigate(window.location.hash, { trigger: true });
		},

		SetupFilters: function ()
		{
			var _this = this;

			$(document).on("click", ".filter .linkbutton", function ()
			{
				var $this = $(this);
				$this.closest(".filter").find(".current").removeClass("current");
				$this.addClass("current");

				var page = 1;//$("#paging-pages .current").data("page");
				if (isNaN(parseInt(page, 10)))
					page = 1;

				$this.attr("href", "#/" + $(".filter .time.current").data("period") + "/" + $(".filter .type.current").data("type") + "/" + page);
			});

			$(document).on("click", "#show-filters", function (e)
			{
				e.preventDefault();
				$(this).toggleClass("expand collapse");
				$("#filters-small").slideToggle("fast");
			});
		},

		SetupPaging: function ()
		{
			var _this = this;

			$(document).on("click", ".data-set", function ()
			{
				var $this = $(this);
				$this.attr("href", "#/" + $(".filter .time.current").data("period") + "/" + $(".filter .type.current").data("type") + "/" + $this.data("page"));
			});
		},

		GetResultSet: function (url, data, oncomplete)
		{
			var _this = this;

			$.ajax({
				type: "POST",
				url: url,
				data: data,
				dataType: "json",
				cache: false,
				success: function (data)
				{
					if (data.success)
						$("#search-results").empty().html(data.html);
					else {
						BAR.AddError("Er is iets fout gegaan bij het ophalen van resultaten.");
						LOG.WriteError(data.error);
					}
				},
				error: function (jqXHR, status, error)
				{
					BAR.AddError("Er is iets fout gegaan bij het ophalen van resultaten.");
					LOG.WriteError(error);
				},
				complete: function ()
				{
					if (oncomplete !== undefined)
						oncomplete();
					if (PROPERTIES.WIDTH === "medium" || PROPERTIES.WIDTH === "small")
						$("#filters-small").prepend(_this.$FILTER2).prepend(_this.$FILTER1);

					$('body,html').scrollTop($('#search-results').offset().top - 45);
				}
			});
		},

		RESIZE_TIMEOUT: null,
		$FILTER1: $("#search-page-wrapper .leftnav .filter:first-of-type"),
		$FILTER2: $("#search-page-wrapper .leftnav .filter:nth-of-type(2)"),
		MoveFiltersOnResize: function ()
		{
			var _this = this;

			$(window).on("resize", function ()
			{
				clearTimeout(_this.RESIZE_TIMEOUT);
				_this.RESIZE_TIMEOUT = setTimeout(function ()
				{
					if (PROPERTIES.WIDTH === "medium" || PROPERTIES.WIDTH === "small")
						$("#filters-small").prepend(_this.$FILTER2).prepend(_this.$FILTER1);
					else
						$("#search-page-wrapper .leftnav").append(_this.$FILTER1).append(_this.$FILTER2);
				}, 100);
			});

			if (PROPERTIES.WIDTH === "medium" || PROPERTIES.WIDTH === "small")
				$("#filters-small").prepend(_this.$FILTER2).prepend(_this.$FILTER1);
		},

		SetupRouter: function ()
		{
			var _this = this;

			var router = {
				AjaxUrl: "",
				Paging: Backbone.Router.extend({
					routes: {
						"(:period)(/:type)(/:page)": "loadResults"
					},
					loadResults: function (period, type, page)
					{
						$(".filter").find("a").removeClass("active current misc check").addClass("more");

						var $time = period === null ? $(".filter .time[data-period='all']") : $(".filter .time[data-period='" + period + "']");
						var $type = type === null ? $(".filter .type[data-type='all']") : $(".filter .type[data-type='" + type + "']");

						var origTime = $time.text();
						var origType = $type.text();
						$time.removeClass("icon more").addClass("loading spinner-green current").text("Bezig met filteren...");
						$type.removeClass("icon more").addClass("loading spinner-green current").text("Bezig met filteren...");

						page = page === null ? 1 : parseInt(page, 10);
						var time = parseInt($time.data("value"), 10);
							type = parseInt($type.data("value"), 10);
						var text = XURL.GetQueryString()["text"] || "";
						var data = { text: JSON.stringify(text), time: time, type: type, page: page };
						var url = "/Search/GetSet";

						var oncomplete = function ()
						{
							$time.removeClass("loading spinner-green").addClass("icon misc check active").text(origTime);
							$type.removeClass("loading spinner-green").addClass("icon misc check active").text(origType);
						};

						_this.GetResultSet(url, data, oncomplete);
					}
				})
			};

			this.$ROUTER = new router.Paging();
		}
	};;
$(document).ready(function ()
{
	MENUFILTER.Setup();
});

var MENUFILTER =
{
	IS_FILTER_SHOWING: $(".menu-filter").length > 0,
	CONSTANTS:
		{
		    $leftmenucontainer: $(".leftnav"),
			$filters: $(".menu-filter-option"),
			$filtergroups: $(".menu-filter-group"),
			$filterselection: $(".menu-filter-group input:checkbox"),
			$filtertitle: $(".menu-filter"),
			$filterremove: $(".menu-filter-remove-filters"),
			$filterclose: $(".menu-filter-close-link"),
			$filteropenmobile: $(".menu-filter-open-mobile"),
			$filtertotalselected: $(".menu-filter-total-selected"),
			$filterbacklink: $(".menu-filter-option-link")
		},

	Setup: function ()
	{
		var _this = this;

		if (_this.IS_FILTER_SHOWING)
		{
			_this.SetupShowFilters();
			_this.SetupClickFilter();
			_this.SetupRemoveFilters();
		}
	},

	SetupShowFilters: function()
	{
		var _this = this;

		var toggleWithSliding = function () {
		    if ($(window).width() < 900) {
		        if (_this.CONSTANTS.$leftmenucontainer.hasClass("active")) {
		            _this.CONSTANTS.$filteropenmobile.removeClass("foldable");
		            $(".menu-filter-options").slideUp(300, function () {
		                _this.CONSTANTS.$leftmenucontainer.removeClass("active");
		            });
		        }
		        else {
		            _this.CONSTANTS.$filteropenmobile.addClass("foldable");
		            $(".menu-filter-options").slideDown(300, function () {
		                _this.CONSTANTS.$leftmenucontainer.addClass("active");
		            });
		        }
		    }
		}

		_this.CONSTANTS.$filters.on("click", function (e)
		{
			e.preventDefault();
			var $this = $(this);
			var isActive = $this.hasClass("active");

			_this.CONSTANTS.$filters.removeClass("active");
			_this.CONSTANTS.$filtergroups.hide();

			if (!isActive)
			{
			    if ($(window).width() < 900) {
			        var $container = $("#" + $this.closest(".menu-filter-options").data("container"));
			        $container.css("top", "-80px !important;").show();
			        $this.addClass("active");
			        _this.CONSTANTS.$filteropenmobile.addClass("foldable");
			    }
			    else {
			        var $container = $("#" + $this.closest(".menu-filter-options").data("container"));
			        $container.css({ top: $this.position().top }).show();
			        $this.addClass("active");
			    }
			}
		});

		_this.CONSTANTS.$filterclose.on("click", function (e) {
		    e.preventDefault();
		    _this.CONSTANTS.$filters.removeClass("active");
		    _this.CONSTANTS.$filtergroups.hide();
		});

		_this.CONSTANTS.$filteropenmobile.on("click", function (e) {
		    toggleWithSliding();
		});

		_this.CONSTANTS.$filterbacklink.on("click", function (e) {
		    e.preventDefault();
		    _this.CONSTANTS.$filters.removeClass("active");
		    _this.CONSTANTS.$filtergroups.hide();
		    toggleWithSliding();
		});
	},

	SetupClickFilter: function()
	{
		var _this = this;

		_this.CONSTANTS.$filterselection.on("change", function ()
		{
			var $this = $(this);
			_this.TraverseDownTree($this);
			_this.TraverseUpTree($this);
			_this.TriggerChange();
		});
	},

	TraverseDownTree: function ($element)
	{
		var _this = this;

		_this.AddRemoveFilterButton($element);

		$("input:checkbox[data-parent='" + $element.attr("id") + "']").each(function ()
		{
			var $this = $(this);
			$this.prop({ checked: $element.prop("checked"), indeterminate: false });
			_this.TraverseDownTree($this);
		});
	},

	TraverseUpTree: function ($element)
	{
		var _this = this;

		_this.AddRemoveFilterButton($element);

		var parent = $element.data("parent")
		var $parent = $("#" + parent);
		
		if ($parent.length)
		{
			var all = $("input:checkbox[data-parent='" + parent + "']").length;
			var chk = $("input:checkbox[data-parent='" + parent + "']:checked").length;
			var idt = $("input:checkbox[data-parent='" + parent + "']").filter(function () { return this.indeterminate; }).length;
			
			if (idt > 0)
				$parent.prop({ checked: false, indeterminate: true });
			else if (all === chk)
				$parent.prop({ checked: true, indeterminate: false });
			else if (chk === 0)
				$parent.prop({ checked: false, indeterminate: false });
			else
				$parent.prop({ checked: false, indeterminate: true });

			_this.TraverseUpTree($parent);
		}
	},

	AddRemoveFilterButton: function($element)
	{
		var _this = this;
		var value = $element.data("value");
		var label = $element.data("label");
		var containerId = $element.closest(".menu-filter-group").attr("id");
		var $container = $(".menu-filter-options[data-container='" + containerId + "']").find(".menu-filter-selected");

		if (value !== "")
		{
			if ($element.is(":checked")) // ADD BUTTON
			{
				if (!$container.find("a.menu-filter-set[data-value='" + value + "']").length) // ONLY ADD BUTTON IF IT DOESN'T ALREADY EXIST
				{
					var $btn = $("<a class='menu-filter-set icon actions delete' data-value='" + value + "' title='Verwijder filter " + label + "'>" + label + "</a>");
					$btn.on("click", function (e)
					{
						e.preventDefault();
						$(this).remove();
						$element.prop({ checked: false }).trigger("change");
					});

					$container.append($btn);
				}
			}
			else // REMOVE BUTTON
				$container.find("a.menu-filter-set[data-value='" + value + "']").remove();
		}
	},

	UpdateFilterInfo: function()
	{
		var _this = this;

		var count = $(".menu-filter-set").length;
		if (count > 0)
			_this.CONSTANTS.$filtertitle.addClass("menu-filter-has-filters").find(".menu-filter-open-mobile").attr("data-filtercount", count);
		else
			_this.CONSTANTS.$filtertitle.removeClass("menu-filter-has-filters").find(".menu-filter-open-mobile").attr("data-filtercount", 0);
	},

	SetupRemoveFilters: function()
	{
		var _this = this;

		_this.CONSTANTS.$filterremove.on("click", function (e)
		{
			e.preventDefault();
			_this.CONSTANTS.$filters.removeClass("active");
			_this.CONSTANTS.$filtergroups.hide();
			$(".menu-filter-set").remove();
			_this.CONSTANTS.$filtergroups.each(function ()
			{
				$(this).find("input:checkbox").prop({ checked: false, indeterminate: false });
			});

			_this.TriggerChange();
		});
	},

	TriggerChange: function()
	{
		var _this = this;
		var filters = [];

		$(".menu-filter-options").each(function ()
		{
			var $this = $(this);
			var group = $this.data("group");
			var id = $this.data("id");
			var selection = [];

			$this.find(".menu-filter-selected .menu-filter-set").each(function ()
			{
				var $this2 = $(this);
				selection.push({ id: $this2.data("id"), value: $this2.data("value") });
			});

			filters.push({ id: id, group: group, selection: selection });
		});

		$(document).trigger(
		{
			type: "filters:changed",
			selectedFilters: filters
		});

		_this.UpdateFilterInfo();
	}
};;
$(document).ready(function ()
{
	SESSION_TIMEOUT_WARNING.Setup();
});

var SESSION_TIMEOUT_WARNING =
{
	TIMEOUT: parseInt($("#session-timeout").val(), 10) * 60, // TIME IN WHICH A SESSION EXPIRES IN SECONDS
	OFFSET: 10, // AMOUNT OF TIME IN SECONDS TO BE DEDUCTED FROM TIMEOUT TO MAKE SURE THERE IS ENOUGH TIME LEFT TO REFRESH THE SESSION
	AUTOREFRESH: 3, // NUMBER OF TIMES AN EXTENSION WILL BE TRIGGERED AUTOMATICALLY
	Setup: function()
	{
		var _this = this;
		if ($("#session-timeout").length)
			_this.SetupCountdown();
	},

	TO: null,
	SetupCountdown: function()
	{
		var _this = this;
		var timeout = (_this.TIMEOUT - _this.OFFSET) * 1000;

		_this.TO = setTimeout(function ()
		{
			if (_this.AUTOREFRESH > 0)
			{
				_this.AUTOREFRESH--;
				_this.ExtendSession();
			}
			else
			{
				clearTimeout(_this.TO);
				_this.TO = null;
			}
		}, timeout);
	},

	ExtendSession: function()
	{
		var _this = this;

		$.ajax({
			type: "POST",
			url: "/home/keepalive",
			dataType: "json",
			cache: false,
			complete: function()
			{
				clearTimeout(_this.TO);
				_this.TO = null;
				_this.SetupCountdown();
			}
		});
	}
};;
$(document).ready(function ()
{
	SIMULATION.Setup();
});

var SIMULATION = {
	CONSTANTS:
	{
		$toggle: $("#show-simulation"),
		$wrapper: $("#simulator-wrapper"),
		$input: $("#simulator-filter"),
		$results: $("#simulator-list-of-results"),
		$searching: $("#simulator-searching"),
		$stop: $("#stop-simulation"),
		$clearinput: $("#clear-simulator-search")
	},

	Setup: function ()
	{
		var _this = this;
		
		_this.SetupToggle();
		_this.SetupSearch();
		_this.SetupStartSimulation();
		_this.SetupStopSimulation();
	},

	SetupToggle: function ()
	{
		var _this = this;

		_this.CONSTANTS.$toggle.on("click", function (e)
		{
			e.preventDefault();
			if ($(this).hasClass("loading"))
				return;

			_this.CONSTANTS.$wrapper.toggleClass("showing");
            if (_this.CONSTANTS.$wrapper.hasClass("showing")) 
            {
				setTimeout(function ()
				{
					_this.CONSTANTS.$input.focus();
				}, 1050);
			}
		});

		$(document).on("click", function (e)
		{
            if (!$(e.target).closest("#simulator-wrapper").length && _this.CONSTANTS.$wrapper.hasClass("showing") && !_this.CONSTANTS.$toggle.hasClass("loading")) 
            {
                _this.CONSTANTS.$wrapper.removeClass("expanded showing");
                _this.CONSTANTS.$input.val("");
                _this.CONSTANTS.$results.empty();
                _this.CONSTANTS.$clearinput.hide();
                _this.CONSTANTS.$input.focus();
            }
		});
	},

	SetupSearch: function ()
	{
		var _this = this;

		_this.CONSTANTS.$input.on("keypress", function (e)
		{
			var $this = $(this);
			var $searching = _this.CONSTANTS.$searching;
			var key = e.keyCode || e.which || e.charCode;
			var text = $.trim($this.val());

            if (text === "") 
            {
				_this.CONSTANTS.$results.empty();
				return;
			}

			if (key === 13) // ENTER
			{
				if ($this.parent().hasClass("loading"))
					return;

				_this.CONSTANTS.$toggle.addClass("loading spinner-fuchsia");
				_this.CONSTANTS.$results.empty();
                _this.CONSTANTS.$wrapper.removeClass("expanded");
                _this.CONSTANTS.$clearinput.hide();
				$this.prop("disabled", true).hide();
                $searching.text(text + " zoeken...").show();

				$.ajax({
					type: "POST",
					url: "/Home/SearchUsers",
					data: { search: JSON.stringify(text) },
					dataType: "json",
					cache: false,
					success: function (data)
					{
                        if (data.success) 
                        {
							_this.CONSTANTS.$results.empty().append(data.html);
							_this.CONSTANTS.$wrapper.addClass("expanded");
						}
                        else 
                        {
							BAR.AddError("Er is iets fout gegaan bij het zoeken naar ambassadeurs.");
							LOG.WriteError(data.error);
						}
					},
					error: function (jqXHR, status, error)
					{
						BAR.AddError("Er is iets fout gegaan bij het zoeken naar ambassadeurs.");
						LOG.WriteError(error);
					},
					complete: function ()
					{
                        _this.CONSTANTS.$toggle.removeClass("loading spinner-fuchsia");
                        _this.CONSTANTS.$clearinput.show();
						$this.prop("disabled", false).show();
						$searching.text("").hide();
					}
				});
			}
		})
		.on("keyup", function ()
		{
			var text = $.trim($(this).val());
            if (text === "") 
            {
				_this.CONSTANTS.$results.empty();
				_this.CONSTANTS.$wrapper.removeClass("expanded");
			}

			_this.CONSTANTS.$clearinput.toggle(text !== "");
		});

		_this.CONSTANTS.$clearinput.on("click", function (e)
		{
			e.preventDefault();
			_this.CONSTANTS.$input.val("");
			_this.CONSTANTS.$results.empty();
			_this.CONSTANTS.$wrapper.removeClass("expanded");
			_this.CONSTANTS.$input.focus();
			$(this).hide();
		});
	},

	SetupStartSimulation: function ()
	{
		var _this = this;

		$(document).on("click", ".simulator-result:not(.no-results):not(.more-results)", function (e)
		{
			e.preventDefault();
			var $this = $(this);

			if (_this.CONSTANTS.$results.find(".loading").length)
				return;
            $this.addClass("loading spinner-fuchsia").removeClass("icon simulation-start");            

			$.ajax({
				type: "POST",
				url: "/Home/StartSimulation",
				data: { lidnummer: parseInt($this.data("id"), 10) },
				dataType: "json",
				cache: false,
				success: function (data)
				{
					if (data.success)
						location.reload(true);
                    else 
                    {
						$this.removeClass("loading spinner-blue").addClass("icon interactive play");
						BAR.AddError("Er is iets fout gegaan bij het simuleren van " + $this.text() + ".");
						LOG.WriteError(data.error);
					}
				},
				error: function (jqXHR, status, error)
				{
				    $this.removeClass("loading spinner-blue").addClass("icon simulation-start");
					BAR.AddError("Er is iets fout gegaan bij het simuleren van " + $this.text() + ".");
					LOG.WriteError(error);
				}
			});
		});

		$(document).on("click", ".simulator-result.more-results", function (e)
		{
			e.preventDefault();
			$(this).hide();
			$(".simulator-result:not(.more-results)").show();
		});
	},

	SetupStopSimulation: function ()
	{
		var _this = this;

		_this.CONSTANTS.$stop.on("click", function (e)
		{
			e.preventDefault();

			var $this = $(this);

			if ($this.hasClass("loading"))
				return;

			$this.removeClass("icon interactive stop").addClass("loading spinner-white");

			$.ajax({
				type: "POST",
				url: "/Home/StopSimulation",
				dataType: "json",
				cache: false,
				success: function (data)
				{
					if (data.success)
						location.reload(true);
                    else 
                    {
						BAR.AddError("Er is iets fout gegaan bij het stoppen van de simulatie.");
						LOG.WriteError(data.error);
						$this.removeClass("loading spinner-white").addClass("icon simulation-stop");
					}
				},
				error: function (jqXHR, status, error)
				{
					BAR.AddError("Er is iets fout gegaan bij het stoppen van de simulatie.");
					LOG.WriteError(error);
					$this.removeClass("loading spinner-white").addClass("icon simulation-stop");
				}
			});
		});
	}
};;
$(document).ready(function()
{
	$(".footer").find("section > ul:not(.ltr):not(.follow) li:first-child").on("click", function()
	{
		var parentList = $(this).closest("ul");
		if (parentList.hasClass("expanded"))
		{
			parentList.find("li:not(:first-child)").hide();
			parentList.removeClass("expanded");
		}
		else
		{
			$(".footer").find("section > ul").removeClass("expanded");
			$(".footer").find("section > ul").find("li:not(:first-child)").hide();
			parentList.find("li").show();
			parentList.addClass("expanded");
		}
		return false;
	});
});;
$(document).ready(function ()
{
	NOTIFICATIONNEWSLETTERS.Setup();
});

var NOTIFICATIONNEWSLETTERS =
{
	Setup: function ()
	{
		var _this = this;

		_this.SetupNewsletterSelect();
		_this.SetupSubmit();
	},

	SetupNewsletterSelect: function ()
	{
		$(document).on("change", "#inlnot-newsletters input[type=checkbox]", function ()
		{
			var disabled = $("#inlnot-newsletters input[type=checkbox]:checked").length === 0; 
			$("#inlnot-submitnewsletters").toggleClass("disabled", disabled).prop("disabled", disabled);
		});
	},

	SetupSubmit: function ()
	{
		$(document).on("click", "#inlnot-submitnewsletters", function (e)
		{
			e.preventDefault();

			var $this = $(this);
			if ($this.hasClass("disabled"))
				return;

			$this.addClass("disabled");

			var subscribe = $("#inlnot-newsletters input[type=checkbox]:checked").map(function () { return this.value; }).get();
			var exactcode = parseInt($("#inlnot-exactcode").val(), 10);
			var $title    = $(".notification-title");
			var $wrapper  = $title.closest(".success");

			$wrapper.removeClass("success").addClass("loading spinner-white");
			$title.text("Bezig met opslaan voorkeuren...");

			$.ajax({
				type: "POST",
				url: "/newsletters/setsubscriptionsbyexactcode",
				data: { subscribe, unsubscribe: null, exactcode },
				dataType: "json",
				cache: false,
				success: function (result)
				{
					if (result.success)
					{
						$wrapper.removeClass("error").addClass("success");
						$title.text("Voorkeuren opgeslagen!");
					}
					else
					{
						$wrapper.removeClass("success").addClass("error");
						$title.text("Fout bij opslaan voorkeuren.");
						LOG.WriteError(result.error);
					}
				},
				error: function (jqXHR, status, error)
				{
					$wrapper.removeClass("success").addClass("error");
					$title.text("Fout bij opslaan voorkeuren.");
					LOG.WriteError(error);
				},
				complete: function ()
				{
					$this.removeClass("disabled");
					$wrapper.removeClass("loading spinner-white");
				}
			});
		});
	}
};;
