if(!Array.prototype.forEach){Array.prototype.forEach=function(b){var a=this.length;if(typeof b!="function"){throw new TypeError()}var d=arguments[1];for(var c=0;c<a;c++){if(c in this){b.call(d,this[c],c,this)}}}}function setCaretPosition(d,b){var c=document.getElementById(d);if(c!=null){if(c.createTextRange){var a=c.createTextRange();a.move("character",b);a.select()}else{if(c.selectionStart){c.focus();c.setSelectionRange(b,b)}else{c.focus()}}}}function serverToIcon(){return"<img alt='"+this.name+"' src='/favicons/"+this.icon+"' title='Settings for "+this.name+"' height='16px' />"}function serverSelectSettings(){document.getElementById("mail_account_port").value=this.port;document.getElementById("mail_account_server").value=this.server;document.getElementById("mail_account_ssl").checked=(this.ssl?"true":"");var a=document.getElementById("mail_account_username");if(a.value.match(/^\s*@/)){a.value=this.postfix;setCaretPosition("mail_account_username",0)}else{if(!a.value.match(/@/)){a.value=a.value+this.postfix;setCaretPosition("mail_account_username",0)}}}function Server(c,e,d,b,f,a){this.server=e;this.icon=d;this.port=b;this.postfix=f;this.ssl=a;this.name=c;this.toIcon=serverToIcon;this.selectSettings=serverSelectSettings}var ISO8601={parse:function(a){a=a.replace(/\s/,"");a=a.replace(/-/,"/").replace(/-/,"/");a=a.replace(/T/," ").replace(/Z/," UTC");a=a.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2");return new Date(a)},humanDate:function(a){if(isNaN(a.getFullYear())||isNaN(a.getMonth())||isNaN(a.getDate())||isNaN(a.getHours())||isNaN(a.getMinutes())){return""}else{return("000"+a.getFullYear()).slice(-4)+"-"+("0"+(a.getMonth()+1)).slice(-2)+"-"+("0"+a.getDate()).slice(-2)+" "+("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)}},humanTime:function(a){if(isNaN(a.getHours())||isNaN(a.getMinutes())){return""}else{return("0"+a.getHours()).slice(-2)+":"+("0"+a.getMinutes()).slice(-2)}},relativeHumanTime:function(c,b){var a=(b.getTime()-c.getTime())/1000;if(a>24*60*60*366){return this.humanDate(c)}else{if(a<24*60*60){return this.humanTime(c)+" ("+this.distanceOfTimeInWords(b,c)+")"}else{return this.humanDate(c)+" ("+this.distanceOfTimeInWords(b,c)+")"}}},convertAll:function(){var d=document.getElementsByTagName("abbr");var b=new Date();for(var c=0;c<d.length;++c){var a=d[c];if(a.className.match(/\btime\b/)){a.innerHTML=this.relativeHumanTime(this.parse(a.innerHTML),b)}}},distanceOfTimeInWords:function(d,c){var b=((d-c)/1000);var a=Math.floor(b/60);if(a==0){return"less than a minute ago"}if(a==1){return"a minute ago"}if(a<45){return a+" minutes ago"}if(a<90){return"about 1 hour ago"}if(a<1440){return"about "+Math.floor(a/60)+" hours ago"}if(a<2880){return"1 day ago"}if(a<43200){return Math.floor(a/1440)+" days ago"}if(a<86400){return"about 1 month ago"}if(a<525960){return Math.floor(a/43200)+" months ago"}if(a<1051199){return"about 1 year ago"}return"over "+Math.floor(a/525960)+" years ago"}};function setInitialSettings(){var c=document.getElementById("message");if(c&&c.innerHTML.match(/^\s*$/)){c.style.display="none"}ISO8601.convertAll();var a=document.getElementById("predefined");if(a){var b=[new Server("Gmail","pop.gmail.com","gmail.png",995,"@gmail.com",true),new Server("Hotmail","pop3.live.com","live.png",995,"@hotmail.com",true),new Server("Aol","pop.aol.com","aol-2.png",110,"",false),new Server("Mail.ru","pop.mail.ru","mail.png",110,"",false),new Server("Яндекс Почта","pop.yandex.ru","yandex.png",110,"@yandex.ru",false),new Server("Почта.ru","pop.nm.ru","nm.png",110,"@nm.ru",false),new Server("Rambler.ru","pop3.rambler.ru","rambler.png",110,"@rambler.ru",false)];b.forEach(function(f){var d=document.createElement("span");a.appendChild(d);d.innerHTML=f.toIcon();d.onclick=function(){f.selectSettings();return false};d.style.cursor="pointer"})}}window.onload=setInitialSettings;