(function(e,t){var n,r,i=typeof t,o=e.location,a=e.document,s=a.documentElement,l=e.jQuery,u=e.$,c={},p=[],f="1.10.1",d=p.concat,h=p.push,g=p.slice,m=p.indexOf,y=c.toString,v=c.hasOwnProperty,b=f.trim,x=function(e,t){return new x.fn.init(e,t,r)},w=/[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source,T=/\S+/g,C=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,N=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,k=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,E=/^[\],:{}\s]*$/,S=/(?:^|:|,)(?:\s*\[)+/g,A=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,j=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,D=/^-ms-/,L=/-([\da-z])/gi,H=function(e,t){return t.toUpperCase()},q=function(e){(a.addEventListener||"load"===e.type||"complete"===a.readyState)&&(_(),x.ready())},_=function(){a.addEventListener?(a.removeEventListener("DOMContentLoaded",q,!1),e.removeEventListener("load",q,!1)):(a.detachEvent("onreadystatechange",q),e.detachEvent("onload",q))};x.fn=x.prototype={jquery:f,constructor:x,init:function(e,n,r){var i,o;if(!e)return this;if("string"==typeof e){if(i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:N.exec(e),!i||!i[1]&&n)return!n||n.jquery?(n||r).find(e):this.constructor(n).find(e);if(i[1]){if(n=n instanceof x?n[0]:n,x.merge(this,x.parseHTML(i[1],n&&n.nodeType?n.ownerDocument||n:a,!0)),k.test(i[1])&&x.isPlainObject(n))for(i in n)x.isFunction(this[i])?this[i](n[i]):this.attr(i,n[i]);return this}if(o=a.getElementById(i[2]),o&&o.parentNode){if(o.id!==i[2])return r.find(e);this.length=1,this[0]=o}return this.context=a,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):x.isFunction(e)?r.ready(e):(e.selector!==t&&(this.selector=e.selector,this.context=e.context),x.makeArray(e,this))},selector:"",length:0,toArray:function(){return g.call(this)},get:function(e){return null==e?this.toArray():0>e?this[this.length+e]:this[e]},pushStack:function(e){var t=x.merge(this.constructor(),e);return t.prevObject=this,t.context=this.context,t},each:function(e,t){return x.each(this,e,t)},ready:function(e){return x.ready.promise().done(e),this},slice:function(){return this.pushStack(g.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(e){var t=this.length,n=+e+(0>e?t:0);return this.pushStack(n>=0&&t>n?[this[n]]:[])},map:function(e){return this.pushStack(x.map(this,function(t,n){return e.call(t,n,t)}))},end:function(){return this.prevObject||this.constructor(null)},push:h,sort:[].sort,splice:[].splice},x.fn.init.prototype=x.fn,x.extend=x.fn.extend=function(){var e,n,r,i,o,a,s=arguments[0]||{},l=1,u=arguments.length,c=!1;for("boolean"==typeof s&&(c=s,s=arguments[1]||{},l=2),"object"==typeof s||x.isFunction(s)||(s={}),u===l&&(s=this,--l);u>l;l++)if(null!=(o=arguments[l]))for(i in o)e=s[i],r=o[i],s!==r&&(c&&r&&(x.isPlainObject(r)||(n=x.isArray(r)))?(n?(n=!1,a=e&&x.isArray(e)?e:[]):a=e&&x.isPlainObject(e)?e:{},s[i]=x.extend(c,a,r)):r!==t&&(s[i]=r));return s},x.extend({expando:"jQuery"+(f+Math.random()).replace(/\D/g,""),noConflict:function(t){return e.$===x&&(e.$=u),t&&e.jQuery===x&&(e.jQuery=l),x},isReady:!1,readyWait:1,holdReady:function(e){e?x.readyWait++:x.ready(!0)},ready:function(e){if(e===!0?!--x.readyWait:!x.isReady){if(!a.body)return setTimeout(x.ready);x.isReady=!0,e!==!0&&--x.readyWait>0||(n.resolveWith(a,[x]),x.fn.trigger&&x(a).trigger("ready").off("ready"))}},isFunction:function(e){return"function"===x.type(e)},isArray:Array.isArray||function(e){return"array"===x.type(e)},isWindow:function(e){return null!=e&&e==e.window},isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?c[y.call(e)]||"object":typeof e},isPlainObject:function(e){var n;if(!e||"object"!==x.type(e)||e.nodeType||x.isWindow(e))return!1;try{if(e.constructor&&!v.call(e,"constructor")&&!v.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(r){return!1}if(x.support.ownLast)for(n in e)return v.call(e,n);for(n in e);return n===t||v.call(e,n)},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},error:function(e){throw Error(e)},parseHTML:function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||a;var r=k.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=x.buildFragment([e],t,i),i&&x(i).remove(),x.merge([],r.childNodes))},parseJSON:function(n){return e.JSON&&e.JSON.parse?e.JSON.parse(n):null===n?n:"string"==typeof n&&(n=x.trim(n),n&&E.test(n.replace(A,"@").replace(j,"]").replace(S,"")))?Function("return "+n)():(x.error("Invalid JSON: "+n),t)},parseXML:function(n){var r,i;if(!n||"string"!=typeof n)return null;try{e.DOMParser?(i=new DOMParser,r=i.parseFromString(n,"text/xml")):(r=new ActiveXObject("Microsoft.XMLDOM"),r.async="false",r.loadXML(n))}catch(o){r=t}return r&&r.documentElement&&!r.getElementsByTagName("parsererror").length||x.error("Invalid XML: "+n),r},noop:function(){},globalEval:function(t){t&&x.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(D,"ms-").replace(L,H)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t,n){var r,i=0,o=e.length,a=M(e);if(n){if(a){for(;o>i;i++)if(r=t.apply(e[i],n),r===!1)break}else for(i in e)if(r=t.apply(e[i],n),r===!1)break}else if(a){for(;o>i;i++)if(r=t.call(e[i],i,e[i]),r===!1)break}else for(i in e)if(r=t.call(e[i],i,e[i]),r===!1)break;return e},trim:b&&!b.call("\ufeff\u00a0")?function(e){return null==e?"":b.call(e)}:function(e){return null==e?"":(e+"").replace(C,"")},makeArray:function(e,t){var n=t||[];return null!=e&&(M(Object(e))?x.merge(n,"string"==typeof e?[e]:e):h.call(n,e)),n},inArray:function(e,t,n){var r;if(t){if(m)return m.call(t,e,n);for(r=t.length,n=n?0>n?Math.max(0,r+n):n:0;r>n;n++)if(n in t&&t[n]===e)return n}return-1},merge:function(e,n){var r=n.length,i=e.length,o=0;if("number"==typeof r)for(;r>o;o++)e[i++]=n[o];else while(n[o]!==t)e[i++]=n[o++];return e.length=i,e},grep:function(e,t,n){var r,i=[],o=0,a=e.length;for(n=!!n;a>o;o++)r=!!t(e[o],o),n!==r&&i.push(e[o]);return i},map:function(e,t,n){var r,i=0,o=e.length,a=M(e),s=[];if(a)for(;o>i;i++)r=t(e[i],i,n),null!=r&&(s[s.length]=r);else for(i in e)r=t(e[i],i,n),null!=r&&(s[s.length]=r);return d.apply([],s)},guid:1,proxy:function(e,n){var r,i,o;return"string"==typeof n&&(o=e[n],n=e,e=o),x.isFunction(e)?(r=g.call(arguments,2),i=function(){return e.apply(n||this,r.concat(g.call(arguments)))},i.guid=e.guid=e.guid||x.guid++,i):t},access:function(e,n,r,i,o,a,s){var l=0,u=e.length,c=null==r;if("object"===x.type(r)){o=!0;for(l in r)x.access(e,n,l,r[l],!0,a,s)}else if(i!==t&&(o=!0,x.isFunction(i)||(s=!0),c&&(s?(n.call(e,i),n=null):(c=n,n=function(e,t,n){return c.call(x(e),n)})),n))for(;u>l;l++)n(e[l],r,s?i:i.call(e[l],l,n(e[l],r)));return o?e:c?n.call(e):u?n(e[0],r):a},now:function(){return(new Date).getTime()},swap:function(e,t,n,r){var i,o,a={};for(o in t)a[o]=e.style[o],e.style[o]=t[o];i=n.apply(e,r||[]);for(o in t)e.style[o]=a[o];return i}}),x.ready.promise=function(t){if(!n)if(n=x.Deferred(),"complete"===a.readyState)setTimeout(x.ready);else if(a.addEventListener)a.addEventListener("DOMContentLoaded",q,!1),e.addEventListener("load",q,!1);else{a.attachEvent("onreadystatechange",q),e.attachEvent("onload",q);var r=!1;try{r=null==e.frameElement&&a.documentElement}catch(i){}r&&r.doScroll&&function o(){if(!x.isReady){try{r.doScroll("left")}catch(e){return setTimeout(o,50)}_(),x.ready()}}()}return n.promise(t)},x.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(e,t){c["[object "+t+"]"]=t.toLowerCase()});function M(e){var t=e.length,n=x.type(e);return x.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}r=x(a),function(e,t){var n,r,i,o,a,s,l,u,c,p,f,d,h,g,m,y,v,b="sizzle"+-new Date,w=e.document,T=0,C=0,N=lt(),k=lt(),E=lt(),S=!1,A=function(){return 0},j=typeof t,D=1<<31,L={}.hasOwnProperty,H=[],q=H.pop,_=H.push,M=H.push,O=H.slice,F=H.indexOf||function(e){var t=0,n=this.length;for(;n>t;t++)if(this[t]===e)return t;return-1},B="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",P="[\\x20\\t\\r\\n\\f]",R="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",W=R.replace("w","w#"),$="\\["+P+"*("+R+")"+P+"*(?:([*^$|!~]?=)"+P+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+W+")|)|)"+P+"*\\]",I=":("+R+")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|"+$.replace(3,8)+")*)|.*)\\)|)",z=RegExp("^"+P+"+|((?:^|[^\\\\])(?:\\\\.)*)"+P+"+$","g"),X=RegExp("^"+P+"*,"+P+"*"),U=RegExp("^"+P+"*([>+~]|"+P+")"+P+"*"),V=RegExp(P+"*[+~]"),Y=RegExp("="+P+"*([^\\]'\"]*)"+P+"*\\]","g"),J=RegExp(I),G=RegExp("^"+W+"$"),Q={ID:RegExp("^#("+R+")"),CLASS:RegExp("^\\.("+R+")"),TAG:RegExp("^("+R.replace("w","w*")+")"),ATTR:RegExp("^"+$),PSEUDO:RegExp("^"+I),CHILD:RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+P+"*(even|odd|(([+-]|)(\\d*)n|)"+P+"*(?:([+-]|)"+P+"*(\\d+)|))"+P+"*\\)|)","i"),bool:RegExp("^(?:"+B+")$","i"),needsContext:RegExp("^"+P+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+P+"*((?:-\\d)?\\d*)"+P+"*\\)|)(?=[^-]|$)","i")},K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,et=/^(?:input|select|textarea|button)$/i,tt=/^h\d$/i,nt=/'|\\/g,rt=RegExp("\\\\([\\da-f]{1,6}"+P+"?|("+P+")|.)","ig"),it=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:0>r?String.fromCharCode(r+65536):String.fromCharCode(55296|r>>10,56320|1023&r)};try{M.apply(H=O.call(w.childNodes),w.childNodes),H[w.childNodes.length].nodeType}catch(ot){M={apply:H.length?function(e,t){_.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function at(e,t,n,i){var o,a,s,l,u,c,d,m,y,x;if((t?t.ownerDocument||t:w)!==f&&p(t),t=t||f,n=n||[],!e||"string"!=typeof e)return n;if(1!==(l=t.nodeType)&&9!==l)return[];if(h&&!i){if(o=Z.exec(e))if(s=o[1]){if(9===l){if(a=t.getElementById(s),!a||!a.parentNode)return n;if(a.id===s)return n.push(a),n}else if(t.ownerDocument&&(a=t.ownerDocument.getElementById(s))&&v(t,a)&&a.id===s)return n.push(a),n}else{if(o[2])return M.apply(n,t.getElementsByTagName(e)),n;if((s=o[3])&&r.getElementsByClassName&&t.getElementsByClassName)return M.apply(n,t.getElementsByClassName(s)),n}if(r.qsa&&(!g||!g.test(e))){if(m=d=b,y=t,x=9===l&&e,1===l&&"object"!==t.nodeName.toLowerCase()){c=bt(e),(d=t.getAttribute("id"))?m=d.replace(nt,"\\$&"):t.setAttribute("id",m),m="[id='"+m+"'] ",u=c.length;while(u--)c[u]=m+xt(c[u]);y=V.test(e)&&t.parentNode||t,x=c.join(",")}if(x)try{return M.apply(n,y.querySelectorAll(x)),n}catch(T){}finally{d||t.removeAttribute("id")}}}return At(e.replace(z,"$1"),t,n,i)}function st(e){return K.test(e+"")}function lt(){var e=[];function t(n,r){return e.push(n+=" ")>o.cacheLength&&delete t[e.shift()],t[n]=r}return t}function ut(e){return e[b]=!0,e}function ct(e){var t=f.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function pt(e,t,n){e=e.split("|");var r,i=e.length,a=n?null:t;while(i--)(r=o.attrHandle[e[i]])&&r!==t||(o.attrHandle[e[i]]=a)}function ft(e,t){var n=e.getAttributeNode(t);return n&&n.specified?n.value:e[t]===!0?t.toLowerCase():null}function dt(e,t){return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}function ht(e){return"input"===e.nodeName.toLowerCase()?e.defaultValue:t}function gt(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||D)-(~e.sourceIndex||D);if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function mt(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function yt(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function vt(e){return ut(function(t){return t=+t,ut(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}s=at.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return t?"HTML"!==t.nodeName:!1},r=at.support={},p=at.setDocument=function(e){var n=e?e.ownerDocument||e:w,i=n.parentWindow;return n!==f&&9===n.nodeType&&n.documentElement?(f=n,d=n.documentElement,h=!s(n),i&&i.frameElement&&i.attachEvent("onbeforeunload",function(){p()}),r.attributes=ct(function(e){return e.innerHTML="<a href='#'></a>",pt("type|href|height|width",dt,"#"===e.firstChild.getAttribute("href")),pt(B,ft,null==e.getAttribute("disabled")),e.className="i",!e.getAttribute("className")}),r.input=ct(function(e){return e.innerHTML="<input>",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")}),pt("value",ht,r.attributes&&r.input),r.getElementsByTagName=ct(function(e){return e.appendChild(n.createComment("")),!e.getElementsByTagName("*").length}),r.getElementsByClassName=ct(function(e){return e.innerHTML="<div class='a'></div><div class='a i'></div>",e.firstChild.className="i",2===e.getElementsByClassName("i").length}),r.getById=ct(function(e){return d.appendChild(e).id=b,!n.getElementsByName||!n.getElementsByName(b).length}),r.getById?(o.find.ID=function(e,t){if(typeof t.getElementById!==j&&h){var n=t.getElementById(e);return n&&n.parentNode?[n]:[]}},o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){return e.getAttribute("id")===t}}):(delete o.find.ID,o.filter.ID=function(e){var t=e.replace(rt,it);return function(e){var n=typeof e.getAttributeNode!==j&&e.getAttributeNode("id");return n&&n.value===t}}),o.find.TAG=r.getElementsByTagName?function(e,n){return typeof n.getElementsByTagName!==j?n.getElementsByTagName(e):t}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},o.find.CLASS=r.getElementsByClassName&&function(e,n){return typeof n.getElementsByClassName!==j&&h?n.getElementsByClassName(e):t},m=[],g=[],(r.qsa=st(n.querySelectorAll))&&(ct(function(e){e.innerHTML="<select><option selected=''></option></select>",e.querySelectorAll("[selected]").length||g.push("\\["+P+"*(?:value|"+B+")"),e.querySelectorAll(":checked").length||g.push(":checked")}),ct(function(e){var t=n.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("t",""),e.querySelectorAll("[t^='']").length&&g.push("[*^$]="+P+"*(?:''|\"\")"),e.querySelectorAll(":enabled").length||g.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),g.push(",.*:")})),(r.matchesSelector=st(y=d.webkitMatchesSelector||d.mozMatchesSelector||d.oMatchesSelector||d.msMatchesSelector))&&ct(function(e){r.disconnectedMatch=y.call(e,"div"),y.call(e,"[s!='']:x"),m.push("!=",I)}),g=g.length&&RegExp(g.join("|")),m=m.length&&RegExp(m.join("|")),v=st(d.contains)||d.compareDocumentPosition?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},r.sortDetached=ct(function(e){return 1&e.compareDocumentPosition(n.createElement("div"))}),A=d.compareDocumentPosition?function(e,t){if(e===t)return S=!0,0;var i=t.compareDocumentPosition&&e.compareDocumentPosition&&e.compareDocumentPosition(t);return i?1&i||!r.sortDetached&&t.compareDocumentPosition(e)===i?e===n||v(w,e)?-1:t===n||v(w,t)?1:c?F.call(c,e)-F.call(c,t):0:4&i?-1:1:e.compareDocumentPosition?-1:1}:function(e,t){var r,i=0,o=e.parentNode,a=t.parentNode,s=[e],l=[t];if(e===t)return S=!0,0;if(!o||!a)return e===n?-1:t===n?1:o?-1:a?1:c?F.call(c,e)-F.call(c,t):0;if(o===a)return gt(e,t);r=e;while(r=r.parentNode)s.unshift(r);r=t;while(r=r.parentNode)l.unshift(r);while(s[i]===l[i])i++;return i?gt(s[i],l[i]):s[i]===w?-1:l[i]===w?1:0},n):f},at.matches=function(e,t){return at(e,null,null,t)},at.matchesSelector=function(e,t){if((e.ownerDocument||e)!==f&&p(e),t=t.replace(Y,"='$1']"),!(!r.matchesSelector||!h||m&&m.test(t)||g&&g.test(t)))try{var n=y.call(e,t);if(n||r.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(i){}return at(t,f,null,[e]).length>0},at.contains=function(e,t){return(e.ownerDocument||e)!==f&&p(e),v(e,t)},at.attr=function(e,n){(e.ownerDocument||e)!==f&&p(e);var i=o.attrHandle[n.toLowerCase()],a=i&&L.call(o.attrHandle,n.toLowerCase())?i(e,n,!h):t;return a===t?r.attributes||!h?e.getAttribute(n):(a=e.getAttributeNode(n))&&a.specified?a.value:null:a},at.error=function(e){throw Error("Syntax error, unrecognized expression: "+e)},at.uniqueSort=function(e){var t,n=[],i=0,o=0;if(S=!r.detectDuplicates,c=!r.sortStable&&e.slice(0),e.sort(A),S){while(t=e[o++])t===e[o]&&(i=n.push(o));while(i--)e.splice(n[i],1)}return e},a=at.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=a(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r];r++)n+=a(t);return n},o=at.selectors={cacheLength:50,createPseudo:ut,match:Q,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(rt,it),e[3]=(e[4]||e[5]||"").replace(rt,it),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||at.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&at.error(e[0]),e},PSEUDO:function(e){var n,r=!e[5]&&e[2];return Q.CHILD.test(e[0])?null:(e[3]&&e[4]!==t?e[2]=e[4]:r&&J.test(r)&&(n=bt(r,!0))&&(n=r.indexOf(")",r.length-n)-r.length)&&(e[0]=e[0].slice(0,n),e[2]=r.slice(0,n)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(rt,it).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=N[e+" "];return t||(t=RegExp("(^|"+P+")"+e+"("+P+"|$)"))&&N(e,function(e){return t.test("string"==typeof e.className&&e.className||typeof e.getAttribute!==j&&e.getAttribute("class")||"")})},ATTR:function(e,t,n){return function(r){var i=at.attr(r,e);return null==i?"!="===t:t?(i+="","="===t?i===n:"!="===t?i!==n:"^="===t?n&&0===i.indexOf(n):"*="===t?n&&i.indexOf(n)>-1:"$="===t?n&&i.slice(-n.length)===n:"~="===t?(" "+i+" ").indexOf(n)>-1:"|="===t?i===n||i.slice(0,n.length+1)===n+"-":!1):!0}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,l){var u,c,p,f,d,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!l&&!s;if(m){if(o){while(g){p=t;while(p=p[g])if(s?p.nodeName.toLowerCase()===y:1===p.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){c=m[b]||(m[b]={}),u=c[e]||[],d=u[0]===T&&u[1],f=u[0]===T&&u[2],p=d&&m.childNodes[d];while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if(1===p.nodeType&&++f&&p===t){c[e]=[T,d,f];break}}else if(v&&(u=(t[b]||(t[b]={}))[e])&&u[0]===T)f=u[1];else while(p=++d&&p&&p[g]||(f=d=0)||h.pop())if((s?p.nodeName.toLowerCase()===y:1===p.nodeType)&&++f&&(v&&((p[b]||(p[b]={}))[e]=[T,f]),p===t))break;return f-=i,f===r||0===f%r&&f/r>=0}}},PSEUDO:function(e,t){var n,r=o.pseudos[e]||o.setFilters[e.toLowerCase()]||at.error("unsupported pseudo: "+e);return r[b]?r(t):r.length>1?(n=[e,e,"",t],o.setFilters.hasOwnProperty(e.toLowerCase())?ut(function(e,n){var i,o=r(e,t),a=o.length;while(a--)i=F.call(e,o[a]),e[i]=!(n[i]=o[a])}):function(e){return r(e,0,n)}):r}},pseudos:{not:ut(function(e){var t=[],n=[],r=l(e.replace(z,"$1"));return r[b]?ut(function(e,t,n,i){var o,a=r(e,null,i,[]),s=e.length;while(s--)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,i,o){return t[0]=e,r(t,null,o,n),!n.pop()}}),has:ut(function(e){return function(t){return at(e,t).length>0}}),contains:ut(function(e){return function(t){return(t.textContent||t.innerText||a(t)).indexOf(e)>-1}}),lang:ut(function(e){return G.test(e||"")||at.error("unsupported lang: "+e),e=e.replace(rt,it).toLowerCase(),function(t){var n;do if(n=h?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===d},focus:function(e){return e===f.activeElement&&(!f.hasFocus||f.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeName>"@"||3===e.nodeType||4===e.nodeType)return!1;return!0},parent:function(e){return!o.pseudos.empty(e)},header:function(e){return tt.test(e.nodeName)},input:function(e){return et.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||t.toLowerCase()===e.type)},first:vt(function(){return[0]}),last:vt(function(e,t){return[t-1]}),eq:vt(function(e,t,n){return[0>n?n+t:n]}),even:vt(function(e,t){var n=0;for(;t>n;n+=2)e.push(n);return e}),odd:vt(function(e,t){var n=1;for(;t>n;n+=2)e.push(n);return e}),lt:vt(function(e,t,n){var r=0>n?n+t:n;for(;--r>=0;)e.push(r);return e}),gt:vt(function(e,t,n){var r=0>n?n+t:n;for(;t>++r;)e.push(r);return e})}};for(n in{radio:!0,checkbox:!0,file:!0,password:!0,image:!0})o.pseudos[n]=mt(n);for(n in{submit:!0,reset:!0})o.pseudos[n]=yt(n);function bt(e,t){var n,r,i,a,s,l,u,c=k[e+" "];if(c)return t?0:c.slice(0);s=e,l=[],u=o.preFilter;while(s){(!n||(r=X.exec(s)))&&(r&&(s=s.slice(r[0].length)||s),l.push(i=[])),n=!1,(r=U.exec(s))&&(n=r.shift(),i.push({value:n,type:r[0].replace(z," ")}),s=s.slice(n.length));for(a in o.filter)!(r=Q[a].exec(s))||u[a]&&!(r=u[a](r))||(n=r.shift(),i.push({value:n,type:a,matches:r}),s=s.slice(n.length));if(!n)break}return t?s.length:s?at.error(e):k(e,l).slice(0)}function xt(e){var t=0,n=e.length,r="";for(;n>t;t++)r+=e[t].value;return r}function wt(e,t,n){var r=t.dir,o=n&&"parentNode"===r,a=C++;return t.first?function(t,n,i){while(t=t[r])if(1===t.nodeType||o)return e(t,n,i)}:function(t,n,s){var l,u,c,p=T+" "+a;if(s){while(t=t[r])if((1===t.nodeType||o)&&e(t,n,s))return!0}else while(t=t[r])if(1===t.nodeType||o)if(c=t[b]||(t[b]={}),(u=c[r])&&u[0]===p){if((l=u[1])===!0||l===i)return l===!0}else if(u=c[r]=[p],u[1]=e(t,n,s)||i,u[1]===!0)return!0}}function Tt(e){return e.length>1?function(t,n,r){var i=e.length;while(i--)if(!e[i](t,n,r))return!1;return!0}:e[0]}function Ct(e,t,n,r,i){var o,a=[],s=0,l=e.length,u=null!=t;for(;l>s;s++)(o=e[s])&&(!n||n(o,r,i))&&(a.push(o),u&&t.push(s));return a}function Nt(e,t,n,r,i,o){return r&&!r[b]&&(r=Nt(r)),i&&!i[b]&&(i=Nt(i,o)),ut(function(o,a,s,l){var u,c,p,f=[],d=[],h=a.length,g=o||St(t||"*",s.nodeType?[s]:s,[]),m=!e||!o&&t?g:Ct(g,f,e,s,l),y=n?i||(o?e:h||r)?[]:a:m;if(n&&n(m,y,s,l),r){u=Ct(y,d),r(u,[],s,l),c=u.length;while(c--)(p=u[c])&&(y[d[c]]=!(m[d[c]]=p))}if(o){if(i||e){if(i){u=[],c=y.length;while(c--)(p=y[c])&&u.push(m[c]=p);i(null,y=[],u,l)}c=y.length;while(c--)(p=y[c])&&(u=i?F.call(o,p):f[c])>-1&&(o[u]=!(a[u]=p))}}else y=Ct(y===a?y.splice(h,y.length):y),i?i(null,a,y,l):M.apply(a,y)})}function kt(e){var t,n,r,i=e.length,a=o.relative[e[0].type],s=a||o.relative[" "],l=a?1:0,c=wt(function(e){return e===t},s,!0),p=wt(function(e){return F.call(t,e)>-1},s,!0),f=[function(e,n,r){return!a&&(r||n!==u)||((t=n).nodeType?c(e,n,r):p(e,n,r))}];for(;i>l;l++)if(n=o.relative[e[l].type])f=[wt(Tt(f),n)];else{if(n=o.filter[e[l].type].apply(null,e[l].matches),n[b]){for(r=++l;i>r;r++)if(o.relative[e[r].type])break;return Nt(l>1&&Tt(f),l>1&&xt(e.slice(0,l-1).concat({value:" "===e[l-2].type?"*":""})).replace(z,"$1"),n,r>l&&kt(e.slice(l,r)),i>r&&kt(e=e.slice(r)),i>r&&xt(e))}f.push(n)}return Tt(f)}function Et(e,t){var n=0,r=t.length>0,a=e.length>0,s=function(s,l,c,p,d){var h,g,m,y=[],v=0,b="0",x=s&&[],w=null!=d,C=u,N=s||a&&o.find.TAG("*",d&&l.parentNode||l),k=T+=null==C?1:Math.random()||.1;for(w&&(u=l!==f&&l,i=n);null!=(h=N[b]);b++){if(a&&h){g=0;while(m=e[g++])if(m(h,l,c)){p.push(h);break}w&&(T=k,i=++n)}r&&((h=!m&&h)&&v--,s&&x.push(h))}if(v+=b,r&&b!==v){g=0;while(m=t[g++])m(x,y,l,c);if(s){if(v>0)while(b--)x[b]||y[b]||(y[b]=q.call(p));y=Ct(y)}M.apply(p,y),w&&!s&&y.length>0&&v+t.length>1&&at.uniqueSort(p)}return w&&(T=k,u=C),x};return r?ut(s):s}l=at.compile=function(e,t){var n,r=[],i=[],o=E[e+" "];if(!o){t||(t=bt(e)),n=t.length;while(n--)o=kt(t[n]),o[b]?r.push(o):i.push(o);o=E(e,Et(i,r))}return o};function St(e,t,n){var r=0,i=t.length;for(;i>r;r++)at(e,t[r],n);return n}function At(e,t,n,i){var a,s,u,c,p,f=bt(e);if(!i&&1===f.length){if(s=f[0]=f[0].slice(0),s.length>2&&"ID"===(u=s[0]).type&&r.getById&&9===t.nodeType&&h&&o.relative[s[1].type]){if(t=(o.find.ID(u.matches[0].replace(rt,it),t)||[])[0],!t)return n;e=e.slice(s.shift().value.length)}a=Q.needsContext.test(e)?0:s.length;while(a--){if(u=s[a],o.relative[c=u.type])break;if((p=o.find[c])&&(i=p(u.matches[0].replace(rt,it),V.test(s[0].type)&&t.parentNode||t))){if(s.splice(a,1),e=i.length&&xt(s),!e)return M.apply(n,i),n;break}}}return l(e,f)(i,t,!h,n,V.test(e)),n}o.pseudos.nth=o.pseudos.eq;function jt(){}jt.prototype=o.filters=o.pseudos,o.setFilters=new jt,r.sortStable=b.split("").sort(A).join("")===b,p(),[0,0].sort(A),r.detectDuplicates=S,x.find=at,x.expr=at.selectors,x.expr[":"]=x.expr.pseudos,x.unique=at.uniqueSort,x.text=at.getText,x.isXMLDoc=at.isXML,x.contains=at.contains}(e);var O={};function F(e){var t=O[e]={};return x.each(e.match(T)||[],function(e,n){t[n]=!0}),t}x.Callbacks=function(e){e="string"==typeof e?O[e]||F(e):x.extend({},e);var n,r,i,o,a,s,l=[],u=!e.once&&[],c=function(t){for(r=e.memory&&t,i=!0,a=s||0,s=0,o=l.length,n=!0;l&&o>a;a++)if(l[a].apply(t[0],t[1])===!1&&e.stopOnFalse){r=!1;break}n=!1,l&&(u?u.length&&c(u.shift()):r?l=[]:p.disable())},p={add:function(){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this},remove:function(){return l&&x.each(arguments,function(e,t){var r;while((r=x.inArray(t,l,r))>-1)l.splice(r,1),n&&(o>=r&&o--,a>=r&&a--)}),this},has:function(e){return e?x.inArray(e,l)>-1:!(!l||!l.length)},empty:function(){return l=[],o=0,this},disable:function(){return l=u=r=t,this},disabled:function(){return!l},lock:function(){return u=t,r||p.disable(),this},locked:function(){return!u},fireWith:function(e,t){return t=t||[],t=[e,t.slice?t.slice():t],!l||i&&!u||(n?u.push(t):c(t)),this},fire:function(){return p.fireWith(this,arguments),this},fired:function(){return!!i}};return p},x.extend({Deferred:function(e){var t=[["resolve","done",x.Callbacks("once memory"),"resolved"],["reject","fail",x.Callbacks("once memory"),"rejected"],["notify","progress",x.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?x.extend(e,r):r}},i={};return r.pipe=r.then,x.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t=0,n=g.call(arguments),r=n.length,i=1!==r||e&&x.isFunction(e.promise)?r:0,o=1===i?e:x.Deferred(),a=function(e,t,n){return function(r){t[e]=this,n[e]=arguments.length>1?g.call(arguments):r,n===s?o.notifyWith(t,n):--i||o.resolveWith(t,n)}},s,l,u;if(r>1)for(s=Array(r),l=Array(r),u=Array(r);r>t;t++)n[t]&&x.isFunction(n[t].promise)?n[t].promise().done(a(t,u,n)).fail(o.reject).progress(a(t,l,s)):--i;return i||o.resolveWith(u,n),o.promise()}}),x.support=function(t){var n,r,o,s,l,u,c,p,f,d=a.createElement("div");if(d.setAttribute("className","t"),d.innerHTML="  <link/><table></table><a href='/a'>a</a><input type='checkbox'/>",n=d.getElementsByTagName("*")||[],r=d.getElementsByTagName("a")[0],!r||!r.style||!n.length)return t;s=a.createElement("select"),u=s.appendChild(a.createElement("option")),o=d.getElementsByTagName("input")[0],r.style.cssText="top:1px;float:left;opacity:.5",t.getSetAttribute="t"!==d.className,t.leadingWhitespace=3===d.firstChild.nodeType,t.tbody=!d.getElementsByTagName("tbody").length,t.htmlSerialize=!!d.getElementsByTagName("link").length,t.style=/top/.test(r.getAttribute("style")),t.hrefNormalized="/a"===r.getAttribute("href"),t.opacity=/^0.5/.test(r.style.opacity),t.cssFloat=!!r.style.cssFloat,t.checkOn=!!o.value,t.optSelected=u.selected,t.enctype=!!a.createElement("form").enctype,t.html5Clone="<:nav></:nav>"!==a.createElement("nav").cloneNode(!0).outerHTML,t.inlineBlockNeedsLayout=!1,t.shrinkWrapBlocks=!1,t.pixelPosition=!1,t.deleteExpando=!0,t.noCloneEvent=!0,t.reliableMarginRight=!0,t.boxSizingReliable=!0,o.checked=!0,t.noCloneChecked=o.cloneNode(!0).checked,s.disabled=!0,t.optDisabled=!u.disabled;try{delete d.test}catch(h){t.deleteExpando=!1}o=a.createElement("input"),o.setAttribute("value",""),t.input=""===o.getAttribute("value"),o.value="t",o.setAttribute("type","radio"),t.radioValue="t"===o.value,o.setAttribute("checked","t"),o.setAttribute("name","t"),l=a.createDocumentFragment(),l.appendChild(o),t.appendChecked=o.checked,t.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,d.attachEvent&&(d.attachEvent("onclick",function(){t.noCloneEvent=!1}),d.cloneNode(!0).click());for(f in{submit:!0,change:!0,focusin:!0})d.setAttribute(c="on"+f,"t"),t[f+"Bubbles"]=c in e||d.attributes[c].expando===!1;d.style.backgroundClip="content-box",d.cloneNode(!0).style.backgroundClip="",t.clearCloneStyle="content-box"===d.style.backgroundClip;for(f in x(t))break;return t.ownLast="0"!==f,x(function(){var n,r,o,s="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",l=a.getElementsByTagName("body")[0];l&&(n=a.createElement("div"),n.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",l.appendChild(n).appendChild(d),d.innerHTML="<table><tr><td></td><td>t</td></tr></table>",o=d.getElementsByTagName("td"),o[0].style.cssText="padding:0;margin:0;border:0;display:none",p=0===o[0].offsetHeight,o[0].style.display="",o[1].style.display="none",t.reliableHiddenOffsets=p&&0===o[0].offsetHeight,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",x.swap(l,null!=l.style.zoom?{zoom:1}:{},function(){t.boxSizing=4===d.offsetWidth}),e.getComputedStyle&&(t.pixelPosition="1%"!==(e.getComputedStyle(d,null)||{}).top,t.boxSizingReliable="4px"===(e.getComputedStyle(d,null)||{width:"4px"}).width,r=d.appendChild(a.createElement("div")),r.style.cssText=d.style.cssText=s,r.style.marginRight=r.style.width="0",d.style.width="1px",t.reliableMarginRight=!parseFloat((e.getComputedStyle(r,null)||{}).marginRight)),typeof d.style.zoom!==i&&(d.innerHTML="",d.style.cssText=s+"width:1px;padding:1px;display:inline;zoom:1",t.inlineBlockNeedsLayout=3===d.offsetWidth,d.style.display="block",d.innerHTML="<div></div>",d.firstChild.style.width="5px",t.shrinkWrapBlocks=3!==d.offsetWidth,t.inlineBlockNeedsLayout&&(l.style.zoom=1)),l.removeChild(n),n=d=o=r=null)}),n=s=l=u=r=o=null,t}({});var B=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,P=/([A-Z])/g;function R(e,n,r,i){if(x.acceptData(e)){var o,a,s=x.expando,l=e.nodeType,u=l?x.cache:e,c=l?e[s]:e[s]&&s;if(c&&u[c]&&(i||u[c].data)||r!==t||"string"!=typeof n)return c||(c=l?e[s]=p.pop()||x.guid++:s),u[c]||(u[c]=l?{}:{toJSON:x.noop}),("object"==typeof n||"function"==typeof n)&&(i?u[c]=x.extend(u[c],n):u[c].data=x.extend(u[c].data,n)),a=u[c],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[x.camelCase(n)]=r),"string"==typeof n?(o=a[n],null==o&&(o=a[x.camelCase(n)])):o=a,o}}function W(e,t,n){if(x.acceptData(e)){var r,i,o=e.nodeType,a=o?x.cache:e,s=o?e[x.expando]:x.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){x.isArray(t)?t=t.concat(x.map(t,x.camelCase)):t in r?t=[t]:(t=x.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;while(i--)delete r[t[i]];if(n?!I(r):!x.isEmptyObject(r))return}(n||(delete a[s].data,I(a[s])))&&(o?x.cleanData([e],!0):x.support.deleteExpando||a!=a.window?delete a[s]:a[s]=null)}}}x.extend({cache:{},noData:{applet:!0,embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?x.cache[e[x.expando]]:e[x.expando],!!e&&!I(e)},data:function(e,t,n){return R(e,t,n)},removeData:function(e,t){return W(e,t)},_data:function(e,t,n){return R(e,t,n,!0)},_removeData:function(e,t){return W(e,t,!0)},acceptData:function(e){if(e.nodeType&&1!==e.nodeType&&9!==e.nodeType)return!1;var t=e.nodeName&&x.noData[e.nodeName.toLowerCase()];return!t||t!==!0&&e.getAttribute("classid")===t}}),x.fn.extend({data:function(e,n){var r,i,o=null,a=0,s=this[0];if(e===t){if(this.length&&(o=x.data(s),1===s.nodeType&&!x._data(s,"parsedAttrs"))){for(r=s.attributes;r.length>a;a++)i=r[a].name,0===i.indexOf("data-")&&(i=x.camelCase(i.slice(5)),$(s,i,o[i]));x._data(s,"parsedAttrs",!0)}return o}return"object"==typeof e?this.each(function(){x.data(this,e)}):arguments.length>1?this.each(function(){x.data(this,e,n)}):s?$(s,e,x.data(s,e)):null},removeData:function(e){return this.each(function(){x.removeData(this,e)})}});function $(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(P,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:B.test(r)?x.parseJSON(r):r}catch(o){}x.data(e,n,r)}else r=t}return r}function I(e){var t;for(t in e)if(("data"!==t||!x.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}x.extend({queue:function(e,n,r){var i;return e?(n=(n||"fx")+"queue",i=x._data(e,n),r&&(!i||x.isArray(r)?i=x._data(e,n,x.makeArray(r)):i.push(r)),i||[]):t},dequeue:function(e,t){t=t||"fx";var n=x.queue(e,t),r=n.length,i=n.shift(),o=x._queueHooks(e,t),a=function(){x.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return x._data(e,n)||x._data(e,n,{empty:x.Callbacks("once memory").add(function(){x._removeData(e,t+"queue"),x._removeData(e,n)})})}}),x.fn.extend({queue:function(e,n){var r=2;return"string"!=typeof e&&(n=e,e="fx",r--),r>arguments.length?x.queue(this[0],e):n===t?this:this.each(function(){var t=x.queue(this,e,n);x._queueHooks(this,e),"fx"===e&&"inprogress"!==t[0]&&x.dequeue(this,e)})},dequeue:function(e){return this.each(function(){x.dequeue(this,e)})},delay:function(e,t){return e=x.fx?x.fx.speeds[e]||e:e,t=t||"fx",this.queue(t,function(t,n){var r=setTimeout(t,e);n.stop=function(){clearTimeout(r)}})},clearQueue:function(e){return this.queue(e||"fx",[])},promise:function(e,n){var r,i=1,o=x.Deferred(),a=this,s=this.length,l=function(){--i||o.resolveWith(a,[a])};"string"!=typeof e&&(n=e,e=t),e=e||"fx";while(s--)r=x._data(a[s],e+"queueHooks"),r&&r.empty&&(i++,r.empty.add(l));return l(),o.promise(n)}});var z,X,U=/[\t\r\n\f]/g,V=/\r/g,Y=/^(?:input|select|textarea|button|object)$/i,J=/^(?:a|area)$/i,G=/^(?:checked|selected)$/i,Q=x.support.getSetAttribute,K=x.support.input;x.fn.extend({attr:function(e,t){return x.access(this,x.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){x.removeAttr(this,e)})},prop:function(e,t){return x.access(this,x.prop,e,t,arguments.length>1)},removeProp:function(e){return e=x.propFix[e]||e,this.each(function(){try{this[e]=t,delete this[e]}catch(n){}})},addClass:function(e){var t,n,r,i,o,a=0,s=this.length,l="string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).addClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):" ")){o=0;while(i=t[o++])0>r.indexOf(" "+i+" ")&&(r+=i+" ");n.className=x.trim(r)}return this},removeClass:function(e){var t,n,r,i,o,a=0,s=this.length,l=0===arguments.length||"string"==typeof e&&e;if(x.isFunction(e))return this.each(function(t){x(this).removeClass(e.call(this,t,this.className))});if(l)for(t=(e||"").match(T)||[];s>a;a++)if(n=this[a],r=1===n.nodeType&&(n.className?(" "+n.className+" ").replace(U," "):"")){o=0;while(i=t[o++])while(r.indexOf(" "+i+" ")>=0)r=r.replace(" "+i+" "," ");n.className=e?x.trim(r):""}return this},toggleClass:function(e,t){var n=typeof e,r="boolean"==typeof t;return x.isFunction(e)?this.each(function(n){x(this).toggleClass(e.call(this,n,this.className,t),t)}):this.each(function(){if("string"===n){var o,a=0,s=x(this),l=t,u=e.match(T)||[];while(o=u[a++])l=r?l:!s.hasClass(o),s[l?"addClass":"removeClass"](o)}else(n===i||"boolean"===n)&&(this.className&&x._data(this,"__className__",this.className),this.className=this.className||e===!1?"":x._data(this,"__className__")||"")})},hasClass:function(e){var t=" "+e+" ",n=0,r=this.length;for(;r>n;n++)if(1===this[n].nodeType&&(" "+this[n].className+" ").replace(U," ").indexOf(t)>=0)return!0;return!1},val:function(e){var n,r,i,o=this[0];{if(arguments.length)return i=x.isFunction(e),this.each(function(n){var o;1===this.nodeType&&(o=i?e.call(this,n,x(this).val()):e,null==o?o="":"number"==typeof o?o+="":x.isArray(o)&&(o=x.map(o,function(e){return null==e?"":e+""})),r=x.valHooks[this.type]||x.valHooks[this.nodeName.toLowerCase()],r&&"set"in r&&r.set(this,o,"value")!==t||(this.value=o))});if(o)return r=x.valHooks[o.type]||x.valHooks[o.nodeName.toLowerCase()],r&&"get"in r&&(n=r.get(o,"value"))!==t?n:(n=o.value,"string"==typeof n?n.replace(V,""):null==n?"":n)}}}),x.extend({valHooks:{option:{get:function(e){var t=x.find.attr(e,"value");return null!=t?t:e.text}},select:{get:function(e){var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||0>i,a=o?null:[],s=o?i+1:r.length,l=0>i?s:o?i:0;for(;s>l;l++)if(n=r[l],!(!n.selected&&l!==i||(x.support.optDisabled?n.disabled:null!==n.getAttribute("disabled"))||n.parentNode.disabled&&x.nodeName(n.parentNode,"optgroup"))){if(t=x(n).val(),o)return t;a.push(t)}return a},set:function(e,t){var n,r,i=e.options,o=x.makeArray(t),a=i.length;while(a--)r=i[a],(r.selected=x.inArray(x(r).val(),o)>=0)&&(n=!0);return n||(e.selectedIndex=-1),o}}},attr:function(e,n,r){var o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return typeof e.getAttribute===i?x.prop(e,n,r):(1===s&&x.isXMLDoc(e)||(n=n.toLowerCase(),o=x.attrHooks[n]||(x.expr.match.bool.test(n)?X:z)),r===t?o&&"get"in o&&null!==(a=o.get(e,n))?a:(a=x.find.attr(e,n),null==a?t:a):null!==r?o&&"set"in o&&(a=o.set(e,r,n))!==t?a:(e.setAttribute(n,r+""),r):(x.removeAttr(e,n),t))},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(T);if(o&&1===e.nodeType)while(n=o[i++])r=x.propFix[n]||n,x.expr.match.bool.test(n)?K&&Q||!G.test(n)?e[r]=!1:e[x.camelCase("default-"+n)]=e[r]=!1:x.attr(e,n,""),e.removeAttribute(Q?n:r)},attrHooks:{type:{set:function(e,t){if(!x.support.radioValue&&"radio"===t&&x.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},propFix:{"for":"htmlFor","class":"className"},prop:function(e,n,r){var i,o,a,s=e.nodeType;if(e&&3!==s&&8!==s&&2!==s)return a=1!==s||!x.isXMLDoc(e),a&&(n=x.propFix[n]||n,o=x.propHooks[n]),r!==t?o&&"set"in o&&(i=o.set(e,r,n))!==t?i:e[n]=r:o&&"get"in o&&null!==(i=o.get(e,n))?i:e[n]},propHooks:{tabIndex:{get:function(e){var t=x.find.attr(e,"tabindex");return t?parseInt(t,10):Y.test(e.nodeName)||J.test(e.nodeName)&&e.href?0:-1}}}}),X={set:function(e,t,n){return t===!1?x.removeAttr(e,n):K&&Q||!G.test(n)?e.setAttribute(!Q&&x.propFix[n]||n,n):e[x.camelCase("default-"+n)]=e[n]=!0,n}},x.each(x.expr.match.bool.source.match(/\w+/g),function(e,n){var r=x.expr.attrHandle[n]||x.find.attr;x.expr.attrHandle[n]=K&&Q||!G.test(n)?function(e,n,i){var o=x.expr.attrHandle[n],a=i?t:(x.expr.attrHandle[n]=t)!=r(e,n,i)?n.toLowerCase():null;return x.expr.attrHandle[n]=o,a}:function(e,n,r){return r?t:e[x.camelCase("default-"+n)]?n.toLowerCase():null}}),K&&Q||(x.attrHooks.value={set:function(e,n,r){return x.nodeName(e,"input")?(e.defaultValue=n,t):z&&z.set(e,n,r)}}),Q||(z={set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},x.expr.attrHandle.id=x.expr.attrHandle.name=x.expr.attrHandle.coords=function(e,n,r){var i;return r?t:(i=e.getAttributeNode(n))&&""!==i.value?i.value:null},x.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&r.specified?r.value:t},set:z.set},x.attrHooks.contenteditable={set:function(e,t,n){z.set(e,""===t?!1:t,n)}},x.each(["width","height"],function(e,n){x.attrHooks[n]={set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}}})),x.support.hrefNormalized||x.each(["href","src"],function(e,t){x.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),x.support.style||(x.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),x.support.optSelected||(x.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}}),x.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){x.propFix[this.toLowerCase()]=this}),x.support.enctype||(x.propFix.enctype="encoding"),x.each(["radio","checkbox"],function(){x.valHooks[this]={set:function(e,n){return x.isArray(n)?e.checked=x.inArray(x(e).val(),n)>=0:t}},x.support.checkOn||(x.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Z=/^(?:input|select|textarea)$/i,et=/^key/,tt=/^(?:mouse|contextmenu)|click/,nt=/^(?:focusinfocus|focusoutblur)$/,rt=/^([^.]*)(?:\.(.+)|)$/;function it(){return!0}function ot(){return!1}function at(){try{return a.activeElement}catch(e){}}x.event={global:{},add:function(e,n,r,o,a){var s,l,u,c,p,f,d,h,g,m,y,v=x._data(e);if(v){r.handler&&(c=r,r=c.handler,a=c.selector),r.guid||(r.guid=x.guid++),(l=v.events)||(l=v.events={}),(f=v.handle)||(f=v.handle=function(e){return typeof x===i||e&&x.event.triggered===e.type?t:x.event.dispatch.apply(f.elem,arguments)},f.elem=e),n=(n||"").match(T)||[""],u=n.length;while(u--)s=rt.exec(n[u])||[],g=y=s[1],m=(s[2]||"").split(".").sort(),g&&(p=x.event.special[g]||{},g=(a?p.delegateType:p.bindType)||g,p=x.event.special[g]||{},d=x.extend({type:g,origType:y,data:o,handler:r,guid:r.guid,selector:a,needsContext:a&&x.expr.match.needsContext.test(a),namespace:m.join(".")},c),(h=l[g])||(h=l[g]=[],h.delegateCount=0,p.setup&&p.setup.call(e,o,m,f)!==!1||(e.addEventListener?e.addEventListener(g,f,!1):e.attachEvent&&e.attachEvent("on"+g,f))),p.add&&(p.add.call(e,d),d.handler.guid||(d.handler.guid=r.guid)),a?h.splice(h.delegateCount++,0,d):h.push(d),x.event.global[g]=!0);e=null}},remove:function(e,t,n,r,i){var o,a,s,l,u,c,p,f,d,h,g,m=x.hasData(e)&&x._data(e);if(m&&(c=m.events)){t=(t||"").match(T)||[""],u=t.length;while(u--)if(s=rt.exec(t[u])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){p=x.event.special[d]||{},d=(r?p.delegateType:p.bindType)||d,f=c[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),l=o=f.length;while(o--)a=f[o],!i&&g!==a.origType||n&&n.guid!==a.guid||s&&!s.test(a.namespace)||r&&r!==a.selector&&("**"!==r||!a.selector)||(f.splice(o,1),a.selector&&f.delegateCount--,p.remove&&p.remove.call(e,a));l&&!f.length&&(p.teardown&&p.teardown.call(e,h,m.handle)!==!1||x.removeEvent(e,d,m.handle),delete c[d])}else for(d in c)x.event.remove(e,d+t[u],n,r,!0);x.isEmptyObject(c)&&(delete m.handle,x._removeData(e,"events"))}},trigger:function(n,r,i,o){var s,l,u,c,p,f,d,h=[i||a],g=v.call(n,"type")?n.type:n,m=v.call(n,"namespace")?n.namespace.split("."):[];if(u=f=i=i||a,3!==i.nodeType&&8!==i.nodeType&&!nt.test(g+x.event.triggered)&&(g.indexOf(".")>=0&&(m=g.split("."),g=m.shift(),m.sort()),l=0>g.indexOf(":")&&"on"+g,n=n[x.expando]?n:new x.Event(g,"object"==typeof n&&n),n.isTrigger=o?2:3,n.namespace=m.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+m.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:x.makeArray(r,[n]),p=x.event.special[g]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!x.isWindow(i)){for(c=p.delegateType||g,nt.test(c+g)||(u=u.parentNode);u;u=u.parentNode)h.push(u),f=u;f===(i.ownerDocument||a)&&h.push(f.defaultView||f.parentWindow||e)}d=0;while((u=h[d++])&&!n.isPropagationStopped())n.type=d>1?c:p.bindType||g,s=(x._data(u,"events")||{})[n.type]&&x._data(u,"handle"),s&&s.apply(u,r),s=l&&u[l],s&&x.acceptData(u)&&s.apply&&s.apply(u,r)===!1&&n.preventDefault();if(n.type=g,!o&&!n.isDefaultPrevented()&&(!p._default||p._default.apply(h.pop(),r)===!1)&&x.acceptData(i)&&l&&i[g]&&!x.isWindow(i)){f=i[l],f&&(i[l]=null),x.event.triggered=g;try{i[g]()}catch(y){}x.event.triggered=t,f&&(i[l]=f)}return n.result}},dispatch:function(e){e=x.event.fix(e);var n,r,i,o,a,s=[],l=g.call(arguments),u=(x._data(this,"events")||{})[e.type]||[],c=x.event.special[e.type]||{};if(l[0]=e,e.delegateTarget=this,!c.preDispatch||c.preDispatch.call(this,e)!==!1){s=x.event.handlers.call(this,e,u),n=0;while((o=s[n++])&&!e.isPropagationStopped()){e.currentTarget=o.elem,a=0;while((i=o.handlers[a++])&&!e.isImmediatePropagationStopped())(!e.namespace_re||e.namespace_re.test(i.namespace))&&(e.handleObj=i,e.data=i.data,r=((x.event.special[i.origType]||{}).handle||i.handler).apply(o.elem,l),r!==t&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()))}return c.postDispatch&&c.postDispatch.call(this,e),e.result}},handlers:function(e,n){var r,i,o,a,s=[],l=n.delegateCount,u=e.target;if(l&&u.nodeType&&(!e.button||"click"!==e.type))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(o=[],a=0;l>a;a++)i=n[a],r=i.selector+" ",o[r]===t&&(o[r]=i.needsContext?x(r,this).index(u)>=0:x.find(r,this,null,[u]).length),o[r]&&o.push(i);o.length&&s.push({elem:u,handlers:o})}return n.length>l&&s.push({elem:this,handlers:n.slice(l)}),s},fix:function(e){if(e[x.expando])return e;var t,n,r,i=e.type,o=e,s=this.fixHooks[i];s||(this.fixHooks[i]=s=tt.test(i)?this.mouseHooks:et.test(i)?this.keyHooks:{}),r=s.props?this.props.concat(s.props):this.props,e=new x.Event(o),t=r.length;while(t--)n=r[t],e[n]=o[n];return e.target||(e.target=o.srcElement||a),3===e.target.nodeType&&(e.target=e.target.parentNode),e.metaKey=!!e.metaKey,s.filter?s.filter(e,o):e},props:"altKey bubbles cancelable ctrlKey currentTarget eventPhase metaKey relatedTarget shiftKey target timeStamp view which".split(" "),fixHooks:{},keyHooks:{props:"char charCode key keyCode".split(" "),filter:function(e,t){return null==e.which&&(e.which=null!=t.charCode?t.charCode:t.keyCode),e}},mouseHooks:{props:"button buttons clientX clientY fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" "),filter:function(e,n){var r,i,o,s=n.button,l=n.fromElement;return null==e.pageX&&null!=n.clientX&&(i=e.target.ownerDocument||a,o=i.documentElement,r=i.body,e.pageX=n.clientX+(o&&o.scrollLeft||r&&r.scrollLeft||0)-(o&&o.clientLeft||r&&r.clientLeft||0),e.pageY=n.clientY+(o&&o.scrollTop||r&&r.scrollTop||0)-(o&&o.clientTop||r&&r.clientTop||0)),!e.relatedTarget&&l&&(e.relatedTarget=l===e.target?n.toElement:l),e.which||s===t||(e.which=1&s?1:2&s?3:4&s?2:0),e}},special:{load:{noBubble:!0},focus:{trigger:function(){if(this!==at()&&this.focus)try{return this.focus(),!1}catch(e){}},delegateType:"focusin"},blur:{trigger:function(){return this===at()&&this.blur?(this.blur(),!1):t},delegateType:"focusout"},click:{trigger:function(){return x.nodeName(this,"input")&&"checkbox"===this.type&&this.click?(this.click(),!1):t},_default:function(e){return x.nodeName(e.target,"a")}},beforeunload:{postDispatch:function(e){e.result!==t&&(e.originalEvent.returnValue=e.result)}}},simulate:function(e,t,n,r){var i=x.extend(new x.Event,n,{type:e,isSimulated:!0,originalEvent:{}});r?x.event.trigger(i,null,t):x.event.dispatch.call(t,i),i.isDefaultPrevented()&&n.preventDefault()}},x.removeEvent=a.removeEventListener?function(e,t,n){e.removeEventListener&&e.removeEventListener(t,n,!1)}:function(e,t,n){var r="on"+t;e.detachEvent&&(typeof e[r]===i&&(e[r]=null),e.detachEvent(r,n))},x.Event=function(e,n){return this instanceof x.Event?(e&&e.type?(this.originalEvent=e,this.type=e.type,this.isDefaultPrevented=e.defaultPrevented||e.returnValue===!1||e.getPreventDefault&&e.getPreventDefault()?it:ot):this.type=e,n&&x.extend(this,n),this.timeStamp=e&&e.timeStamp||x.now(),this[x.expando]=!0,t):new x.Event(e,n)},x.Event.prototype={isDefaultPrevented:ot,isPropagationStopped:ot,isImmediatePropagationStopped:ot,preventDefault:function(){var e=this.originalEvent;this.isDefaultPrevented=it,e&&(e.preventDefault?e.preventDefault():e.returnValue=!1)},stopPropagation:function(){var e=this.originalEvent;this.isPropagationStopped=it,e&&(e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0)},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=it,this.stopPropagation()}},x.each({mouseenter:"mouseover",mouseleave:"mouseout"},function(e,t){x.event.special[e]={delegateType:t,bindType:t,handle:function(e){var n,r=this,i=e.relatedTarget,o=e.handleObj;return(!i||i!==r&&!x.contains(r,i))&&(e.type=o.origType,n=o.handler.apply(this,arguments),e.type=t),n}}}),x.support.submitBubbles||(x.event.special.submit={setup:function(){return x.nodeName(this,"form")?!1:(x.event.add(this,"click._submit keypress._submit",function(e){var n=e.target,r=x.nodeName(n,"input")||x.nodeName(n,"button")?n.form:t;r&&!x._data(r,"submitBubbles")&&(x.event.add(r,"submit._submit",function(e){e._submit_bubble=!0}),x._data(r,"submitBubbles",!0))}),t)},postDispatch:function(e){e._submit_bubble&&(delete e._submit_bubble,this.parentNode&&!e.isTrigger&&x.event.simulate("submit",this.parentNode,e,!0))},teardown:function(){return x.nodeName(this,"form")?!1:(x.event.remove(this,"._submit"),t)}}),x.support.changeBubbles||(x.event.special.change={setup:function(){return Z.test(this.nodeName)?(("checkbox"===this.type||"radio"===this.type)&&(x.event.add(this,"propertychange._change",function(e){"checked"===e.originalEvent.propertyName&&(this._just_changed=!0)}),x.event.add(this,"click._change",function(e){this._just_changed&&!e.isTrigger&&(this._just_changed=!1),x.event.simulate("change",this,e,!0)})),!1):(x.event.add(this,"beforeactivate._change",function(e){var t=e.target;Z.test(t.nodeName)&&!x._data(t,"changeBubbles")&&(x.event.add(t,"change._change",function(e){!this.parentNode||e.isSimulated||e.isTrigger||x.event.simulate("change",this.parentNode,e,!0)}),x._data(t,"changeBubbles",!0))}),t)},handle:function(e){var n=e.target;return this!==n||e.isSimulated||e.isTrigger||"radio"!==n.type&&"checkbox"!==n.type?e.handleObj.handler.apply(this,arguments):t},teardown:function(){return x.event.remove(this,"._change"),!Z.test(this.nodeName)}}),x.support.focusinBubbles||x.each({focus:"focusin",blur:"focusout"},function(e,t){var n=0,r=function(e){x.event.simulate(t,e.target,x.event.fix(e),!0)};x.event.special[t]={setup:function(){0===n++&&a.addEventListener(e,r,!0)},teardown:function(){0===--n&&a.removeEventListener(e,r,!0)}}}),x.fn.extend({on:function(e,n,r,i,o){var a,s;if("object"==typeof e){"string"!=typeof n&&(r=r||n,n=t);for(a in e)this.on(a,n,r,e[a],o);return this}if(null==r&&null==i?(i=n,r=n=t):null==i&&("string"==typeof n?(i=r,r=t):(i=r,r=n,n=t)),i===!1)i=ot;else if(!i)return this;return 1===o&&(s=i,i=function(e){return x().off(e),s.apply(this,arguments)},i.guid=s.guid||(s.guid=x.guid++)),this.each(function(){x.event.add(this,e,i,r,n)})},one:function(e,t,n,r){return this.on(e,t,n,r,1)},off:function(e,n,r){var i,o;if(e&&e.preventDefault&&e.handleObj)return i=e.handleObj,x(e.delegateTarget).off(i.namespace?i.origType+"."+i.namespace:i.origType,i.selector,i.handler),this;if("object"==typeof e){for(o in e)this.off(o,n,e[o]);return this}return(n===!1||"function"==typeof n)&&(r=n,n=t),r===!1&&(r=ot),this.each(function(){x.event.remove(this,e,r,n)})},trigger:function(e,t){return this.each(function(){x.event.trigger(e,t,this)})},triggerHandler:function(e,n){var r=this[0];return r?x.event.trigger(e,n,r,!0):t}});var st=/^.[^:#\[\.,]*$/,lt=/^(?:parents|prev(?:Until|All))/,ut=x.expr.match.needsContext,ct={children:!0,contents:!0,next:!0,prev:!0};x.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(x(e).filter(function(){for(t=0;i>t;t++)if(x.contains(r[t],this))return!0}));for(t=0;i>t;t++)x.find(e,r[t],n);return n=this.pushStack(i>1?x.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},has:function(e){var t,n=x(e,this),r=n.length;return this.filter(function(){for(t=0;r>t;t++)if(x.contains(this,n[t]))return!0})},not:function(e){return this.pushStack(ft(this,e||[],!0))},filter:function(e){return this.pushStack(ft(this,e||[],!1))},is:function(e){return!!ft(this,"string"==typeof e&&ut.test(e)?x(e):e||[],!1).length},closest:function(e,t){var n,r=0,i=this.length,o=[],a=ut.test(e)||"string"!=typeof e?x(e,t||this.context):0;for(;i>r;r++)for(n=this[r];n&&n!==t;n=n.parentNode)if(11>n.nodeType&&(a?a.index(n)>-1:1===n.nodeType&&x.find.matchesSelector(n,e))){n=o.push(n);break}return this.pushStack(o.length>1?x.unique(o):o)},index:function(e){return e?"string"==typeof e?x.inArray(this[0],x(e)):x.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){var n="string"==typeof e?x(e,t):x.makeArray(e&&e.nodeType?[e]:e),r=x.merge(this.get(),n);return this.pushStack(x.unique(r))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}});function pt(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}x.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return x.dir(e,"parentNode")},parentsUntil:function(e,t,n){return x.dir(e,"parentNode",n)},next:function(e){return pt(e,"nextSibling")},prev:function(e){return pt(e,"previousSibling")},nextAll:function(e){return x.dir(e,"nextSibling")},prevAll:function(e){return x.dir(e,"previousSibling")},nextUntil:function(e,t,n){return x.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return x.dir(e,"previousSibling",n)},siblings:function(e){return x.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return x.sibling(e.firstChild)},contents:function(e){return x.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:x.merge([],e.childNodes)}},function(e,t){x.fn[e]=function(n,r){var i=x.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=x.filter(r,i)),this.length>1&&(ct[e]||(i=x.unique(i)),lt.test(e)&&(i=i.reverse())),this.pushStack(i)}}),x.extend({filter:function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?x.find.matchesSelector(r,e)?[r]:[]:x.find.matches(e,x.grep(t,function(e){return 1===e.nodeType}))},dir:function(e,n,r){var i=[],o=e[n];while(o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!x(o).is(r)))1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){var n=[];for(;e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});function ft(e,t,n){if(x.isFunction(t))return x.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return x.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(st.test(t))return x.filter(t,e,n);t=x.filter(t,e)}return x.grep(e,function(e){return x.inArray(e,t)>=0!==n})}function dt(e){var t=ht.split("|"),n=e.createDocumentFragment();if(n.createElement)while(t.length)n.createElement(t.pop());return n}var ht="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",gt=/ jQuery\d+="(?:null|\d+)"/g,mt=RegExp("<(?:"+ht+")[\\s/>]","i"),yt=/^\s+/,vt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bt=/<([\w:]+)/,xt=/<tbody/i,wt=/<|&#?\w+;/,Tt=/<(?:script|style|link)/i,Ct=/^(?:checkbox|radio)$/i,Nt=/checked\s*(?:[^=]|=\s*.checked.)/i,kt=/^$|\/(?:java|ecma)script/i,Et=/^true\/(.*)/,St=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,At={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:x.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},jt=dt(a),Dt=jt.appendChild(a.createElement("div"));At.optgroup=At.option,At.tbody=At.tfoot=At.colgroup=At.caption=At.thead,At.th=At.td,x.fn.extend({text:function(e){return x.access(this,function(e){return e===t?x.text(this):this.empty().append((this[0]&&this[0].ownerDocument||a).createTextNode(e))},null,e,arguments.length)},append:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.appendChild(e)}})},prepend:function(){return this.domManip(arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Lt(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){var n,r=e?x.filter(e,this):this,i=0;for(;null!=(n=r[i]);i++)t||1!==n.nodeType||x.cleanData(Ft(n)),n.parentNode&&(t&&x.contains(n.ownerDocument,n)&&_t(Ft(n,"script")),n.parentNode.removeChild(n));return this},empty:function(){var e,t=0;for(;null!=(e=this[t]);t++){1===e.nodeType&&x.cleanData(Ft(e,!1));while(e.firstChild)e.removeChild(e.firstChild);e.options&&x.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return x.clone(this,e,t)})},html:function(e){return x.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,""):t;if(!("string"!=typeof e||Tt.test(e)||!x.support.htmlSerialize&&mt.test(e)||!x.support.leadingWhitespace&&yt.test(e)||At[(bt.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(vt,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(x.cleanData(Ft(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(){var e=x.map(this,function(e){return[e.nextSibling,e.parentNode]}),t=0;return this.domManip(arguments,function(n){var r=e[t++],i=e[t++];i&&(r&&r.parentNode!==i&&(r=this.nextSibling),x(this).remove(),i.insertBefore(n,r))},!0),t?this:this.remove()},detach:function(e){return this.remove(e,!0)},domManip:function(e,t,n){e=d.apply([],e);var r,i,o,a,s,l,u=0,c=this.length,p=this,f=c-1,h=e[0],g=x.isFunction(h);if(g||!(1>=c||"string"!=typeof h||x.support.checkClone)&&Nt.test(h))return this.each(function(r){var i=p.eq(r);g&&(e[0]=h.call(this,r,i.html())),i.domManip(e,t,n)});if(c&&(l=x.buildFragment(e,this[0].ownerDocument,!1,!n&&this),r=l.firstChild,1===l.childNodes.length&&(l=r),r)){for(a=x.map(Ft(l,"script"),Ht),o=a.length;c>u;u++)i=l,u!==f&&(i=x.clone(i,!0,!0),o&&x.merge(a,Ft(i,"script"))),t.call(this[u],i,u);if(o)for(s=a[a.length-1].ownerDocument,x.map(a,qt),u=0;o>u;u++)i=a[u],kt.test(i.type||"")&&!x._data(i,"globalEval")&&x.contains(s,i)&&(i.src?x._evalUrl(i.src):x.globalEval((i.text||i.textContent||i.innerHTML||"").replace(St,"")));l=r=null}return this}});function Lt(e,t){return x.nodeName(e,"table")&&x.nodeName(1===t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function Ht(e){return e.type=(null!==x.find.attr(e,"type"))+"/"+e.type,e}function qt(e){var t=Et.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function _t(e,t){var n,r=0;for(;null!=(n=e[r]);r++)x._data(n,"globalEval",!t||x._data(t[r],"globalEval"))}function Mt(e,t){if(1===t.nodeType&&x.hasData(e)){var n,r,i,o=x._data(e),a=x._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)x.event.add(t,n,s[n][r])}a.data&&(a.data=x.extend({},a.data))}}function Ot(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!x.support.noCloneEvent&&t[x.expando]){i=x._data(t);for(r in i.events)x.removeEvent(t,r,i.handle);t.removeAttribute(x.expando)}"script"===n&&t.text!==e.text?(Ht(t).text=e.text,qt(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),x.support.html5Clone&&e.innerHTML&&!x.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ct.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}x.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(e,t){x.fn[e]=function(e){var n,r=0,i=[],o=x(e),a=o.length-1;for(;a>=r;r++)n=r===a?this:this.clone(!0),x(o[r])[t](n),h.apply(i,n.get());return this.pushStack(i)}});function Ft(e,n){var r,o,a=0,s=typeof e.getElementsByTagName!==i?e.getElementsByTagName(n||"*"):typeof e.querySelectorAll!==i?e.querySelectorAll(n||"*"):t;if(!s)for(s=[],r=e.childNodes||e;null!=(o=r[a]);a++)!n||x.nodeName(o,n)?s.push(o):x.merge(s,Ft(o,n));return n===t||n&&x.nodeName(e,n)?x.merge([e],s):s}function Bt(e){Ct.test(e.type)&&(e.defaultChecked=e.checked)}x.extend({clone:function(e,t,n){var r,i,o,a,s,l=x.contains(e.ownerDocument,e);if(x.support.html5Clone||x.isXMLDoc(e)||!mt.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(Dt.innerHTML=e.outerHTML,Dt.removeChild(o=Dt.firstChild)),!(x.support.noCloneEvent&&x.support.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||x.isXMLDoc(e)))for(r=Ft(o),s=Ft(e),a=0;null!=(i=s[a]);++a)r[a]&&Ot(i,r[a]);if(t)if(n)for(s=s||Ft(e),r=r||Ft(o),a=0;null!=(i=s[a]);a++)Mt(i,r[a]);else Mt(e,o);return r=Ft(o,"script"),r.length>0&&_t(r,!l&&Ft(e,"script")),r=s=i=null,o},buildFragment:function(e,t,n,r){var i,o,a,s,l,u,c,p=e.length,f=dt(t),d=[],h=0;for(;p>h;h++)if(o=e[h],o||0===o)if("object"===x.type(o))x.merge(d,o.nodeType?[o]:o);else if(wt.test(o)){s=s||f.appendChild(t.createElement("div")),l=(bt.exec(o)||["",""])[1].toLowerCase(),c=At[l]||At._default,s.innerHTML=c[1]+o.replace(vt,"<$1></$2>")+c[2],i=c[0];while(i--)s=s.lastChild;if(!x.support.leadingWhitespace&&yt.test(o)&&d.push(t.createTextNode(yt.exec(o)[0])),!x.support.tbody){o="table"!==l||xt.test(o)?"<table>"!==c[1]||xt.test(o)?0:s:s.firstChild,i=o&&o.childNodes.length;while(i--)x.nodeName(u=o.childNodes[i],"tbody")&&!u.childNodes.length&&o.removeChild(u)}x.merge(d,s.childNodes),s.textContent="";while(s.firstChild)s.removeChild(s.firstChild);s=f.lastChild}else d.push(t.createTextNode(o));s&&f.removeChild(s),x.support.appendChecked||x.grep(Ft(d,"input"),Bt),h=0;while(o=d[h++])if((!r||-1===x.inArray(o,r))&&(a=x.contains(o.ownerDocument,o),s=Ft(f.appendChild(o),"script"),a&&_t(s),n)){i=0;while(o=s[i++])kt.test(o.type||"")&&n.push(o)}return s=null,f},cleanData:function(e,t){var n,r,o,a,s=0,l=x.expando,u=x.cache,c=x.support.deleteExpando,f=x.event.special;for(;null!=(n=e[s]);s++)if((t||x.acceptData(n))&&(o=n[l],a=o&&u[o])){if(a.events)for(r in a.events)f[r]?x.event.remove(n,r):x.removeEvent(n,r,a.handle);u[o]&&(delete u[o],c?delete n[l]:typeof n.removeAttribute!==i?n.removeAttribute(l):n[l]=null,p.push(o))}},_evalUrl:function(e){return x.ajax({url:e,type:"GET",dataType:"script",async:!1,global:!1,"throws":!0})}}),x.fn.extend({wrapAll:function(e){if(x.isFunction(e))return this.each(function(t){x(this).wrapAll(e.call(this,t))});if(this[0]){var t=x(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){var e=this;while(e.firstChild&&1===e.firstChild.nodeType)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return x.isFunction(e)?this.each(function(t){x(this).wrapInner(e.call(this,t))}):this.each(function(){var t=x(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=x.isFunction(e);return this.each(function(n){x(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){x.nodeName(this,"body")||x(this).replaceWith(this.childNodes)}).end()}});var Pt,Rt,Wt,$t=/alpha\([^)]*\)/i,It=/opacity\s*=\s*([^)]*)/,zt=/^(top|right|bottom|left)$/,Xt=/^(none|table(?!-c[ea]).+)/,Ut=/^margin/,Vt=RegExp("^("+w+")(.*)$","i"),Yt=RegExp("^("+w+")(?!px)[a-z%]+$","i"),Jt=RegExp("^([+-])=("+w+")","i"),Gt={BODY:"block"},Qt={position:"absolute",visibility:"hidden",display:"block"},Kt={letterSpacing:0,fontWeight:400},Zt=["Top","Right","Bottom","Left"],en=["Webkit","O","Moz","ms"];function tn(e,t){if(t in e)return t;var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=en.length;while(i--)if(t=en[i]+n,t in e)return t;return r}function nn(e,t){return e=t||e,"none"===x.css(e,"display")||!x.contains(e.ownerDocument,e)}function rn(e,t){var n,r,i,o=[],a=0,s=e.length;for(;s>a;a++)r=e[a],r.style&&(o[a]=x._data(r,"olddisplay"),n=r.style.display,t?(o[a]||"none"!==n||(r.style.display=""),""===r.style.display&&nn(r)&&(o[a]=x._data(r,"olddisplay",ln(r.nodeName)))):o[a]||(i=nn(r),(n&&"none"!==n||!i)&&x._data(r,"olddisplay",i?n:x.css(r,"display"))));for(a=0;s>a;a++)r=e[a],r.style&&(t&&"none"!==r.style.display&&""!==r.style.display||(r.style.display=t?o[a]||"":"none"));return e}x.fn.extend({css:function(e,n){return x.access(this,function(e,n,r){var i,o,a={},s=0;if(x.isArray(n)){for(o=Rt(e),i=n.length;i>s;s++)a[n[s]]=x.css(e,n[s],!1,o);return a}return r!==t?x.style(e,n,r):x.css(e,n)},e,n,arguments.length>1)},show:function(){return rn(this,!0)},hide:function(){return rn(this)},toggle:function(e){var t="boolean"==typeof e;return this.each(function(){(t?e:nn(this))?x(this).show():x(this).hide()})}}),x.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=Wt(e,"opacity");return""===n?"1":n}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":x.support.cssFloat?"cssFloat":"styleFloat"},style:function(e,n,r,i){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var o,a,s,l=x.camelCase(n),u=e.style;if(n=x.cssProps[l]||(x.cssProps[l]=tn(u,l)),s=x.cssHooks[n]||x.cssHooks[l],r===t)return s&&"get"in s&&(o=s.get(e,!1,i))!==t?o:u[n];if(a=typeof r,"string"===a&&(o=Jt.exec(r))&&(r=(o[1]+1)*o[2]+parseFloat(x.css(e,n)),a="number"),!(null==r||"number"===a&&isNaN(r)||("number"!==a||x.cssNumber[l]||(r+="px"),x.support.clearCloneStyle||""!==r||0!==n.indexOf("background")||(u[n]="inherit"),s&&"set"in s&&(r=s.set(e,r,i))===t)))try{u[n]=r}catch(c){}}},css:function(e,n,r,i){var o,a,s,l=x.camelCase(n);return n=x.cssProps[l]||(x.cssProps[l]=tn(e.style,l)),s=x.cssHooks[n]||x.cssHooks[l],s&&"get"in s&&(a=s.get(e,!0,r)),a===t&&(a=Wt(e,n,i)),"normal"===a&&n in Kt&&(a=Kt[n]),""===r||r?(o=parseFloat(a),r===!0||x.isNumeric(o)?o||0:a):a}}),e.getComputedStyle?(Rt=function(t){return e.getComputedStyle(t,null)},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s.getPropertyValue(n)||s[n]:t,u=e.style;return s&&(""!==l||x.contains(e.ownerDocument,e)||(l=x.style(e,n)),Yt.test(l)&&Ut.test(n)&&(i=u.width,o=u.minWidth,a=u.maxWidth,u.minWidth=u.maxWidth=u.width=l,l=s.width,u.width=i,u.minWidth=o,u.maxWidth=a)),l}):a.documentElement.currentStyle&&(Rt=function(e){return e.currentStyle},Wt=function(e,n,r){var i,o,a,s=r||Rt(e),l=s?s[n]:t,u=e.style;return null==l&&u&&u[n]&&(l=u[n]),Yt.test(l)&&!zt.test(n)&&(i=u.left,o=e.runtimeStyle,a=o&&o.left,a&&(o.left=e.currentStyle.left),u.left="fontSize"===n?"1em":l,l=u.pixelLeft+"px",u.left=i,a&&(o.left=a)),""===l?"auto":l});function on(e,t,n){var r=Vt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function an(e,t,n,r,i){var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;for(;4>o;o+=2)"margin"===n&&(a+=x.css(e,n+Zt[o],!0,i)),r?("content"===n&&(a-=x.css(e,"padding"+Zt[o],!0,i)),"margin"!==n&&(a-=x.css(e,"border"+Zt[o]+"Width",!0,i))):(a+=x.css(e,"padding"+Zt[o],!0,i),"padding"!==n&&(a+=x.css(e,"border"+Zt[o]+"Width",!0,i)));return a}function sn(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=Rt(e),a=x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,o);if(0>=i||null==i){if(i=Wt(e,t,o),(0>i||null==i)&&(i=e.style[t]),Yt.test(i))return i;r=a&&(x.support.boxSizingReliable||i===e.style[t]),i=parseFloat(i)||0}return i+an(e,t,n||(a?"border":"content"),r,o)+"px"}function ln(e){var t=a,n=Gt[e];return n||(n=un(e,t),"none"!==n&&n||(Pt=(Pt||x("<iframe frameborder='0' width='0' height='0'/>").css("cssText","display:block !important")).appendTo(t.documentElement),t=(Pt[0].contentWindow||Pt[0].contentDocument).document,t.write("<!doctype html><html><body>"),t.close(),n=un(e,t),Pt.detach()),Gt[e]=n),n}function un(e,t){var n=x(t.createElement(e)).appendTo(t.body),r=x.css(n[0],"display");return n.remove(),r}x.each(["height","width"],function(e,n){x.cssHooks[n]={get:function(e,r,i){return r?0===e.offsetWidth&&Xt.test(x.css(e,"display"))?x.swap(e,Qt,function(){return sn(e,n,i)}):sn(e,n,i):t},set:function(e,t,r){var i=r&&Rt(e);return on(e,t,r?an(e,n,r,x.support.boxSizing&&"border-box"===x.css(e,"boxSizing",!1,i),i):0)}}}),x.support.opacity||(x.cssHooks.opacity={get:function(e,t){return It.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=x.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===x.trim(o.replace($t,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=$t.test(o)?o.replace($t,i):o+" "+i)}}),x(function(){x.support.reliableMarginRight||(x.cssHooks.marginRight={get:function(e,n){return n?x.swap(e,{display:"inline-block"},Wt,[e,"marginRight"]):t}}),!x.support.pixelPosition&&x.fn.position&&x.each(["top","left"],function(e,n){x.cssHooks[n]={get:function(e,r){return r?(r=Wt(e,n),Yt.test(r)?x(e).position()[n]+"px":r):t}}})}),x.expr&&x.expr.filters&&(x.expr.filters.hidden=function(e){return 0>=e.offsetWidth&&0>=e.offsetHeight||!x.support.reliableHiddenOffsets&&"none"===(e.style&&e.style.display||x.css(e,"display"))},x.expr.filters.visible=function(e){return!x.expr.filters.hidden(e)}),x.each({margin:"",padding:"",border:"Width"},function(e,t){x.cssHooks[e+t]={expand:function(n){var r=0,i={},o="string"==typeof n?n.split(" "):[n];for(;4>r;r++)i[e+Zt[r]+t]=o[r]||o[r-2]||o[0];return i}},Ut.test(e)||(x.cssHooks[e+t].set=on)});var cn=/%20/g,pn=/\[\]$/,fn=/\r?\n/g,dn=/^(?:submit|button|image|reset|file)$/i,hn=/^(?:input|select|textarea|keygen)/i;x.fn.extend({serialize:function(){return x.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=x.prop(this,"elements");return e?x.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!x(this).is(":disabled")&&hn.test(this.nodeName)&&!dn.test(e)&&(this.checked||!Ct.test(e))}).map(function(e,t){var n=x(this).val();return null==n?null:x.isArray(n)?x.map(n,function(e){return{name:t.name,value:e.replace(fn,"\r\n")}}):{name:t.name,value:n.replace(fn,"\r\n")}}).get()}}),x.param=function(e,n){var r,i=[],o=function(e,t){t=x.isFunction(t)?t():null==t?"":t,i[i.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(n===t&&(n=x.ajaxSettings&&x.ajaxSettings.traditional),x.isArray(e)||e.jquery&&!x.isPlainObject(e))x.each(e,function(){o(this.name,this.value)});else for(r in e)gn(r,e[r],n,o);return i.join("&").replace(cn,"+")};function gn(e,t,n,r){var i;if(x.isArray(t))x.each(t,function(t,i){n||pn.test(e)?r(e,i):gn(e+"["+("object"==typeof i?t:"")+"]",i,n,r)});else if(n||"object"!==x.type(t))r(e,t);else for(i in t)gn(e+"["+i+"]",t[i],n,r)}x.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){x.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),x.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)},bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}});var mn,yn,vn=x.now(),bn=/\?/,xn=/#.*$/,wn=/([?&])_=[^&]*/,Tn=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Cn=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Nn=/^(?:GET|HEAD)$/,kn=/^\/\//,En=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Sn=x.fn.load,An={},jn={},Dn="*/".concat("*");try{yn=o.href}catch(Ln){yn=a.createElement("a"),yn.href="",yn=yn.href}mn=En.exec(yn.toLowerCase())||[];function Hn(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(T)||[];if(x.isFunction(n))while(r=o[i++])"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function qn(e,n,r,i){var o={},a=e===jn;function s(l){var u;return o[l]=!0,x.each(e[l]||[],function(e,l){var c=l(n,r,i);return"string"!=typeof c||a||o[c]?a?!(u=c):t:(n.dataTypes.unshift(c),s(c),!1)}),u}return s(n.dataTypes[0])||!o["*"]&&s("*")}function _n(e,n){var r,i,o=x.ajaxSettings.flatOptions||{};for(i in n)n[i]!==t&&((o[i]?e:r||(r={}))[i]=n[i]);return r&&x.extend(!0,e,r),e}x.fn.load=function(e,n,r){if("string"!=typeof e&&Sn)return Sn.apply(this,arguments);var i,o,a,s=this,l=e.indexOf(" ");return l>=0&&(i=e.slice(l,e.length),e=e.slice(0,l)),x.isFunction(n)?(r=n,n=t):n&&"object"==typeof n&&(a="POST"),s.length>0&&x.ajax({url:e,type:a,dataType:"html",data:n}).done(function(e){o=arguments,s.html(i?x("<div>").append(x.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},x.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){x.fn[t]=function(e){return this.on(t,e)}}),x.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Cn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":x.parseJSON,"text xml":x.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?_n(_n(e,x.ajaxSettings),t):_n(x.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,l,u,c,p=x.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?x(f):x.event,h=x.Deferred(),g=x.Callbacks("once memory"),m=p.statusCode||{},y={},v={},b=0,w="canceled",C={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return b||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this},abort:function(e){var t=e||w;return u&&u.abort(t),k(0,t),this}};if(h.promise(C).complete=g.add,C.success=C.done,C.error=C.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=x.trim(p.dataType||"*").toLowerCase().match(T)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?"80":"443"))===(mn[3]||("http:"===mn[1]?"80":"443")))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=x.param(p.data,p.traditional)),qn(An,p,n,C),2===b)return C;l=p.global,l&&0===x.active++&&x.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Nn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(x.lastModified[o]&&C.setRequestHeader("If-Modified-Since",x.lastModified[o]),x.etag[o]&&C.setRequestHeader("If-None-Match",x.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&C.setRequestHeader("Content-Type",p.contentType),C.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)C.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,C,p)===!1||2===b))return C.abort();w="abort";for(i in{success:1,error:1,complete:1})C[i](p[i]);if(u=qn(jn,p,n,C)){C.readyState=1,l&&d.trigger("ajaxSend",[C,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){C.abort("timeout")},p.timeout));try{b=1,u.send(y,k)}catch(N){if(!(2>b))throw N;k(-1,N)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,N=n;2!==b&&(b=2,s&&clearTimeout(s),u=t,a=i||"",C.readyState=e>0?4:0,c=e>=200&&300>e||304===e,r&&(w=Mn(p,C,r)),w=On(p,w,C,c),c?(p.ifModified&&(T=C.getResponseHeader("Last-Modified"),T&&(x.lastModified[o]=T),T=C.getResponseHeader("etag"),T&&(x.etag[o]=T)),204===e||"HEAD"===p.type?N="nocontent":304===e?N="notmodified":(N=w.state,y=w.data,v=w.error,c=!v)):(v=N,(e||!N)&&(N="error",0>e&&(e=0))),C.status=e,C.statusText=(n||N)+"",c?h.resolveWith(f,[y,N,C]):h.rejectWith(f,[C,N,v]),C.statusCode(m),m=t,l&&d.trigger(c?"ajaxSuccess":"ajaxError",[C,p,c?y:v]),g.fireWith(f,[C,N]),l&&(d.trigger("ajaxComplete",[C,p]),--x.active||x.event.trigger("ajaxStop")))}return C},getJSON:function(e,t,n){return x.get(e,t,n,"json")},getScript:function(e,n){return x.get(e,t,n,"script")}}),x.each(["get","post"],function(e,n){x[n]=function(e,r,i,o){return x.isFunction(r)&&(o=o||i,i=r,r=t),x.ajax({url:e,type:n,dataType:o,data:r,success:i})}});function Mn(e,n,r){var i,o,a,s,l=e.contents,u=e.dataTypes;while("*"===u[0])u.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in l)if(l[s]&&l[s].test(o)){u.unshift(s);break}if(u[0]in r)a=u[0];else{for(s in r){if(!u[0]||e.converters[s+" "+u[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==u[0]&&u.unshift(a),r[a]):t}function On(e,t,n,r){var i,o,a,s,l,u={},c=e.dataTypes.slice();if(c[1])for(a in e.converters)u[a.toLowerCase()]=e.converters[a];o=c.shift();while(o)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(a=u[l+" "+o]||u["* "+o],!a)for(i in u)if(s=i.split(" "),s[1]===o&&(a=u[l+" "+s[0]]||u["* "+s[0]])){a===!0?a=u[i]:u[i]!==!0&&(o=s[0],c.unshift(s[1]));break}if(a!==!0)if(a&&e["throws"])t=a(t);else try{t=a(t)}catch(p){return{state:"parsererror",error:a?p:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}x.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return x.globalEval(e),e}}}),x.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),x.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=a.head||x("head")[0]||a.documentElement;return{send:function(t,i){n=a.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var Fn=[],Bn=/(=)\?(?=&|$)|\?\?/;x.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Fn.pop()||x.expando+"_"+vn++;return this[e]=!0,e}}),x.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,l=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return l||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=x.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,l?n[l]=n[l].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||x.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,Fn.push(o)),s&&x.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}x.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=x.ajaxSettings.xhr(),x.support.cors=!!Rn&&"withCredentials"in Rn,Rn=x.support.ajax=!!Rn,Rn&&x.ajaxTransport(function(n){if(!n.crossDomain||x.support.cors){var r;return{send:function(i,o){var a,s,l=n.xhr();if(n.username?l.open(n.type,n.url,n.async,n.username,n.password):l.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)l[s]=n.xhrFields[s];n.mimeType&&l.overrideMimeType&&l.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)l.setRequestHeader(s,i[s])}catch(u){}l.send(n.hasContent&&n.data||null),r=function(e,i){var s,u,c,p;try{if(r&&(i||4===l.readyState))if(r=t,a&&(l.onreadystatechange=x.noop,$n&&delete Pn[a]),i)4!==l.readyState&&l.abort();else{p={},s=l.status,u=l.getAllResponseHeaders(),"string"==typeof l.responseText&&(p.text=l.responseText);try{c=l.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,u)},n.async?4===l.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},x(e).unload($n)),Pn[a]=r),l.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+w+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n=this.createTween(e,t),r=n.cur(),i=Yn.exec(t),o=i&&i[3]||(x.cssNumber[e]?"":"px"),a=(x.cssNumber[e]||"px"!==o&&+r)&&Yn.exec(x.css(n.elem,e)),s=1,l=20;if(a&&a[3]!==o){o=o||a[3],i=i||[],a=+r||1;do s=s||".5",a/=s,x.style(n.elem,e,a+o);while(s!==(s=n.cur()/r)&&1!==s&&--l)}return i&&(a=n.start=+a||+r||0,n.unit=o,n.end=i[1]?a+(i[1]+1)*i[2]:+i[2]),n}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=x.now()}function Zn(e,t,n){var r,i=(Qn[t]||[]).concat(Qn["*"]),o=0,a=i.length;for(;a>o;o++)if(r=i[o].call(n,t,e))return r}function er(e,t,n){var r,i,o=0,a=Gn.length,s=x.Deferred().always(function(){delete l.elem}),l=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,u.startTime+u.duration-t),r=n/u.duration||0,o=1-r,a=0,l=u.tweens.length;for(;l>a;a++)u.tweens[a].run(o);return s.notifyWith(e,[u,o,n]),1>o&&l?n:(s.resolveWith(e,[u]),!1)},u=s.promise({elem:e,props:x.extend({},t),opts:x.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=x.Tween(e,u.opts,t,n,u.opts.specialEasing[t]||u.opts.easing);return u.tweens.push(r),r},stop:function(t){var n=0,r=t?u.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)u.tweens[n].run(1);return t?s.resolveWith(e,[u,t]):s.rejectWith(e,[u,t]),this}}),c=u.props;for(tr(c,u.opts.specialEasing);a>o;o++)if(r=Gn[o].call(u,e,c,u.opts))return r;return x.map(c,Zn,u),x.isFunction(u.opts.start)&&u.opts.start.call(e,u),x.fx.timer(x.extend(l,{elem:e,anim:u,queue:u.opts.queue})),u.progress(u.opts.progress).done(u.opts.done,u.opts.complete).fail(u.opts.fail).always(u.opts.always)}function tr(e,t){var n,r,i,o,a;for(n in e)if(r=x.camelCase(n),i=t[r],o=e[n],x.isArray(o)&&(i=o[1],o=e[n]=o[0]),n!==r&&(e[r]=o,delete e[n]),a=x.cssHooks[r],a&&"expand"in a){o=a.expand(o),delete e[r];for(n in o)n in e||(e[n]=o[n],t[n]=i)}else t[r]=i}x.Animation=x.extend(er,{tweener:function(e,t){x.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,l,u=this,c={},p=e.style,f=e.nodeType&&nn(e),d=x._data(e,"fxshow");n.queue||(s=x._queueHooks(e,"fx"),null==s.unqueued&&(s.unqueued=0,l=s.empty.fire,s.empty.fire=function(){s.unqueued||l()}),s.unqueued++,u.always(function(){u.always(function(){s.unqueued--,x.queue(e,"fx").length||s.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[p.overflow,p.overflowX,p.overflowY],"inline"===x.css(e,"display")&&"none"===x.css(e,"float")&&(x.support.inlineBlockNeedsLayout&&"inline"!==ln(e.nodeName)?p.zoom=1:p.display="inline-block")),n.overflow&&(p.overflow="hidden",x.support.shrinkWrapBlocks||u.always(function(){p.overflow=n.overflow[0],p.overflowX=n.overflow[1],p.overflowY=n.overflow[2]}));for(r in t)if(i=t[r],Vn.exec(i)){if(delete t[r],o=o||"toggle"===i,i===(f?"hide":"show"))continue;c[r]=d&&d[r]||x.style(e,r)}if(!x.isEmptyObject(c)){d?"hidden"in d&&(f=d.hidden):d=x._data(e,"fxshow",{}),o&&(d.hidden=!f),f?x(e).show():u.done(function(){x(e).hide()}),u.done(function(){var t;x._removeData(e,"fxshow");for(t in c)x.style(e,t,c[t])});for(r in c)a=Zn(f?d[r]:0,r,u),r in d||(d[r]=a.start,f&&(a.end=a.start,a.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}x.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(x.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?x.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=x.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){x.fx.step[e.prop]?x.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[x.cssProps[e.prop]]||x.cssHooks[e.prop])?x.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},x.each(["toggle","show","hide"],function(e,t){var n=x.fn[t];x.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),x.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=x.isEmptyObject(e),o=x.speed(t,n,r),a=function(){var t=er(this,x.extend({},e),o);(i||x._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=x.timers,a=x._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&x.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=x._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=x.timers,a=r?r.length:0;for(n.finish=!0,x.queue(this,e,[]),i&&i.stop&&i.stop.call(this,!0),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}x.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){x.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),x.speed=function(e,t,n){var r=e&&"object"==typeof e?x.extend({},e):{complete:n||!n&&t||x.isFunction(e)&&e,duration:e,easing:n&&t||t&&!x.isFunction(t)&&t};return r.duration=x.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in x.fx.speeds?x.fx.speeds[r.duration]:x.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){x.isFunction(r.old)&&r.old.call(this),r.queue&&x.dequeue(this,r.queue)},r},x.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},x.timers=[],x.fx=rr.prototype.init,x.fx.tick=function(){var e,n=x.timers,r=0;for(Xn=x.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||x.fx.stop(),Xn=t},x.fx.timer=function(e){e()&&x.timers.push(e)&&x.fx.start()},x.fx.interval=13,x.fx.start=function(){Un||(Un=setInterval(x.fx.tick,x.fx.interval))},x.fx.stop=function(){clearInterval(Un),Un=null},x.fx.speeds={slow:600,fast:200,_default:400},x.fx.step={},x.expr&&x.expr.filters&&(x.expr.filters.animated=function(e){return x.grep(x.timers,function(t){return e===t.elem}).length}),x.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){x.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,x.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},x.offset={setOffset:function(e,t,n){var r=x.css(e,"position");"static"===r&&(e.style.position="relative");var i=x(e),o=i.offset(),a=x.css(e,"top"),s=x.css(e,"left"),l=("absolute"===r||"fixed"===r)&&x.inArray("auto",[a,s])>-1,u={},c={},p,f;l?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),x.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(u.top=t.top-o.top+p),null!=t.left&&(u.left=t.left-o.left+f),"using"in t?t.using.call(e,u):i.css(u)}},x.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===x.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),x.nodeName(e[0],"html")||(n=e.offset()),n.top+=x.css(e[0],"borderTopWidth",!0),n.left+=x.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-x.css(r,"marginTop",!0),left:t.left-n.left-x.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||s;while(e&&!x.nodeName(e,"html")&&"static"===x.css(e,"position"))e=e.offsetParent;return e||s})}}),x.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);x.fn[e]=function(i){return x.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?x(a).scrollLeft():o,r?o:x(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return x.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}x.each({Height:"height",Width:"width"},function(e,n){x.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){x.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return x.access(this,function(n,r,i){var o;return x.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?x.css(n,r,s):x.style(n,r,i,s)},n,a?i:t,a,null)}})}),x.fn.size=function(){return this.length},x.fn.andSelf=x.fn.addBack,"object"==typeof module&&module&&"object"==typeof module.exports?module.exports=x:(e.jQuery=e.$=x,"function"==typeof define&&define.amd&&define("jquery",[],function(){return x}))})(window);(function($){var cookie_local_prefix="ls_";var cookie_session_prefix="ss_";function _get(storage){var l=arguments.length,s=window[storage],a=arguments,a1=a[1],vi,ret,tmp;if(l<2)throw new Error('Minimum 2 arguments must be given');else if($.isArray(a1)){ret={};for(var i in a1){vi=a1[i];try{ret[vi]=JSON.parse(s.getItem(vi));}catch(e){ret[vi]=s.getItem(vi);}}
return ret;}else if(l==2){try{return JSON.parse(s.getItem(a1));}catch(e){return s.getItem(a1);}}else{try{ret=JSON.parse(s.getItem(a1));}catch(e){throw new ReferenceError(a1+' is not defined in this storage');}
for(var i=2;i<l-1;i++){ret=ret[a[i]];if(ret===undefined)throw new ReferenceError([].slice.call(a,1,i+1).join('.')+' is not defined in this storage');}
if($.isArray(a[i])){tmp=ret;ret={};for(var j in a[i]){ret[a[i][j]]=tmp[a[i][j]];}
return ret;}else{return ret[a[i]];}}}
function _set(storage){var l=arguments.length,s=window[storage],a=arguments,a1=a[1],a2=a[2],vi,to_store={},tmp;if(l<2||!$.isPlainObject(a1)&&l<3)throw new Error('Minimum 3 arguments must be given or second parameter must be an object');else if($.isPlainObject(a1)){for(var i in a1){vi=a1[i];if(!$.isPlainObject(vi))s.setItem(i,vi);else s.setItem(i,JSON.stringify(vi));}
return a1;}else if(l==3){if(typeof a2==='object')s.setItem(a1,JSON.stringify(a2));else s.setItem(a1,a2);return a2;}else{try{tmp=s.getItem(a1);if(tmp!=null){to_store=JSON.parse(tmp);}}catch(e){}
tmp=to_store;for(var i=2;i<l-2;i++){vi=a[i];if(!tmp[vi]||!$.isPlainObject(tmp[vi]))tmp[vi]={};tmp=tmp[vi];}
tmp[a[i]]=a[i+1];s.setItem(a1,JSON.stringify(to_store));return to_store;}}
function _remove(storage){var l=arguments.length,s=window[storage],a=arguments,a1=a[1],to_store,tmp;if(l<2)throw new Error('Minimum 2 arguments must be given');else if($.isArray(a1)){for(var i in a1){s.removeItem(a1[i]);}
return true;}else if(l==2){s.removeItem(a1);return true;}else{try{to_store=tmp=JSON.parse(s.getItem(a1));}catch(e){throw new ReferenceError(a1+' is not defined in this storage');}
for(var i=2;i<l-1;i++){tmp=tmp[a[i]];if(tmp===undefined)throw new ReferenceError([].slice.call(a,1,i).join('.')+' is not defined in this storage');}
if($.isArray(a[i])){for(var j in a[i]){delete tmp[a[i][j]];}}else{delete tmp[a[i]];}
s.setItem(a1,JSON.stringify(to_store));return true;}}
function _removeAll(storage,reinit_ns){var keys=_keys(storage);for(var i in keys){_remove(storage,keys[i]);}
if(reinit_ns){for(var i in $.namespaceStorages){_createNamespace(i);}}}
function _isEmpty(storage){var l=arguments.length,a=arguments,s=window[storage],a1=a[1];if(l==1){return(_keys(storage).length==0);}else if($.isArray(a1)){for(var i=0;i<a1.length;i++){if(!_isEmpty(storage,a1[i]))return false;}
return true;}else{try{var v=_get.apply(this,arguments);if(!$.isArray(a[l-1]))v={'totest':v};for(var i in v){if(!(($.isPlainObject(v[i])&&$.isEmptyObject(v[i]))||($.isArray(v[i])&&!v[i].length)||(!v[i])))return false;}
return true;}catch(e){return true;}}}
function _isSet(storage){var l=arguments.length,a=arguments,s=window[storage],a1=a[1];if(l<2)throw new Error('Minimum 2 arguments must be given');if($.isArray(a1)){for(var i=0;i<a1.length;i++){if(!_isSet(storage,a1[i]))return false;}
return true;}else{try{var v=_get.apply(this,arguments);if(!$.isArray(a[l-1]))v={'totest':v};for(var i in v){if(!(v[i]!==undefined&&v[i]!==null))return false;}
return true;}catch(e){return false;}}}
function _keys(storage){var l=arguments.length,s=window[storage],a=arguments,a1=a[1],keys=[],o={};if(l>1){o=_get.apply(this,a);}else{o=s;}
if(o._cookie){for(var key in $.cookie()){if(key!=''){keys.push(key.replace(o._prefix,''));}}}else{for(var i in o){keys.push(i);}}
return keys;}
function _createNamespace(name){if(!name||typeof name!="string")throw new Error('First parameter must be a string');if(!window.localStorage.getItem(name))window.localStorage.setItem(name,'{}');if(!window.sessionStorage.getItem(name))window.sessionStorage.setItem(name,'{}');var ns={localStorage:$.extend({},$.localStorage,{_ns:name}),sessionStorage:$.extend({},$.sessionStorage,{_ns:name})};if($.cookie){if(!window.cookieStorage.getItem(name))window.cookieStorage.setItem(name,'{}');ns.cookieStorage=$.extend({},$.cookieStorage,{_ns:name});}
$.namespaceStorages[name]=ns;return ns;}
var storage={_type:'',_ns:'',_callMethod:function(f,a){var p=[this._type];if(this._ns)p.push(this._ns);[].push.apply(p,a);return f.apply(this,p);},get:function(){return this._callMethod(_get,arguments);},set:function(){var l=arguments.length,a=arguments,a0=a[0];if(l<1||!$.isPlainObject(a0)&&l<2)throw new Error('Minimum 2 arguments must be given or first parameter must be an object');if($.isPlainObject(a0)&&this._ns){for(var i in a0){_set(this._type,this._ns,i,a0[i]);}
return a0;}else{r=this._callMethod(_set,a);if(this._ns)return r[a0];else return r;}},remove:function(){if(arguments.length<1)throw new Error('Minimum 1 argument must be given');return this._callMethod(_remove,arguments);},removeAll:function(reinit_ns){if(this._ns){_set(this._type,this._ns,{});return true;}else{return _removeAll(this._type,reinit_ns);}},isEmpty:function(){return this._callMethod(_isEmpty,arguments);},isSet:function(){if(arguments.length<1)throw new Error('Minimum 1 argument must be given');return this._callMethod(_isSet,arguments);},keys:function(){return this._callMethod(_keys,arguments);}};if($.cookie){if(!window.name)window.name=Math.floor(Math.random()*100000000);var cookie_storage={_cookie:true,_prefix:'',_expires:null,_path:null,_domain:null,setItem:function(n,v){$.cookie(this._prefix+n,v,{expires:this._expires,path:this._path,domain:this._domain});},getItem:function(n){return $.cookie(this._prefix+n);},removeItem:function(n){return $.removeCookie(this._prefix+n);},clear:function(){for(var key in $.cookie()){if(key!=''){if(!this._prefix&&key.indexOf(cookie_local_prefix)===-1&&key.indexOf(cookie_session_prefix)===-1||this._prefix&&key.indexOf(this._prefix)===0){$.removeCookie(key);}}}},setExpires:function(e){this._expires=e;return this;},setPath:function(p){this._path=p;return this;},setDomain:function(d){this._domain=d;return this;},setConf:function(c){if(c.path)this._path=c.path;if(c.domain)this._domain=c.domain;if(c.expires)this._expires=c.expires;return this;},setDefaultConf:function(){this._path=this._domain=this._expires=null;}};if(!window.localStorage){window.localStorage=$.extend({},cookie_storage,{_prefix:cookie_local_prefix,_expires:365*10});window.sessionStorage=$.extend({},cookie_storage,{_prefix:cookie_session_prefix+window.name+'_'});}
window.cookieStorage=$.extend({},cookie_storage);$.cookieStorage=$.extend({},storage,{_type:'cookieStorage',setExpires:function(e){window.cookieStorage.setExpires(e);return this;},setPath:function(p){window.cookieStorage.setPath(p);return this;},setDomain:function(d){window.cookieStorage.setDomain(d);return this;},setConf:function(c){window.cookieStorage.setConf(c);return this;},setDefaultConf:function(){window.cookieStorage.setDefaultConf();return this;}});}
$.initNamespaceStorage=function(ns){return _createNamespace(ns);};$.localStorage=$.extend({},storage,{_type:'localStorage'});$.sessionStorage=$.extend({},storage,{_type:'sessionStorage'});$.namespaceStorages={};$.removeAllStorages=function(reinit_ns){$.localStorage.removeAll(reinit_ns);$.sessionStorage.removeAll(reinit_ns);if($.cookieStorage)$.cookieStorage.removeAll(reinit_ns);if(!reinit_ns){$.namespaceStorages={};}}})(jQuery);(function($)
{var uuid=0;"use strict";var Range=function(range)
{this[0]=range.startOffset;this[1]=range.endOffset;this.range=range;return this;};Range.prototype.equals=function()
{return this[0]===this[1];};$.fn.redactor=function(options)
{var val=[];var args=Array.prototype.slice.call(arguments,1);if(typeof options==='string')
{this.each(function()
{var instance=$.data(this,'redactor');if(typeof instance!=='undefined'&&$.isFunction(instance[options]))
{var methodVal=instance[options].apply(instance,args);if(methodVal!==undefined&&methodVal!==instance)val.push(methodVal);}
else return $.error('No such method "'+options+'" for Redactor');});}
else
{this.each(function()
{if(!$.data(this,'redactor'))$.data(this,'redactor',Redactor(this,options));});}
if(val.length===0)return this;else if(val.length===1)return val[0];else return val;};function Redactor(el,options)
{return new Redactor.prototype.init(el,options);}
$.Redactor=Redactor;$.Redactor.VERSION='9.1.9';$.Redactor.opts={rangy:false,iframe:false,fullpage:false,css:false,lang:'en',direction:'ltr',placeholder:false,wym:false,mobile:true,cleanup:true,tidyHtml:true,pastePlainText:false,removeEmptyTags:true,templateVars:false,xhtml:false,visual:true,focus:false,tabindex:false,autoresize:true,minHeight:false,maxHeight:false,shortcuts:true,autosave:false,autosaveInterval:60,plugins:false,linkAnchor:true,linkEmail:true,linkProtocol:'http://',linkNofollow:false,linkSize:50,imageFloatMargin:'10px',imageGetJson:false,imageUpload:false,imageUploadParam:'file',fileUpload:false,fileUploadParam:'file',clipboardUpload:true,clipboardUploadUrl:false,dragUpload:true,dnbImageTypes:['image/png','image/jpeg','image/gif'],s3:false,uploadFields:false,observeImages:true,observeLinks:true,modalOverlay:true,tabSpaces:false,tabFocus:false,air:false,airButtons:['formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent'],toolbar:true,toolbarFixed:false,toolbarFixedTarget:document,toolbarFixedTopOffset:0,toolbarFixedBox:false,toolbarExternal:false,buttonSource:true,buttonSeparator:'<li class="redactor_separator"></li>',buttonsCustom:{},buttonsAdd:[],buttons:['html','|','formatting','|','bold','italic','deleted','|','unorderedlist','orderedlist','outdent','indent','|','image','video','file','table','link','|','alignment','|','horizontalrule'],activeButtons:['deleted','italic','bold','underline','unorderedlist','orderedlist','alignleft','aligncenter','alignright','justify','table'],activeButtonsStates:{b:'bold',strong:'bold',i:'italic',em:'italic',del:'deleted',strike:'deleted',ul:'unorderedlist',ol:'orderedlist',u:'underline',tr:'table',td:'table',table:'table'},activeButtonsAdd:false,formattingTags:['p','blockquote','pre','h1','h2','h3','h4','h5','h6'],linebreaks:false,paragraphy:true,convertDivs:true,convertLinks:true,convertImageLinks:false,convertVideoLinks:false,formattingPre:false,phpTags:false,allowedTags:false,deniedTags:['html','head','link','body','meta','script','style','applet'],boldTag:'strong',italicTag:'em',indentValue:20,buffer:[],rebuffer:[],textareamode:false,emptyHtml:'<p>&#x200b;</p>',invisibleSpace:'&#x200b;',rBlockTest:/^(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)$/i,alignmentTags:['P','H1','H2','H3','H4','H5','H6','DD','DL','DT','DIV','TD','BLOCKQUOTE','OUTPUT','FIGCAPTION','ADDRESS','SECTION','HEADER','FOOTER','ASIDE','ARTICLE'],ownLine:['area','body','head','hr','i?frame','link','meta','noscript','style','script','table','tbody','thead','tfoot'],contOwnLine:['li','dt','dt','h[1-6]','option','script'],newLevel:['blockquote','div','dl','fieldset','form','frameset','map','ol','p','pre','select','td','th','tr','ul'],blockLevelElements:['P','H1','H2','H3','H4','H5','H6','DD','DL','DT','DIV','LI','BLOCKQUOTE','OUTPUT','FIGCAPTION','PRE','ADDRESS','SECTION','HEADER','FOOTER','ASIDE','ARTICLE','TD'],langs:{en:{html:'HTML',video:pageContext.i18n.toolTipsInsertVideo,image:pageContext.i18n.inputImageForm,table:pageContext.i18n.toolTipsInsertTable,link:pageContext.i18n.toolTipLink,link_insert:pageContext.i18n.linkMenuInsertLink,link_edit:pageContext.i18n.linkMenuEditLink,unlink:pageContext.i18n.linkMenuUnlink,formatting:pageContext.i18n.formattingLabel,paragraph:pageContext.i18n.formattingParagraph,quote:pageContext.i18n.formattingQuote,code:pageContext.i18n.formattingCode,header:pageContext.i18n.formattingHeader,header1:'Header 1',header2:'Header 2',header3:'Header 3',header4:'Header 4',header5:'Header 5',bold:pageContext.i18n.formattingBold,italic:pageContext.i18n.formattingItalic,fontcolor:pageContext.i18n.formattingFontColor,backcolor:pageContext.i18n.formattingBackColor,unorderedlist:pageContext.i18n.toolTipsunorderedList,orderedlist:pageContext.i18n.toolTipsorderedList,outdent:pageContext.i18n.formattingOutdent,indent:pageContext.i18n.formattingIndent,cancel:pageContext.i18n.cancel,insert:pageContext.i18n.insert,save:pageContext.i18n.save,_delete:pageContext.i18n["delete"],insert_table:pageContext.i18n.tableInsert,insert_row_above:pageContext.i18n.tableInsertRowAbove,insert_row_below:pageContext.i18n.tableInsertRowBelow,insert_column_left:pageContext.i18n.tableInsertColumnLeft,insert_column_right:pageContext.i18n.tableInsertColumnRight,delete_column:pageContext.i18n.tableDeleteColumn,delete_row:pageContext.i18n.tableDeleteRow,delete_table:pageContext.i18n.tableDelete,rows:pageContext.i18n.tableRows,columns:pageContext.i18n.tableColumns,add_head:pageContext.i18n.tableAddHead,delete_head:pageContext.i18n.tableDeleteHead,title:pageContext.i18n.inputImageTitle,image_position:pageContext.i18n.inputImagePosition,none:pageContext.i18n.inputImagePositionNone,left:pageContext.i18n.inputImagePositionLeft,right:pageContext.i18n.inputImagePositionRight,image_web_link:'Image Web Link',text:pageContext.i18n.inputTextPrompt,mailto:pageContext.i18n.linkMenuMailto,web:pageContext.i18n.inputWebPrompt,video_html_code:'Video Embed Code',file:pageContext.i18n.toolTipsInsertFile,upload:pageContext.i18n.upload,download:pageContext.i18n.download,choose:pageContext.i18n.choose,or_choose:pageContext.i18n.uploadOrChoose,drop_file_here:pageContext.i18n.uploadDropFileHere,align_left:pageContext.i18n.formattingAlignLeft,align_center:pageContext.i18n.formattingAlignCenter,align_right:pageContext.i18n.formattingAlignRight,align_justify:pageContext.i18n.formattingAlignJustify,horizontalrule:pageContext.i18n.formattingHorizontalRule,deleted:pageContext.i18n.deleted,anchor:pageContext.i18n.linkMenuAnchor,link_new_tab:pageContext.i18n.inputLinkNewTab,underline:pageContext.i18n.formattingUnderline,alignment:pageContext.i18n.formattingAlignment,filename:pageContext.i18n.uploadFilenameOptional,edit:pageContext.i18n.edit}}};Redactor.fn=$.Redactor.prototype={keyCode:{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,ESC:27,TAB:9,CTRL:17,META:91,LEFT:37,LEFT_WIN:91},init:function(el,options)
{this.rtePaste=false;this.$element=this.$source=$(el);this.uuid=uuid++;var opts=$.extend(true,{},$.Redactor.opts);this.opts=$.extend({},opts,this.$element.data(),options);this.start=true;this.dropdowns=[];this.sourceHeight=this.$source.css('height');this.sourceWidth=this.$source.css('width');if(this.opts.fullpage)this.opts.iframe=true;if(this.opts.linebreaks)this.opts.paragraphy=false;if(this.opts.paragraphy)this.opts.linebreaks=false;if(this.opts.toolbarFixedBox)this.opts.toolbarFixed=true;this.document=document;this.window=window;this.savedSel=false;this.cleanlineBefore=new RegExp('^<(/?'+this.opts.ownLine.join('|/?')+'|'+this.opts.contOwnLine.join('|')+')[ >]');this.cleanlineAfter=new RegExp('^<(br|/?'+this.opts.ownLine.join('|/?')+'|/'+this.opts.contOwnLine.join('|/')+')[ >]');this.cleannewLevel=new RegExp('^</?('+this.opts.newLevel.join('|')+')[ >]');this.rTestBlock=new RegExp('^('+this.opts.blockLevelElements.join('|')+')$','i');if(this.opts.linebreaks===false)
{if(this.opts.allowedTags!==false)
{var arrSearch=['strong','em','del'];var arrAdd=['b','i','strike'];if($.inArray('p',this.opts.allowedTags)==='-1')this.opts.allowedTags.push('p');for(i in arrSearch)
{if($.inArray(arrSearch[i],this.opts.allowedTags)!='-1')this.opts.allowedTags.push(arrAdd[i]);}}
if(this.opts.deniedTags!==false)
{var pos=$.inArray('p',this.opts.deniedTags);if(pos!=='-1')this.opts.deniedTags.splice(pos,pos);}}
if(this.browser('msie')||this.browser('opera'))
{this.opts.buttons=this.removeFromArrayByValue(this.opts.buttons,'horizontalrule');}
this.opts.curLang=this.opts.langs[this.opts.lang];this.buildStart();},toolbarInit:function(lang)
{return{html:{title:lang.html,func:'toggle'},formatting:{title:lang.formatting,func:'show',dropdown:{p:{title:lang.paragraph,func:'formatBlocks'},blockquote:{title:lang.quote,func:'formatQuote',className:'redactor_format_blockquote'},pre:{title:lang.code,func:'formatBlocks',className:'redactor_format_pre'},h1:{title:lang.header+' 1',func:'formatBlocks',className:'redactor_format_h1'},h2:{title:lang.header+' 2',func:'formatBlocks',className:'redactor_format_h2'},h3:{title:lang.header+' 3',func:'formatBlocks',className:'redactor_format_h3'},h4:{title:lang.header+' 4',func:'formatBlocks',className:'redactor_format_h4'},h5:{title:lang.header+' 5',func:'formatBlocks',className:'redactor_format_h5'}}},bold:{title:lang.bold,exec:'bold'},italic:{title:lang.italic,exec:'italic'},deleted:{title:lang.deleted,exec:'strikethrough'},underline:{title:lang.underline,exec:'underline'},unorderedlist:{title:'&bull; '+lang.unorderedlist,exec:'insertunorderedlist'},orderedlist:{title:'1. '+lang.orderedlist,exec:'insertorderedlist'},outdent:{title:'< '+lang.outdent,func:'indentingOutdent'},indent:{title:'> '+lang.indent,func:'indentingIndent'},image:{title:lang.image,func:'imageShow'},video:{title:lang.video,func:'videoShow'},file:{title:lang.file,func:'fileShow'},table:{title:lang.table,func:'show',dropdown:{insert_table:{title:lang.insert_table,func:'tableShow'},separator_drop1:{name:'separator'},insert_row_above:{title:lang.insert_row_above,func:'tableAddRowAbove'},insert_row_below:{title:lang.insert_row_below,func:'tableAddRowBelow'},insert_column_left:{title:lang.insert_column_left,func:'tableAddColumnLeft'},insert_column_right:{title:lang.insert_column_right,func:'tableAddColumnRight'},separator_drop2:{name:'separator'},add_head:{title:lang.add_head,func:'tableAddHead'},delete_head:{title:lang.delete_head,func:'tableDeleteHead'},separator_drop3:{name:'separator'},delete_column:{title:lang.delete_column,func:'tableDeleteColumn'},delete_row:{title:lang.delete_row,func:'tableDeleteRow'},delete_table:{title:lang.delete_table,func:'tableDeleteTable'}}},link:{title:lang.link,func:'show',dropdown:{link:{title:lang.link_insert,func:'linkShow'},unlink:{title:lang.unlink,exec:'unlink'}}},fontcolor:{title:lang.fontcolor,func:'show'},backcolor:{title:lang.backcolor,func:'show'},alignment:{title:lang.alignment,func:'show',dropdown:{alignleft:{title:lang.align_left,func:'alignmentLeft'},aligncenter:{title:lang.align_center,func:'alignmentCenter'},alignright:{title:lang.align_right,func:'alignmentRight'},justify:{title:lang.align_justify,func:'alignmentJustify'}}},alignleft:{title:lang.align_left,func:'alignmentLeft'},aligncenter:{title:lang.align_center,func:'alignmentCenter'},alignright:{title:lang.align_right,func:'alignmentRight'},justify:{title:lang.align_justify,func:'alignmentJustify'},horizontalrule:{exec:'inserthorizontalrule',title:lang.horizontalrule}}},callback:function(type,event,data)
{var callback=this.opts[type+'Callback'];if($.isFunction(callback))
{if(event===false)return callback.call(this,data);else return callback.call(this,event,data);}
else return data;},destroy:function()
{clearInterval(this.autosaveInterval);$(window).off('.redactor');this.$source.off('redactor-textarea');this.$element.off('.redactor').removeData('redactor');var html=this.get();if(this.opts.textareamode)
{this.$box.after(this.$source);this.$box.remove();this.$source.val(html).show();}
else
{var $elem=this.$editor;if(this.opts.iframe)$elem=this.$element;this.$box.after($elem);this.$box.remove();$elem.removeClass('redactor_editor').removeClass('redactor_editor_wym').removeAttr('contenteditable').html(html).show();}
if(this.opts.air)
{$('#redactor_air_'+this.uuid).remove();}},getObject:function()
{return $.extend({},this);},getEditor:function()
{return this.$editor;},getBox:function()
{return this.$box;},getIframe:function()
{return(this.opts.iframe)?this.$frame:false;},getToolbar:function()
{return(this.$toolbar)?this.$toolbar:false;},get:function()
{return this.$source.val();},getCodeIframe:function()
{this.$editor.removeAttr('contenteditable').removeAttr('dir');var html=this.outerHtml(this.$frame.contents().children());this.$editor.attr({'contenteditable':true,'dir':this.opts.direction});return html;},set:function(html,strip,placeholderRemove)
{html=html.toString();html=html.replace(/\$/g,'&#36;');if(this.opts.fullpage)this.setCodeIframe(html);else this.setEditor(html,strip);if(html=='')placeholderRemove=false;if(placeholderRemove!==false)this.placeholderRemove();},setEditor:function(html,strip)
{if(strip!==false)
{html=this.cleanSavePreCode(html);html=this.cleanStripTags(html);html=this.cleanConvertProtected(html);html=this.cleanConvertInlineTags(html,true);if(this.opts.linebreaks===false)html=this.cleanConverters(html);else html=html.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,'$2<br>');}
html=html.replace(/&amp;#36;/g,'$');html=this.cleanEmpty(html);this.$editor.html(html);this.setNonEditable();this.setSpansVerified();this.sync();},setCodeIframe:function(html)
{var doc=this.iframePage();this.$frame[0].src="about:blank";html=this.cleanConvertProtected(html);html=this.cleanConvertInlineTags(html);html=this.cleanRemoveSpaces(html);doc.open();doc.write(html);doc.close();if(this.opts.fullpage)
{this.$editor=this.$frame.contents().find('body').attr({'contenteditable':true,'dir':this.opts.direction});}
this.setNonEditable();this.setSpansVerified();this.sync();},setFullpageOnInit:function(html)
{html=this.cleanSavePreCode(html,true);html=this.cleanConverters(html);html=this.cleanEmpty(html);this.$editor.html(html);this.setNonEditable();this.setSpansVerified();this.sync();},setSpansVerified:function()
{var spans=this.$editor.find('span');var replacementTag='inline';$.each(spans,function(){var outer=this.outerHTML;var regex=new RegExp('<'+this.tagName,'gi');var newTag=outer.replace(regex,'<'+replacementTag);regex=new RegExp('</'+this.tagName,'gi');newTag=newTag.replace(regex,'</'+replacementTag);$(this).replaceWith(newTag);});},setSpansVerifiedHtml:function(html)
{html=html.replace(/<span(.*?)>/,'<inline$1>');return html.replace(/<\/span>/,'</inline>');},setNonEditable:function()
{this.$editor.find('.noneditable').attr('contenteditable',false);},sync:function()
{var html='';this.cleanUnverified();if(this.opts.fullpage)html=this.getCodeIframe();else html=this.$editor.html();html=this.syncClean(html);html=this.cleanRemoveEmptyTags(html);html=html.replace(/<\/li><(ul|ol)>([\w\W]*?)<\/(ul|ol)>/gi,'<$1>$2</$1></li>');if($.trim(html)==='<br>')html='';if(this.opts.xhtml)
{var xhtmlTags=['br','hr','img','link','input','meta'];$.each(xhtmlTags,function(i,s)
{html=html.replace(new RegExp('<'+s+'(.*?[^\/$]?)>','gi'),'<'+s+'$1 />');});}
html=this.callback('syncBefore',false,html);this.$source.val(html);this.callback('syncAfter',false,html);if(this.start===false)
{this.callback('change',false,html);}},syncClean:function(html)
{if(!this.opts.fullpage)html=this.cleanStripTags(html);html=$.trim(html);html=this.placeholderRemoveFromCode(html);html=html.replace(/&#x200b;/gi,'');html=html.replace(/&#8203;/gi,'');html=html.replace(/<\/a>&nbsp;/gi,'<\/a> ');if(this.opts.linkNofollow)
{html=html.replace(/<a(.*?)rel="nofollow"(.*?)>/gi,'<a$1$2>');html=html.replace(/<a(.*?)>/gi,'<a$1 rel="nofollow">');}
html=html.replace('<!--?php','<?php');html=html.replace('?-->','?>');html=html.replace(/<(.*?)class="noeditable"(.*?) contenteditable="false"(.*?)>/gi,'<$1class="noeditable"$2$3>');html=html.replace(/ data-tagblock=""/gi,'');html=html.replace(/<br\s?\/?>\n?<\/(P|H[1-6]|LI|ADDRESS|SECTION|HEADER|FOOTER|ASIDE|ARTICLE)>/gi,'</$1>');html=html.replace(/<span(.*?)id="redactor-image-box"(.*?)>([\w\W]*?)<img(.*?)><\/span>/i,'$3<img$4>');html=html.replace(/<span(.*?)id="redactor-image-resizer"(.*?)>(.*?)<\/span>/i,'');html=html.replace(/<span(.*?)id="redactor-image-editter"(.*?)>(.*?)<\/span>/i,'');html=html.replace(/<font(.*?)>([\w\W]*?)<\/font>/gi,'$2');html=html.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,'$2');html=html.replace(/<inline>/gi,'<span>');html=html.replace(/<inline /gi,'<span ');html=html.replace(/<\/inline>/gi,'</span>');html=html.replace(/<span(.*?)class="redactor_placeholder"(.*?)>([\w\W]*?)<\/span>/gi,'');html=html.replace(/<span>([\w\W]*?)<\/span>/gi,'$1');html=html.replace(/&amp;/gi,'&');html=html.replace(/™/gi,'&trade;');html=html.replace(/©/gi,'&copy;');html=this.cleanReConvertProtected(html);return html;},buildStart:function()
{this.content='';this.$box=$('<div class="redactor_box" />');if(this.$source[0].tagName==='TEXTAREA')this.opts.textareamode=true;if(this.opts.mobile===false&&this.isMobile())
{this.buildMobile();}
else
{this.buildContent();if(this.opts.iframe)
{this.opts.autoresize=false;this.iframeStart();}
else if(this.opts.textareamode)this.buildFromTextarea();else this.buildFromElement();if(!this.opts.iframe)
{this.buildOptions();this.buildAfter();}}},buildMobile:function()
{if(!this.opts.textareamode)
{this.$editor=this.$source;this.$editor.hide();this.$source=this.buildCodearea(this.$editor);this.$source.val(this.content);}
this.$box.insertAfter(this.$source).append(this.$source);},buildContent:function()
{if(this.opts.textareamode)this.content=$.trim(this.$source.val());else this.content=$.trim(this.$source.html());},buildFromTextarea:function()
{this.$editor=$('<div />');this.$box.insertAfter(this.$source).append(this.$editor).append(this.$source);this.buildAddClasses(this.$editor);this.buildEnable();},buildFromElement:function()
{this.$editor=this.$source;this.$source=this.buildCodearea(this.$editor);this.$box.insertAfter(this.$editor).append(this.$editor).append(this.$source);this.buildEnable();},buildCodearea:function($source)
{return $('<textarea />').attr('name',$source.attr('id')).css('height',this.sourceHeight);},buildAddClasses:function(el)
{$.each(this.$source.get(0).className.split(/\s+/),function(i,s)
{el.addClass('redactor_'+s);});},buildEnable:function()
{this.$editor.addClass('redactor_editor').attr({'contenteditable':true,'dir':this.opts.direction});this.$source.attr('dir',this.opts.direction).hide();this.set(this.content,true,false);},buildOptions:function()
{var $source=this.$editor;if(this.opts.iframe)$source=this.$frame;if(this.opts.tabindex)$source.attr('tabindex',this.opts.tabindex);if(this.opts.minHeight)$source.css('min-height',this.opts.minHeight+'px');if(this.opts.maxHeight)
{this.opts.autoresize=false;this.sourceHeight=this.opts.maxHeight;}
if(this.opts.wym)this.$editor.addClass('redactor_editor_wym');if(!this.opts.autoresize)$source.css('height',this.sourceHeight);},buildAfter:function()
{this.start=false;if(this.opts.toolbar)
{this.opts.toolbar=this.toolbarInit(this.opts.curLang);this.toolbarBuild();}
this.modalTemplatesInit();this.buildPlugins();this.buildBindKeyboard();if(this.opts.autosave)this.autosave();setTimeout($.proxy(this.observeStart,this),4);if(this.browser('mozilla'))
{try{this.document.execCommand('enableObjectResizing',false,false);this.document.execCommand('enableInlineTableEditing',false,false);}catch(e){}}
if(this.opts.focus)setTimeout($.proxy(this.focus,this),100);if(!this.opts.visual)
{setTimeout($.proxy(function()
{this.opts.visual=true;this.toggle(false);},this),200);}
this.callback('init');},buildBindKeyboard:function()
{this.dblEnter=0;if(this.opts.dragUpload&&this.opts.imageUpload!==false)
{this.$editor.on('drop.redactor',$.proxy(this.buildEventDrop,this));}
this.$editor.on('paste.redactor',$.proxy(this.buildEventPaste,this));this.$editor.on('keydown.redactor',$.proxy(this.buildEventKeydown,this));this.$editor.on('keyup.redactor',$.proxy(this.buildEventKeyup,this));if($.isFunction(this.opts.textareaKeydownCallback))
{this.$source.on('keydown.redactor-textarea',$.proxy(this.opts.textareaKeydownCallback,this));}
if($.isFunction(this.opts.focusCallback))
{this.$editor.on('focus.redactor',$.proxy(this.opts.focusCallback,this));}
var clickedElement;$(document).mousedown(function(e){clickedElement=$(e.target);});this.$editor.on('blur.redactor',$.proxy(function(e)
{if(!$(clickedElement).hasClass('redactor_toolbar')&&$(clickedElement).parents('.redactor_toolbar').size()==0)
{this.selectall=false;if($.isFunction(this.opts.blurCallback))this.callback('blur',e);}},this));},buildEventDrop:function(e)
{e=e.originalEvent||e;if(window.FormData===undefined||!e.dataTransfer)return true;var length=e.dataTransfer.files.length;if(length==0)return true;e.preventDefault();var file=e.dataTransfer.files[0];if(this.opts.dnbImageTypes!==false&&this.opts.dnbImageTypes.indexOf(file.type)==-1)
{return true;}
this.bufferSet();var progress=$('<div id="redactor-progress-drag" class="redactor-progress redactor-progress-striped"><div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div></div>');$(document.body).append(progress);if(this.opts.s3===false)
{this.dragUploadAjax(this.opts.imageUpload,file,true,progress,e,this.opts.imageUploadParam);}
else
{this.s3uploadFile(file);}},buildEventPaste:function(e)
{var oldsafari=false;if(this.browser('webkit')&&navigator.userAgent.indexOf('Chrome')===-1)
{var arr=this.browser('version').split('.');if(arr[0]<536)oldsafari=true;}
if(oldsafari)return true;if(this.browser('opera'))return true;if(this.opts.clipboardUpload&&this.buildEventClipboardUpload(e))return true;if(this.opts.cleanup)
{this.rtePaste=true;this.selectionSave();if(!this.selectall)
{if(this.opts.autoresize===true&&this.fullscreen!==true)
{this.$editor.height(this.$editor.height());this.saveScroll=this.document.body.scrollTop;}
else
{this.saveScroll=this.$editor.scrollTop();}}
var frag=this.extractContent();setTimeout($.proxy(function()
{var pastedFrag=this.extractContent();this.$editor.append(frag);this.selectionRestore();var html=this.getFragmentHtml(pastedFrag);this.pasteClean(html);if(this.opts.autoresize===true&&this.fullscreen!==true)this.$editor.css('height','auto');},this),1);}},buildEventClipboardUpload:function(e)
{var event=e.originalEvent||e;this.clipboardFilePaste=false;if(typeof(event.clipboardData)==='undefined')return false;if(event.clipboardData.items)
{var file=event.clipboardData.items[0].getAsFile();if(file!==null)
{this.bufferSet();this.clipboardFilePaste=true;var reader=new FileReader();reader.onload=$.proxy(this.pasteClipboardUpload,this);reader.readAsDataURL(file);return true;}}
return false;},buildEventKeydown:function(e)
{if(this.rtePaste)return false;var key=e.which;var ctrl=e.ctrlKey||e.metaKey;var parent=this.getParent();var current=this.getCurrent();var block=this.getBlock();var pre=false;this.callback('keydown',e);this.imageResizeHide(false);if((parent&&$(parent).get(0).tagName==='PRE')||(current&&$(current).get(0).tagName==='PRE'))
{pre=true;if(key===this.keyCode.DOWN)this.insertAfterLastElement(block);}
if(key===this.keyCode.DOWN)
{if(parent&&$(parent)[0].tagName==='BLOCKQUOTE')this.insertAfterLastElement(parent);if(current&&$(current)[0].tagName==='BLOCKQUOTE')this.insertAfterLastElement(current);if(parent&&$(parent)[0].tagName==='P'&&$(parent).parent()[0].tagName=='BLOCKQUOTE')
{this.insertAfterLastElement(parent,$(parent).parent()[0]);}
if(current&&$(current)[0].tagName==='P'&&parent&&$(parent)[0].tagName=='BLOCKQUOTE')
{this.insertAfterLastElement(current,parent);}}
if(ctrl&&!e.shiftKey)this.shortcuts(e,key);if(ctrl&&key===90&&!e.shiftKey&&!e.altKey)
{e.preventDefault();if(this.opts.buffer.length)this.bufferUndo();else this.document.execCommand('undo',false,false);return;}
else if(ctrl&&key===90&&e.shiftKey&&!e.altKey)
{e.preventDefault();if(this.opts.rebuffer.length!=0)this.bufferRedo();else this.document.execCommand('redo',false,false);return;}
if(ctrl&&key===65)this.selectall=true;else if(key!=this.keyCode.LEFT_WIN&&!ctrl)this.selectall=false;if(key==this.keyCode.ENTER&&!e.shiftKey&&!e.ctrlKey&&!e.metaKey)
{if(this.browser('msie')&&(parent.nodeType==1&&(parent.tagName=='TD'||parent.tagName=='TH')))
{e.preventDefault();this.bufferSet();this.insertNode(document.createElement('br'));this.callback('enter',e);return false;}
if(block&&(block.tagName=='BLOCKQUOTE'||$(block).parent()[0].tagName=='BLOCKQUOTE'))
{if(this.isEndOfElement())
{if(this.dblEnter==1)
{var element;var last;if(block.tagName=='BLOCKQUOTE')
{last='br';element=block;}
else
{last='p';element=$(block).parent()[0];}
e.preventDefault();this.insertingAfterLastElement(element);this.dblEnter=0;if(last=='p')
{$(block).parent().find('p').last().remove();}
else
{var tmp=$.trim($(block).html());$(block).html(tmp.replace(/<br\s?\/?>$/i,''));}
return;}
else this.dblEnter++;}
else this.dblEnter++;}
if(pre===true)return this.buildEventKeydownPre(e,current);else
{if(!this.opts.linebreaks)
{if(block&&this.opts.rBlockTest.test(block.tagName))
{this.bufferSet();setTimeout($.proxy(function()
{var blockElem=this.getBlock();if(blockElem.tagName==='DIV'&&!$(blockElem).hasClass('redactor_editor'))
{var node=$('<p>'+this.opts.invisibleSpace+'</p>');$(blockElem).replaceWith(node);this.selectionStart(node);}},this),1);}
else if(block===false)
{this.bufferSet();var node=$('<p>'+this.opts.invisibleSpace+'</p>');this.insertNode(node[0]);this.selectionStart(node);this.callback('enter',e);return false;}}
if(this.opts.linebreaks)
{if(block&&this.opts.rBlockTest.test(block.tagName))
{this.bufferSet();setTimeout($.proxy(function()
{var blockElem=this.getBlock();if((blockElem.tagName==='DIV'||blockElem.tagName==='P')&&!$(blockElem).hasClass('redactor_editor'))
{this.replaceLineBreak(blockElem);}},this),1);}
else
{return this.buildEventKeydownInsertLineBreak(e);}}
if(block.tagName=='BLOCKQUOTE'||block.tagName=='FIGCAPTION')
{return this.buildEventKeydownInsertLineBreak(e);}}
this.callback('enter',e);}
else if(key===this.keyCode.ENTER&&(e.ctrlKey||e.shiftKey))
{this.bufferSet();e.preventDefault();this.insertLineBreak();}
if(key===this.keyCode.TAB&&this.opts.shortcuts)return this.buildEventKeydownTab(e,pre);if(key===this.keyCode.BACKSPACE)this.buildEventKeydownBackspace(current);},buildEventKeydownPre:function(e,current)
{e.preventDefault();this.bufferSet();var html=$(current).parent().text();this.insertNode(document.createTextNode('\n'));if(html.search(/\s$/)==-1)
{this.insertNode(document.createTextNode('\n'));}
this.sync();this.callback('enter',e);return false;},buildEventKeydownTab:function(e,pre)
{if(!this.opts.tabFocus)return true;if(this.isEmpty(this.get())&&this.opts.tabSpaces===false)return true;e.preventDefault();if(pre===true&&!e.shiftKey)
{this.bufferSet();this.insertNode(document.createTextNode('\t'));this.sync();return false;}
else if(this.opts.tabSpaces!==false)
{this.bufferSet();this.insertNode(document.createTextNode(Array(this.opts.tabSpaces+1).join('\u00a0')));this.sync();return false;}
else
{if(!e.shiftKey)this.indentingIndent();else this.indentingOutdent();}
return false;},buildEventKeydownBackspace:function(current)
{if(typeof current.tagName!=='undefined'&&/^(H[1-6])$/i.test(current.tagName))
{var node;if(this.opts.linebreaks===false)node=$('<p>'+this.opts.invisibleSpace+'</p>');else node=$('<br>'+this.opts.invisibleSpace);$(current).replaceWith(node);this.selectionStart(node);}
if(typeof current.nodeValue!=='undefined'&&current.nodeValue!==null)
{if(current.remove&&current.nodeType===3&&current.nodeValue.match(/[^/\u200B]/g)==null)
{current.remove();}}},buildEventKeydownInsertLineBreak:function(e)
{this.bufferSet();e.preventDefault();this.insertLineBreak();this.callback('enter',e);return;},buildEventKeyup:function(e)
{if(this.rtePaste)return false;var key=e.which;var parent=this.getParent();var current=this.getCurrent();if(!this.opts.linebreaks&&current.nodeType==3&&(parent==false||parent.tagName=='BODY'))
{var node=$('<p>').append($(current).clone());$(current).replaceWith(node);var next=$(node).next();if(typeof(next[0])!=='undefined'&&next[0].tagName=='BR')
{next.remove();}
this.selectionEnd(node);}
if((this.opts.convertLinks||this.opts.convertImageLinks||this.opts.convertVideoLinks)&&key===this.keyCode.ENTER)
{this.buildEventKeyupConverters();}
if(key===this.keyCode.DELETE||key===this.keyCode.BACKSPACE)
{return this.formatEmpty(e);}
this.callback('keyup',e);this.sync();},buildEventKeyupConverters:function()
{this.formatLinkify(this.opts.linkProtocol,this.opts.convertLinks,this.opts.convertImageLinks,this.opts.convertVideoLinks,this.opts.linkSize);setTimeout($.proxy(function()
{if(this.opts.convertImageLinks)this.observeImages();if(this.opts.observeLinks)this.observeLinks();},this),5);},buildPlugins:function()
{if(!this.opts.plugins)return;$.each(this.opts.plugins,$.proxy(function(i,s)
{if(RedactorPlugins[s])
{$.extend(this,RedactorPlugins[s]);if($.isFunction(RedactorPlugins[s].init))this.init();}},this));},iframeStart:function()
{this.iframeCreate();if(this.opts.textareamode)this.iframeAppend(this.$source);else
{this.$sourceOld=this.$source.hide();this.$source=this.buildCodearea(this.$sourceOld);this.iframeAppend(this.$sourceOld);}},iframeAppend:function(el)
{this.$source.attr('dir',this.opts.direction).hide();this.$box.insertAfter(el).append(this.$frame).append(this.$source);},iframeCreate:function()
{this.$frame=$('<iframe style="width: 100%;" frameborder="0" />').one('load',$.proxy(function()
{if(this.opts.fullpage)
{this.iframePage();if(this.content==='')this.content=this.opts.invisibleSpace;this.$frame.contents()[0].write(this.content);this.$frame.contents()[0].close();var timer=setInterval($.proxy(function()
{if(this.$frame.contents().find('body').html())
{clearInterval(timer);this.iframeLoad();}},this),0);}
else this.iframeLoad();},this));},iframeDoc:function()
{return this.$frame[0].contentWindow.document;},iframePage:function()
{var doc=this.iframeDoc();if(doc.documentElement)doc.removeChild(doc.documentElement);return doc;},iframeAddCss:function(css)
{css=css||this.opts.css;if(this.isString(css))
{this.$frame.contents().find('head').append('<link rel="stylesheet" href="'+css+'" />');}
if($.isArray(css))
{$.each(css,$.proxy(function(i,url)
{this.iframeAddCss(url);},this));}},iframeLoad:function()
{this.$editor=this.$frame.contents().find('body').attr({'contenteditable':true,'dir':this.opts.direction});if(this.$editor[0])
{this.document=this.$editor[0].ownerDocument;this.window=this.document.defaultView||window;}
this.iframeAddCss();if(this.opts.fullpage)this.setFullpageOnInit(this.$editor.html());else this.set(this.content,true,false);this.buildOptions();this.buildAfter();},placeholderStart:function(html)
{if(this.isEmpty(html))
{if(this.$element.attr('placeholder'))this.opts.placeholder=this.$element.attr('placeholder');if(this.opts.placeholder==='')this.opts.placeholder=false;if(this.opts.placeholder!==false)
{this.opts.focus=false;this.$editor.one('focus.redactor_placeholder',$.proxy(this.placeholderFocus,this));return $('<span class="redactor_placeholder" data-redactor="verified">').attr('contenteditable',false).text(this.opts.placeholder);}}
return false;},placeholderFocus:function()
{this.$editor.find('span.redactor_placeholder').remove();var html='';if(this.opts.linebreaks===false)html=this.opts.emptyHtml;this.$editor.off('focus.redactor_placeholder');this.$editor.html(html);if(this.opts.linebreaks===false)
{this.selectionStart(this.$editor.children()[0]);}
else
{this.focus();}
this.sync();},placeholderRemove:function()
{this.opts.placeholder=false;this.$editor.find('span.redactor_placeholder').remove();this.$editor.off('focus.redactor_placeholder');},placeholderRemoveFromCode:function(html)
{return html.replace(/<span class="redactor_placeholder"(.*?)>(.*?)<\/span>/i,'');},shortcuts:function(e,key)
{if(!this.opts.shortcuts)return;if(!e.altKey)
{if(key===77)this.shortcutsLoad(e,'removeFormat');else if(key===66)this.shortcutsLoad(e,'bold');else if(key===73)this.shortcutsLoad(e,'italic');else if(key===74)this.shortcutsLoad(e,'insertunorderedlist');else if(key===75)this.shortcutsLoad(e,'insertorderedlist');else if(key===72)this.shortcutsLoad(e,'superscript');else if(key===76)this.shortcutsLoad(e,'subscript');}},shortcutsLoad:function(e,cmd)
{e.preventDefault();this.execCommand(cmd,false);},shortcutsLoadFormat:function(e,cmd)
{e.preventDefault();this.formatBlocks(cmd);},focus:function()
{if(!this.browser('opera'))this.window.setTimeout($.proxy(this.focusSet,this,true),1);else this.$editor.focus();},focusEnd:function()
{this.focusSet();},focusSet:function(collapse)
{this.$editor.focus();var range=this.getRange();range.selectNodeContents(this.$editor[0]);range.collapse(collapse||false);var sel=this.getSelection();sel.removeAllRanges();sel.addRange(range);},toggle:function(direct)
{if(this.opts.visual)this.toggleCode(direct);else this.toggleVisual();},toggleVisual:function()
{var html=this.$source.hide().val();if(typeof this.modified!=='undefined')
{this.modified=this.cleanRemoveSpaces(this.modified,false)!==this.cleanRemoveSpaces(html,false);}
if(this.modified)
{if(this.opts.fullpage&&html==='')this.setFullpageOnInit(html);else
{this.set(html);if(this.opts.fullpage)this.buildBindKeyboard();}}
if(this.opts.iframe)this.$frame.show();else this.$editor.show();if(this.opts.fullpage)this.$editor.attr('contenteditable',true);this.$source.off('keydown.redactor-textarea-indenting');this.$editor.focus();this.selectionRestore();this.observeStart();this.buttonActiveVisual();this.buttonInactive('html');this.opts.visual=true;},toggleCode:function(direct)
{if(direct!==false)this.selectionSave();var height=null;if(this.opts.iframe)
{height=this.$frame.height();if(this.opts.fullpage)this.$editor.removeAttr('contenteditable');this.$frame.hide();}
else
{height=this.$editor.innerHeight();this.$editor.hide();}
var html=this.$source.val();if(html!==''&&this.opts.tidyHtml)
{this.$source.val(this.cleanHtml(html));}
this.modified=html;this.$source.height(height).show().focus();this.$source.on('keydown.redactor-textarea-indenting',this.textareaIndenting);this.buttonInactiveVisual();this.buttonActive('html');this.opts.visual=false;},textareaIndenting:function(e)
{if(e.keyCode===9)
{var $el=$(this);var start=$el.get(0).selectionStart;$el.val($el.val().substring(0,start)+"\t"+$el.val().substring($el.get(0).selectionEnd));$el.get(0).selectionStart=$el.get(0).selectionEnd=start+1;return false;}},autosave:function()
{var savedHtml=false;this.autosaveInterval=setInterval($.proxy(function()
{var html=this.get();if(savedHtml!==html)
{$.ajax({url:this.opts.autosave,type:'post',data:this.$source.attr('name')+'='+escape(encodeURIComponent(html)),success:$.proxy(function(data)
{this.callback('autosave',false,data);savedHtml=html;},this)});}},this),this.opts.autosaveInterval*1000);},toolbarBuild:function()
{if(this.opts.air)
{this.opts.buttons=this.opts.airButtons;}
else
{if(!this.opts.buttonSource)
{var index=this.opts.buttons.indexOf('html'),next=this.opts.buttons[index+1];this.opts.buttons.splice(index,1);if(next==='|')this.opts.buttons.splice(index,1);}}
$.extend(this.opts.toolbar,this.opts.buttonsCustom);$.each(this.opts.buttonsAdd,$.proxy(function(i,s)
{this.opts.buttons.push(s);},this));if(this.opts.toolbar)
{$.each(this.opts.toolbar.formatting.dropdown,$.proxy(function(i,s)
{if($.inArray(i,this.opts.formattingTags)=='-1')delete this.opts.toolbar.formatting.dropdown[i];},this));}
if(this.opts.buttons.length===0)return false;this.airEnable();this.$toolbar=$('<ul>').addClass('redactor_toolbar').attr('id','redactor_toolbar_'+this.uuid);if(this.opts.air)
{this.$air=$('<div class="redactor_air">').attr('id','redactor_air_'+this.uuid).hide();this.$air.append(this.$toolbar);$('body').append(this.$air);}
else
{if(this.opts.toolbarExternal)$(this.opts.toolbarExternal).html(this.$toolbar);else this.$box.prepend(this.$toolbar);}
$.each(this.opts.buttons,$.proxy(function(i,btnName)
{if(btnName==='|')this.$toolbar.append($(this.opts.buttonSeparator));else if(this.opts.toolbar[btnName])
{var btnObject=this.opts.toolbar[btnName];if(this.opts.fileUpload===false&&btnName==='file')return true;this.$toolbar.append($('<li>').append(this.buttonBuild(btnName,btnObject)));}},this));this.$toolbar.find('a').attr('tabindex','-1');if(this.opts.toolbarFixed)
{this.toolbarObserveScroll();$(this.opts.toolbarFixedTarget).on('scroll.redactor',$.proxy(this.toolbarObserveScroll,this));}
if(this.opts.activeButtons)
{var buttonActiveObserver=$.proxy(this.buttonActiveObserver,this);this.$editor.on('mouseup.redactor keyup.redactor',buttonActiveObserver);}},toolbarObserveScroll:function()
{var scrollTop=$(this.opts.toolbarFixedTarget).scrollTop();var boxTop=this.$box.offset().top;var left=0;var end=boxTop+this.$box.height()+40;if(scrollTop>boxTop)
{var width='100%';if(this.opts.toolbarFixedBox)
{left=this.$box.offset().left;width=this.$box.innerWidth();this.$toolbar.addClass('toolbar_fixed_box');}
this.toolbarFixed=true;this.$toolbar.css({position:'fixed',width:width,zIndex:1005,top:this.opts.toolbarFixedTopOffset+'px',left:left});if(scrollTop<end)this.$toolbar.css('visibility','visible');else this.$toolbar.css('visibility','hidden');}
else
{this.toolbarFixed=false;this.$toolbar.css({position:'relative',width:'auto',top:0,left:left});if(this.opts.toolbarFixedBox)this.$toolbar.removeClass('toolbar_fixed_box');}},airEnable:function()
{if(!this.opts.air)return;this.$editor.on('mouseup.redactor keyup.redactor',this,$.proxy(function(e)
{var text=this.getSelectionText();if(e.type==='mouseup'&&text!='')this.airShow(e);if(e.type==='keyup'&&e.shiftKey&&text!='')
{var $focusElem=$(this.getElement(this.getSelection().focusNode)),offset=$focusElem.offset();offset.height=$focusElem.height();this.airShow(offset,true);}},this));},airShow:function(e,keyboard)
{if(!this.opts.air)return;var left,top;$('.redactor_air').hide();if(keyboard)
{left=e.left;top=e.top+e.height+14;if(this.opts.iframe)
{top+=this.$box.position().top-$(this.document).scrollTop();left+=this.$box.position().left;}}
else
{var width=this.$air.innerWidth();left=e.clientX;if($(this.document).width()<(left+width))left-=width;top=e.clientY+14;if(this.opts.iframe)
{top+=this.$box.position().top;left+=this.$box.position().left;}
else top+=$(this.document).scrollTop();}
this.$air.css({left:left+'px',top:top+'px'}).show();this.airBindHide();},airBindHide:function()
{if(!this.opts.air)return;var hideHandler=$.proxy(function(doc)
{$(doc).on('mousedown.redactor',$.proxy(function(e)
{if($(e.target).closest(this.$toolbar).length===0)
{this.$air.fadeOut(100);this.selectionRemove();$(doc).off(e);}},this)).on('keydown.redactor',$.proxy(function(e)
{if(e.which===this.keyCode.ESC)
{this.getSelection().collapseToStart();}
this.$air.fadeOut(100);$(doc).off(e);},this));},this);hideHandler(document);if(this.opts.iframe)hideHandler(this.document);},airBindMousemoveHide:function()
{if(!this.opts.air)return;var hideHandler=$.proxy(function(doc)
{$(doc).on('mousemove.redactor',$.proxy(function(e)
{if($(e.target).closest(this.$toolbar).length===0)
{this.$air.fadeOut(100);$(doc).off(e);}},this));},this);hideHandler(document);if(this.opts.iframe)hideHandler(this.document);},dropdownBuild:function($dropdown,dropdownObject)
{$.each(dropdownObject,$.proxy(function(btnName,btnObject)
{if(!btnObject.className)btnObject.className='';var $item;if(btnObject.name==='separator')$item=$('<a class="redactor_separator_drop">');else
{$item=$('<a href="#" class="'+btnObject.className+' redactor_dropdown_'+btnName+'">'+btnObject.title+'</a>');$item.on('click',$.proxy(function(e)
{if(e.preventDefault)e.preventDefault();if(this.browser('msie'))e.returnValue=false;if(btnObject.callback)btnObject.callback.call(this,btnName,$item,btnObject,e);if(btnObject.exec)this.execCommand(btnObject.exec,btnName);if(btnObject.func)this[btnObject.func](btnName);this.buttonActiveObserver();if(this.opts.air)this.$air.fadeOut(100);},this));}
$dropdown.append($item);},this));},dropdownShow:function(e,key)
{if(!this.opts.visual)
{e.preventDefault();return false;}
var $dropdown=this.$toolbar.find('.redactor_dropdown_box_'+key);var $button=this.buttonGet(key);if($button.hasClass('dropact'))this.dropdownHideAll();else
{this.dropdownHideAll();this.buttonActive(key);$button.addClass('dropact');var keyPosition=$button.position();if(this.toolbarFixed)
{keyPosition=$button.offset();}
var dropdownWidth=$dropdown.width();if((keyPosition.left+dropdownWidth)>$(document).width())
{keyPosition.left-=dropdownWidth;}
var left=keyPosition.left+'px';var btnHeight=29;var position='absolute';var top=btnHeight+'px';if(this.opts.toolbarFixed&&this.toolbarFixed)position='fixed';else if(!this.opts.air)top=keyPosition.top+btnHeight+'px';$dropdown.css({position:position,left:left,top:top}).show();}
var hdlHideDropDown=$.proxy(function(e)
{this.dropdownHide(e,$dropdown);},this);$(document).one('click',hdlHideDropDown);this.$editor.one('click',hdlHideDropDown);e.stopPropagation();this.$editor.focus();},dropdownHideAll:function()
{this.$toolbar.find('a.dropact').removeClass('redactor_act').removeClass('dropact');$('.redactor_dropdown').hide();},dropdownHide:function(e,$dropdown)
{if(!$(e.target).hasClass('dropact'))
{$dropdown.removeClass('dropact');this.dropdownHideAll();}},buttonBuild:function(btnName,btnObject)
{var $button=$('<a href="javascript:;" title="'+btnObject.title+'" tabindex="-1" class="redactor_btn redactor_btn_'+btnName+'"></a>');$button.on('click',$.proxy(function(e)
{if(e.preventDefault)e.preventDefault();if(this.browser('msie'))e.returnValue=false;if($button.hasClass('redactor_button_disabled'))return false;if(this.isFocused()===false&&!btnObject.exec)
{this.$editor.focus();}
if(btnObject.exec)
{this.$editor.focus();this.execCommand(btnObject.exec,btnName);this.airBindMousemoveHide();}
else if(btnObject.func&&btnObject.func!=='show')
{this[btnObject.func](btnName);this.airBindMousemoveHide();}
else if(btnObject.callback)
{btnObject.callback.call(this,btnName,$button,btnObject,e);this.airBindMousemoveHide();}
else if(btnObject.dropdown)
{this.dropdownShow(e,btnName);}
this.buttonActiveObserver(false,btnName);},this));if(btnObject.dropdown)
{var $dropdown=$('<div class="redactor_dropdown redactor_dropdown_box_'+btnName+'" style="display: none;">');$dropdown.appendTo(this.$toolbar);this.dropdownBuild($dropdown,btnObject.dropdown);}
return $button;},buttonGet:function(key)
{if(!this.opts.toolbar)return false;return $(this.$toolbar.find('a.redactor_btn_'+key));},buttonActiveToggle:function(key)
{var btn=this.buttonGet(key);if(btn.hasClass('redactor_act'))btn.removeClass('redactor_act');else btn.addClass('redactor_act');},buttonActive:function(key)
{this.buttonGet(key).addClass('redactor_act');},buttonInactive:function(key)
{this.buttonGet(key).removeClass('redactor_act');},buttonInactiveAll:function(btnName)
{$.each(this.opts.toolbar,$.proxy(function(k)
{if(k!=btnName)this.buttonInactive(k);},this));},buttonActiveVisual:function()
{this.$toolbar.find('a.redactor_btn').not('a.redactor_btn_html').removeClass('redactor_button_disabled');},buttonInactiveVisual:function()
{this.$toolbar.find('a.redactor_btn').not('a.redactor_btn_html').addClass('redactor_button_disabled');},buttonChangeIcon:function(key,classname)
{this.buttonGet(key).addClass('redactor_btn_'+classname);},buttonRemoveIcon:function(key,classname)
{this.buttonGet(key).removeClass('redactor_btn_'+classname);},buttonAddSeparator:function()
{this.$toolbar.append($(this.opts.buttonSeparator));},buttonAddSeparatorAfter:function(key)
{this.buttonGet(key).parent().after($(this.opts.buttonSeparator));},buttonAddSeparatorBefore:function(key)
{this.buttonGet(key).parent().before($(this.opts.buttonSeparator));},buttonRemoveSeparatorAfter:function(key)
{this.buttonGet(key).parent().next().remove();},buttonRemoveSeparatorBefore:function(key)
{this.buttonGet(key).parent().prev().remove();},buttonSetRight:function(key)
{if(!this.opts.toolbar)return;this.buttonGet(key).parent().addClass('redactor_btn_right');},buttonSetLeft:function(key)
{if(!this.opts.toolbar)return;this.buttonGet(key).parent().removeClass('redactor_btn_right');},buttonAdd:function(key,title,callback,dropdown)
{if(!this.opts.toolbar)return;var btn=this.buttonBuild(key,{title:title,callback:callback,dropdown:dropdown});this.$toolbar.append($('<li>').append(btn));},buttonAddFirst:function(key,title,callback,dropdown)
{if(!this.opts.toolbar)return;var btn=this.buttonBuild(key,{title:title,callback:callback,dropdown:dropdown});this.$toolbar.prepend($('<li>').append(btn));},buttonAddAfter:function(afterkey,key,title,callback,dropdown)
{if(!this.opts.toolbar)return;var btn=this.buttonBuild(key,{title:title,callback:callback,dropdown:dropdown});var $btn=this.buttonGet(afterkey);if($btn.size()!==0)$btn.parent().after($('<li>').append(btn));else this.$toolbar.append($('<li>').append(btn));},buttonAddBefore:function(beforekey,key,title,callback,dropdown)
{if(!this.opts.toolbar)return;var btn=this.buttonBuild(key,{title:title,callback:callback,dropdown:dropdown});var $btn=this.buttonGet(beforekey);if($btn.size()!==0)$btn.parent().before($('<li>').append(btn));else this.$toolbar.append($('<li>').append(btn));},buttonRemove:function(key,separator)
{var $btn=this.buttonGet(key);if(separator)$btn.parent().next().remove();$btn.parent().removeClass('redactor_btn_right');$btn.remove();},buttonActiveObserver:function(e,btnName)
{var parent=this.getParent();this.buttonInactiveAll(btnName);if(e===false&&btnName!=='html')
{if($.inArray(btnName,this.opts.activeButtons)!=-1)
{this.buttonActiveToggle(btnName);}
return;}
if(parent&&parent.tagName==='A')this.$toolbar.find('a.redactor_dropdown_link').text(this.opts.curLang.link_edit);else this.$toolbar.find('a.redactor_dropdown_link').text(this.opts.curLang.link_insert);if(this.opts.activeButtonsAdd)
{$.each(this.opts.activeButtonsAdd,$.proxy(function(i,s)
{this.opts.activeButtons.push(s);},this));$.extend(this.opts.activeButtonsStates,this.opts.activeButtonsAdd);}
$.each(this.opts.activeButtonsStates,$.proxy(function(key,value)
{if($(parent).closest(key,this.$editor.get()[0]).length!=0)
{this.buttonActive(value);}},this));var $parent=$(parent).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);if($parent.length)
{var align=$parent.css('text-align');switch(align)
{case'right':this.buttonActive('alignright');break;case'center':this.buttonActive('aligncenter');break;case'justify':this.buttonActive('justify');break;default:this.buttonActive('alignleft');break;}}},execPasteFrag:function(html)
{var sel=this.getSelection();if(sel.getRangeAt&&sel.rangeCount)
{range=sel.getRangeAt(0);range.deleteContents();var el=document.createElement("div");el.innerHTML=html;var frag=document.createDocumentFragment(),node,lastNode;while((node=el.firstChild))
{lastNode=frag.appendChild(node);}
var firstNode=frag.firstChild;range.insertNode(frag);if(lastNode)
{range=range.cloneRange();range.setStartAfter(lastNode);range.collapse(true);sel.removeAllRanges();sel.addRange(range);}}},exec:function(cmd,param,sync)
{if(cmd==='formatblock'&&this.browser('msie'))param='<'+param+'>';if(cmd==='inserthtml'&&this.browser('msie'))
{if(!this.isIe11())
{this.$editor.focus();this.document.selection.createRange().pasteHTML(param);}
else this.execPasteFrag(param);}
else
{if(this.isIe11()&&cmd==='formatblock')this.$editor.focus();this.document.execCommand(cmd,false,param);}
if(sync!==false)this.sync();this.callback('execCommand',cmd,param);},execCommand:function(cmd,param,sync)
{if(!this.opts.visual)
{this.$source.focus();return false;}
if(cmd==='inserthtml')
{this.insertHtml(param,sync);this.callback('execCommand',cmd,param);return;}
if(this.currentOrParentIs('PRE')&&!this.opts.formattingPre)return false;if(cmd==='insertunorderedlist'||cmd==='insertorderedlist')return this.execLists(cmd,param);if(cmd==='unlink')return this.execUnlink(cmd,param);this.exec(cmd,param,sync);if(cmd==='inserthorizontalrule')this.$editor.find('hr').removeAttr('id');},execUnlink:function(cmd,param)
{this.bufferSet();var link=this.currentOrParentIs('A');if(link)
{$(link).replaceWith($(link).text());this.sync();this.callback('execCommand',cmd,param);return;}},execLists:function(cmd,param)
{this.bufferSet();var parent=this.getParent();var $list=$(parent).closest('ol, ul');var remove=false;if($list.length)
{remove=true;var listTag=$list[0].tagName;if((cmd==='insertunorderedlist'&&listTag==='OL')||(cmd==='insertorderedlist'&&listTag==='UL'))
{remove=false;}}
this.selectionSave();if(remove)
{var nodes=this.getNodes();var elems=this.getBlocks(nodes);if(typeof nodes[0]!='undefined'&&nodes.length>1&&nodes[0].nodeType==3)
{elems.unshift(this.getBlock());}
var data='',replaced='';$.each(elems,$.proxy(function(i,s)
{if(s.tagName=='LI')
{var $s=$(s);var cloned=$s.clone();cloned.find('ul','ol').remove();if(this.opts.linebreaks===false)data+=this.outerHtml($('<p>').append(cloned.contents()));else data+=cloned.html()+'<br>';if(i==0)
{$s.addClass('redactor-replaced').empty();replaced=this.outerHtml($s);}
else $s.remove();}},this));html=this.$editor.html().replace(replaced,'</'+listTag+'>'+data+'<'+listTag+'>');this.$editor.html(html);this.$editor.find(listTag+':empty').remove();}
else
{var firstParent=this.getParent();this.document.execCommand(cmd);var parent=this.getParent();var $list=$(parent).closest('ol, ul');if(firstParent&&firstParent.tagName=='TD')
{$list.wrapAll('<td>');}
if($list.length)
{var li=$list.children().first();if($.trim($(li).text())=='')
{var marker=$('<span id="selection-marker-1"></span>');$(li).prepend(marker);}
if((this.browser('msie')||this.browser('mozilla'))&&parent.tagName!=='LI')
{$(parent).replaceWith($(parent).html());}
var $listParent=$list.parent();if(this.isParentRedactor($listParent)&&this.nodeTestBlocks($listParent[0]))
{$listParent.replaceWith($listParent.contents());}}
if(this.browser('mozilla'))this.$editor.focus();}
this.selectionRestore();$(marker).remove();this.sync();this.callback('execCommand',cmd,param);return;},indentingIndent:function()
{this.indentingStart('indent');},indentingOutdent:function()
{this.indentingStart('outdent');},indentingStart:function(cmd)
{this.bufferSet();if(cmd==='indent')
{var block=this.getBlock();this.selectionSave();if(block&&block.tagName=='LI')
{var parent=this.getParent();var $list=$(parent).closest('ol, ul');var listTag=$list[0].tagName;var elems=this.getBlocks();$.each(elems,function(i,s)
{if(s.tagName=='LI')
{var $prev=$(s).prev();if($prev.size()!=0&&$prev[0].tagName=='LI')
{var $childList=$prev.children('ul, ol');if($childList.size()==0)
{$prev.append($('<'+listTag+'>').append(s));}
else $childList.append(s);}}});}
else if(block===false&&this.opts.linebreaks===true)
{this.exec('formatBlock','blockquote');var newblock=this.getBlock();var block=$('<div data-tagblock="">').html($(newblock).html());$(newblock).replaceWith(block);var left=this.normalize($(block).css('margin-left'))+this.opts.indentValue;$(block).css('margin-left',left+'px');}
else
{var elements=this.getBlocks();$.each(elements,$.proxy(function(i,elem)
{var $el=false;if(elem.tagName==='TD')return;if($.inArray(elem.tagName,this.opts.alignmentTags)!==-1)
{$el=$(elem);}
else
{$el=$(elem).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);}
var left=this.normalize($el.css('margin-left'))+this.opts.indentValue;$el.css('margin-left',left+'px');},this));}
this.selectionRestore();}
else
{this.selectionSave();var block=this.getBlock();if(block&&block.tagName=='LI')
{var elems=this.getBlocks();var index=0;this.insideOutdent(block,index,elems);}
else
{var elements=this.getBlocks();$.each(elements,$.proxy(function(i,elem)
{var $el=false;if($.inArray(elem.tagName,this.opts.alignmentTags)!==-1)
{$el=$(elem);}
else
{$el=$(elem).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);}
var left=this.normalize($el.css('margin-left'))-this.opts.indentValue;if(left<=0)
{if(this.opts.linebreaks===true&&typeof($el.data('tagblock'))!=='undefined')
{$el.replaceWith($el.html());}
else
{$el.css('margin-left','');this.removeEmptyAttr($el,'style');}}
else
{$el.css('margin-left',left+'px');}},this));}
this.selectionRestore();}
this.sync();},insideOutdent:function(li,index,elems)
{if(li&&li.tagName=='LI')
{var $parent=$(li).parent().parent();if($parent.size()!=0&&$parent[0].tagName=='LI')
{$parent.after(li);}
else
{if(typeof elems[index]!='undefined')
{li=elems[index];index++;this.insideOutdent(li,index,elems);}
else
{this.execCommand('insertunorderedlist');}}}},alignmentLeft:function()
{this.alignmentSet('','JustifyLeft');},alignmentRight:function()
{this.alignmentSet('right','JustifyRight');},alignmentCenter:function()
{this.alignmentSet('center','JustifyCenter');},alignmentJustify:function()
{this.alignmentSet('justify','JustifyFull');},alignmentSet:function(type,cmd)
{this.bufferSet();if(this.oldIE())
{this.document.execCommand(cmd,false,false);return true;}
this.selectionSave();var block=this.getBlock();if(!block&&this.opts.linebreaks)
{this.exec('formatBlock','blockquote');var newblock=this.getBlock();var block=$('<div data-tagblock="">').html($(newblock).html());$(newblock).replaceWith(block);$(block).css('text-align',type);this.removeEmptyAttr(block,'style');if(type==''&&typeof($(block).data('tagblock'))!=='undefined')
{$(block).replaceWith($(block).html());}}
else
{var elements=this.getBlocks();$.each(elements,$.proxy(function(i,elem)
{var $el=false;if($.inArray(elem.tagName,this.opts.alignmentTags)!==-1)
{$el=$(elem);}
else
{$el=$(elem).closest(this.opts.alignmentTags.toString().toLowerCase(),this.$editor[0]);}
if($el)
{$el.css('text-align',type);this.removeEmptyAttr($el,'style');}},this));}
this.selectionRestore();this.sync();},cleanEmpty:function(html)
{var ph=this.placeholderStart(html);if(ph!==false)return ph;if(this.opts.linebreaks===false)
{if(html==='')html=this.opts.emptyHtml;else if(html.search(/^<hr\s?\/?>$/gi)!==-1)html='<hr>'+this.opts.emptyHtml;}
return html;},cleanConverters:function(html)
{if(this.opts.convertDivs)html=html.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,'<p$1>$2</p>');if(this.opts.paragraphy)html=this.cleanParagraphy(html);return html;},cleanConvertProtected:function(html)
{if(this.opts.templateVars)
{html=html.replace(/\{\{(.*?)\}\}/gi,'<!-- template double $1 -->');html=html.replace(/\{(.*?)\}/gi,'<!-- template $1 -->');}
html=html.replace(/<script(.*?)>([\w\W]*?)<\/script>/gi,'<title type="text/javascript" style="display: none;" class="redactor-script-tag"$1>$2</title>');html=html.replace(/<style(.*?)>([\w\W]*?)<\/style>/gi,'<section$1 style="display: none;" rel="redactor-style-tag">$2</section>');html=html.replace(/<form(.*?)>([\w\W]*?)<\/form>/gi,'<section$1 rel="redactor-form-tag">$2</section>');if(this.opts.phpTags)html=html.replace(/<\?php([\w\W]*?)\?>/gi,'<section style="display: none;" rel="redactor-php-tag">$1</section>');else html=html.replace(/<\?php([\w\W]*?)\?>/gi,'');return html;},cleanReConvertProtected:function(html)
{if(this.opts.templateVars)
{html=html.replace(/<!-- template double (.*?) -->/gi,'{{$1}}');html=html.replace(/<!-- template (.*?) -->/gi,'{$1}');}
html=html.replace(/<title type="text\/javascript" style="display: none;" class="redactor-script-tag"(.*?)>([\w\W]*?)<\/title>/gi,'<script$1 type="text/javascript">$2</script>');html=html.replace(/<section(.*?) style="display: none;" rel="redactor-style-tag">([\w\W]*?)<\/section>/gi,'<style$1>$2</style>');html=html.replace(/<section(.*?)rel="redactor-form-tag"(.*?)>([\w\W]*?)<\/section>/gi,'<form$1$2>$3</form>');if(this.opts.phpTags)html=html.replace(/<section style="display: none;" rel="redactor-php-tag">([\w\W]*?)<\/section>/gi,'<?php\r\n$1\r\n?>');return html;},cleanRemoveSpaces:function(html,buffer)
{if(buffer!==false)
{var buffer=[]
var matches=html.match(/<(pre|style|script|title)(.*?)>([\w\W]*?)<\/(pre|style|script|title)>/gi);if(matches===null)matches=[];if(this.opts.phpTags)
{var phpMatches=html.match(/<\?php([\w\W]*?)\?>/gi);if(phpMatches)matches=$.merge(matches,phpMatches);}
if(matches)
{$.each(matches,function(i,s)
{html=html.replace(s,'buffer_'+i);buffer.push(s);});}}
html=html.replace(/\n/g,' ');html=html.replace(/[\t]*/g,'');html=html.replace(/\n\s*\n/g,"\n");html=html.replace(/^[\s\n]*/g,' ');html=html.replace(/[\s\n]*$/g,' ');html=html.replace(/>\s{2,}</g,'> <');html=this.cleanReplacer(html,buffer);html=html.replace(/\n\n/g,"\n");return html;},cleanReplacer:function(html,buffer)
{if(buffer===false)return html;$.each(buffer,function(i,s)
{html=html.replace('buffer_'+i,s);});return html;},cleanRemoveEmptyTags:function(html)
{html=html.replace(/<span>([\w\W]*?)<\/span>/gi,'$1');html=html.replace(/[\u200B-\u200D\uFEFF]/g,'');var etagsInline=["<b>\\s*</b>","<b>&nbsp;</b>","<em>\\s*</em>"]
var etags=["<pre></pre>","<blockquote>\\s*</blockquote>","<dd></dd>","<dt></dt>","<ul></ul>","<ol></ol>","<li></li>","<table></table>","<tr></tr>","<span>\\s*<span>","<span>&nbsp;<span>","<p>\\s*</p>","<p></p>","<p>&nbsp;</p>","<p>\\s*<br>\\s*</p>","<div>\\s*</div>","<div>\\s*<br>\\s*</div>"];if(this.opts.removeEmptyTags)
{etags=etags.concat(etagsInline);}
else etags=etagsInline;var len=etags.length;for(var i=0;i<len;++i)
{html=html.replace(new RegExp(etags[i],'gi'),"");}
return html;},cleanParagraphy:function(html)
{html=$.trim(html);if(this.opts.linebreaks===true)return html;if(html===''||html==='<p></p>')return this.opts.emptyHtml;html=html+"\n";var safes=[];var matches=html.match(/<(table|div|pre|object)(.*?)>([\w\W]*?)<\/(table|div|pre|object)>/gi);if(!matches)matches=[];var commentsMatches=html.match(/<!--([\w\W]*?)-->/gi);if(commentsMatches)matches=$.merge(matches,commentsMatches);if(this.opts.phpTags)
{var phpMatches=html.match(/<section(.*?)rel="redactor-php-tag">([\w\W]*?)<\/section>/gi);if(phpMatches)matches=$.merge(matches,phpMatches);}
if(matches)
{$.each(matches,function(i,s)
{safes[i]=s;html=html.replace(s,'{replace'+i+'}\n');});}
html=html.replace(/<br \/>\s*<br \/>/gi,"\n\n");function R(str,mod,r)
{return html.replace(new RegExp(str,mod),r);}
var blocks='(comment|html|body|head|title|meta|style|script|link|iframe|table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|option|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';html=R('(<'+blocks+'[^>]*>)','gi',"\n$1");html=R('(</'+blocks+'>)','gi',"$1\n\n");html=R("\r\n",'g',"\n");html=R("\r",'g',"\n");html=R("/\n\n+/",'g',"\n\n");var htmls=html.split(new RegExp('\n\s*\n','g'),-1);html='';for(var i in htmls)
{if(htmls.hasOwnProperty(i))
{if(htmls[i].search('{replace')==-1)
{htmls[i]=htmls[i].replace(/<p>\n\t<\/p>/gi,'');htmls[i]=htmls[i].replace(/<p><\/p>/gi,'');if(htmls[i]!='')
{html+='<p>'+htmls[i].replace(/^\n+|\n+$/g,"")+"</p>";}}
else html+=htmls[i];}}
html=R('<p>\s*</p>','gi','');html=R('<p>([^<]+)</(div|address|form)>','gi',"<p>$1</p></$2>");html=R('<p>\s*(</?'+blocks+'[^>]*>)\s*</p>','gi',"$1");html=R("<p>(<li.+?)</p>",'gi',"$1");html=R('<p>\s*(</?'+blocks+'[^>]*>)','gi',"$1");html=R('(</?'+blocks+'[^>]*>)\s*</p>','gi',"$1");html=R('(</?'+blocks+'[^>]*>)\s*<br />','gi',"$1");html=R('<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)','gi','$1');html=R("\n</p>",'gi','</p>');html=R('<li><p>','gi','<li>');html=R('</p></li>','gi','</li>');html=R('</li><p>','gi','</li>');html=R('<p>\t?\n?<p>','gi','<p>');html=R('</dt><p>','gi','</dt>');html=R('</dd><p>','gi','</dd>');html=R('<br></p></blockquote>','gi','</blockquote>');html=R('<p>\t*</p>','gi','');$.each(safes,function(i,s)
{html=html.replace('{replace'+i+'}',s);});return $.trim(html);},cleanConvertInlineTags:function(html,set)
{var boldTag='strong';if(this.opts.boldTag==='b')boldTag='b';var italicTag='em';if(this.opts.italicTag==='i')italicTag='i';html=html.replace(/<span style="font-style: italic;">([\w\W]*?)<\/span>/gi,'<'+italicTag+'>$1</'+italicTag+'>');html=html.replace(/<span style="font-weight: bold;">([\w\W]*?)<\/span>/gi,'<'+boldTag+'>$1</'+boldTag+'>');if(this.opts.boldTag==='strong')html=html.replace(/<b>([\w\W]*?)<\/b>/gi,'<strong>$1</strong>');else html=html.replace(/<strong>([\w\W]*?)<\/strong>/gi,'<b>$1</b>');if(this.opts.italicTag==='em')html=html.replace(/<i>([\w\W]*?)<\/i>/gi,'<em>$1</em>');else html=html.replace(/<em>([\w\W]*?)<\/em>/gi,'<i>$1</i>');if(set!==true)
{html=html.replace(/<strike>([\w\W]*?)<\/strike>/gi,'<del>$1</del>');}
else
{html=html.replace(/<del>([\w\W]*?)<\/del>/gi,'<strike>$1</strike>');}
return html;},cleanStripTags:function(html)
{if(html==''||typeof html=='undefined')return html;var allowed=false;if(this.opts.allowedTags!==false)allowed=true;var arr=allowed===true?this.opts.allowedTags:this.opts.deniedTags;var tags=/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi;html=html.replace(tags,function($0,$1)
{if(allowed===true)return $.inArray($1.toLowerCase(),arr)>'-1'?$0:'';else return $.inArray($1.toLowerCase(),arr)>'-1'?'':$0;});html=this.cleanConvertInlineTags(html);return html;},cleanSavePreCode:function(html,encode)
{var pre=html.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/gi);if(pre!==null)
{$.each(pre,$.proxy(function(i,s)
{var arr=s.match(/<(pre|code)(.*?)>([\w\W]*?)<\/(pre|code)>/i);arr[3]=arr[3].replace(/&nbsp;/g,' ');if(encode!==false)arr[3]=this.cleanEncodeEntities(arr[3]);arr[3]=arr[3].replace(/\$/g,'&#36;');html=html.replace(s,'<'+arr[1]+arr[2]+'>'+arr[3]+'</'+arr[1]+'>');},this));}
return html;},cleanEncodeEntities:function(str)
{str=String(str).replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"');return str.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');},cleanUnverified:function()
{var $elem=this.$editor.find('li, img, a, b, strong, sub, sup, i, em, u, small, strike, del, span, cite');$elem.filter('[style*="background-color: transparent;"][style*="line-height"]').css('background-color','').css('line-height','');$elem.filter('[style*="background-color: transparent;"]').css('background-color','');$elem.css('line-height','');$.each($elem,$.proxy(function(i,s)
{this.removeEmptyAttr(s,'style');},this));this.$editor.find('div[style="text-align: -webkit-auto;"]').contents().unwrap();},cleanHtml:function(code)
{var i=0,codeLength=code.length,point=0,start=null,end=null,tag='',out='',cont='';this.cleanlevel=0;for(;i<codeLength;i++)
{point=i;if(-1==code.substr(i).indexOf('<'))
{out+=code.substr(i);return this.cleanFinish(out);}
while(point<codeLength&&code.charAt(point)!='<')
{point++;}
if(i!=point)
{cont=code.substr(i,point-i);if(!cont.match(/^\s{2,}$/g))
{if('\n'==out.charAt(out.length-1))out+=this.cleanGetTabs();else if('\n'==cont.charAt(0))
{out+='\n'+this.cleanGetTabs();cont=cont.replace(/^\s+/,'');}
out+=cont;}
if(cont.match(/\n/))out+='\n'+this.cleanGetTabs();}
start=point;while(point<codeLength&&'>'!=code.charAt(point))
{point++;}
tag=code.substr(start,point-start);i=point;var t;if('!--'==tag.substr(1,3))
{if(!tag.match(/--$/))
{while('-->'!=code.substr(point,3))
{point++;}
point+=2;tag=code.substr(start,point-start);i=point;}
if('\n'!=out.charAt(out.length-1))out+='\n';out+=this.cleanGetTabs();out+=tag+'>\n';}
else if('!'==tag[1])
{out=this.placeTag(tag+'>',out);}
else if('?'==tag[1])
{out+=tag+'>\n';}
else if(t=tag.match(/^<(script|style|pre)/i))
{t[1]=t[1].toLowerCase();tag=this.cleanTag(tag);out=this.placeTag(tag,out);end=String(code.substr(i+1)).toLowerCase().indexOf('</'+t[1]);if(end)
{cont=code.substr(i+1,end);i+=end;out+=cont;}}
else
{tag=this.cleanTag(tag);out=this.placeTag(tag,out);}}
return this.cleanFinish(out);},cleanGetTabs:function()
{var s='';for(var j=0;j<this.cleanlevel;j++)
{s+='\t';}
return s;},cleanFinish:function(code)
{code=code.replace(/\n\s*\n/g,'\n');code=code.replace(/^[\s\n]*/,'');code=code.replace(/[\s\n]*$/,'');code=code.replace(/<script(.*?)>\n<\/script>/gi,'<script$1></script>');this.cleanlevel=0;return code;},cleanTag:function(tag)
{var tagout='';tag=tag.replace(/\n/g,' ');tag=tag.replace(/\s{2,}/g,' ');tag=tag.replace(/^\s+|\s+$/g,' ');var suffix='';if(tag.match(/\/$/))
{suffix='/';tag=tag.replace(/\/+$/,'');}
var m;while(m=/\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/.exec(tag))
{if(m[2])tagout+=m[1].toLowerCase()+'='+m[2];else if(m[1])tagout+=m[1].toLowerCase();tagout+=' ';tag=tag.substr(m[0].length);}
return tagout.replace(/\s*$/,'')+suffix+'>';},placeTag:function(tag,out)
{var nl=tag.match(this.cleannewLevel);if(tag.match(this.cleanlineBefore)||nl)
{out=out.replace(/\s*$/,'');out+='\n';}
if(nl&&'/'==tag.charAt(1))this.cleanlevel--;if('\n'==out.charAt(out.length-1))out+=this.cleanGetTabs();if(nl&&'/'!=tag.charAt(1))this.cleanlevel++;out+=tag;if(tag.match(this.cleanlineAfter)||tag.match(this.cleannewLevel))
{out=out.replace(/ *$/,'');out+='\n';}
return out;},formatEmpty:function(e)
{var html=$.trim(this.$editor.html());if(this.opts.linebreaks)
{if(html=='')
{e.preventDefault();this.$editor.html('');this.focus();}}
else
{html=html.replace(/<br\s?\/?>/i,'');var thtml=html.replace(/<p>\s?<\/p>/gi,'');if(html===''||thtml==='')
{e.preventDefault();var node=$(this.opts.emptyHtml).get(0);this.$editor.html(node);this.focus();}}
this.sync();},formatBlocks:function(tag)
{this.bufferSet();var nodes=this.getBlocks();this.selectionSave();$.each(nodes,$.proxy(function(i,node)
{if(node.tagName!=='LI')
{var parent=$(node).parent();if(tag==='p')
{if((node.tagName==='P'&&parent.size()!=0&&parent[0].tagName==='BLOCKQUOTE')||node.tagName==='BLOCKQUOTE')
{this.formatQuote();return;}
else if(this.opts.linebreaks)return;else
{this.formatBlock(tag,node);}}
else
{this.formatBlock(tag,node);}}},this));this.selectionRestore();this.sync();},formatBlock:function(tag,block)
{if(block===false)block=this.getBlock();if(block===false)
{if(this.opts.linebreaks===true)this.execCommand('formatblock',tag);return true;}
var contents='';if(tag!=='pre')
{contents=$(block).contents();}
else
{contents=$(block).html();if($.trim(contents)==='')
{contents='<span id="selection-marker-1"></span>';}}
if(block.tagName==='PRE')tag='p';if(this.opts.linebreaks===true&&tag==='p')
{$(block).replaceWith($('<div>').append(contents).html()+'<br>');}
else
{var parent=this.getParent();var node=$('<'+tag+'>').append(contents);$(block).replaceWith(node);if(parent&&parent.tagName=='TD')
{$(node).wrapAll('<td>');}}},formatChangeTag:function(fromElement,toTagName,save)
{if(save!==false)this.selectionSave();var newElement=$('<'+toTagName+'/>');$(fromElement).replaceWith(function(){return newElement.append($(this).contents());});if(save!==false)this.selectionRestore();return newElement;},formatQuote:function()
{this.bufferSet();if(this.opts.linebreaks===false)
{this.selectionSave();var blocks=this.getBlocks();var blockquote=false;var blocksLen=blocks.length;if(blocks)
{var data='';var replaced='';var replace=false;var paragraphsOnly=true;$.each(blocks,function(i,s)
{if(s.tagName!=='P')paragraphsOnly=false;});$.each(blocks,$.proxy(function(i,s)
{if(s.tagName==='BLOCKQUOTE')
{this.formatBlock('p',s,false);}
else if(s.tagName==='P')
{blockquote=$(s).parent();if(blockquote[0].tagName=='BLOCKQUOTE')
{var count=$(blockquote).children('p').size();if(count==1)
{$(blockquote).replaceWith(s);}
else if(count==blocksLen)
{replace='blockquote';data+=this.outerHtml(s);}
else
{replace='html';data+=this.outerHtml(s);if(i==0)
{$(s).addClass('redactor-replaced').empty();replaced=this.outerHtml(s);}
else $(s).remove();}}
else
{if(paragraphsOnly===false||blocks.length==1)
{this.formatBlock('blockquote',s,false);}
else
{replace='paragraphs';data+=this.outerHtml(s);}}}
else if(s.tagName!=='LI')
{this.formatBlock('blockquote',s,false);}},this));if(replace)
{if(replace=='paragraphs')
{$(blocks[0]).replaceWith('<blockquote>'+data+'</blockquote>');$(blocks).remove();}
else if(replace=='blockquote')
{$(blockquote).replaceWith(data);}
else if(replace=='html')
{var html=this.$editor.html().replace(replaced,'</blockquote>'+data+'<blockquote>');this.$editor.html(html);this.$editor.find('blockquote').each(function()
{if($.trim($(this).html())=='')$(this).remove();})}}}
this.selectionRestore();}
else
{var block=this.getBlock();if(block.tagName==='BLOCKQUOTE')
{this.selectionSave();var html=$.trim($(block).html());var selection=$.trim(this.getSelectionHtml());html=html.replace(/<span(.*?)id="selection-marker(.*?)<\/span>/gi,'');if(html==selection)
{$(block).replaceWith($(block).html()+'<br>');}
else
{this.inlineFormat('tmp');var tmp=this.$editor.find('tmp');tmp.empty();var newhtml=this.$editor.html().replace('<tmp></tmp>','</blockquote><span id="selection-marker-1">'+this.opts.invisibleSpace+'</span>'+selection+'<blockquote>');this.$editor.html(newhtml);tmp.remove();this.$editor.find('blockquote').each(function()
{if($.trim($(this).html())=='')$(this).remove();})}
this.selectionRestore();this.$editor.find('span#selection-marker-1').attr('id',false);}
else
{var wrapper=this.selectionWrap('blockquote');var html=$(wrapper).html();var blocksElemsRemove=['ul','ol','table','tr','tbody','thead','tfoot','dl'];$.each(blocksElemsRemove,function(i,s)
{html=html.replace(new RegExp('<'+s+'(.*?)>','gi'),'');html=html.replace(new RegExp('</'+s+'>','gi'),'');});var blocksElems=this.opts.blockLevelElements;blocksElems.push('td');$.each(blocksElems,function(i,s)
{html=html.replace(new RegExp('<'+s+'(.*?)>','gi'),'');html=html.replace(new RegExp('</'+s+'>','gi'),'<br>');});$(wrapper).html(html);this.selectionElement(wrapper);var next=$(wrapper).next();if(next.size()!=0&&next[0].tagName==='BR')
{next.remove();}}}
this.sync();},blockRemoveAttr:function(attr,value)
{var nodes=this.getBlocks();$(nodes).removeAttr(attr);this.sync();},blockSetAttr:function(attr,value)
{var nodes=this.getBlocks();$(nodes).attr(attr,value);this.sync();},blockRemoveStyle:function(rule)
{var nodes=this.getBlocks();$(nodes).css(rule,'');this.removeEmptyAttr(nodes,'style');this.sync();},blockSetStyle:function(rule,value)
{var nodes=this.getBlocks();$(nodes).css(rule,value);this.sync();},blockRemoveClass:function(className)
{var nodes=this.getBlocks();$(nodes).removeClass(className);this.removeEmptyAttr(nodes,'class');this.sync();},blockSetClass:function(className)
{var nodes=this.getBlocks();$(nodes).addClass(className);this.sync();},inlineRemoveClass:function(className)
{this.selectionSave();this.inlineEachNodes(function(node)
{$(node).removeClass(className);this.removeEmptyAttr(node,'class');});this.selectionRestore();this.sync();},inlineSetClass:function(className)
{var current=this.getCurrent();if(!$(current).hasClass(className))this.inlineMethods('addClass',className);},inlineRemoveStyle:function(rule)
{this.selectionSave();this.inlineEachNodes(function(node)
{$(node).css(rule,'');this.removeEmptyAttr(node,'style');});this.selectionRestore();this.sync();},inlineSetStyle:function(rule,value)
{this.inlineMethods('css',rule,value);},inlineRemoveAttr:function(attr)
{this.selectionSave();var range=this.getRange(),node=this.getElement(),nodes=this.getNodes();if(range.collapsed||range.startContainer===range.endContainer&&node)
{nodes=$(node);}
$(nodes).removeAttr(attr);this.inlineUnwrapSpan();this.selectionRestore();this.sync();},inlineSetAttr:function(attr,value)
{this.inlineMethods('attr',attr,value);},inlineMethods:function(type,attr,value)
{this.bufferSet();this.selectionSave();var range=this.getRange()
var el=this.getElement();if((range.collapsed||range.startContainer===range.endContainer)&&el&&!this.nodeTestBlocks(el))
{$(el)[type](attr,value);}
else
{this.document.execCommand('fontSize',false,4);var fonts=this.$editor.find('font');$.each(fonts,$.proxy(function(i,s)
{this.inlineSetMethods(type,s,attr,value);},this));}
this.selectionRestore();this.sync();},inlineSetMethods:function(type,s,attr,value)
{var parent=$(s).parent(),el;var selectionHtml=this.getSelectionText();var parentHtml=$(parent).text();var selected=selectionHtml==parentHtml;if(selected&&parent&&parent[0].tagName==='INLINE'&&parent[0].attributes.length!=0)
{el=parent;$(s).replaceWith($(s).html());}
else
{el=$('<inline>').append($(s).contents());$(s).replaceWith(el);}
$(el)[type](attr,value);return el;},inlineEachNodes:function(callback)
{var range=this.getRange(),node=this.getElement(),nodes=this.getNodes(),collapsed;if(range.collapsed||range.startContainer===range.endContainer&&node)
{nodes=$(node);collapsed=true;}
$.each(nodes,$.proxy(function(i,node)
{if(!collapsed&&node.tagName!=='INLINE')
{var selectionHtml=this.getSelectionText();var parentHtml=$(node).parent().text();var selected=selectionHtml==parentHtml;if(selected&&node.parentNode.tagName==='INLINE'&&!$(node.parentNode).hasClass('redactor_editor'))
{node=node.parentNode;}
else return;}
callback.call(this,node);},this));},inlineUnwrapSpan:function()
{var $spans=this.$editor.find('inline');$.each($spans,$.proxy(function(i,span)
{var $span=$(span);if($span.attr('class')===undefined&&$span.attr('style')===undefined)
{$span.contents().unwrap();}},this));},inlineFormat:function(tag)
{this.selectionSave();this.document.execCommand('fontSize',false,4);var fonts=this.$editor.find('font');var last;$.each(fonts,function(i,s)
{var el=$('<'+tag+'/>').append($(s).contents());$(s).replaceWith(el);last=el;});this.selectionRestore();this.sync();},inlineRemoveFormat:function(tag)
{this.selectionSave();var utag=tag.toUpperCase();var nodes=this.getNodes();var parent=$(this.getParent()).parent();$.each(nodes,function(i,s)
{if(s.tagName===utag)this.inlineRemoveFormatReplace(s);});if(parent&&parent[0].tagName===utag)this.inlineRemoveFormatReplace(parent);this.selectionRestore();this.sync();},inlineRemoveFormatReplace:function(el)
{$(el).replaceWith($(el).contents());},insertHtml:function(html,sync)
{var current=this.getCurrent();var parent=current.parentNode;this.$editor.focus();this.bufferSet();var $html=$('<div>').append($.parseHTML(html));html=$html.html();html=this.cleanRemoveEmptyTags(html);$html=$('<div>').append($.parseHTML(html));var currBlock=this.getBlock();if($html.contents().length==1)
{var htmlTagName=$html.contents()[0].tagName;if(htmlTagName!='P'&&htmlTagName==currBlock.tagName||htmlTagName=='PRE')
{$html=$('<div>').append(html);}}
if(!this.opts.linebreaks&&$html.contents().length==1&&$html.contents()[0].nodeType==3&&(this.getRangeSelectedNodes().length>2||(!current||current.tagName=='BODY'&&!parent||parent.tagName=='HTML')))
{html='<p>'+html+'</p>';}
html=this.setSpansVerifiedHtml(html);if($html.contents().length>1&&currBlock||$html.contents().is('p, :header, ul, ol, li, div, table, td, blockquote, pre, address, section, header, footer, aside, article'))
{if(this.browser('msie'))
{if(!this.isIe11())
{this.document.selection.createRange().pasteHTML(html);}
else
{this.execPasteFrag(html);}}
else this.document.execCommand('inserthtml',false,html);}
else this.insertHtmlAdvanced(html,false);if(this.selectall)
{this.window.setTimeout($.proxy(function()
{if(!this.opts.linebreaks)this.selectionEnd(this.$editor.contents().last());else this.focusEnd();},this),1);}
this.observeStart();this.setNonEditable();if(sync!==false)this.sync();},insertHtmlAdvanced:function(html,sync)
{html=this.setSpansVerifiedHtml(html);var sel=this.getSelection();if(sel.getRangeAt&&sel.rangeCount)
{var range=sel.getRangeAt(0);range.deleteContents();var el=this.document.createElement('div');el.innerHTML=html;var frag=this.document.createDocumentFragment(),node,lastNode;while((node=el.firstChild))
{lastNode=frag.appendChild(node);}
range.insertNode(frag);if(lastNode)
{range=range.cloneRange();range.setStartAfter(lastNode);range.collapse(true);sel.removeAllRanges();sel.addRange(range);}}
if(sync!==false)
{this.sync();}},insertBeforeCursor:function(html)
{html=this.setSpansVerifiedHtml(html);var node=$(html);var space=document.createElement("span");space.innerHTML="\u200B";var range=this.getRange();range.insertNode(space);range.insertNode(node[0]);range.collapse(false);var sel=this.getSelection();sel.removeAllRanges();sel.addRange(range);this.sync();},insertText:function(html)
{var $html=$($.parseHTML(html));if($html.length)html=$html.text();this.$editor.focus();if(this.browser('msie')&&!this.isIe11())this.document.selection.createRange().pasteHTML(html);else this.document.execCommand('inserthtml',false,html);this.sync();},insertNode:function(node)
{node=node[0]||node;if(node.tagName=='SPAN')
{var replacementTag='inline';var outer=node.outerHTML;var regex=new RegExp('<'+node.tagName,'i');var newTag=outer.replace(regex,'<'+replacementTag);regex=new RegExp('</'+node.tagName,'i');newTag=newTag.replace(regex,'</'+replacementTag);node=$(newTag)[0];}
var sel=this.getSelection();if(sel.getRangeAt&&sel.rangeCount)
{range=sel.getRangeAt(0);range.deleteContents();range.insertNode(node);range.setEndAfter(node);range.setStartAfter(node);sel.removeAllRanges();sel.addRange(range);}},insertNodeToCaretPositionFromPoint:function(e,node)
{var range;var x=e.clientX,y=e.clientY;if(this.document.caretPositionFromPoint)
{var pos=this.document.caretPositionFromPoint(x,y);range=this.getRange();range.setStart(pos.offsetNode,pos.offset);range.collapse(true);range.insertNode(node);}
else if(this.document.caretRangeFromPoint)
{range=this.document.caretRangeFromPoint(x,y);range.insertNode(node);}
else if(typeof document.body.createTextRange!="undefined")
{range=this.document.body.createTextRange();range.moveToPoint(x,y);var endRange=range.duplicate();endRange.moveToPoint(x,y);range.setEndPoint("EndToEnd",endRange);range.select();}},insertAfterLastElement:function(element,parent)
{if(typeof(parent)!='undefined')element=parent;if(this.isEndOfElement())
{if(this.opts.linebreaks)
{var contents=$('<div>').append($.trim(this.$editor.html())).contents();if(this.outerHtml(contents.last()[0])!=this.outerHtml(element))
{return false;}}
else
{if(this.$editor.contents().last()[0]!==element)
{return false;}}
this.insertingAfterLastElement(element);}},insertingAfterLastElement:function(element)
{this.bufferSet();if(this.opts.linebreaks===false)
{var node=$(this.opts.emptyHtml);$(element).after(node);this.selectionStart(node);}
else
{var node=$('<span id="selection-marker-1">'+this.opts.invisibleSpace+'</span>',this.document)[0];$(element).after(node);$(node).after(this.opts.invisibleSpace);this.selectionRestore();this.$editor.find('span#selection-marker-1').removeAttr('id');}},insertLineBreak:function()
{this.selectionSave();this.$editor.find('#selection-marker-1').before('<br>'+(this.browser('webkit')?this.opts.invisibleSpace:''));this.selectionRestore();},insertDoubleLineBreak:function()
{this.selectionSave();this.$editor.find('#selection-marker-1').before('<br><br>'+(this.browser('webkit')?this.opts.invisibleSpace:''));this.selectionRestore();},replaceLineBreak:function(element)
{var node=$('<br>'+this.opts.invisibleSpace);$(element).replaceWith(node);this.selectionStart(node);},pasteClean:function(html)
{html=this.callback('pasteBefore',false,html);if(this.browser('msie'))
{var tmp=$.trim(html);if(tmp.search(/^<a(.*?)>(.*?)<\/a>$/i)==0)
{html=html.replace(/^<a(.*?)>(.*?)<\/a>$/i,"$2");}}
if(this.opts.pastePlainText)
{var tmp=this.document.createElement('div');html=html.replace(/<br>|<\/H[1-6]>|<\/p>|<\/div>/gi,'\n');tmp.innerHTML=html;html=tmp.textContent||tmp.innerText;html=$.trim(html);html=html.replace('\n','<br>');html=this.cleanParagraphy(html);this.pasteInsert(html);return false;}
if(this.currentOrParentIs('PRE'))
{html=this.pastePre(html);this.pasteInsert(html);return true;}
html=html.replace(/<p(.*?)class="MsoListParagraphCxSpFirst"([\w\W]*?)<\/p>/gi,'<ul><li$2</li>');html=html.replace(/<p(.*?)class="MsoListParagraphCxSpMiddle"([\w\W]*?)<\/p>/gi,'<li$2</li>');html=html.replace(/<p(.*?)class="MsoListParagraphCxSpLast"([\w\W]*?)<\/p>/gi,'<li$2</li></ul>');html=html.replace(/<p(.*?)class="MsoListParagraph"([\w\W]*?)<\/p>/gi,'<ul><li$2</li></ul>');html=html.replace(/·/g,'');html=html.replace(/<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi,'');html=html.replace(/(&nbsp;){2,}/gi,'&nbsp;');html=html.replace(/&nbsp;/gi,' ');html=html.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2");html=html.replace(/<b(.*?)id="docs-internal-guid(.*?)">([\w\W]*?)<\/b>/gi,"$3");html=this.cleanStripTags(html);html=html.replace(/<td><\/td>/gi,'[td]');html=html.replace(/<td>&nbsp;<\/td>/gi,'[td]');html=html.replace(/<td><br><\/td>/gi,'[td]');html=html.replace(/<td(.*?)colspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td colspan="$2"]$4[/td]');html=html.replace(/<td(.*?)rowspan="(.*?)"(.*?)>([\w\W]*?)<\/td>/gi,'[td rowspan="$2"]$4[/td]');html=html.replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]');html=html.replace(/<iframe(.*?)>([\w\W]*?)<\/iframe>/gi,'[iframe$1]$2[/iframe]');html=html.replace(/<video(.*?)>([\w\W]*?)<\/video>/gi,'[video$1]$2[/video]');html=html.replace(/<audio(.*?)>([\w\W]*?)<\/audio>/gi,'[audio$1]$2[/audio]');html=html.replace(/<embed(.*?)>([\w\W]*?)<\/embed>/gi,'[embed$1]$2[/embed]');html=html.replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,'[object$1]$2[/object]');html=html.replace(/<param(.*?)>/gi,'[param$1]');html=html.replace(/<img(.*?)>/gi,'[img$1]');html=html.replace(/ class="(.*?)"/gi,'');html=html.replace(/<(\w+)([\w\W]*?)>/gi,'<$1>');html=html.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,'');html=html.replace(/<div>\s*?\t*?\n*?(<ul>|<ol>|<p>)/gi,'$1');html=html.replace(/\[td colspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td colspan="$1">$2</td>');html=html.replace(/\[td rowspan="(.*?)"\]([\w\W]*?)\[\/td\]/gi,'<td rowspan="$1">$2</td>');html=html.replace(/\[td\]/gi,'<td>&nbsp;</td>');html=html.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>');html=html.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,'<iframe$1>$2</iframe>');html=html.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,'<video$1>$2</video>');html=html.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,'<audio$1>$2</audio>');html=html.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,'<embed$1>$2</embed>');html=html.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,'<object$1>$2</object>');html=html.replace(/\[param(.*?)\]/gi,'<param$1>');html=html.replace(/\[img(.*?)\]/gi,'<img$1>');if(this.opts.convertDivs)
{html=html.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,'<p>$2</p>');html=html.replace(/<\/div><p>/gi,'<p>');html=html.replace(/<\/p><\/div>/gi,'</p>');}
if(this.currentOrParentIs('LI'))
{html=html.replace(/<p>([\w\W]*?)<\/p>/gi,'$1<br>');}
else
{html=this.cleanParagraphy(html);}
html=html.replace(/<span(.*?)>([\w\W]*?)<\/span>/gi,'$2');html=html.replace(/<img>/gi,'');html=html.replace(/<[^\/>][^>][^img|param|source]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,'');html=html.replace(/\n{3,}/gi,'\n');html=html.replace(/<p><p>/gi,'<p>');html=html.replace(/<\/p><\/p>/gi,'</p>');html=html.replace(/<li>(\s*|\t*|\n*)<p>/gi,'<li>');html=html.replace(/<\/p>(\s*|\t*|\n*)<\/li>/gi,'</li>');if(this.opts.linebreaks===true)
{html=html.replace(/<p(.*?)>([\w\W]*?)<\/p>/gi,'$2<br>');}
html=html.replace(/<[^\/>][^>][^img|param|source]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,'');html=html.replace(/<img src="webkit-fake-url\:\/\/(.*?)"(.*?)>/gi,'');html=html.replace(/<td(.*?)>(\s*|\t*|\n*)<p>([\w\W]*?)<\/p>(\s*|\t*|\n*)<\/td>/gi,'<td$1>$3</td>');html=html.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,'$2');html=html.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,'$2');this.pasteClipboardMozilla=false;if(this.browser('mozilla'))
{if(this.opts.clipboardUpload)
{var matches=html.match(/<img src="data:image(.*?)"(.*?)>/gi);if(matches!==null)
{this.pasteClipboardMozilla=matches;for(k in matches)
{var img=matches[k].replace('<img','<img data-mozilla-paste-image="'+k+'" ');html=html.replace(matches[k],img);}}}
while(/<br>$/gi.test(html))
{html=html.replace(/<br>$/gi,'');}}
html=html.replace(/<p>•([\w\W]*?)<\/p>/gi,'<li>$1</li>');while(/<font>([\w\W]*?)<\/font>/gi.test(html))
{html=html.replace(/<font>([\w\W]*?)<\/font>/gi,'$1');}
html=html.replace(/<p>\n?<li>/gi,'<li>');if(this.browser('msie')&&!this.isIe11())
{html=html.replace(/\n/g,'');}
this.pasteInsert(html);},pastePre:function(s)
{s=s.replace(/<br>|<\/H[1-6]>|<\/p>|<\/div>/gi,'\n');var tmp=this.document.createElement('div');tmp.innerHTML=s;return this.cleanEncodeEntities(tmp.textContent||tmp.innerText);},pasteInsert:function(html)
{if(this.selectall)
{if(!this.opts.linebreaks)this.$editor.html(this.opts.emptyHtml);else this.$editor.html('');this.$editor.focus();}
html=this.callback('pasteAfter',false,html);this.insertHtml(html);this.selectall=false;setTimeout($.proxy(function()
{this.rtePaste=false;if(this.browser('mozilla'))
{this.$editor.find('p:empty').remove()}
if(this.pasteClipboardMozilla!==false)
{this.pasteClipboardUploadMozilla();}},this),100);if(this.opts.autoresize&&this.fullscreen!==true)$(this.document.body).scrollTop(this.saveScroll);else this.$editor.scrollTop(this.saveScroll);},pasteClipboardUploadMozilla:function()
{var imgs=this.$editor.find('img[data-mozilla-paste-image]');$.each(imgs,$.proxy(function(i,s)
{var $s=$(s);var arr=s.src.split(",");var data=arr[1];var contentType=arr[0].split(";")[0].split(":")[1];$.post(this.opts.clipboardUploadUrl,{contentType:contentType,data:data},$.proxy(function(data)
{var json=(typeof data==='string'?$.parseJSON(data):data);$s.attr('src',json.filelink);$s.removeAttr('data-mozilla-paste-image');this.sync();this.callback('imageUpload',$s,json);},this));},this));},pasteClipboardUpload:function(e)
{var result=e.target.result;var arr=result.split(",");var data=arr[1];var contentType=arr[0].split(";")[0].split(":")[1];if(this.opts.clipboardUpload)
{$.post(this.opts.clipboardUploadUrl,{contentType:contentType,data:data},$.proxy(function(data)
{var json=(typeof data==='string'?$.parseJSON(data):data);var html='<img src="'+json.filelink+'" id="clipboard-image-marker" />';this.execCommand('inserthtml',html,false);var image=$(this.$editor.find('img#clipboard-image-marker'));if(image.length)image.removeAttr('id');else image=false;this.sync();if(image)
{this.callback('imageUpload',image,json);}},this));}
else
{this.insertHtml('<img src="'+result+'" />');}},bufferSet:function(html)
{if(html!==undefined)this.opts.buffer.push(html);else
{this.selectionSave();this.opts.buffer.push(this.$editor.html());this.selectionRemoveMarkers('buffer');}},bufferUndo:function()
{if(this.opts.buffer.length===0)
{this.$editor.focus();return;}
this.selectionSave();this.opts.rebuffer.push(this.$editor.html());this.selectionRestore(false,true);this.$editor.html(this.opts.buffer.pop());this.selectionRestore();setTimeout($.proxy(this.observeStart,this),100);},bufferRedo:function()
{if(this.opts.rebuffer.length===0)
{this.$editor.focus();return false;}
this.selectionSave();this.opts.buffer.push(this.$editor.html());this.selectionRestore(false,true);this.$editor.html(this.opts.rebuffer.pop());this.selectionRestore(true);setTimeout($.proxy(this.observeStart,this),4);},observeStart:function()
{this.observeImages();if(this.opts.observeLinks)this.observeLinks();},observeLinks:function()
{this.$editor.find('a').on('click',$.proxy(this.linkObserver,this));this.$editor.on('click.redactor',$.proxy(function(e)
{this.linkObserverTooltipClose(e);},this));$(document).on('click.redactor',$.proxy(function(e)
{this.linkObserverTooltipClose(e);},this));},observeImages:function()
{if(this.opts.observeImages===false)return false;this.$editor.find('img').each($.proxy(function(i,elem)
{if(this.browser('msie'))$(elem).attr('unselectable','on');this.imageResize(elem);},this));},linkObserver:function(e)
{var $link=$(e.target);var pos=$link.offset();if(this.opts.iframe)
{var posFrame=this.$frame.offset();pos.top=posFrame.top+(pos.top-$(this.document).scrollTop());pos.left+=posFrame.left;}
var tooltip=$('<span class="redactor-link-tooltip"></span>');var href=$link.attr('href');if(href.length>24)href=href.substring(0,24)+'...';var aLink=$('<a href="'+$link.attr('href')+'" target="_blank">'+href+'</a>').on('click',$.proxy(function(e)
{this.linkObserverTooltipClose(false);},this));var aEdit=$('<a href="#">'+this.opts.curLang.edit+'</a>').on('click',$.proxy(function(e)
{e.preventDefault();this.linkShow();this.linkObserverTooltipClose(false);},this));var aUnlink=$('<a href="#">'+this.opts.curLang.unlink+'</a>').on('click',$.proxy(function(e)
{e.preventDefault();this.execCommand('unlink');this.linkObserverTooltipClose(false);},this));tooltip.append(aLink);tooltip.append(' | ');tooltip.append(aEdit);tooltip.append(' | ');tooltip.append(aUnlink);tooltip.css({top:(pos.top+20)+'px',left:pos.left+'px'});$('.redactor-link-tooltip').remove();$('body').append(tooltip);},linkObserverTooltipClose:function(e)
{if(e!==false&&e.target.tagName=='A')return false;$('.redactor-link-tooltip').remove();},getSelection:function()
{if(!this.opts.rangy)return this.document.getSelection();else
{if(!this.opts.iframe)return rangy.getSelection();else return rangy.getSelection(this.$frame[0]);}},getRange:function()
{if(!this.opts.rangy)
{if(this.document.getSelection)
{var sel=this.getSelection();if(sel.getRangeAt&&sel.rangeCount)return sel.getRangeAt(0);}
return this.document.createRange();}
else
{if(!this.opts.iframe)return rangy.createRange();else return rangy.createRange(this.iframeDoc());}},selectionElement:function(node)
{this.setCaret(node);},selectionStart:function(node)
{this.selectionSet(node[0]||node,0,null,0);},selectionEnd:function(node)
{this.selectionSet(node[0]||node,1,null,1);},selectionSet:function(orgn,orgo,focn,foco)
{if(focn==null)focn=orgn;if(foco==null)foco=orgo;var sel=this.getSelection();if(!sel)return;var range=this.getRange();range.setStart(orgn,orgo);range.setEnd(focn,foco);try{sel.removeAllRanges();}catch(e){}
sel.addRange(range);},selectionWrap:function(tag)
{tag=tag.toLowerCase();var block=this.getBlock();if(block)
{var wrapper=this.formatChangeTag(block,tag);this.sync();return wrapper;}
var sel=this.getSelection();var range=sel.getRangeAt(0);var wrapper=document.createElement(tag);wrapper.appendChild(range.extractContents());range.insertNode(wrapper);this.selectionElement(wrapper);return wrapper;},selectionAll:function()
{var range=this.getRange();range.selectNodeContents(this.$editor[0]);var sel=this.getSelection();sel.removeAllRanges();sel.addRange(range);},selectionRemove:function()
{this.getSelection().removeAllRanges();},getCaretOffset:function(element)
{var caretOffset=0;var range=this.getRange();var preCaretRange=range.cloneRange();preCaretRange.selectNodeContents(element);preCaretRange.setEnd(range.endContainer,range.endOffset);caretOffset=$.trim(preCaretRange.toString()).length;return caretOffset;},getCaretOffsetRange:function()
{return new Range(this.getSelection().getRangeAt(0));},setCaret:function(el,start,end)
{if(typeof end==='undefined')end=start;el=el[0]||el;var range=this.getRange();range.selectNodeContents(el);var textNodes=this.getTextNodesIn(el);var foundStart=false;var charCount=0,endCharCount;if(textNodes.length==1&&start)
{range.setStart(textNodes[0],start);range.setEnd(textNodes[0],end);}
else
{for(var i=0,textNode;textNode=textNodes[i++];)
{endCharCount=charCount+textNode.length;if(!foundStart&&start>=charCount&&(start<endCharCount||(start==endCharCount&&i<textNodes.length)))
{range.setStart(textNode,start-charCount);foundStart=true;}
if(foundStart&&end<=endCharCount)
{range.setEnd(textNode,end-charCount);break;}
charCount=endCharCount;}}
var sel=this.getSelection();sel.removeAllRanges();sel.addRange(range);},getTextNodesIn:function(node)
{var textNodes=[];if(node.nodeType==3)textNodes.push(node);else
{var children=node.childNodes;for(var i=0,len=children.length;i<len;++i)
{textNodes.push.apply(textNodes,this.getTextNodesIn(children[i]));}}
return textNodes;},getCurrent:function()
{var el=false;var sel=this.getSelection();if(sel&&sel.rangeCount>0)el=sel.getRangeAt(0).startContainer;return this.isParentRedactor(el);},getParent:function(elem)
{elem=elem||this.getCurrent();if(elem)return this.isParentRedactor($(elem).parent()[0]);else return false;},getBlock:function(node)
{if(typeof node==='undefined')node=this.getCurrent();while(node)
{if(this.nodeTestBlocks(node))
{if($(node).hasClass('redactor_editor'))return false;return node;}
node=node.parentNode;}
return false;},getBlocks:function(nodes)
{var newnodes=[];if(typeof nodes=='undefined')
{var range=this.getRange();if(range&&range.collapsed===true)return[this.getBlock()];var nodes=this.getNodes(range);}
$.each(nodes,$.proxy(function(i,node)
{if(this.opts.iframe===false&&$(node).parents('div.redactor_editor').size()==0)return false;if(this.nodeTestBlocks(node))newnodes.push(node);},this));if(newnodes.length===0)newnodes=[this.getBlock()];return newnodes;},nodeTestBlocks:function(node)
{return node.nodeType==1&&this.rTestBlock.test(node.nodeName);},tagTestBlock:function(tag)
{return this.rTestBlock.test(tag);},getNodes:function(range,tag)
{if(typeof range=='undefined'||range==false)var range=this.getRange();if(range&&range.collapsed===true)
{if(typeof tag==='undefined'&&this.tagTestBlock(tag))
{var block=this.getBlock();if(block.tagName==tag)return[block];else return[];}
else
{return[this.getCurrent()];}}
var nodes=[],finalnodes=[];var sel=this.document.getSelection();if(!sel.isCollapsed)nodes=this.getRangeSelectedNodes(sel.getRangeAt(0));$.each(nodes,$.proxy(function(i,node)
{if(this.opts.iframe===false&&$(node).parents('div.redactor_editor').size()==0)return false;if(typeof tag==='undefined')
{if($.trim(node.textContent)!='')
{finalnodes.push(node);}}
else if(node.tagName==tag)
{finalnodes.push(node);}},this));if(finalnodes.length==0)
{if(typeof tag==='undefined'&&this.tagTestBlock(tag))
{var block=this.getBlock();if(block.tagName==tag)return finalnodes.push(block);else return[];}
else
{finalnodes.push(this.getCurrent());}}
var last=finalnodes[finalnodes.length-1];if(this.nodeTestBlocks(last))
{finalnodes=finalnodes.slice(0,-1);}
return finalnodes;},getElement:function(node)
{if(!node)node=this.getCurrent();while(node)
{if(node.nodeType==1)
{if($(node).hasClass('redactor_editor'))return false;return node;}
node=node.parentNode;}
return false;},getRangeSelectedNodes:function(range)
{range=range||this.getRange();var node=range.startContainer;var endNode=range.endContainer;if(node==endNode)return[node];var rangeNodes=[];while(node&&node!=endNode)
{rangeNodes.push(node=this.nextNode(node));}
node=range.startContainer;while(node&&node!=range.commonAncestorContainer)
{rangeNodes.unshift(node);node=node.parentNode;}
return rangeNodes;},nextNode:function(node)
{if(node.hasChildNodes())return node.firstChild;else
{while(node&&!node.nextSibling)
{node=node.parentNode;}
if(!node)return null;return node.nextSibling;}},getSelectionText:function()
{return this.getSelection().toString();},getSelectionHtml:function()
{var html='';var sel=this.getSelection();if(sel.rangeCount)
{var container=this.document.createElement("div");var len=sel.rangeCount;for(var i=0;i<len;++i)
{container.appendChild(sel.getRangeAt(i).cloneContents());}
html=container.innerHTML;}
return this.syncClean(html);},selectionSave:function()
{if(!this.isFocused())this.$editor.focus();if(!this.opts.rangy)
{this.selectionCreateMarker(this.getRange());}
else
{this.savedSel=rangy.saveSelection();}},selectionCreateMarker:function(range,remove)
{if(!range)return;var node1=$('<span id="selection-marker-1" class="redactor-selection-marker">'+this.opts.invisibleSpace+'</span>',this.document)[0];var node2=$('<span id="selection-marker-2" class="redactor-selection-marker">'+this.opts.invisibleSpace+'</span>',this.document)[0];if(range.collapsed===true)
{this.selectionSetMarker(range,node1,true);}
else
{this.selectionSetMarker(range,node1,true);this.selectionSetMarker(range,node2,false);}
this.savedSel=this.$editor.html();this.selectionRestore(false,false);},selectionSetMarker:function(range,node,type)
{var boundaryRange=range.cloneRange();boundaryRange.collapse(type);boundaryRange.insertNode(node);boundaryRange.detach();},selectionRestore:function(replace,remove)
{if(!this.opts.rangy)
{if(replace===true&&this.savedSel)
{this.$editor.html(this.savedSel);}
var node1=this.$editor.find('span#selection-marker-1');var node2=this.$editor.find('span#selection-marker-2');if(this.browser('mozilla'))
{this.$editor.focus();}
else if(!this.isFocused())
{this.$editor.focus();}
if(node1.length!=0&&node2.length!=0)
{this.selectionSet(node1[0],0,node2[0],0);}
else if(node1.length!=0)
{this.selectionSet(node1[0],0,null,0);}
if(remove!==false)
{this.selectionRemoveMarkers();this.savedSel=false;}}
else
{rangy.restoreSelection(this.savedSel);}},selectionRemoveMarkers:function(type)
{if(!this.opts.rangy)
{$.each(this.$editor.find('span.redactor-selection-marker'),function()
{var html=$.trim($(this).html().replace(/[^\u0000-\u1C7F]/g,''));if(html=='')
{$(this).remove();}
else
{$(this).removeAttr('class').removeAttr('id');}});}
else
{rangy.removeMarkers(this.savedSel);}},tableShow:function()
{this.selectionSave();this.modalInit(this.opts.curLang.table,this.opts.modal_table,300,$.proxy(function()
{$('#redactor_insert_table_btn').click($.proxy(this.tableInsert,this));setTimeout(function()
{$('#redactor_table_rows').focus();},200);},this));},tableInsert:function()
{var rows=$('#redactor_table_rows').val(),columns=$('#redactor_table_columns').val(),$table_box=$('<div></div>'),tableId=Math.floor(Math.random()*99999),$table=$('<table id="table'+tableId+'"><tbody></tbody></table>'),i,$row,z,$column;for(i=0;i<rows;i++)
{$row=$('<tr></tr>');for(z=0;z<columns;z++)
{$column=$('<td>'+this.opts.invisibleSpace+'</td>');if(i===0&&z===0)$column.append('<span id="selection-marker-1">'+this.opts.invisibleSpace+'</span>');$($row).append($column);}
$table.append($row);}
$table_box.append($table);var html=$table_box.html();this.modalClose();this.selectionRestore();var current=this.getBlock()||this.getCurrent();if(current&&current.tagName!='BODY')$(current).after(html)
else this.insertHtmlAdvanced(html,false);this.selectionRestore();var table=this.$editor.find('#table'+tableId);this.buttonActiveObserver();table.find('span#selection-marker-1').remove();table.removeAttr('id');this.sync();},tableDeleteTable:function()
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();$table.remove();this.sync();},tableDeleteRow:function()
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();var $current_tr=$(this.getParent()).closest('tr');var $focus_tr=$current_tr.prev().length?$current_tr.prev():$current_tr.next();if($focus_tr.length)
{var $focus_td=$focus_tr.children('td').first();if($focus_td.length)
{$focus_td.prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+'</span>');}}
$current_tr.remove();this.selectionRestore();this.sync();},tableDeleteColumn:function()
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();var $current_td=$(this.getParent()).closest('td');var index=$current_td.get(0).cellIndex;$table.find('tr').each($.proxy(function(i,elem)
{var focusIndex=index-1<0?index+1:index-1;if(i===0)
{$(elem).find('td').eq(focusIndex).prepend('<span id="selection-marker-1">'+this.opts.invisibleSpace+'</span>');}
$(elem).find('td').eq(index).remove();},this));this.selectionRestore();this.sync();},tableAddHead:function()
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();if($table.find('thead').size()!==0)this.tableDeleteHead();else
{var tr=$table.find('tr').first().clone();tr.find('td').html(this.opts.invisibleSpace);$thead=$('<thead></thead>');$thead.append(tr);$table.prepend($thead);this.sync();}},tableDeleteHead:function()
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;var $thead=$table.find('thead');if($thead.size()==0)return false;this.bufferSet();$thead.remove();this.sync();},tableAddRowAbove:function()
{this.tableAddRow('before');},tableAddRowBelow:function()
{this.tableAddRow('after');},tableAddColumnLeft:function()
{this.tableAddColumn('before');},tableAddColumnRight:function()
{this.tableAddColumn('after');},tableAddRow:function(type)
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();var $current_tr=$(this.getParent()).closest('tr');var new_tr=$current_tr.clone();new_tr.find('td').html(this.opts.invisibleSpace);if(type==='after')$current_tr.after(new_tr);else $current_tr.before(new_tr);this.sync();},tableAddColumn:function(type)
{var $table=$(this.getParent()).closest('table');if(!this.isParentRedactor($table))return false;if($table.size()==0)return false;this.bufferSet();var index=0;var $current_tr=$(this.getParent()).closest('tr');var $current_td=$(this.getParent()).closest('td');$current_tr.find('td').each($.proxy(function(i,elem)
{if($(elem)[0]===$current_td[0])index=i;},this));$table.find('tr').each($.proxy(function(i,elem)
{var $current=$(elem).find('td').eq(index);var td=$current.clone();td.html(this.opts.invisibleSpace);type==='after'?$current.after(td):$current.before(td);},this));this.sync();},videoShow:function()
{this.selectionSave();this.modalInit(this.opts.curLang.video,this.opts.modal_video,600,$.proxy(function()
{$('#redactor_insert_video_btn').click($.proxy(this.videoInsert,this));setTimeout(function()
{$('#redactor_insert_video_area').focus();},200);},this));},videoInsert:function()
{var data=$('#redactor_insert_video_area').val();data=this.cleanStripTags(data);this.selectionRestore();var current=this.getBlock()||this.getCurrent();if(current)$(current).after(data)
else this.insertHtmlAdvanced(data,false);this.sync();this.modalClose();},linkShow:function()
{this.selectionSave();var callback=$.proxy(function()
{this.insert_link_node=false;var sel=this.getSelection();var url='',text='',target='';var elem=this.getParent();var par=$(elem).parent().get(0);if(par&&par.tagName==='A')
{elem=par;}
if(elem&&elem.tagName==='A')
{url=elem.href;text=$(elem).text();target=elem.target;this.insert_link_node=elem;}
else text=sel.toString();$('.redactor_link_text').val(text);var thref=self.location.href.replace(/\/$/i,'');var turl=url.replace(thref,'');if(this.opts.linkProtocol===false)
{var re=new RegExp('^(http|ftp|https)://'+self.location.host,'i');turl=turl.replace(re,'');}
var tabs=$('#redactor_tabs').find('a');if(this.opts.linkEmail===false)tabs.eq(1).remove();if(this.opts.linkAnchor===false)tabs.eq(2).remove();if(this.opts.linkEmail===false&&this.opts.linkAnchor===false)
{$('#redactor_tabs').remove();$('#redactor_link_url').val(turl);}
else
{if(url.search('mailto:')===0)
{this.modalSetTab.call(this,2);$('#redactor_tab_selected').val(2);$('#redactor_link_mailto').val(url.replace('mailto:',''));}
else if(turl.search(/^#/gi)===0)
{this.modalSetTab.call(this,3);$('#redactor_tab_selected').val(3);$('#redactor_link_anchor').attr('name',turl.replace(/^#/gi,''));}
else
{$('#redactor_link_url').val(turl);}}
if(target==='_blank')$('#redactor_link_blank').prop('checked',true);$('#redactor_insert_link_btn').click($.proxy(this.linkProcess,this));setTimeout(function()
{$('#redactor_link_url').focus();},200);},this);this.modalInit(this.opts.curLang.link,this.opts.modal_link,460,callback);},linkProcess:function()
{var tab_selected=$('#redactor_tab_selected').val();var link='',text='',target='',targetBlank='';if(tab_selected==='1')
{link=$('#redactor_link_url').val();text=$('#redactor_link_url_text').val();if($('#redactor_link_blank').prop('checked'))
{target=' target="_blank"';targetBlank='_blank';}
var pattern='((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{2,}';var re=new RegExp('^(http|ftp|https)://'+pattern,'i');var re2=new RegExp('^'+pattern,'i');if(link.search(re)==-1&&link.search(re2)==0&&this.opts.linkProtocol)
{link=this.opts.linkProtocol+link;}}
else if(tab_selected==='2')
{link='mailto:'+$('#redactor_link_mailto').val();text=$('#redactor_link_mailto_text').val();}
else if(tab_selected==='3')
{var anchor=true;link=$('#redactor_link_anchor').val();text=$('#redactor_link_anchor_text').val();}
link=link.replace(/(<([^>]+)>)/ig,"");link=link.replace(/\"/ig,"");text=text.replace(/<|>/g,'');link=$("<div />").html(link).text();link=link.replace(/(<([^>]+)>)/ig,"");link=link.replace(/\"/ig,"");if(anchor)
this.linkInsert('<a name="'+link+'"'+target+'></a>',$.trim("null"),link,targetBlank);else
this.linkInsert('<a href="'+link+'"'+target+'>'+text+'</a>',$.trim(text),link,targetBlank);},linkInsert:function(a,text,link,target)
{this.selectionRestore();if(text!=='')
{if(this.insert_link_node)
{this.bufferSet();$(this.insert_link_node).text(text).attr('href',link);if(target!=='')$(this.insert_link_node).attr('target',target);else $(this.insert_link_node).removeAttr('target');this.sync();}
else
{var $a=$(a).addClass('redactor-added-link');this.exec('inserthtml',this.outerHtml($a),false);this.$editor.find('a.redactor-added-link').removeAttr('style').removeClass('redactor-added-link').each(function()
{if(this.className=='')$(this).removeAttr('class');});this.sync();}}
setTimeout($.proxy(function()
{if(this.opts.observeLinks)this.observeLinks();},this),5);this.modalClose();},fileShow:function()
{this.selectionSave();var callback=$.proxy(function()
{var sel=this.getSelection();var text='';if(this.oldIE())text=sel.text;else text=sel.toString();$('#redactor_filename').val(text);if(!this.isMobile())
{this.draguploadInit('#redactor_file',{url:this.opts.fileUpload,uploadFields:this.opts.uploadFields,success:$.proxy(this.fileCallback,this),error:$.proxy(function(obj,json)
{this.callback('fileUploadError',json);},this),uploadParam:this.opts.fileUploadParam});}
this.uploadInit('redactor_file',{auto:true,url:this.opts.fileUpload,success:$.proxy(this.fileCallback,this),error:$.proxy(function(obj,json)
{this.callback('fileUploadError',json);},this)});},this);this.modalInit(this.opts.curLang.file,this.opts.modal_file,500,callback);},fileCallback:function(json)
{this.selectionRestore();if(json!==false)
{var text=$('#redactor_filename').val();if(text==='')text=json.filename;var link='<a href="'+json.filelink+'" id="filelink-marker">'+text+'</a>';if(this.browser('webkit')&&!!this.window.chrome)
{link=link+'&nbsp;';}
this.execCommand('inserthtml',link,false);var linkmarker=$(this.$editor.find('a#filelink-marker'));if(linkmarker.size()!=0)linkmarker.removeAttr('id');else linkmarker=false;this.sync();this.callback('fileUpload',linkmarker,json);}
this.modalClose();},imageShow:function()
{this.selectionSave();var callback=$.proxy(function()
{if(this.opts.imageGetJson)
{$.getJSON(this.opts.imageGetJson,$.proxy(function(data)
{var folders={},count=0;$.each(data,$.proxy(function(key,val)
{if(typeof val.folder!=='undefined')
{count++;folders[val.folder]=count;}},this));var folderclass=false;$.each(data,$.proxy(function(key,val)
{var thumbtitle='';if(typeof val.title!=='undefined')thumbtitle=val.title;var folderkey=0;if(!$.isEmptyObject(folders)&&typeof val.folder!=='undefined')
{folderkey=folders[val.folder];if(folderclass===false)folderclass='.redactorfolder'+folderkey;}
var img=$('<img src="'+val.thumb+'" class="redactorfolder redactorfolder'+folderkey+'" rel="'+val.image+'" title="'+thumbtitle+'" />');$('#redactor_image_box').append(img);$(img).click($.proxy(this.imageThumbClick,this));},this));if(!$.isEmptyObject(folders))
{$('.redactorfolder').hide();$(folderclass).show();var onchangeFunc=function(e)
{$('.redactorfolder').hide();$('.redactorfolder'+$(e.target).val()).show();};var select=$('<select id="redactor_image_box_select">');$.each(folders,function(k,v)
{select.append($('<option value="'+v+'">'+k+'</option>'));});$('#redactor_image_box').before(select);select.change(onchangeFunc);}},this));}
else
{$('#redactor_tabs').find('a').eq(1).remove();}
if(this.opts.imageUpload||this.opts.s3)
{if(!this.isMobile()&&this.opts.s3===false)
{if($('#redactor_file').length)
{this.draguploadInit('#redactor_file',{url:this.opts.imageUpload,uploadFields:this.opts.uploadFields,success:$.proxy(this.imageCallback,this),error:$.proxy(function(obj,json)
{this.callback('imageUploadError',json);},this),uploadParam:this.opts.imageUploadParam});}}
if(this.opts.s3===false)
{this.uploadInit('redactor_file',{auto:true,url:this.opts.imageUpload,success:$.proxy(this.imageCallback,this),error:$.proxy(function(obj,json)
{this.callback('imageUploadError',json);},this)});}
else
{$('#redactor_file').on('change.redactor',$.proxy(this.s3handleFileSelect,this));}}
else
{$('.redactor_tab').hide();if(!this.opts.imageGetJson)
{$('#redactor_tabs').remove();$('#redactor_tab3').show();}
else
{var tabs=$('#redactor_tabs').find('a');tabs.eq(0).remove();tabs.eq(1).addClass('redactor_tabs_act');$('#redactor_tab2').show();}}
$('#redactor_upload_btn').click($.proxy(this.imageCallbackLink,this));if(!this.opts.imageUpload&&!this.opts.imageGetJson)
{setTimeout(function()
{$('#redactor_file_link').focus();},200);}},this);this.modalInit(this.opts.curLang.image,this.opts.modal_image,610,callback);},imageEdit:function(image)
{var $el=image;var parent=$el.parent().parent();var callback=$.proxy(function()
{$('#redactor_file_alt').val($el.attr('alt'));$('#redactor_image_edit_src').attr('href',$el.attr('src'));$('#redactor_form_image_align').val($el.css('float'));if($(parent).get(0).tagName==='A')
{$('#redactor_file_link').val($(parent).attr('href'));if($(parent).attr('target')=='_blank')
{$('#redactor_link_blank').prop('checked',true);}}
$('#redactor_image_delete_btn').click($.proxy(function()
{this.imageRemove($el);},this));$('#redactorSaveBtn').click($.proxy(function()
{this.imageSave($el);},this));},this);this.modalInit(this.opts.curLang.edit,this.opts.modal_image_edit,380,callback);},imageRemove:function(el)
{var parent=$(el).parent();$(el).remove();if(parent.length&&parent[0].tagName==='P')
{this.$editor.focus();this.selectionStart(parent);}
this.callback('imageDelete',el);this.modalClose();this.sync();},imageSave:function(el)
{var $el=$(el);var parent=$el.parent();$el.attr('alt',$('#redactor_file_alt').val());var floating=$('#redactor_form_image_align').val();if(floating==='left')
{this.imageMargin='0 '+this.opts.imageFloatMargin+' '+this.opts.imageFloatMargin+' 0';$el.css({'float':'left','margin':this.imageMargin});}
else if(floating==='right')
{this.imageMargin='0 0 '+this.opts.imageFloatMargin+' '+this.opts.imageFloatMargin+'';$el.css({'float':'right','margin':this.imageMargin});}
else
{this.imageMargin='0px';var imageBox=$el.closest('#redactor-image-box');if(imageBox.size()!=0)imageBox.css({'float':'','margin':''});$el.css({'float':'','margin':''});}
var link=$.trim($('#redactor_file_link').val());if(link!=='')
{var target=false;if($('#redactor_link_blank').prop('checked'))
{target=true;}
if(parent.get(0).tagName!=='A')
{var a=$('<a>'+this.outerHtml(el)+'</a>');a.attr('href',link);if(target)
{a.attr('target','_blank');}
$el.replaceWith(a);}
else
{parent.attr('href',link);if(target)
{parent.attr('target','_blank');}
else
{parent.removeAttr('target');}}}
else
{if(parent.get(0).tagName==='A')
{parent.replaceWith(this.outerHtml(el));}}
this.modalClose();this.observeImages();this.sync();},imageResizeHide:function(e)
{if(e!==false&&$(e.target).parent().size()!=0&&$(e.target).parent()[0].id==='redactor-image-box')
{return false;}
var imageBox=this.$editor.find('#redactor-image-box');if(imageBox.size()==0)
{return false;}
this.$editor.find('#redactor-image-editter, #redactor-image-resizer').remove();if(this.imageMargin!='0px')
{imageBox.find('img').css('margin',this.imageMargin);imageBox.css('margin','');this.imageMargin='0px';}
imageBox.find('img').css('opacity','');imageBox.replaceWith(function()
{return $(this).contents();});$(document).off('click.redactor-image-resize-hide');this.$editor.off('click.redactor-image-resize-hide');this.$editor.off('keydown.redactor-image-delete');this.sync()},imageResize:function(image)
{var $image=$(image);$image.on('mousedown',$.proxy(function()
{this.imageResizeHide(false);},this));$image.on('dragstart',$.proxy(function()
{this.$editor.on('drop.redactor-image-inside-drop',$.proxy(function()
{setTimeout($.proxy(function()
{this.observeImages();this.$editor.off('drop.redactor-image-inside-drop');this.sync();},this),1);},this));},this));$image.on('click',$.proxy(function(e)
{if(this.$editor.find('#redactor-image-box').size()!=0)
{return false;}
var clicked=false,start_x,start_y,ratio=$image.width()/$image.height(),min_w=20,min_h=10;var imageResizer=this.imageResizeControls($image);var isResizing=false;imageResizer.on('mousedown',function(e)
{isResizing=true;e.preventDefault();ratio=$image.width()/$image.height();start_x=Math.round(e.pageX-$image.eq(0).offset().left);start_y=Math.round(e.pageY-$image.eq(0).offset().top);});$(this.document.body).on('mousemove',$.proxy(function(e)
{if(isResizing)
{var mouse_x=Math.round(e.pageX-$image.eq(0).offset().left)-start_x;var mouse_y=Math.round(e.pageY-$image.eq(0).offset().top)-start_y;var div_h=$image.height();var new_h=parseInt(div_h,10)+mouse_y;var new_w=Math.round(new_h*ratio);if(new_w>min_w)
{$image.width(new_w);if(new_w<100)
{this.imageEditter.css({marginTop:'-7px',marginLeft:'-13px',fontSize:'9px',padding:'3px 5px'});}
else
{this.imageEditter.css({marginTop:'-11px',marginLeft:'-18px',fontSize:'11px',padding:'7px 10px'});}}
start_x=Math.round(e.pageX-$image.eq(0).offset().left);start_y=Math.round(e.pageY-$image.eq(0).offset().top);this.sync()}},this)).on('mouseup',function()
{isResizing=false;});this.$editor.on('keydown.redactor-image-delete',$.proxy(function(e)
{var key=e.which;if(this.keyCode.BACKSPACE==key||this.keyCode.DELETE==key)
{this.bufferSet();this.imageResizeHide(false);this.imageRemove($image);}},this));$(document).on('click.redactor-image-resize-hide',$.proxy(this.imageResizeHide,this));this.$editor.on('click.redactor-image-resize-hide',$.proxy(this.imageResizeHide,this));},this));},imageResizeControls:function($image)
{var imageBox=$('<span id="redactor-image-box" data-redactor="verified">');imageBox.css({position:'relative',display:'inline-block',lineHeight:0,outline:'1px dashed rgba(0, 0, 0, .6)','float':$image.css('float')});imageBox.attr('contenteditable',false);this.imageMargin=$image[0].style.margin;if(this.imageMargin!='0px')
{imageBox.css('margin',this.imageMargin);$image.css('margin','');}
$image.css('opacity',.5).after(imageBox);this.imageEditter=$('<span id="redactor-image-editter" data-redactor="verified">'+this.opts.curLang.edit+'</span>');this.imageEditter.css({position:'absolute',zIndex:2,top:'50%',left:'50%',marginTop:'-11px',marginLeft:'-18px',lineHeight:1,backgroundColor:'#000',color:'#fff',fontSize:'11px',padding:'7px 10px',cursor:'pointer'});this.imageEditter.attr('contenteditable',false);this.imageEditter.on('click',$.proxy(function()
{this.imageEdit($image);},this));imageBox.append(this.imageEditter);var imageResizer=$('<span id="redactor-image-resizer" data-redactor="verified"></span>');imageResizer.css({position:'absolute',zIndex:2,lineHeight:1,cursor:'nw-resize',bottom:'-4px',right:'-5px',border:'1px solid #fff',backgroundColor:'#000',width:'8px',height:'8px'});imageResizer.attr('contenteditable',false);imageBox.append(imageResizer);imageBox.append($image);return imageResizer;},imageThumbClick:function(e)
{var img='<img id="image-marker" src="'+$(e.target).attr('rel')+'" alt="'+$(e.target).attr('title')+'" />';var parent=this.getParent();if(this.opts.paragraphy&&$(parent).closest('li').size()==0)img='<p>'+img+'</p>';this.imageInsert(img,true);},imageCallbackLink:function()
{var val=$('#redactor_file_link').val();if(val!=='')
{var data='<img id="image-marker" src="'+val+'" />';if(this.opts.linebreaks===false)data='<p>'+data+'</p>';this.imageInsert(data,true);}
else this.modalClose();},imageCallback:function(data)
{this.imageInsert(data);},imageInsert:function(json,link)
{this.selectionRestore();if(json!==false)
{var html='';if(link!==true)
{html='<img id="image-marker" src="'+json.filelink+'" />';var parent=this.getParent();if(this.opts.paragraphy&&$(parent).closest('li').size()==0)
{html='<p>'+html+'</p>';}}
else
{html=json;}
this.execCommand('inserthtml',html,false);var image=$(this.$editor.find('img#image-marker'));if(image.length)image.removeAttr('id');else image=false;this.sync();link!==true&&this.callback('imageUpload',image,json);}
this.modalClose();this.observeImages();},modalTemplatesInit:function()
{$.extend(this.opts,{modal_file:String()
+'<section>'
+'<div id="redactor-progress" class="redactor-progress redactor-progress-striped" style="display: none;">'
+'<div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div>'
+'</div>'
+'<form id="redactorUploadFileForm" method="post" action="" enctype="multipart/form-data">'
+'<label>'+this.opts.curLang.filename+'</label>'
+'<input type="text" id="redactor_filename" class="redactor_input" />'
+'<div style="margin-top: 7px;">'
+'<input type="file" id="redactor_file" name="'+this.opts.fileUploadParam+'" />'
+'</div>'
+'</form>'
+'</section>',modal_image_edit:String()
+'<section>'
+'<label>'+this.opts.curLang.title+'</label>'
+'<input id="redactor_file_alt" class="redactor_input" />'
+'<label>'+this.opts.curLang.link+'</label>'
+'<input id="redactor_file_link" class="redactor_input" />'
+'<label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+'</label>'
+'<label>'+this.opts.curLang.image_position+'</label>'
+'<select id="redactor_form_image_align">'
+'<option value="none">'+this.opts.curLang.none+'</option>'
+'<option value="left">'+this.opts.curLang.left+'</option>'
+'<option value="right">'+this.opts.curLang.right+'</option>'
+'</select>'
+'</section>'
+'<footer>'
+'<button id="redactor_image_delete_btn" class="redactor_modal_btn redactor_modal_delete_btn">'+this.opts.curLang._delete+'</button>&nbsp;&nbsp;&nbsp;'
+'<button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button>'
+'<input type="button" name="save" class="redactor_modal_btn redactor_modal_action_btn" id="redactorSaveBtn" value="'+this.opts.curLang.save+'" />'
+'</footer>',modal_image:String()
+'<section>'
+'<div id="redactor_tabs">'
+'<a href="#" class="redactor_tabs_act">'+this.opts.curLang.upload+'</a>'
+'<a href="#">'+this.opts.curLang.choose+'</a>'
+'<a href="#">'+this.opts.curLang.link+'</a>'
+'</div>'
+'<div id="redactor-progress" class="redactor-progress redactor-progress-striped" style="display: none;">'
+'<div id="redactor-progress-bar" class="redactor-progress-bar" style="width: 100%;"></div>'
+'</div>'
+'<form id="redactorInsertImageForm" method="post" action="" enctype="multipart/form-data">'
+'<div id="redactor_tab1" class="redactor_tab">'
+'<input type="file" id="redactor_file" name="'+this.opts.imageUploadParam+'" />'
+'</div>'
+'<div id="redactor_tab2" class="redactor_tab" style="display: none;">'
+'<div id="redactor_image_box"></div>'
+'</div>'
+'</form>'
+'<div id="redactor_tab3" class="redactor_tab" style="display: none;">'
+'<label>'+this.opts.curLang.image_web_link+'</label>'
+'<input type="text" name="redactor_file_link" id="redactor_file_link" class="redactor_input"  />'
+'</div>'
+'</section>'
+'<footer>'
+'<a href="#" class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</a>'
+'<input type="button" name="upload" class="redactor_modal_btn" id="redactor_upload_btn" value="'+this.opts.curLang.upload+'" />'
+'</footer>',modal_link:String()
+'<section>'
+'<form id="redactorInsertLinkForm" method="post" action="">'
+'<div id="redactor_tabs">'
+'<a href="#" class="redactor_tabs_act">'+this.opts.curLang.web+'</a>'
+'<a href="#">'+this.opts.curLang.mailto+'</a>'
+'<a href="#">'+this.opts.curLang.anchor+'</a>'
+'</div>'
+'<input type="hidden" id="redactor_tab_selected" value="1" />'
+'<div class="redactor_tab" id="redactor_tab1">'
+'<label for="redactor_link_url">'+this.opts.curLang.web+'</label>'
+'<input type="text" id="redactor_link_url" class="redactor_input"  />'
+'<label for="redactor_link_url_text">'+this.opts.curLang.text+'</label>'
+'<input type="text" class="redactor_input redactor_link_text" id="redactor_link_url_text" />'
+'<label><input type="checkbox" id="redactor_link_blank"> '+this.opts.curLang.link_new_tab+'</label>'
+'</div>'
+'<div class="redactor_tab" id="redactor_tab2" style="display: none;">'
+'<label>'+this.opts.curLang.mailto+'</label>'
+'<input type="text" id="redactor_link_mailto" class="redactor_input" />'
+'<label>'+this.opts.curLang.text+'</label>'
+'<input type="text" class="redactor_input redactor_link_text" id="redactor_link_mailto_text" />'
+'</div>'
+'<div class="redactor_tab" id="redactor_tab3" style="display: none;">'
+'<label>'+this.opts.curLang.anchor+'</label>'
+'<input type="text" class="redactor_input" id="redactor_link_anchor"  />'
+'<input type="text" class="redactor_input redactor_link_text" id="redactor_link_anchor_text" value="null" style="display:none" disabled="true"/>'
+'</div>'
+'</form>'
+'</section>'
+'<footer>'
+'<button class="redactor_modal_btn redactor_btn_modal_close" id="redactor_cancel_link_btn">'+this.opts.curLang.cancel+'</button>'
+'<input type="button" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_link_btn" value="'+this.opts.curLang.insert+'" />'
+'</footer>',modal_table:String()
+'<section>'
+'<label>'+this.opts.curLang.rows+'</label>'
+'<input type="text" size="5" value="2" id="redactor_table_rows" />'
+'<label>'+this.opts.curLang.columns+'</label>'
+'<input type="text" size="5" value="3" id="redactor_table_columns" />'
+'</section>'
+'<footer>'
+'<button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button>'
+'<input type="button" name="upload" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_table_btn" value="'+this.opts.curLang.insert+'" />'
+'</footer>',modal_video:String()
+'<section>'
+'<form id="redactorInsertVideoForm">'
+'<label>'+this.opts.curLang.video_html_code+'</label>'
+'<textarea id="redactor_insert_video_area" style="width: 99%; height: 160px;"></textarea>'
+'</form>'
+'</section>'
+'<footer>'
+'<button class="redactor_modal_btn redactor_btn_modal_close">'+this.opts.curLang.cancel+'</button>'
+'<input type="button" class="redactor_modal_btn redactor_modal_action_btn" id="redactor_insert_video_btn" value="'+this.opts.curLang.insert+'" />'
+'</footer>'});},modalInit:function(title,content,width,callback)
{var $redactorModalOverlay=$('#redactor_modal_overlay');if(!$redactorModalOverlay.length)
{this.$overlay=$redactorModalOverlay=$('<div id="redactor_modal_overlay" style="display: none;"></div>');$('body').prepend(this.$overlay);}
if(this.opts.modalOverlay)
{$redactorModalOverlay.show().on('click',$.proxy(this.modalClose,this));}
var $redactorModal=$('#redactor_modal');if(!$redactorModal.length)
{this.$modal=$redactorModal=$('<div id="redactor_modal" style="display: none;"><div id="redactor_modal_close">&times;</div><header id="redactor_modal_header"></header><div id="redactor_modal_inner"></div></div>');$('body').append(this.$modal);}
$('#redactor_modal_close').on('click',$.proxy(this.modalClose,this));this.hdlModalClose=$.proxy(function(e)
{if(e.keyCode===this.keyCode.ESC)
{this.modalClose();return false;}},this);$(document).keyup(this.hdlModalClose);this.$editor.keyup(this.hdlModalClose);this.modalcontent=false;if(content.indexOf('#')==0)
{this.modalcontent=$(content);$('#redactor_modal_inner').empty().append(this.modalcontent.html());this.modalcontent.html('');}
else
{$('#redactor_modal_inner').empty().append(content);}
$redactorModal.find('#redactor_modal_header').html(title);if(typeof $.fn.draggable!=='undefined')
{$redactorModal.draggable({handle:'#redactor_modal_header'});$redactorModal.find('#redactor_modal_header').css('cursor','move');}
var $redactor_tabs=$('#redactor_tabs');if($redactor_tabs.length)
{var that=this;$redactor_tabs.find('a').each(function(i,s)
{i++;$(s).on('click',function(e)
{e.preventDefault();$redactor_tabs.find('a').removeClass('redactor_tabs_act');$(this).addClass('redactor_tabs_act');$('.redactor_tab').hide();$('#redactor_tab'+i).show();$('#redactor_tab_selected').val(i);if(that.isMobile()===false)
{var height=$redactorModal.outerHeight();$redactorModal.css('margin-top','-'+(height+10)/2+'px');}});});}
$redactorModal.find('.redactor_btn_modal_close').on('click',$.proxy(this.modalClose,this));if(this.opts.autoresize===true)
{this.saveModalScroll=this.document.body.scrollTop;}
else
{this.saveModalScroll=this.$editor.scrollTop();}
if(this.isMobile()===false)
{$redactorModal.css({position:'fixed',top:'-2000px',left:'50%',width:width+'px',marginLeft:'-'+(width+60)/2+'px'}).show();this.modalSaveBodyOveflow=$(document.body).css('overflow');$(document.body).css('overflow','hidden');}
else
{$redactorModal.css({position:'fixed',width:'100%',height:'100%',top:'0',left:'0',margin:'0',minHeight:'300px'}).show();}
if(typeof callback==='function')callback();this.$element.trigger("modalOpenedCallback",title);if(this.isMobile()===false)
{setTimeout(function()
{var height=$redactorModal.outerHeight();$redactorModal.css({top:'50%',height:'auto',minHeight:'auto',marginTop:'-'+(height+10)/2+'px'});},10);}},modalClose:function()
{$('#redactor_modal_close').off('click',this.modalClose);$('#redactor_modal').fadeOut('fast',$.proxy(function()
{var redactorModalInner=$('#redactor_modal_inner');if(this.modalcontent!==false)
{this.modalcontent.html(redactorModalInner.html());this.modalcontent=false;}
redactorModalInner.html('');if(this.opts.modalOverlay)
{$('#redactor_modal_overlay').hide().off('click',this.modalClose);}
$(document).unbind('keyup',this.hdlModalClose);this.$editor.unbind('keyup',this.hdlModalClose);this.selectionRestore();if(this.opts.autoresize&&this.saveModalScroll)
{$(this.document.body).scrollTop(this.saveModalScroll);}
else if(this.opts.autoresize===false&&this.saveModalScroll)
{this.$editor.scrollTop(this.saveModalScroll);}},this));if(this.isMobile()===false)
{$(document.body).css('overflow',this.modalSaveBodyOveflow?this.modalSaveBodyOveflow:'visible');}
return false;},modalSetTab:function(num)
{$('.redactor_tab').hide();$('#redactor_tabs').find('a').removeClass('redactor_tabs_act').eq(num-1).addClass('redactor_tabs_act');$('#redactor_tab'+num).show();},s3handleFileSelect:function(e)
{var files=e.target.files;for(var i=0,f;f=files[i];i++)
{this.s3uploadFile(f);}},s3uploadFile:function(file)
{this.s3executeOnSignedUrl(file,$.proxy(function(signedURL)
{this.s3uploadToS3(file,signedURL);},this));},s3executeOnSignedUrl:function(file,callback)
{var xhr=new XMLHttpRequest();var mark='?';if(this.opts.s3.search(/\?/)!='-1')mark='&';xhr.open('GET',this.opts.s3+mark+'name='+file.name+'&type='+file.type,true);if(xhr.overrideMimeType)xhr.overrideMimeType('text/plain; charset=x-user-defined');xhr.onreadystatechange=function(e)
{if(this.readyState==4&&this.status==200)
{$('#redactor-progress').fadeIn();callback(decodeURIComponent(this.responseText));}
else if(this.readyState==4&&this.status!=200)
{}};xhr.send();},s3createCORSRequest:function(method,url)
{var xhr=new XMLHttpRequest();if("withCredentials"in xhr)
{xhr.open(method,url,true);}
else if(typeof XDomainRequest!="undefined")
{xhr=new XDomainRequest();xhr.open(method,url);}
else
{xhr=null;}
return xhr;},s3uploadToS3:function(file,url)
{var xhr=this.s3createCORSRequest('PUT',url);if(!xhr)
{}
else
{xhr.onload=$.proxy(function()
{if(xhr.status==200)
{$('#redactor-progress, #redactor-progress-drag').hide();var s3image=url.split('?');if(!s3image[0])
{return false;}
this.selectionRestore();var html='';html='<img id="image-marker" src="'+s3image[0]+'" />';if(this.opts.paragraphy)html='<p>'+html+'</p>';this.execCommand('inserthtml',html,false);var image=$(this.$editor.find('img#image-marker'));if(image.length)image.removeAttr('id');else image=false;this.sync();this.callback('imageUpload',image,false);this.modalClose();this.observeImages();}
else
{}},this);xhr.onerror=function()
{};xhr.upload.onprogress=function(e)
{};xhr.setRequestHeader('Content-Type',file.type);xhr.setRequestHeader('x-amz-acl','public-read');xhr.send(file);}},uploadInit:function(el,options)
{this.uploadOptions={url:false,success:false,error:false,start:false,trigger:false,auto:false,input:false};$.extend(this.uploadOptions,options);var $el=$('#'+el);if($el.length&&$el[0].tagName==='INPUT')
{this.uploadOptions.input=$el;this.el=$($el[0].form);}
else this.el=$el;this.element_action=this.el.attr('action');if(this.uploadOptions.auto)
{$(this.uploadOptions.input).change($.proxy(function(e)
{this.el.submit(function(e)
{return false;});this.uploadSubmit(e);},this));}
else if(this.uploadOptions.trigger)
{$('#'+this.uploadOptions.trigger).click($.proxy(this.uploadSubmit,this));}},uploadSubmit:function(e)
{$('#redactor-progress').fadeIn();this.uploadForm(this.element,this.uploadFrame());},uploadFrame:function()
{this.id='f'+Math.floor(Math.random()*99999);var d=this.document.createElement('div');var iframe='<iframe style="display:none" id="'+this.id+'" name="'+this.id+'"></iframe>';d.innerHTML=iframe;$(d).appendTo("body");if(this.uploadOptions.start)this.uploadOptions.start();$('#'+this.id).load($.proxy(this.uploadLoaded,this));return this.id;},uploadForm:function(f,name)
{if(this.uploadOptions.input)
{var formId='redactorUploadForm'+this.id,fileId='redactorUploadFile'+this.id;this.form=$('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+name+'" name="'+formId+'" id="'+formId+'" enctype="multipart/form-data" />');if(this.opts.uploadFields!==false&&typeof this.opts.uploadFields==='object')
{$.each(this.opts.uploadFields,$.proxy(function(k,v)
{if(v!=null&&v.toString().indexOf('#')===0)v=$(v).val();var hidden=$('<input/>',{'type':"hidden",'name':k,'value':v});$(this.form).append(hidden);},this));}
var oldElement=this.uploadOptions.input;var newElement=$(oldElement).clone();$(oldElement).attr('id',fileId).before(newElement).appendTo(this.form);$(this.form).css('position','absolute').css('top','-2000px').css('left','-2000px').appendTo('body');this.form.submit();}
else
{f.attr('target',name).attr('method','POST').attr('enctype','multipart/form-data').attr('action',this.uploadOptions.url);this.element.submit();}},uploadLoaded:function()
{var i=$('#'+this.id)[0],d;if(i.contentDocument)d=i.contentDocument;else if(i.contentWindow)d=i.contentWindow.document;else d=window.frames[this.id].document;if(this.uploadOptions.success)
{$('#redactor-progress').hide();if(typeof d!=='undefined')
{var rawString=d.body.innerHTML;var jsonString=rawString.match(/\{(.|\n)*\}/)[0];jsonString=jsonString.replace(/^\[/,'');jsonString=jsonString.replace(/\]$/,'');var json=$.parseJSON(jsonString);if(typeof json.error=='undefined')this.uploadOptions.success(json);else
{this.uploadOptions.error(this,json);this.modalClose();}}
else
{this.modalClose();alert('Upload failed!');}}
this.el.attr('action',this.element_action);this.el.attr('target','');},draguploadInit:function(el,options)
{this.draguploadOptions=$.extend({url:false,success:false,error:false,preview:false,uploadFields:false,text:this.opts.curLang.drop_file_here,atext:this.opts.curLang.or_choose,uploadParam:false},options);if(window.FormData===undefined)return false;this.droparea=$('<div class="redactor_droparea"></div>');this.dropareabox=$('<div class="redactor_dropareabox">'+this.draguploadOptions.text+'</div>');this.dropalternative=$('<div class="redactor_dropalternative">'+this.draguploadOptions.atext+'</div>');this.droparea.append(this.dropareabox);$(el).before(this.droparea);$(el).before(this.dropalternative);this.dropareabox.on('dragover',$.proxy(function()
{return this.draguploadOndrag();},this));this.dropareabox.on('dragleave',$.proxy(function()
{return this.draguploadOndragleave();},this));this.dropareabox.get(0).ondrop=$.proxy(function(e)
{e.preventDefault();this.dropareabox.removeClass('hover').addClass('drop');this.dragUploadAjax(this.draguploadOptions.url,e.dataTransfer.files[0],false,false,false,this.draguploadOptions.uploadParam);},this);},dragUploadAjax:function(url,file,directupload,progress,e,uploadParam)
{if(!directupload)
{var xhr=$.ajaxSettings.xhr();if(xhr.upload)
{xhr.upload.addEventListener('progress',$.proxy(this.uploadProgress,this),false);}
$.ajaxSetup({xhr:function(){return xhr;}});}
var fd=new FormData();if(uploadParam!==false)
{fd.append(uploadParam,file);}
else
{fd.append('file',file);}
if(this.opts.uploadFields!==false&&typeof this.opts.uploadFields==='object')
{$.each(this.opts.uploadFields,$.proxy(function(k,v)
{if(v!=null&&v.toString().indexOf('#')===0)v=$(v).val();fd.append(k,v);},this));}
$.ajax({url:url,dataType:'html',data:fd,cache:false,contentType:false,processData:false,type:'POST',success:$.proxy(function(data)
{data=data.replace(/^\[/,'');data=data.replace(/\]$/,'');var json=(typeof data==='string'?$.parseJSON(data):data);if(directupload)
{progress.fadeOut('slow',function()
{$(this).remove();});var $img=$('<img>');$img.attr('src',json.filelink).attr('id','drag-image-marker');this.insertNodeToCaretPositionFromPoint(e,$img[0]);var image=$(this.$editor.find('img#drag-image-marker'));if(image.length)image.removeAttr('id');else image=false;this.sync();this.observeImages();if(image)this.callback('imageUpload',image,json);if(typeof json.error!=='undefined')this.callback('imageUploadError',json);}
else
{if(typeof json.error=='undefined')
{this.draguploadOptions.success(json);}
else
{this.draguploadOptions.error(this,json);this.draguploadOptions.success(false);}}},this)});},draguploadOndrag:function()
{this.dropareabox.addClass('hover');return false;},draguploadOndragleave:function()
{this.dropareabox.removeClass('hover');return false;},uploadProgress:function(e,text)
{var percent=e.loaded?parseInt(e.loaded/e.total*100,10):e;this.dropareabox.text('Loading '+percent+'% '+(text||''));},isMobile:function()
{return/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent);},normalize:function(str)
{if(typeof(str)==='undefined')return 0;return parseInt(str.replace('px',''),10);},outerHtml:function(el)
{return $('<div>').append($(el).eq(0).clone()).html();},isString:function(obj)
{return Object.prototype.toString.call(obj)=='[object String]';},isEmpty:function(html)
{html=html.replace(/&#x200b;|<br>|<br\/>|&nbsp;/gi,'');html=html.replace(/\s/g,'');html=html.replace(/^<p>[^\W\w\D\d]*?<\/p>$/i,'');return html=='';},isIe11:function()
{return!!navigator.userAgent.match(/Trident\/7\./);},browser:function(browser)
{var ua=navigator.userAgent.toLowerCase();var match=/(opr)[\/]([\w.]+)/.exec(ua)||/(chrome)[ \/]([\w.]+)/.exec(ua)||/(webkit)[ \/]([\w.]+).*(safari)[ \/]([\w.]+)/.exec(ua)||/(webkit)[ \/]([\w.]+)/.exec(ua)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua)||/(msie) ([\w.]+)/.exec(ua)||ua.indexOf("trident")>=0&&/(rv)(?::| )([\w.]+)/.exec(ua)||ua.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua)||[];if(browser=='version')return match[2];if(browser=='webkit')return(match[1]=='chrome'||match[1]=='webkit');if(match[1]=='rv')return browser=='msie';if(match[1]=='opr')return browser=='webkit';return browser==match[1];},oldIE:function()
{if(this.browser('msie')&&parseInt(this.browser('version'),10)<9)return true;return false;},getFragmentHtml:function(fragment)
{var cloned=fragment.cloneNode(true);var div=this.document.createElement('div');div.appendChild(cloned);return div.innerHTML;},extractContent:function()
{var node=this.$editor[0];var frag=this.document.createDocumentFragment();var child;while((child=node.firstChild))
{frag.appendChild(child);}
return frag;},isParentRedactor:function(el)
{if(!el)return false;if(this.opts.iframe)return el;if($(el).parents('div.redactor_editor').length==0||$(el).hasClass('redactor_editor'))return false;else return el;},currentOrParentIs:function(tagName)
{var parent=this.getParent(),current=this.getCurrent();return parent&&parent.tagName===tagName?parent:current&&current.tagName===tagName?current:false;},isEndOfElement:function()
{var current=this.getBlock();var offset=this.getCaretOffset(current);var text=$.trim($(current).text()).replace(/\n\r\n/g,'');var len=text.length;if(offset==len)return true;else return false;},isFocused:function()
{var el,sel=this.getSelection();if(sel&&sel.rangeCount&&sel.rangeCount>0)el=sel.getRangeAt(0).startContainer;if(!el)return false;if(this.opts.iframe)
{if(this.getCaretOffsetRange().equals())return!this.$editor.is(el);else return true;}
return $(el).closest('div.redactor_editor').length!=0;},removeEmptyAttr:function(el,attr)
{if($(el).attr(attr)=='')$(el).removeAttr(attr);},removeFromArrayByValue:function(array,value)
{var index=null;while((index=array.indexOf(value))!==-1)
{array.splice(index,1);}
return array;}};Redactor.prototype.init.prototype=Redactor.prototype;$.Redactor.fn.formatLinkify=function(protocol,convertLinks,convertImageLinks,convertVideoLinks,linkSize)
{var url1=/(^|&lt;|\s)(www\..+?\..+?)(\s|&gt;|$)/g,url2=/(^|&lt;|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$)/g,urlImage=/(https?:\/\/.*\.(?:png|jpg|jpeg|gif))/gi,urlYoutube=/https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube\.com\S*[^\w\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig,urlVimeo=/https?:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/;var childNodes=(this.$editor?this.$editor.get(0):this).childNodes,i=childNodes.length;while(i--)
{var n=childNodes[i];if(n.nodeType===3)
{var html=n.nodeValue;if(convertVideoLinks&&html)
{var iframeStart='<iframe width="500" height="281" src="',iframeEnd='" frameborder="0" allowfullscreen></iframe>';if(html.match(urlYoutube))
{html=html.replace(urlYoutube,iframeStart+'//www.youtube.com/embed/$1'+iframeEnd);$(n).after(html).remove();}
else if(html.match(urlVimeo))
{html=html.replace(urlVimeo,iframeStart+'//player.vimeo.com/video/$2'+iframeEnd);$(n).after(html).remove();}}
if(convertImageLinks&&html&&html.match(urlImage))
{html=html.replace(urlImage,'<img src="$1">');$(n).after(html).remove();}
if(convertLinks&&html&&(html.match(url1)||html.match(url2)))
{var href=(html.match(url1)||html.match(url2));href=href[0];if(href.length>linkSize)href=href.substring(0,linkSize)+'...';html=html.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(url1,'$1<a href="'+protocol+'$2">'+$.trim(href)+'</a>$3').replace(url2,'$1<a href="$2">'+$.trim(href)+'</a>$5');$(n).after(html).remove();}}
else if(n.nodeType===1&&!/^(a|button|textarea)$/i.test(n.tagName))
{$.Redactor.fn.formatLinkify.call(n,protocol,convertLinks,convertImageLinks,convertVideoLinks,linkSize);}}};})(jQuery);$(function(){$validationMessage=null;$redactorLinkUrl=null;$redactorLinkUrlText=null;$redactorInsertLinkBtn=null;$redactorTabs=null;$redactorTab1=null;$redactorTabSelected=null;const regExpURL=new RegExp(/((\s*)?((http:\/\/|ftp:\/\/|https:\/\/)?(www.)?(([a-zA-Z0-9-]){1,}\.){1,}([a-zA-Z]){1,}(:[0-9]{1,5})?(\/([a-zA-Z-_\/\.0-9#:?=~&%;,*+!$@\[\]\)\(\']*)?)?(\s*)?))/gim);function showTheProperMessage(alertType,message){$validationMessage.prop('class',alertType);$validationMessage.text(message);}
function createWrapperElement(element){const wrapper=document.createElement('div');wrapper.setAttribute('id','alert-message-wrapper');element.parentNode.insertBefore(wrapper,element);wrapper.appendChild(element);}
const newAlertDangerClass='ds-message ds-message--error';const newAlertInfoClass='ds-message ds-message--info';const newAlertSuccessClass='ds-message ds-message--success';function validateInsertLink(link,text){if(link==''||link.replace(/ /g,'')==''||text==''||text.replace(/ /g,'')==''){document.getElementById('alert-message-wrapper').setAttribute('class',newAlertDangerClass);showTheProperMessage('ds-message__content','Both the URL and text are required.');return true;}else{text=text.replace(/[\u200B-\u200D\uFEFF\u00AD\u0000-\u001F\u007F-\u009F]/g,'');link=link.replace(/[\u200B-\u200D\uFEFF\u00AD\u0000-\u001F\u007F-\u009F]/g,'');const currentLinkURL=applyRegExp(regExpURL,link);if(currentLinkURL==null){document.getElementById('alert-message-wrapper').setAttribute('class',newAlertDangerClass);showTheProperMessage('ds-message__content','The entered URL is not valid.');return true;}
if(currentLinkURL.length>1){document.getElementById('alert-message-wrapper').setAttribute('class',newAlertDangerClass);showTheProperMessage('ds-message__content','Only one URL is allowed in the URL Field.');return true;}
if(currentLinkURL.length==1){if($redactorLinkUrl.val()!=currentLinkURL||currentLinkURL[0].length>253){document.getElementById('alert-message-wrapper').setAttribute('class',newAlertDangerClass);showTheProperMessage('ds-message__content','The entered URL is not valid.');return true;}
try{if(text.trim()!==link.trim()&&(text.substring(0,5)=='http:'||text.substring(0,6)=='https:')){document.getElementById('alert-message-wrapper').setAttribute('class',newAlertDangerClass);showTheProperMessage('ds-message__content','Link text '+text+' is a valid URL and it does not match the href attribute.');return true;}}catch(error){}}}
document.getElementById('alert-message-wrapper').setAttribute('class',newAlertSuccessClass);showTheProperMessage('ds-message__content','Your Inputs are valid.');return false;}
function applyRegExp(regExp,field){regExp.lastIndex=0;return field.match(regExp);}
function handelEvents(){$redactorLinkUrl.keyup(function(){$redactorInsertLinkBtn.prop('disabled',validateInsertLink($redactorLinkUrl.val(),$redactorLinkUrlText.val()));});$redactorLinkUrlText.keyup(function(){$redactorInsertLinkBtn.prop('disabled',validateInsertLink($redactorLinkUrl.val(),$redactorLinkUrlText.val()));});$redactorTabs.click(function(){if($redactorTabSelected.val()==1){$redactorInsertLinkBtn.prop('disabled',true);if($redactorLinkUrl.val()!=''||$redactorLinkUrlText.val()!=''){$redactorInsertLinkBtn.prop('disabled',validateInsertLink($redactorLinkUrl.val(),$redactorLinkUrlText.val()));}}else{$redactorInsertLinkBtn.prop('disabled',false);}});$redactorInsertLinkBtn.on('mouseup keyup',function(){$redactorLinkUrl.val($redactorLinkUrl.val().trim());});}
$('.redactor, .commentBox').on('modalOpenedCallback',function(event,name){if(name==='Link'){$redactorLinkUrl=$('#redactor_link_url');$redactorLinkUrlText=$('#redactor_link_url_text');$redactorInsertLinkBtn=$('#redactor_insert_link_btn');$redactorTabs=$('#redactor_tabs');$redactorTab1=$('#redactor_tab1');$redactorTabSelected=$('#redactor_tab_selected');if($redactorLinkUrl.val()==''&&$redactorLinkUrlText.val()==''){$redactorInsertLinkBtn.prop('disabled',true);$redactorTab1.prepend("<div id='validation_message' class='ds-message__content'>Info! To add a URL link please provide both a URL and a Text description.</div>");createWrapperElement(document.getElementById('validation_message'));document.getElementById('alert-message-wrapper').setAttribute('class',newAlertInfoClass);$validationMessage=$('#validation_message');}else{$redactorTab1.prepend("<div id='validation_message' class='ds-message__content'>Your Inputs are correct.</div>");createWrapperElement(document.getElementById('validation_message'));$validationMessage=$('#validation_message');$redactorInsertLinkBtn.prop('disabled',validateInsertLink($redactorLinkUrl.val(),$redactorLinkUrlText.val()));}
if($redactorTabSelected.val()==2){$redactorInsertLinkBtn.prop('disabled',false);}
document.getElementById('redactor_cancel_link_btn').setAttribute('class','ds-button ds-button--secondary');document.getElementById('redactor_insert_link_btn').setAttribute('class','ds-button ds-button--primary redactor_distance_between_btns');handelEvents();}});});