text: !function(e,t){"function"==typeof define&&define.amd?define(["exports"],t):t("object"==typeof exports&&"string"!=typeof exports.nodeName?exports:e.commonJsStrict={})}(this,function(e){function t(e){if(e in T)return e;for(var t=e[0].toUpperCase()+e.slice(1),n=z.length;n--;)if(e=z[n]+t,e in T)return e}function n(e,t){e=e||{};for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},arguments.callee(e[n],t[n])):e[n]=t[n];return e}function i(e,t,n){var i;return function(){var o=this,r=arguments,a=function(){i=null,n||e.apply(o,r)},s=n&&!i;clearTimeout(i),i=setTimeout(a,t),s&&e.apply(o,r)}}function o(e){if("createEvent"in document){var t=document.createEvent("HTMLEvents");t.initEvent("change",!1,!0),e.dispatchEvent(t)}else e.fireEvent("onchange")}function r(e,t,n){if("string"==typeof t){var i=t;t={},t[i]=n}for(var o in t)e.style[o]=t[o]}function a(e,t){e.classList?e.classList.add(t):e.className+=" "+t}function s(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(t,"")}function l(e,t){var n,i=t||new Image;return i.src===e?n=new Promise(function(e,t){e(i)}):(n=new Promise(function(t,n){"http"===e.substring(0,4).toLowerCase()&&i.setAttribute("crossOrigin","anonymous"),i.onload=function(){setTimeout(function(){t(i)},1)}}),i.src=e),i.style.opacity=0,n}function u(e,t){window.EXIF||t(0),EXIF.getData(e,function(){var e=EXIF.getTag(this,"Orientation");t(e)})}function c(e,t,n){var i=t.width,o=t.height,r=e.getContext("2d");switch(e.width=t.width,e.height=t.height,r.save(),n){case 2:r.translate(i,0),r.scale(-1,1);break;case 3:r.translate(i,o),r.rotate(180*Math.PI/180);break;case 4:r.translate(0,o),r.scale(1,-1);break;case 5:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.scale(1,-1);break;case 6:e.width=o,e.height=i,r.rotate(90*Math.PI/180),r.translate(0,-o);break;case 7:e.width=o,e.height=i,r.rotate(-90*Math.PI/180),r.translate(-i,o),r.scale(1,-1);break;case 8:e.width=o,e.height=i,r.translate(0,i),r.rotate(-90*Math.PI/180)}r.drawImage(t,0,0,i,o),r.restore()}function h(){var e,t,n,i,o=this,s="croppie-container",l=o.options.viewport.type?"cr-vp-"+o.options.viewport.type:null;o.options.useCanvas=o.options.enableOrientation||p.call(o),o.data={},o.elements={},e=o.elements.boundary=document.createElement("div"),n=o.elements.viewport=document.createElement("div"),t=o.elements.img=document.createElement("img"),i=o.elements.overlay=document.createElement("div"),o.options.useCanvas?(o.elements.canvas=document.createElement("canvas"),o.elements.preview=o.elements.canvas):o.elements.preview=o.elements.img,a(e,"cr-boundary"),r(e,{width:o.options.boundary.width+"px",height:o.options.boundary.height+"px"}),a(n,"cr-viewport"),l&&a(n,l),r(n,{width:o.options.viewport.width+"px",height:o.options.viewport.height+"px"}),a(o.elements.preview,"cr-image"),a(i,"cr-overlay"),o.element.appendChild(e),e.appendChild(o.elements.preview),e.appendChild(n),e.appendChild(i),a(o.element,s),o.options.customClass&&a(o.element,o.options.customClass),w.call(this),o.options.enableZoom&&d.call(o)}function p(){return(this.options.enableExif||this.options.exif)&&window.EXIF}function m(e){this.options.enableZoom&&(this.elements.zoomer.value=Z(e,4))}function d(){function e(){f.call(n,{value:parseFloat(o.value),origin:new H(n.elements.preview),viewportRect:n.elements.viewport.getBoundingClientRect(),transform:D.parse(n.elements.preview)})}function t(t){var i,o;i=t.wheelDelta?t.wheelDelta/1200:t.deltaY?t.deltaY/1060:t.detail?t.detail/-60:0,o=n._currentZoom+i,t.preventDefault(),m.call(n,o),e()}var n=this,i=n.elements.zoomerWrap=document.createElement("div"),o=n.elements.zoomer=document.createElement("input");a(i,"cr-slider-wrap"),a(o,"cr-slider"),o.type="range",o.step="0.01",o.value=1,o.style.display=n.options.showZoomer?"":"none",n.element.appendChild(i),i.appendChild(o),n._currentZoom=1,n.elements.zoomer.addEventListener("input",e),n.elements.zoomer.addEventListener("change",e),n.options.mouseWheelZoom&&(n.elements.boundary.addEventListener("mousewheel",t),n.elements.boundary.addEventListener("DOMMouseScroll",t))}function f(e){var t=this,n=e?e.transform:D.parse(t.elements.preview),i=e?e.viewportRect:t.elements.viewport.getBoundingClientRect(),o=e?e.origin:new H(t.elements.preview);if(t._currentZoom=e?e.value:t._currentZoom,n.scale=t._currentZoom,t.options.enforceBoundary){var a=v.call(t,i),s=a.translate,l=a.origin;n.x>=s.maxX&&(o.x=l.minX,n.x=s.maxX),n.x<=s.minX&&(o.x=l.maxX,n.x=s.minX),n.y>=s.maxY&&(o.y=l.minY,n.y=s.maxY),n.y<=s.minY&&(o.y=l.maxY,n.y=s.minY)}var u={};u[O]=n.toString(),u[P]=o.toString(),r(t.elements.preview,u),k.call(t),x.call(t)}function v(e){var t=this,n=t._currentZoom,i=e.width,o=e.height,r=t.options.boundary.width/2,a=t.options.boundary.height/2,s=t.elements.preview.getBoundingClientRect(),l=s.width,u=s.height,c=i/2,h=o/2,p=(c/n-r)*-1,m=p-(l*(1/n)-i*(1/n)),d=(h/n-a)*-1,f=d-(u*(1/n)-o*(1/n)),v=1/n*c,g=l*(1/n)-v,w=1/n*h,y=u*(1/n)-w;return{translate:{maxX:p,minX:m,maxY:d,minY:f},origin:{maxX:g,minX:v,maxY:y,minY:w}}}function g(){var e=this,t=e._currentZoom,n=e.elements.preview.getBoundingClientRect(),i=e.elements.viewport.getBoundingClientRect(),o=D.parse(e.elements.preview.style[O]),a=new H(e.elements.preview),s=i.top-n.top+i.height/2,l=i.left-n.left+i.width/2,u={},c={};u.y=s/t,u.x=l/t,c.y=(u.y-a.y)*(1-t),c.x=(u.x-a.x)*(1-t),o.x-=c.x,o.y-=c.y;var h={};h[P]=u.x+"px "+u.y+"px",h[O]=o.toString(),r(e.elements.preview,h)}function w(){function e(e){if(e.preventDefault(),!c){if(c=!0,i=e.pageX,a=e.pageY,e.touches){var o=e.touches[0];i=o.pageX,a=o.pageY}transform=D.parse(u.elements.preview),window.addEventListener("mousemove",t),window.addEventListener("touchmove",t),window.addEventListener("mouseup",n),window.addEventListener("touchend",n),document.body.style[W]="none",l=u.elements.viewport.getBoundingClientRect()}}function t(e){e.preventDefault();var t=e.pageX,n=e.pageY;if(e.touches){var c=e.touches[0];t=c.pageX,n=c.pageY}var h=t-i,p=n-a,d=u.elements.preview.getBoundingClientRect(),f=transform.y+p,v=transform.x+h,g={};if("touchmove"==e.type&&e.touches.length>1){var w=e.touches[0],x=e.touches[1],b=Math.sqrt((w.pageX-x.pageX)*(w.pageX-x.pageX)+(w.pageY-x.pageY)*(w.pageY-x.pageY));s||(s=b/u._currentZoom);var C=b/s;return m.call(u,C),void o(u.elements.zoomer)}u.options.enforceBoundary?(l.top>d.top+p&&l.bottom<d.bottom+p&&(transform.y=f),l.left>d.left+h&&l.right<d.right+h&&(transform.x=v)):(transform.y=f,transform.x=v),g[O]=transform.toString(),r(u.elements.preview,g),y.call(u),a=n,i=t}function n(){c=!1,window.removeEventListener("mousemove",t),window.removeEventListener("touchmove",t),window.removeEventListener("mouseup",n),window.removeEventListener("touchend",n),document.body.style[W]="",g.call(u),x.call(u),s=0}var i,a,s,l,u=this,c=!1;u.elements.overlay.addEventListener("mousedown",e),u.elements.overlay.addEventListener("touchstart",e)}function y(){var e=this,t=e.elements.boundary.getBoundingClientRect(),n=e.elements.preview.getBoundingClientRect();r(e.elements.overlay,{width:n.width+"px",height:n.height+"px",top:n.top-t.top+"px",left:n.left-t.left+"px"})}function x(){var e=this;b.call(e)&&e.options.update.call(e,e.get())}function b(){return this.elements.preview.offsetHeight>0&&this.elements.preview.offsetWidth>0}function C(){var e,t,n,i,a,s=this,l=0,u=1.5,c=1,h={},p=s.elements.preview,d=s.elements.zoomer,f=new D(0,0,c),v=new H,w=b.call(s);w&&!s.data.bound&&(s.data.bound=!0,h[O]=f.toString(),h[P]=v.toString(),h.opacity=1,r(p,h),e=p.getBoundingClientRect(),t=s.elements.viewport.getBoundingClientRect(),n=s.elements.boundary.getBoundingClientRect(),s._originalImageWidth=e.width,s._originalImageHeight=e.height,s.options.enableZoom&&(s.options.enforceBoundary&&(i=t.width/e.width,a=t.height/e.height,l=Math.max(i,a)),l>=u&&(u=l+1),d.min=Z(l,4),d.max=Z(u,4),c=Math.max(n.width/e.width,n.height/e.height),m.call(s,c),o(d)),s._currentZoom=f.scale=c,h[O]=f.toString(),r(p,h),s.data.points.length?E.call(s,s.data.points):_.call(s),g.call(s),y.call(s))}function E(e){if(4!=e.length)throw"Croppie - Invalid number of points supplied: "+e;var t=this,n=e[2]-e[0],i=t.elements.viewport.getBoundingClientRect(),o=t.elements.boundary.getBoundingClientRect(),a={left:i.left-o.left,top:i.top-o.top},s=i.width/n,l=e[1],u=e[0],c=-1*e[1]+a.top,h=-1*e[0]+a.left,p={};p[P]=u+"px "+l+"px",p[O]=new D(h,c,s).toString(),r(t.elements.preview,p),m.call(t,s),t._currentZoom=s}function _(){var e=this,t=e.elements.preview.getBoundingClientRect(),n=e.elements.viewport.getBoundingClientRect(),i=e.elements.boundary.getBoundingClientRect(),o=n.left-i.left,a=n.top-i.top,s=o-(t.width-n.width)/2,l=a-(t.height-n.height)/2,u=new D(s,l,e._currentZoom);r(e.elements.preview,O,u.toString())}function I(e){var t=this,n=t.elements.canvas,i=t.elements.img,o=n.getContext("2d"),r=p.call(t),e=t.options.enableOrientation&&e;o.clearRect(0,0,n.width,n.height),n.width=i.width,n.height=i.height,r?u(i,function(t){c(n,i,parseInt(t)),e&&c(n,i,e)}):e&&c(n,i,e)}function R(e){var t=e.points,n=document.createElement("div"),i=document.createElement("img"),o=t[2]-t[0],s=t[3]-t[1];return a(n,"croppie-result"),n.appendChild(i),r(i,{left:-1*t[0]+"px",top:-1*t[1]+"px"}),i.src=e.url,r(n,{width:o+"px",height:s+"px"}),n}function B(e,t){var n=t.points,i=n[0],o=n[1],r=n[2]-n[0],a=n[3]-n[1],s=t.circle,l=document.createElement("canvas"),u=l.getContext("2d"),c=r,h=a;return t.outputWidth&&t.outputHeight&&(c=t.outputWidth,h=t.outputHeight),l.width=c,l.height=h,u.drawImage(e,i,o,r,a,0,0,c,h),s&&(u.fillStyle="#fff",u.globalCompositeOperation="destination-in",u.beginPath(),u.arc(c/2,h/2,c/2,0,2*Math.PI,!0),u.closePath(),u.fill()),l.toDataURL(t.format,t.quality)}function X(e,t){var n,i=this,o=[];if("string"==typeof e)n=e,e={};else if(Array.isArray(e))o=e.slice();else{if("undefined"==typeof e&&i.data.url)return C.call(i),x.call(i),null;n=e.url,o=e.points||[]}i.data.bound=!1,i.data.url=n||i.data.url,i.data.points=(o||i.data.points).map(function(e){return parseFloat(e)});var r=l(n,i.elements.img);return r.then(function(){i.options.useCanvas&&(i.elements.img.exifdata=null,I.call(i,e.orientation||1)),C.call(i),x.call(i),t&&t()}),r}function Z(e,t){return parseFloat(e).toFixed(t||0)}function L(){var e=this,t=e.elements.preview.getBoundingClientRect(),n=e.elements.viewport.getBoundingClientRect(),i=n.left-t.left,o=n.top-t.top,r=i+n.width,a=o+n.height,s=e._currentZoom;(s===1/0||isNaN(s))&&(s=1);var l=e.options.enforceBoundary?0:Number.NEGATIVE_INFINITY;return i=Math.max(l,i/s),o=Math.max(l,o/s),r=Math.max(l,r/s),a=Math.max(l,a/s),{points:[Z(i),Z(o),Z(r),Z(a)],zoom:s}}function Y(e){var t,i=this,o=L.call(i),r=n(q,n({},e)),a="string"==typeof e?e:r.type||"viewport",s=r.size,l=r.format,u=r.quality,c=i.elements.viewport.getBoundingClientRect(),h=c.width/c.height;return"viewport"===s?(o.outputWidth=c.width,o.outputHeight=c.height):"object"==typeof s&&(s.width&&s.height?(o.outputWidth=s.width,o.outputHeight=s.height):s.width?(o.outputWidth=s.width,o.outputHeight=s.width/h):s.height&&(o.outputWidth=s.height*h,o.outputHeight=s.height)),Q.indexOf(l)>-1&&(o.format="image/"+l,o.quality=u),o.circle="circle"===i.options.viewport.type,o.url=i.data.url,t=new Promise(function(e,t){e("canvas"===a?B.call(i,i.elements.preview,o):R.call(i,o))})}function j(){C.call(this)}function F(e){if(!this.options.useCanvas)throw"Croppie: Cannot rotate without enableOrientation";var t=this,n=t.elements.canvas,i=(t.elements.img,document.createElement("canvas")),o=1;i.width=n.width,i.height=n.height;var r=i.getContext("2d");r.drawImage(n,0,0),90!==e&&e!==-270||(o=6),e!==-90&&270!==e||(o=8),180!==e&&e!==-180||(o=3),c(n,i,o),f.call(t)}function M(){var e=this;e.element.removeChild(e.elements.boundary),s(e.element,"croppie-container"),e.options.enableZoom&&e.element.removeChild(e.elements.zoomerWrap),delete e.elements}function S(e,t){if(this.element=e,this.options=n(n({},S.defaults),t),h.call(this),this.options.url){var i={url:this.options.url,points:this.options.points};delete this.options.url,delete this.options.points,X.call(this,i)}}"function"!=typeof Promise&&!function(e){function t(e,t){return function(){e.apply(t,arguments)}}function n(e){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],l(e,t(o,this),t(r,this))}function i(e){var t=this;return null===this._state?void this._deferreds.push(e):void c(function(){var n=t._state?e.onFulfilled:e.onRejected;if(null===n)return void(t._state?e.resolve:e.reject)(t._value);var i;try{i=n(t._value)}catch(t){return void e.reject(t)}e.resolve(i)})}function o(e){try{if(e===this)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if("function"==typeof n)return void l(t(n,e),t(o,this),t(r,this))}this._state=!0,this._value=e,a.call(this)}catch(e){r.call(this,e)}}function r(e){this._state=!1,this._value=e,a.call(this)}function a(){for(var e=0,t=this._deferreds.length;t>e;e++)i.call(this,this._deferreds[e]);this._deferreds=null}function s(e,t,n,i){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=i}function l(e,t,n){var i=!1;try{e(function(e){i||(i=!0,t(e))},function(e){i||(i=!0,n(e))})}catch(e){if(i)return;i=!0,n(e)}}var u=setTimeout,c="function"==typeof setImmediate&&setImmediate||function(e){u(e,1)},h=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};n.prototype.catch=function(e){return this.then(null,e)},n.prototype.then=function(e,t){var o=this;return new n(function(n,r){i.call(o,new s(e,t,n,r))})},n.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&h(arguments[0])?arguments[0]:arguments);return new n(function(t,n){function i(r,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){i(r,e)},n)}e[r]=a,0===--o&&t(e)}catch(e){n(e)}}if(0===e.length)return t([]);for(var o=e.length,r=0;r<e.length;r++)i(r,e[r])})},n.resolve=function(e){return e&&"object"==typeof e&&e.constructor===n?e:new n(function(t){t(e)})},n.reject=function(e){return new n(function(t,n){n(e)})},n.race=function(e){return new n(function(t,n){for(var i=0,o=e.length;o>i;i++)e[i].then(t,n)})},n._setImmediateFn=function(e){c=e},"undefined"!=typeof module&&module.exports?module.exports=n:e.Promise||(e.Promise=n)}(this);var P,O,W,z=["Webkit","Moz","ms"],T=document.createElement("div").style;O=t("transform"),P=t("transformOrigin"),W=t("userSelect");var A="translate3d",N=", 0px",D=function(e,t,n){this.x=parseFloat(e),this.y=parseFloat(t),this.scale=parseFloat(n)};D.parse=function(e){return e.style?D.parse(e.style[O]):e.indexOf("matrix")>-1||e.indexOf("none")>-1?D.fromMatrix(e):D.fromString(e)},D.fromMatrix=function(e){var t=e.substring(7).split(",");return t.length&&"none"!==e||(t=[1,0,0,1,0,0]),new D(parseInt(t[4],10),parseInt(t[5],10),parseFloat(t[0]))},D.fromString=function(e){var t=e.split(") "),n=t[0].substring(A.length+1).split(","),i=t.length>1?t[1].substring(6):1,o=n.length>1?n[0]:0,r=n.length>1?n[1]:0;return new D(o,r,i)},D.prototype.toString=function(){return A+"("+this.x+"px, "+this.y+"px"+N+") scale("+this.scale+")"};var H=function(e){if(!e||!e.style[P])return this.x=0,void(this.y=0);var t=e.style[P].split(" ");this.x=parseFloat(t[0]),this.y=parseFloat(t[1])};H.prototype.toString=function(){return this.x+"px "+this.y+"px"};var k=i(y,500),q={type:"canvas",format:"png",quality:1},Q=["jpeg","webp","png"];if(window.jQuery){var U=window.jQuery;U.fn.croppie=function(e){var t=typeof e;if("string"===t){var n=Array.prototype.slice.call(arguments,1),i=U(this).data("croppie");return"get"===e?i.get():"result"===e?i.result.apply(i,n):this.each(function(){var t=U(this).data("croppie");if(t){var i=t[e];if(!U.isFunction(i))throw"Croppie "+e+" method not found";i.apply(t,n),"destroy"===e&&U(this).removeData("croppie")}})}return this.each(function(){var t=new S(this,e);U(this).data("croppie",t)})}}S.defaults={viewport:{width:100,height:100,type:"square"},boundary:{width:300,height:300},orientationControls:{enabled:!0,leftClass:"",rightClass:""},customClass:"",showZoomer:!0,enableZoom:!0,mouseWheelZoom:!0,enableExif:!1,enforceBoundary:!0,enableOrientation:!1,update:function(){}},n(S.prototype,{bind:function(e,t){return X.call(this,e,t)},get:function(){return L.call(this)},result:function(e){return Y.call(this,e)},refresh:function(){return j.call(this)},setZoom:function(e){m.call(this,e),o(this.elements.zoomer)},rotate:function(e){F.call(this,e)},destroy:function(){return M.call(this)}}),e.Croppie=window.Croppie=S,"object"==typeof module&&module.exports&&(module.exports=S)});
  !function($){$.extend({tablesorter:new function(){function benchmark(e,t){log(e+","+((new Date).getTime()-t.getTime())+"ms")}function log(e){"undefined"!=typeof console&&"undefined"!=typeof console.debug?console.log(e):alert(e)}function buildParserCache(e,t){if(e.config.debug)var r="";if(0!=e.tBodies.length){var n=e.tBodies[0].rows;if(n[0])for(var o=[],a=n[0].cells,i=a.length,s=0;s<i;s++){var d=!1;$.metadata&&$(t[s]).metadata()&&$(t[s]).metadata().sorter?d=getParserById($(t[s]).metadata().sorter):e.config.headers[s]&&e.config.headers[s].sorter&&(d=getParserById(e.config.headers[s].sorter)),d||(d=detectParserForColumn(e,n,-1,s)),e.config.debug&&(r+="column:"+s+" parser:"+d.id+"\n"),o.push(d)}return e.config.debug&&log(r),o}}function detectParserForColumn(e,t,r,n){for(var o=parsers.length,a=!1,i=!1,s=!0;""==i&&s;)r++,t[r]?(a=getNodeFromRowAndCellIndex(t,r,n),i=trimAndGetNodeText(e.config,a),e.config.debug&&log("Checking if value was empty on row:"+r)):s=!1;for(var d=1;d<o;d++)if(parsers[d].is(i,e,a))return parsers[d];return parsers[0]}function getNodeFromRowAndCellIndex(e,t,r){return e[t].cells[r]}function trimAndGetNodeText(e,t){return $.trim(getElementText(e,t))}function getParserById(e){for(var t=parsers.length,r=0;r<t;r++)if(parsers[r].id.toLowerCase()==e.toLowerCase())return parsers[r];return!1}function buildCache(e){if(e.config.debug)var t=new Date;for(var r=e.tBodies[0]&&e.tBodies[0].rows.length||0,n=e.tBodies[0].rows[0]&&e.tBodies[0].rows[0].cells.length||0,o=e.config.parsers,a={row:[],normalized:[]},i=0;i<r;++i){var s=$(e.tBodies[0].rows[i]),d=[];if(s.hasClass(e.config.cssChildRow))a.row[a.row.length-1]=a.row[a.row.length-1].add(s);else{a.row.push(s);for(var c=0;c<n;++c)d.push(o[c].format(getElementText(e.config,s[0].cells[c]),e,s[0].cells[c]));d.push(a.normalized.length),a.normalized.push(d),d=null}}return e.config.debug&&benchmark("Building cache for "+r+" rows:",t),a}function getElementText(e,t){var r="";return t?(e.supportsTextContent||(e.supportsTextContent=t.textContent||!1),r="simple"==e.textExtraction?e.supportsTextContent?t.textContent:t.childNodes[0]&&t.childNodes[0].hasChildNodes()?t.childNodes[0].innerHTML:t.innerHTML:"function"==typeof e.textExtraction?e.textExtraction(t):$(t).text()):""}function appendToTable(e,t){if(e.config.debug)var r=new Date;for(var n=t,o=n.row,a=n.normalized,i=a.length,s=a[0].length-1,d=$(e.tBodies[0]),c=[],u=0;u<i;u++){var l=a[u][s];if(c.push(o[l]),!e.config.appender)for(var f=o[l].length,h=0;h<f;h++)d[0].appendChild(o[l][h])}e.config.appender&&e.config.appender(e,c),c=null,e.config.debug&&benchmark("Rebuilt table:",r),applyWidget(e),setTimeout(function(){$(e).trigger("sortEnd")},0)}function buildHeaders(e){if(e.config.debug)var t=new Date;var r=(!!$.metadata,computeTableHeaderCellIndexes(e));return $tableHeaders=$(e.config.selectorHeaders,e).each(function(t){if(this.column=r[this.parentNode.rowIndex+"-"+this.cellIndex],this.order=formatSortingOrder(e.config.sortInitialOrder),this.count=this.order,(checkHeaderMetadata(this)||checkHeaderOptions(e,t))&&(this.sortDisabled=!0),checkHeaderOptionsSortingLocked(e,t)&&(this.order=this.lockedOrder=checkHeaderOptionsSortingLocked(e,t)),!this.sortDisabled){var n=$(this).addClass(e.config.cssHeader);e.config.onRenderHeader&&e.config.onRenderHeader.apply(n)}e.config.headerList[t]=this}),e.config.debug&&(benchmark("Built headers:",t),log($tableHeaders)),$tableHeaders}function computeTableHeaderCellIndexes(e){for(var t=[],r={},n=e.getElementsByTagName("THEAD")[0],o=n.getElementsByTagName("TR"),a=0;a<o.length;a++)for(var i=o[a].cells,s=0;s<i.length;s++){var d,c=i[s],u=c.parentNode.rowIndex,l=u+"-"+c.cellIndex,f=c.rowSpan||1,h=c.colSpan||1;"undefined"==typeof t[u]&&(t[u]=[]);for(var g=0;g<t[u].length+1;g++)if("undefined"==typeof t[u][g]){d=g;break}r[l]=d;for(var g=u;g<u+f;g++){"undefined"==typeof t[g]&&(t[g]=[]);for(var m=t[g],p=d;p<d+h;p++)m[p]="x"}}return r}function checkCellColSpan(e,t,r){for(var n=[],o=e.tHead.rows,a=o[r].cells,i=0;i<a.length;i++){var s=a[i];s.colSpan>1?n=n.concat(checkCellColSpan(e,headerArr,r++)):(1==e.tHead.length||s.rowSpan>1||!o[r+1])&&n.push(s)}return n}function checkHeaderMetadata(e){return!(!$.metadata||$(e).metadata().sorter!==!1)}function checkHeaderOptions(e,t){return!(!e.config.headers[t]||e.config.headers[t].sorter!==!1)}function checkHeaderOptionsSortingLocked(e,t){return!(!e.config.headers[t]||!e.config.headers[t].lockedOrder)&&e.config.headers[t].lockedOrder}function applyWidget(e){for(var t=e.config.widgets,r=t.length,n=0;n<r;n++)getWidgetById(t[n]).format(e)}function getWidgetById(e){for(var t=widgets.length,r=0;r<t;r++)if(widgets[r].id.toLowerCase()==e.toLowerCase())return widgets[r]}function formatSortingOrder(e){return"Number"!=typeof e?"desc"==e.toLowerCase()?1:0:1==e?1:0}function isValueInArray(e,t){for(var r=t.length,n=0;n<r;n++)if(t[n][0]==e)return!0;return!1}function setHeadersCss(e,t,r,n){t.removeClass(n[0]).removeClass(n[1]);var o=[];t.each(function(e){this.sortDisabled||(o[this.column]=$(this))});for(var a=r.length,i=0;i<a;i++)o[r[i][0]].addClass(n[r[i][1]])}function fixColumnWidth(e,t){var r=e.config;if(r.widthFixed){var n=$("<colgroup>");$("tr:first td",e.tBodies[0]).each(function(){n.append($("<col>").css("width",$(this).width()))}),$(e).prepend(n)}}function updateHeaderSortCount(e,t){for(var r=e.config,n=t.length,o=0;o<n;o++){var a=t[o],i=r.headerList[a[0]];i.count=a[1],i.count++}}function multisort(table,sortList,cache){if(table.config.debug)var sortTime=new Date;for(var dynamicExp="var sortWrapper = function(a,b) {",l=sortList.length,i=0;i<l;i++){var c=sortList[i][0],order=sortList[i][1],s="text"==table.config.parsers[c].type?0==order?makeSortFunction("text","asc",c):makeSortFunction("text","desc",c):0==order?makeSortFunction("numeric","asc",c):makeSortFunction("numeric","desc",c),e="e"+i;dynamicExp+="var "+e+" = "+s,dynamicExp+="if("+e+") { return "+e+"; } ",dynamicExp+="else { "}var orgOrderCol=cache.normalized[0].length-1;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(var i=0;i<l;i++)dynamicExp+="}; ";return dynamicExp+="return 0; ",dynamicExp+="}; ",table.config.debug&&benchmark("Evaling expression:"+dynamicExp,new Date),eval(dynamicExp),cache.normalized.sort(sortWrapper),table.config.debug&&benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time:",sortTime),cache}function makeSortFunction(e,t,r){var n="a["+r+"]",o="b["+r+"]";return"text"==e&&"asc"==t?"("+n+" == "+o+" ? 0 : ("+n+" === null ? Number.POSITIVE_INFINITY : ("+o+" === null ? Number.NEGATIVE_INFINITY : ("+n+" < "+o+") ? -1 : 1 )));":"text"==e&&"desc"==t?"("+n+" == "+o+" ? 0 : ("+n+" === null ? Number.POSITIVE_INFINITY : ("+o+" === null ? Number.NEGATIVE_INFINITY : ("+o+" < "+n+") ? -1 : 1 )));":"numeric"==e&&"asc"==t?"("+n+" === null && "+o+" === null) ? 0 :("+n+" === null ? Number.POSITIVE_INFINITY : ("+o+" === null ? Number.NEGATIVE_INFINITY : "+n+" - "+o+"));":"numeric"==e&&"desc"==t?"("+n+" === null && "+o+" === null) ? 0 :("+n+" === null ? Number.POSITIVE_INFINITY : ("+o+" === null ? Number.NEGATIVE_INFINITY : "+o+" - "+n+"));":void 0}function makeSortText(e){return"((a["+e+"] < b["+e+"]) ? -1 : ((a["+e+"] > b["+e+"]) ? 1 : 0));"}function makeSortTextDesc(e){return"((b["+e+"] < a["+e+"]) ? -1 : ((b["+e+"] > a["+e+"]) ? 1 : 0));"}function makeSortNumeric(e){return"a["+e+"]-b["+e+"];"}function makeSortNumericDesc(e){return"b["+e+"]-a["+e+"];"}function sortText(e,t){return table.config.sortLocaleCompare?e.localeCompare(t):e<t?-1:e>t?1:0}function sortTextDesc(e,t){return table.config.sortLocaleCompare?t.localeCompare(e):t<e?-1:t>e?1:0}function sortNumeric(e,t){return e-t}function sortNumericDesc(e,t){return t-e}function getCachedSortType(e,t){return e[t].type}var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:!0,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:!1,cancelSelection:!0,sortList:[],headerList:[],dateFormat:"us",decimal:"/.|,/g",onRenderHeader:null,selectorHeaders:"thead th",debug:!1},this.benchmark=benchmark,this.construct=function(e){return this.each(function(){if(this.tHead&&this.tBodies){var t,r,n,o;this.config={},o=$.extend(this.config,$.tablesorter.defaults,e),t=$(this),$.data(this,"tablesorter",o),r=buildHeaders(this),this.config.parsers=buildParserCache(this,r),n=buildCache(this);var a=[o.cssDesc,o.cssAsc];fixColumnWidth(this),r.click(function(e){var i=t[0].tBodies[0]&&t[0].tBodies[0].rows.length||0;if(!this.sortDisabled&&i>0){t.trigger("sortStart");var s=($(this),this.column);if(this.order=this.count++%2,this.lockedOrder&&(this.order=this.lockedOrder),e[o.sortMultiSortKey])if(isValueInArray(s,o.sortList))for(var d=0;d<o.sortList.length;d++){var c=o.sortList[d],u=o.headerList[c[0]];c[0]==s&&(u.count=c[1],u.count++,c[1]=u.count%2)}else o.sortList.push([s,this.order]);else{if(o.sortList=[],null!=o.sortForce)for(var l=o.sortForce,d=0;d<l.length;d++)l[d][0]!=s&&o.sortList.push(l[d]);o.sortList.push([s,this.order])}return setTimeout(function(){setHeadersCss(t[0],r,o.sortList,a),appendToTable(t[0],multisort(t[0],o.sortList,n))},1),!1}}).mousedown(function(){if(o.cancelSelection)return this.onselectstart=function(){return!1},!1}),t.bind("update",function(){var e=this;setTimeout(function(){e.config.parsers=buildParserCache(e,r),n=buildCache(e)},1)}).bind("updateCell",function(e,t){var r=this.config,o=[t.parentNode.rowIndex-1,t.cellIndex];n.normalized[o[0]][o[1]]=r.parsers[o[1]].format(getElementText(r,t),t)}).bind("sorton",function(e,t){$(this).trigger("sortStart"),o.sortList=t;var i=o.sortList;updateHeaderSortCount(this,i),setHeadersCss(this,r,i,a),appendToTable(this,multisort(this,i,n))}).bind("appendCache",function(){appendToTable(this,n)}).bind("applyWidgetId",function(e,t){getWidgetById(t).format(this)}).bind("applyWidgets",function(){applyWidget(this)}),$.metadata&&$(this).metadata()&&$(this).metadata().sortlist&&(o.sortList=$(this).metadata().sortlist),o.sortList.length>0&&t.trigger("sorton",[o.sortList]),applyWidget(this)}})},this.addParser=function(e){for(var t=parsers.length,r=!0,n=0;n<t;n++)parsers[n].id.toLowerCase()==e.id.toLowerCase()&&(r=!1);r&&parsers.push(e)},this.addWidget=function(e){widgets.push(e)},this.formatFloat=function(e){var t=parseFloat(e);return isNaN(t)?0:t},this.formatInt=function(e){var t=parseInt(e);return isNaN(t)?0:t},this.isDigit=function(e,t){return/^[-+]?\d*$/.test($.trim(e.replace(/[,.']/g,"")))},this.clearTableBody=function(e){function t(){for(;this.firstChild;)this.removeChild(this.firstChild)}$.browser.msie?t.apply(e.tBodies[0]):e.tBodies[0].innerHTML=""}}}),$.fn.extend({tablesorter:$.tablesorter.construct});var ts=$.tablesorter;ts.addParser({id:"text",is:function(e){return!0},format:function(e){return $.trim(e.toLocaleLowerCase())},type:"text"}),ts.addParser({id:"digit",is:function(e,t){var r=t.config;return $.tablesorter.isDigit(e,r)},format:function(e){return $.tablesorter.formatFloat(e)},type:"numeric"}),ts.addParser({id:"currency",is:function(e){return/^[£$€?.]/.test(e)},format:function(e){return $.tablesorter.formatFloat(e.replace(new RegExp(/[£$€]/g),""))},type:"numeric"}),ts.addParser({id:"ipAddress",is:function(e){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(e)},format:function(e){for(var t=e.split("."),r="",n=t.length,o=0;o<n;o++){var a=t[o];r+=2==a.length?"0"+a:a}return $.tablesorter.formatFloat(r)},type:"numeric"}),ts.addParser({id:"url",is:function(e){return/^(https?|ftp|file):\/\/$/.test(e)},format:function(e){return jQuery.trim(e.replace(new RegExp(/(https?|ftp|file):\/\//),""))},type:"text"}),ts.addParser({id:"isoDate",is:function(e){return/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(e)},format:function(e){return $.tablesorter.formatFloat(""!=e?new Date(e.replace(new RegExp(/-/g),"/")).getTime():"0")},type:"numeric"}),ts.addParser({id:"percent",is:function(e){return/\%$/.test($.trim(e))},format:function(e){return $.tablesorter.formatFloat(e.replace(new RegExp(/%/g),""))},type:"numeric"}),ts.addParser({id:"usLongDate",is:function(e){return e.match(new RegExp(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/))},format:function(e){return $.tablesorter.formatFloat(new Date(e).getTime())},type:"numeric"}),ts.addParser({id:"shortDate",is:function(e){return/\d{1,2}[\/\-]\d{1,2}[\/\-]\d{2,4}/.test(e)},format:function(e,t){var r=t.config;return e=e.replace(/\-/g,"/"),"us"==r.dateFormat?e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$1/$2"):"pt"==r.dateFormat?e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1"):"uk"==r.dateFormat?e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/,"$3/$2/$1"):"dd/mm/yy"!=r.dateFormat&&"dd-mm-yy"!=r.dateFormat||(e=e.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/,"$1/$2/$3")),$.tablesorter.formatFloat(new Date(e).getTime())},type:"numeric"}),ts.addParser({id:"time",is:function(e){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(e)},format:function(e){return $.tablesorter.formatFloat(new Date("2000/01/01 "+e).getTime())},type:"numeric"}),ts.addParser({id:"metadata",is:function(e){return!1},format:function(e,t,r){var n=t.config,o=n.parserMetadataName?n.parserMetadataName:"sortValue";return $(r).metadata()[o]},type:"numeric"}),ts.addWidget({id:"zebra",format:function(e){if(e.config.debug)var t=new Date;var r,n,o=-1;$("tr:visible",e.tBodies[0]).each(function(t){r=$(this),r.hasClass(e.config.cssChildRow)||o++,n=o%2==0,r.removeClass(e.config.widgetZebra.css[n?0:1]).addClass(e.config.widgetZebra.css[n?1:0])}),e.config.debug&&$.tablesorter.benchmark("Applying Zebra widget",t)}})}(jQuery);
  function closeLoader(){$("#load").dialog("close"),$("#loadContent").empty()}function pad(e){return e<10?"0"+e:e}function getQueryVariable(e){for(var t=window.location.search.substring(1),a=t.split("&"),n=0;n<a.length;n++){var o=a[n].split("=");if(o[0]==e)return o[1]}return!1}function getProjectID(){var e=window.location.href,t=e.split("/");return console.log(t[4]),t[4]}function makeAjaxCall(e,t){var a="/emailproject/ajax";$.ajax({type:"POST",dataType:"text",url:a,data:{options:e,isAjax:!0}}).done(function(e){t(e)})}function codePop(e,t){var a="";if(1==t)var a='<button class="savecode">Save Code Changes</button>';$("#loadContent").html('<textarea id="rawhtml" cols="130" rows="30" style="font-family:monospace">'+e+"</textarea>"+a),$(".ui-dialog").addClass("grabcode"),$("#load").dialog("open")}function doDraggable(){$(".numbered-list").find(".numbered-list-container").sortable({handle:".drag",stop:function(e,t){var a=$(this).find(".numbered-list-item");$.each(a,function(e){$(this).find(".number").text(e+1)})}}),$(".fullhtml").click(function(e){e.preventDefault()}),$(".fullhtml").draggable({revert:function(e,t){return $(".draggedFrom").removeClass("draggedFrom"),$(".dropzone").remove(),!0},start:function(e,t){$container=$("#container");var a=$(".contentarea_container");$.each(a,function(){$(this).after('<div class="dropzone"></div>')}),$(".empty, .dropzone").droppable({hoverClass:"activated",tolerance:"touch",drop:function(e,t){$(this).addClass("droppedHere").removeClass("dropzone");var a={flag:"dropModule",module:t.draggable.data("module")};makeAjaxCall(a,insertDroppedModule),doDraggable()}})}}),$(".draggable").draggable({revert:function(e,t){return $(".draggedFrom").removeClass("draggedFrom"),$(".dropzone").remove(),!0},start:function(e,t){var a=$(this).parent();a.addClass("draggedFrom");a.html();$(".blockme, .nopad").not(a).not(".contentarea_container").droppable({hoverClass:"activated",drop:function(e,t){t.draggable.find(".nopad").hasClass("padLeft")?t.draggable.find(".nopad").css({"padding-right":"15px","padding-left":"0"}).addClass("padRight").removeClass("padLeft"):t.draggable.find(".nopad").hasClass("padRight")&&t.draggable.find(".nopad").css({"padding-left":"15px","padding-right":"0"}).addClass("padLeft");var a=$(this).html();$(this).empty(),t.draggable.detach().appendTo($(this)).css({top:0,left:0,position:"relative"}),$(".draggedFrom").html(a).removeClass("draggedFrom"),$(".ui-droppable").droppable("destroy"),doDraggable()}})}})}console.log("we working"),insertDroppedModule=function(e,t){$(".empty")[0]?$("#container").html(e):$(".droppedHere").after(e),$(".dropzone").remove(),$(".droppedHere").removeClass("droppedHere"),$(".ui-droppable").droppable("destroy")},$(document).ajaxComplete(function(){doDraggable()}),$(document).ready(function(){doDraggable();var e=$("#container");if(e.hasClass("new_project")){var t=e.data("template");$.get("templates/"+t+".html",function(t){e.append(t),e.removeClass("new_project"),$(".senddate").text(fullMonthName+" "+nextFriday+", "+year)})}$("#project_list").tablesorter();var a=$(window).width()-200,n=$(window).height()-100;$("#load").dialog({resizable:!1,height:n,width:a,dialogClass:"noTitle",modal:!0,autoOpen:!1,resizable:!0,position:{my:"left top",at:"left+20 top+20",of:window},close:function(e,t){$("#loadContent").empty()}}),$("#clearContainer").click(function(){window.confirm("Are you sure?")&&$("#container").html('<span class="empty"></span>')}),$("body").on("click",".grabcode .ui-icon-closethick, .savecode",function(){$(".wrapped").removeClass("wrapped").find(".contentarea").unwrap(),$(".ui-dialog").removeClass("grabcode")}),$("body").on("click",".savecode",function(e){var t=$("#rawhtml").val();$(".replaceMe").replaceWith(t),closeLoader()}),$("body").on("click","#grabAllCode, .grab-module-code, .edit-module-code, #syncToET, #saveProject",function(){if(!$("#container").find(".unedited").length||window.confirm("Whoa, it looks like you have some unfilled content areas")){var e="",t=($(this).attr("id"),$(this).data("action"));switch(console.log(t),t){case"syncToET":$(".contentarea_container").each(function(){e+=$(this).find(".contentarea").wrap("<p/>").parent().html()});var a={flag:"syncToExacttarget",html:e,etID:$("#exacttarget_id").val()};makeAjaxCall(a,function(e){console.log(e)});break;case"grabAllCode":$(".contentarea_container").each(function(){$(this).addClass("wrapped"),e+=$(this).find(".contentarea").wrap("<p/>").parent().html()});break;case"saveProject":var n={flag:"saveProject",html:$("#container").clone().find(".draggable").removeClass("ui-draggable-handle ui-draggable").end().html(),projectNum:getProjectID(),tag_4_ga:$("#tag4ga").is(":checked"),template:$("#template").val(),utm_source:$("#utm_source").val(),utm_campaign:$("#utm_campaign").val(),utm_medium:$("#utm_medium").val()};makeAjaxCall(n,function(e){$(".filled").each().unwrap(),$(".saved").fadeIn().delay(3e3).fadeOut()});break;default:$(this).closest(".contentarea_container").addClass("wrapped"),e=$(this).closest(".contentarea_container").find(".contentarea").wrap("<p/>").parent().html()}"grabModuleCode"==t||"grabAllCode"==t?codePop(e,!1):"editModuleCode"==t&&($(".wrapped").find(".contentarea").addClass("replaceMe"),codePop(e,!0))}}),$("body").on("click",".remove",function(e){e.preventDefault(),$(this).closest(".contentarea_container").remove(),$("#container").find(".contentarea_container").length<1&&$("#container").html('<span class="empty"></span>')}),$("body").on("click",".drag",function(e){if($(this).closest(".contentarea_container").hasClass("activated"))$(".activated").removeClass("activated");else{$(".activated").removeClass("activated"),$(this).closest(".contentarea_container").addClass("activated");var t=$(".activated").find(".fullpad").css("padding-bottom");t=t.replace(/\D/g,""),$("#bottom_padding_slider").slider("value",t),$("#bottom_padding").find(".value").text(t);var a=$(".activated").find(".fullpad").css("padding-top");a=a.replace(/\D/g,""),$("#top_padding_slider").slider("value",t),$("#top_padding").find(".value").text(t)}}),$("#container").sortable({handle:".drag"}),$("body").on("click",".duplicate",function(){var e=$(this).closest(".contentarea_container"),t=e.wrap("</p>").parent().html();e.addClass("duplicated"),$("#container").append(t),$(".duplicated").unwrap().removeClass("duplicated")}),$("body").on("click",".events-build",function(e){doAJAX.loadEventBuildForm("events-build.php")}),$("body").on("click",".toggle_sponsored",function(e){var t=$(this).closest(".contentarea_container").find(".sponsored");t.hasClass("on")?(t.text(" "),t.removeClass("on")):(t.text("SPONSORED"),t.addClass("on"))}),$("body").on("click",".remove_headline",function(e){var t=$(this);t.closest(".contentarea_container").find(".headlinebar").remove(),t.siblings(".toggle_sponsored").remove()}),$(".fa-calendar").click(function(){$(".eventDatepicker").show()}),$("#minimize_control_panel").click(function(){var e=$(this).parent();e.hasClass("open")?(e.removeClass("open").addClass("minimized"),$(this).find(".fa").removeClass("fa-chevron-down").addClass("fa-chevron-up")):(e.removeClass("minimized").addClass("open"),$(this).find(".fa").removeClass("fa-chevron-up").addClass("fa-chevron-down"))}),$("#bottom_padding_slider").slider({range:"min",min:0,max:100,step:10,slide:function(e,t){$(".activated").length?($(".activated").find(".fullpad").css({"padding-bottom":t.value}),$("#bottom_padding").find(".value").text(t.value)):alert("You have not activated any modules")}}),$("#top_padding_slider").slider({range:"min",min:0,max:100,step:10,slide:function(e,t){$(".activated").length?($(".activated").find(".fullpad").css({"padding-top":t.value}),$("#top_padding").find(".value").text(t.value)):alert("You have not activated any modules")}}),$("#resize_control_panel").resizable({handles:"w"}),$(".resize_control_panel").resizable({handles:"w"}),$("body").on("click",".editable",function(e){e.preventDefault();var t=$(this),a=t.closest(".dest_url, .description").css("font-size"),n=t.html();t.hasClass("editing")||(t.hasClass("textarea")?t.wrap('<textarea autofocus class="editing" style="font-size:'+a+'"/>'):t.wrap('<input autofocus class="editing" style="font-size:'+a+'"/>'),t.closest(".editing").val(n),$(".editing").before('                <div class="fontSize display"></div>                <i class="fa fa-plus fontSize" aria-hidden="true" title="Increase font size"></i>                <i class="fa fa-minus fontSize" aria-hidden="true" title="Decrease font size"></i>'))}),$("body").on("click",".fontSize",function(e){e.preventDefault();var t=$(this);$currentFontSize=t.closest("td").css("font-size"),$currentFontSize=Number($currentFontSize.replace("px","")),$currentLineHeight=Number(t.closest("td").css("line-height").replace("px","")),console.log($currentLineHeight),t.hasClass("fa-plus")?($currentFontSize++,$currentLineHeight++):($currentFontSize--,$currentLineHeight--),t.closest("td").css("font-size",$currentFontSize+"px"),t.closest("td").css("line-height",$currentLineHeight+"px"),$(".editing").css("font-size",$currentFontSize+"px"),$(".fontSize.display").text($currentFontSize+"px")}),$("body").on("click",".editing",function(e){e.preventDefault()}),$("body").on("click",".fa-external-link, .link",function(e){e.preventDefault();var t=$(this);if(t.hasClass("link")){var a=$(this).closest("a").attr("href"),n=(t.data("linktype"),t.data("position"));$(this).removeClass("linked"),$(this).closest(".blockme, .first_buffer_row, .pasted, .linkinput").prepend('<input autofocus class="editing link-input" data-position="'+n+'"/>'),$(".editing").val(a).focus(),$(this).addClass("linking")}else t.addClass("active_editing"),t.closest(".blockme").prepend('<input autofocus class="editing img-input"/>')}),$("body").on("keydown",".editing",function(e){if(9==e.which){var t=$(this);$(".fontSize").remove();var a=t.val();if(t.hasClass("link-input")){var n=$(t).data("position");"undefined"!=n?t.closest(".blockme, .numbered-list-item, .pasted").find("."+n+" a").attr("href",a):t.closest(".blockme, .numbered-list-item, .pasted").find("a").attr("href",a),$(".linking").addClass("linked").removeClass("linking"),t.remove()}else{if(!t.hasClass("img-input"))return t.find("span").is(".maintitle, .date, .eventname, .dates, .section_title, .dates2")&&(a=a.toUpperCase()),t.find("span").removeClass("unedited").html(a.replace(/(?:\r\n|\r|\n)/g,"<br />")).unwrap(),!1;var o=$(".active_editing");o.attr("src",a),o.removeClass("active_editing"),t.remove()}}}),$("body").delegate(".eventDatepicker","click",function(e){$(this).parent().find(".date").addClass("active"),$(this).datepicker("dialog","",function(e){$(".active").html(e.toUpperCase()).removeClass("active")},{minDate:-1,showButtonPanel:!0,dateFormat:"M<br>dd"})});var o,i,r,s;$("body").delegate(".eventDatepickerRange","click",function(e){e.preventDefault(),$(this).parent().find(".date").addClass("active"),$(this).datepicker({minDate:-1,showButtonPanel:!0,onSelect:function(e){var t=$(this).datepicker("getDate");if(void 0==o){var a=d.getTime();i=monthNames[t.getMonth()],r=t.getDate();var n=t.getTime();console.log(n<a),s=n<a?"THRU":i.toUpperCase()+" "+r,o=e}else{var l=monthNames[t.getMonth()],c=t.getDate();if(i!=l||"THRU"==s){var p=s+"<br>-"+l.toUpperCase()+" "+c;$(".active").html(p).removeClass("active")}else{var p=l.toUpperCase();p+="<br>"+r+"-"+c,$(".active").html(p).removeClass("active")}$(".eventDatepickerRange").datepicker("destroy"),o=void 0}console.log(e)}})}),$("#twitter_text").on("keyup",function(){var e=120-$(this).val().length;$("#charcount").text(e),e<10&&$("#charcount").css({color:"red"})}),$("#datepicker").datepicker(),$("#slider").slider({min:0,max:1440,step:15,slide:function(e,t){var a=Math.floor(t.value/60),n=t.value-60*a;1==a.toString().length&&(a="0"+a),1==n.toString().length&&(n="0"+n),$("#time").val(a+":"+n)}})});
  !function(e){function t(t,r){console.log(r),o="myleb_folder",e(r).addClass("activeImage");var n=e(r).data("width"),l=e(r).data("height"),c=t.originalEvent.dataTransfer.files[0];i=(new Date).getUTCMilliseconds()+c.name,e("#cropbox").show(),a=e("#cropbox").croppie({viewport:{width:n,height:l},boundary:{width:n+100,height:l+100}}),e("#viewport_height").slider("value",e(".cr-viewport").outerHeight()),e(".viewport_height_value").text(e(".cr-viewport").outerHeight());var s=new FileReader;s.onload=function(e){a.croppie("bind",{url:e.target.result})},s.readAsDataURL(c),e(".upload-cancel").on("click",function(t){e("#cropbox").fadeOut("fast"),a.croppie("destroy"),e(".activated").removeClass("activated"),e(".activeImage").removeClass("activeImage")}),e(".upload-result").on("click",function(t){a.croppie("result",{type:"canvas",size:"viewport",format:"jpeg"}).then(function(t){e(".fa-spinner").fadeIn(),e.ajax({url:"http://www.mylittleemailbuilder.com/processUploads2.php",type:"POST",data:{file:t,imagename:i,uploadLocation:o},dataType:"json"}).done(function(t){console.log("my var is "+t.url),e("#cropbox").fadeOut("slow",function(){var i=e(".activeImage");i.is(":input")?i.val(t.url):i.attr("src",t.url),i.removeClass("activeImage"),e(".activated").removeClass("activated"),a.croppie("destroy"),e(".fa-spinner").fadeOut()})}).fail(function(e){alert("there was a problem uploading your image"),console.log(e)})})})}var a,i,o="exacttarget";e(document).on({dragenter:function(t){t.preventDefault(),e(this).addClass("activated")},dragleave:function(t){t.preventDefault(),e(this).removeClass("activated")},dragover:function(e){e.preventDefault()},drop:function(e){e.preventDefault(),t(e,this)}},".drop-area"),e("#viewport_height").slider({range:"min",orientation:"vertical",min:0,max:450,step:5,slide:function(t,a){e(".cr-viewport").css({height:a.value}),e(".viewport_height_value").text(a.value)}})}(jQuery);
  function getNearestTuesday(e,t){var a;switch(t){case 0:a=e+2;break;case 1:a=e+1;break;case 2:a=e;break;case 3:a=e-1;break;case 4:a=e-2;break;case 5:a=e-3;break;case 6:a=e-4;break;default:Date=e}return a}function getNearestFriday(e,t){var a;switch(t){case 0:a=e+5;break;case 1:a=e+4;break;case 2:a=e+3;break;case 3:a=e+2;break;case 4:a=e+1;break;case 5:a=e;break;case 6:a=e-1;break;default:Date=e}return a}function tagForGA(e,t){new Date;if("tttd"==t)var a="Top Things to Do",n=$("#utm_source").val();else if("monthly"==t)var a="Consumer Newsletter Monthly",n=monthNames[d.getMonth()+1];var o=e+"?utm_campaign="+a+"&utm_source="+n+"&utm_medium=email";return o}function updateEventCal(e){console.log(e)}var monthNames=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],monthNums=["01","02","03","04","05","06","07","08","09","10","11","12"],monthNamesFull=["January","February","March","April","May","June","July","August","September","October","November","December"],d=new Date,todaysDate=d.getDate(),todaysWeekday=d.getDay(),monthAbbr=monthNames[d.getMonth()],monthNum=monthNums[d.getMonth()],nextMonthAbbr=monthNames[d.getMonth()+1],fullMonthName=monthNamesFull[d.getMonth()],year=d.getFullYear(),startDate=getNearestTuesday(todaysDate,todaysWeekday),nextFriday=getNearestFriday(todaysDate,todaysWeekday),endDate=Number(startDate+5),yearMonDay=year+"-"+monthNums[d.getMonth()]+"-"+todaysDate,monDayYear=fullMonthName+" "+todaysDate+", "+year;!function(e){e("body").on("change","#addSignature input",function(t){var a=e(this).closest(".contentarea_container"),n=t.target.name;if(e(this).is(":checked")){var o=a.find(".signature").length,r=o%2==1,l={flag:"sdta-custom-insertSignature",oddEven:r,name:n};makeAjaxCall(l,function(e){r?a.find(".eventcal tr:last-child .blockme:last-child").html(e):a.find(".eventcal >tbody").append(e)})}else console.log(a),console.log(n),a.find("."+n).remove()});e("#template").change(function(t){var a=e(this).val();switch(a){case"Press Release":e("#project_name").val(yearMonDay+" - Press Release - "),e("#et_folder_input").val(40560),e("#template").val("pressrelease");break;case"execReport":e("#project_name").val(year+"-"+monthNum+"-"+pad(nextFriday)+"-Executive-Update-Email"),e("#subject").val("SDTA Board of Directors Update - "+fullMonthName+" "+nextFriday+", "+year),e("#et_folder_input").val(343713);break;case"Top Things to Do":e("#project_name").val(yearMonDay+" TTTD"),e("#subject").val("San Diego's Top Things to Do This Weekend"),e("#et_folder_input").val(324989),e("#template").val("tttd");break;case"Consumer News":e("#project_name").val(year+" "+nextMonthAbbr.toUpperCase()+" Consumer News"),e("#subject").val("Next Month in San Diego"),e("#et_folder_input").val(40559),e("#template").val("monthly")}}),e("body").on("change","#template",function(){var t=this.value;if("tttd"==t)var a="Top Things to Do",n=year+"_"+monthAbbr+"_"+startDate+"-"+endDate;else var a="Consumer Monthly",n=nextMonthAbbr;e("#utm_campaign").val(a),e("#utm_source").val(n)}),e("body").on("change",'input[name="title[]"]',function(){var t=e(this),a=t.val();console.log(a),t.parent().siblings().find('input[name="ad_content[]"]').val(a.toLowerCase().replace(/&|\u0027|\u2019|\u2018|and|,|:|\.|!|\u2013|\u2014|\u002d/g,"").replace(/san diego/g,"sd").replace(/[ ]/g,"_").replace(/__/g,"_"))}),e("body").on("click",".fa-italic",function(){var t=e(this).closest(".contentarea_container").find(".dates2");t.parent("em").length?t.unwrap("</em>"):t.wrap("<em>")}),e("body").on("click",".toggle",function(t){var a=e(this).closest(".contentarea_container"),n=a.hasClass("toggled");0==n?(e(this).removeClass("fa-circle-o").addClass("fa-circle"),a.addClass("toggled"),a.find(".section_title").text("INDUSTRY TRENDS"),a.find("img").attr("src","http://image.updates.sandiego.org/lib/fe9e15707566017871/m/4/hotel-icon-modern.gif"),a.find(".insert").html('\t\t\t\t\tUpdated research reports are available <a href="http://www.sandiego.org/research">online</a> including:\t\t\t\t\t\t<ul>\t\t\t\t\t\t\t<li>5-year Travel Forecast</li>\t\t\t\t\t\t\t<li>Visitor Profile Summary (Leisure & Business Overnight Travelers)</li>\t\t\t\t\t\t\t<li>Visitor Industry Performance</li>\t\t\t\t\t\t</ul>          Weekly Lodging Performance\t\t\t\t\t')):(e(this).removeClass("fa-circle").addClass("fa-circle-o"),a.find(".section_title").text("UPCOMING EVENTS"),a.removeClass("toggled"),a.find("img").attr("src","http://www.mylittleemailbuilder.com/images/MyLEB-placeholder_127x105.jpg"),a.find(".insert").html("")),console.log(n)}),e("body").on("click",".ltblue",function(t){e(this).closest(".contentarea_container").find(".fullpad").attr("bgcolor","#dbe7ef").attr("background","none")}),e("body").on("click",".white",function(t){e(this).closest(".contentarea_container").find(".fullpad").attr("bgcolor","#ffffff").attr("background","none")}),e("body").on("click",".orange",function(t){e(this).closest(".contentarea_container").find(".fullpad").attr("bgcolor","#fddea6").attr("background","http://image.exct.net/lib/fe6e15707166047a7715/m/1/sdta_nl_small_texture_tan.jpg")}),e("body").on("click",".addEvent",function(t){var a=e(this).closest(".contentarea_container"),n=a.find(".event").length,o=n%2==1;o?e.get("layouts/events/lyt-singleEvent.html",function(e){a.find(".eventcal tr:last-child .blockme:last-child").html(e)}):e.get("layouts/events/lyt-eventRow.html",function(e){a.find(".eventcal >tbody").append(e)})}),e("body").on("click",".removeEvent",function(t){var a=e(this).closest(".contentarea_container"),n=(a.find(".event").length,a.find(".eventcal tr:last-child .blockme:last-child"));console.log(n.hasClass("right")),n.hasClass("empty")?n.parent().remove():n.empty().addClass("empty")}),e("body").on("click",".addRow",function(t){var a=e(this).closest(".contentarea_container").find(".numbered-list-container"),n=a.find(".numbered-list-item").length;console.log(a),e.get("layouts/numbered-list/lyt-number-row.html",function(e){a.find(".numbered-list-item").last().after(e),a.find(".number").last().text(n+1)})}),e("body").on("click",".removeRow",function(t){var a=e(this).closest(".contentarea_container");a.find(".list-item").last().remove()})}(jQuery);