/**
 * Roundcube common js library
 *
 * This file is part of the Roundcube Webmail client
 *
 * @licstart  The following is the entire license notice for the
 * JavaScript code in this file.
 *
 * Copyright (c) 2005-2014, The Roundcube Dev Team
 *
 * The JavaScript code in this page is free software: you can
 * redistribute it and/or modify it under the terms of the GNU
 * General Public License (GNU GPL) as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option)
 * any later version.  The code is distributed WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU GPL for more details.
 *
 * As additional permission under GNU GPL version 3 section 7, you
 * may distribute non-source (e.g., minimized or compacted) forms of
 * that code without the copy of the GNU GPL normally required by
 * section 4, provided you include this license notice and a URL
 * through which recipients can access the Corresponding Source.
 *
 * @licend  The above is the entire license notice
 * for the JavaScript code in this file.
 */
var CONTROL_KEY=1,SHIFT_KEY=2,CONTROL_SHIFT_KEY=3;
function roundcube_browser(){var a=navigator;this.agent=a.userAgent;this.agent_lc=a.userAgent.toLowerCase();this.name=a.appName;this.vendor=a.vendor?a.vendor:"";this.vendver=a.vendorSub?parseFloat(a.vendorSub):0;this.product=a.product?a.product:"";this.platform=String(a.platform).toLowerCase();this.lang=a.language?a.language.substring(0,2):a.browserLanguage?a.browserLanguage.substring(0,2):a.systemLanguage?a.systemLanguage.substring(0,2):"en";this.win=0<=this.platform.indexOf("win");this.mac=0<=this.platform.indexOf("mac");
this.linux=0<=this.platform.indexOf("linux");this.unix=0<=this.platform.indexOf("unix");this.dom=document.getElementById?!0:!1;this.dom2=document.addEventListener&&document.removeEventListener;this.edge=0<this.agent_lc.indexOf(" edge/");this.webkit=!this.edge&&0<this.agent_lc.indexOf("applewebkit");this.ie=document.all&&!window.opera||this.win&&0<this.agent_lc.indexOf("trident/");window.opera?(this.opera=!0,this.vendver=opera.version()):this.ie||this.edge||(this.chrome=0<this.agent_lc.indexOf("chrome"),
this.opera=this.webkit&&0<this.agent.indexOf(" OPR/"),this.safari=!this.chrome&&!this.opera&&(this.webkit||0<this.agent_lc.indexOf("safari")),this.konq=0<this.agent_lc.indexOf("konqueror"),this.mz=this.dom&&!this.chrome&&!this.safari&&!this.konq&&!this.opera&&0<=this.agent.indexOf("Mozilla"),this.iphone=this.safari&&(0<this.agent_lc.indexOf("iphone")||0<this.agent_lc.indexOf("ipod")),this.ipad=this.safari&&0<this.agent_lc.indexOf("ipad"));this.vendver||(this.vendver=/(opera|opr|khtml|chrome|safari|applewebkit|msie)(\s|\/)([0-9\.]+)/.test(this.agent_lc)?
parseFloat(RegExp.$3):0,this.vendver||(this.vendver=/rv:([0-9\.]+)/.test(this.agent)?parseFloat(RegExp.$1):0));this.safari&&/;\s+([a-z]{2})-[a-z]{2}\)/.test(this.agent_lc)&&(this.lang=RegExp.$1);this.tablet=/ipad|android|xoom|sch-i800|playbook|tablet|kindle/i.test(this.agent_lc);this.touch=(this.mobile=/iphone|ipod|blackberry|iemobile|opera mini|opera mobi|mobile/i.test(this.agent_lc))||this.tablet;this.pointer="function"==typeof window.PointerEvent;this.cookies=a.cookieEnabled;this.xmlhttp_test=
function(){var a=new Function("try{var o=new ActiveXObject('Microsoft.XMLHTTP');return true;}catch(err){return false;}");return this.xmlhttp=window.XMLHttpRequest||"ActiveXObject"in window&&a()};this.set_html_class=function(){var a=" js";this.ie?a+=" ie ie"+parseInt(this.vendver):this.opera?a+=" opera":this.konq?a+=" konqueror":this.safari?a+=" chrome":this.chrome?a+=" chrome":this.mz&&(a+=" mozilla");this.iphone?a+=" iphone":this.ipad?a+=" ipad":this.webkit&&(a+=" webkit");this.mobile&&(a+=" mobile");
this.tablet&&(a+=" tablet");document.documentElement&&(document.documentElement.className+=a)}}
var rcube_event={get_target:function(a){return(a=a||window.event)&&a.target?a.target:a.srcElement},get_keycode:function(a){return(a=a||window.event)&&a.keyCode?a.keyCode:a&&a.which?a.which:0},get_button:function(a){return(a=a||window.event)&&void 0!==a.button?a.button:a&&a.which?a.which:0},get_modifier:function(a){var b=0;a=a||window.event;bw.mac&&a?b+=(a.metaKey&&CONTROL_KEY)+(a.shiftKey&&SHIFT_KEY):a&&(b+=(a.ctrlKey&&CONTROL_KEY)+(a.shiftKey&&SHIFT_KEY));return b},get_mouse_pos:function(a){a||(a=
window.event);var b=a.pageX?a.pageX:a.clientX,c=a.pageY?a.pageY:a.clientY;document.body&&document.all&&(b+=document.body.scrollLeft,c+=document.body.scrollTop);a._offset&&(b+=a._offset.left,c+=a._offset.top);return{x:b,y:c}},add_listener:function(a){if(a.object&&a.method){a.element||(a.element=document);a.object._rc_events||(a.object._rc_events={});var b=a.event+"*"+a.method;a.object._rc_events[b]||(a.object._rc_events[b]=function(b){return a.object[a.method](b)});a.element.addEventListener?a.element.addEventListener(a.event,
a.object._rc_events[b],!1):a.element.attachEvent?(a.element.detachEvent("on"+a.event,a.object._rc_events[b]),a.element.attachEvent("on"+a.event,a.object._rc_events[b])):a.element["on"+a.event]=a.object._rc_events[b]}},remove_listener:function(a){a.element||(a.element=document);var b=a.event+"*"+a.method;a.object&&a.object._rc_events&&a.object._rc_events[b]&&(a.element.removeEventListener?a.element.removeEventListener(a.event,a.object._rc_events[b],!1):a.element.detachEvent?a.element.detachEvent("on"+
a.event,a.object._rc_events[b]):a.element["on"+a.event]=null)},cancel:function(a){a=a?a:window.event;a.preventDefault?a.preventDefault():a.returnValue=!1;a.stopPropagation&&a.stopPropagation();a.cancelBubble=!0;return!1},is_keyboard:function(a){return a&&(a.type&&String(a.type).match(/^key/)||!a.pageX&&0>=(a.pageY||0)&&!a.clientX&&0>=(a.clientY||0))},keyboard_only:function(a){return rcube_event.is_keyboard(a)?!0:rcube_event.cancel(a)},touchevent:function(a){return{pageX:a.pageX,pageY:a.pageY,offsetX:a.pageX-
a.target.offsetLeft,offsetY:a.pageY-a.target.offsetTop,target:a.target,istouch:!0}}};function rcube_event_engine(){this._events={}}
rcube_event_engine.prototype={addEventListener:function(a,b,c){this._events||(this._events={});this._events[a]||(this._events[a]=[]);this._events[a].push({func:b,obj:c?c:window});return this},removeEventListener:function(a,b,c){void 0===c&&(c=window);for(var d,e=0;this._events&&this._events[a]&&e<this._events[a].length;e++)(d=this._events[a][e])&&d.func==b&&d.obj==c&&(this._events[a][e]=null)},triggerEvent:function(a,b){var c,d;void 0===b?b=this:"object"===typeof b&&(b.event=a);this._event_exec||
(this._event_exec={});if(this._events&&this._events[a]&&!this._event_exec[a]){this._event_exec[a]=!0;for(var e=0;e<this._events[a].length;e++)if(d=this._events[a][e])if("function"===typeof d.func?c=d.func.call?d.func.call(d.obj,b):d.func(b):"function"===typeof d.obj[d.func]&&(c=d.obj[d.func](b)),void 0!==c&&!c)break;if(c&&c.event)try{delete c.event}catch(f){$(c).removeAttr("event")}}delete this._event_exec[a];if(b.event)try{delete b.event}catch(f){$(b).removeAttr("event")}return c}};
function rcube_check_email(a,b,c){if(!a)return c?0:!1;c&&(b=!0);b=b?RegExp("(^|<|[,;\\s\\n])((([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22))*\\x40(((\\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}\\])|(\\[IPv6:[0-9a-f:.]+\\]))|(([^@\\x2e]+\\x2e)+([^\\x00-\\x40\\x5b-\\x60\\x7b-\\x7f]{2,}|xn--[a-z0-9]{2,}))))|(mailtest\\x40(\\u0645\\u062b\\u0627\\u0644\\x2e\\u0625\\u062e\\u062a\\u0628\\u0627\\u0631|\\u4f8b\\u5b50\\x2e\\u6d4b\\u8bd5|\\u4f8b\\u5b50\\x2e\\u6e2c\\u8a66|\\u03c0\\u03b1\\u03c1\\u03ac\\u03b4\\u03b5\\u03b9\\u03b3\\u03bc\\u03b1\\x2e\\u03b4\\u03bf\\u03ba\\u03b9\\u03bc\\u03ae|\\u0909\\u0926\\u093e\\u0939\\u0930\\u0923\\x2e\\u092a\\u0930\\u0940\\u0915\\u094d\\u0937\\u093e|\\u4f8b\\u3048\\x2e\\u30c6\\u30b9\\u30c8|\\uc2e4\\ub840\\x2e\\ud14c\\uc2a4\\ud2b8|\\u0645\\u062b\\u0627\\u0644\\x2e\\u0622\\u0632\\u0645\\u0627\\u06cc\\u0634\u06cc|\\u043f\\u0440\\u0438\\u043c\\u0435\\u0440\\x2e\\u0438\\u0441\\u043f\\u044b\\u0442\\u0430\\u043d\\u0438\\u0435|\\u0b89\\u0ba4\\u0bbe\\u0bb0\\u0ba3\\u0bae\\u0bcd\\x2e\\u0baa\\u0bb0\\u0bbf\\u0b9f\\u0bcd\\u0b9a\\u0bc8|\\u05d1\\u05f2\\u05b7\\u05e9\\u05e4\\u05bc\\u05d9\\u05dc\\x2e\\u05d8\\u05e2\\u05e1\\u05d8)))($|>|[,;\\s\\n])",
c?"ig":"i"):/^((([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22)(\x2e([^\x00-\x20\x22\x28\x29\x2c\x2e\x3a-\x3c\x3e\x40\x5b-\x5d\x7f-\xff]+|\x22([^\x0d\x22\x5c\x80-\xff]|\x5c[\x00-\x7f])*\x22))*\x40(((\[(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])(.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])){3}\])|(\[IPv6:[0-9a-f:.]+\]))|(([^@\x2e]+\x2e)+([^\x00-\x40\x5b-\x60\x7b-\x7f]{2,}|xn--[a-z0-9]{2,}))))|(mailtest\x40(\u0645\u062b\u0627\u0644\x2e\u0625\u062e\u062a\u0628\u0627\u0631|\u4f8b\u5b50\x2e\u6d4b\u8bd5|\u4f8b\u5b50\x2e\u6e2c\u8a66|\u03c0\u03b1\u03c1\u03ac\u03b4\u03b5\u03b9\u03b3\u03bc\u03b1\x2e\u03b4\u03bf\u03ba\u03b9\u03bc\u03ae|\u0909\u0926\u093e\u0939\u0930\u0923\x2e\u092a\u0930\u0940\u0915\u094d\u0937\u093e|\u4f8b\u3048\x2e\u30c6\u30b9\u30c8|\uc2e4\ub840\x2e\ud14c\uc2a4\ud2b8|\u0645\u062b\u0627\u0644\x2e\u0622\u0632\u0645\u0627\u06cc\u0634\u06cc|\u043f\u0440\u0438\u043c\u0435\u0440\x2e\u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0435|\u0b89\u0ba4\u0bbe\u0bb0\u0ba3\u0bae\u0bcd\x2e\u0baa\u0bb0\u0bbf\u0b9f\u0bcd\u0b9a\u0bc8|\u05d1\u05f2\u05b7\u05e9\u05e4\u05bc\u05d9\u05dc\x2e\u05d8\u05e2\u05e1\u05d8)))$/i;
return c?a.match(b).length:b.test(a)}function rcube_clone_object(a){var b={},c;for(c in a)b[c]=a[c]&&"object"===typeof a[c]?rcube_clone_object(a[c]):a[c];return b}function urlencode(a){return window.encodeURIComponent?encodeURIComponent(a).replace("*","%2A"):escape(a).replace("+","%2B").replace("*","%2A").replace("/","%2F").replace("@","%40")}
function rcube_find_object(a,b){var c,d;b||(b=document);if(b.getElementById&&(d=b.getElementById(a)))return d;!d&&b.getElementsByName&&(c=b.getElementsByName(a))&&(d=c[0]);!d&&b.all&&(d=b.all[a]);!d&&b.images.length&&(d=b.images[a]);if(!d&&b.forms.length)for(c=0;c<b.forms.length;c++)b.forms[c].name==a?d=b.forms[c]:b.forms[c].elements[a]&&(d=b.forms[c].elements[a]);if(!d&&b.layers)for(b.layers[a]&&(d=b.layers[a]),c=0;!d&&c<b.layers.length;c++)d=rcube_find_object(a,b.layers[c].document);return d}
function rcube_mouse_is_over(a,b){a=rcube_event.get_mouse_pos(a);var c=$(b).offset();return a.x>=c.left&&a.x<c.left+b.offsetWidth&&a.y>=c.top&&a.y<c.top+b.offsetHeight}function setCookie(a,b,c,d,e,f){a=a+"="+escape(b)+(c?"; expires="+c.toGMTString():"")+(d?"; path="+d:"")+(e?"; domain="+e:"")+(f?"; secure":"");document.cookie=a}
function getCookie(a){var b=document.cookie;a+="=";var c=b.indexOf("; "+a);if(-1==c){if(c=b.indexOf(a),0!=c)return null}else c+=2;var d=b.indexOf(";",c);-1==d&&(d=b.length);return unescape(b.substring(c+a.length,d))}roundcube_browser.prototype.set_cookie=setCookie;roundcube_browser.prototype.get_cookie=getCookie;var bw=new roundcube_browser;bw.set_html_class();RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};
Date.prototype.getStdTimezoneOffset=function(){for(var a=12,b=new Date(null,a,1),c=b.getTimezoneOffset();--a;)if(b.setUTCMonth(a),c!=b.getTimezoneOffset())return Math.max(c,b.getTimezoneOffset());return c};String.prototype.startsWith||(String.prototype.startsWith=function(a,b){return this.slice(b||0,a.length)===a});jQuery.last=function(a){return a&&a.length?a[a.length-1]:void 0};jQuery.fn.placeholder=function(a){return this.each(function(){$(this).prop({title:a,placeholder:a})})};
var rcube_parse_query=function(a){if(!a)return{};var b={},c,d=/([^&=]+)=?([^&]*)/g,e=/\+/g;for(a=a.replace(/\?/,"");c=d.exec(a);){var f=decodeURIComponent(c[1].replace(e," "));c=decodeURIComponent(c[2].replace(e," "));"[]"===f.substring(f.length-2)?(f=f.substring(0,f.length-2),(b[f]||(b[f]=[])).push(c)):b[f]=c}return b},Base64=function(){var a=function(a){for(var b=0,d="",e,f,g;b<a.length;)e=a.charCodeAt(b),128>e?(d+=String.fromCharCode(e),b++):191<e&&224>e?(f=a.charCodeAt(b+1),d+=String.fromCharCode((e&
31)<<6|f&63),b+=2):(f=a.charCodeAt(b+1),g=a.charCodeAt(b+2),d+=String.fromCharCode((e&15)<<12|(f&63)<<6|g&63),b+=3);return d};return{encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b="",d=0;d<a.length;d++){var e=a.charCodeAt(d);128>e?b+=String.fromCharCode(e):(127<e&&2048>e?b+=String.fromCharCode(e>>6|192):(b+=String.fromCharCode(e>>12|224),b+=String.fromCharCode(e>>6&63|128)),b+=String.fromCharCode(e&63|128))}a=b;if("function"===typeof window.btoa)try{return btoa(a)}catch(n){}for(var f,g,h,
k=0,l="",m=a.length;k<m;)f=a.charCodeAt(k++),b=a.charCodeAt(k++),d=a.charCodeAt(k++),e=f>>2,f=(f&3)<<4|b>>4,g=(b&15)<<2|d>>6,h=d&63,isNaN(b)?g=h=64:isNaN(d)&&(h=64),l=l+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(g)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(h);return l},decode:function(b){if("function"===
typeof window.atob)try{return a(atob(b))}catch(m){}var c,d=0,e="";b=b.replace(/[^A-Za-z0-9\+\/=]/g,"");for(c=b.length;d<c;){var f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(d++));var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(d++));var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(d++));var k="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(b.charAt(d++));
f=f<<2|g>>4;g=(g&15)<<4|h>>2;var l=(h&3)<<6|k;e+=String.fromCharCode(f);64!=h&&(e+=String.fromCharCode(g));64!=k&&(e+=String.fromCharCode(l))}return a(e)}}}();
