var messagesPopup;function showMessages(b){var a=b+"&ieSucks="+new Date().getTime();if(!messagesPopup||!messagesPopup.popup){messagesPopup=new Popup({url:a,width:700,height:425,loadingImg:"/images/loading.gif"})}else{messagesPopup.loadContent(a)}}var newMsgPopup;function writeNewMessage(a){newMsgPopup=new Popup({url:a,width:676,height:267})}function replyMessage(c,b){var a=$(b);if(a.innerHTML!=""){a.firstChild.style.display=""}new Ajax.Updater(a,c,{method:"get",evalScripts:true})}function cancelMessageForm(a){$(a).innerHTML=$("hiddenLoaderImgContainer").innerHTML}function submitNewMsgFormReply(a,b){if(b!=""){new Ajax.Updater($(b),a.action,{method:"post",parameters:Form.serialize(a),evalScripts:true,onSuccess:function(){}})}else{newMsgPopup.startLoading();new Ajax.Updater(newMsgPopup.popupContent,newMsgPopup.options.url,{method:"post",parameters:Form.serialize(a),evalScripts:true,onSuccess:function(){closeNewMsgForm()}})}}function submitNewMsgForm(a){newMsgPopup.startLoading();new Ajax.Updater(newMsgPopup.popupContent,newMsgPopup.options.url,{method:"post",parameters:Form.serialize(a),evalScripts:true,onSuccess:function(){newMsgPopup.stopLoading()}})}function closeNewMsgForm(){if(newMsgPopup){newMsgPopup.closePopup()}}var activeMsg;function displayMessage(a){cancelMessageForm("replyMessageContent");contentPane=$("messagesContent");msgContent=$("msg.content."+a);msgContent.otwarty;listMsg=$("list.msg."+a);unread=msgContent.getAttribute("unread");folder=msgContent.getAttribute("folder");if(msgContent.otwarty){msgContent.style.display="none";msgContent.otwarty=false}else{msgContent.style.display="block";msgContent.otwarty=true}if(unread&&unread=="yes"){new Ajax.Updater("","/user/msgs/"+folder+"/"+a+"/markAsRead",{method:"get",onComplete:function(){this.removeClassName("nieczytana");msgContent.removeAttribute("unread");decreaseNewMessagesCount()},onFailure:function(b){}})}}function setNewMessagesCount(a){if($("newMessagesCount")){$("newMessagesCount").innerHTML=a}}function decreaseNewMessagesCount(){messagesCountContainer=$("newMessagesCount");count=parseInt(messagesCountContainer.innerHTML);if(count>0){count--}setNewMessagesCount(count)}function deleteMessage(c,b,a){contentPane=$("messagesContent");msgContent=$("msg.content."+b);listMsg=$("list.msg."+b);folder=msgContent.getAttribute("folder");contentPane.innerHTML="";new Ajax.Request("/user/msgs/"+folder+"/deleteMessages",{method:"POST",parameters:"msgIds="+b+"&token="+a,onFailure:function(d){},onComplete:function(){Element.remove(listMsg);unread=msgContent.getAttribute("unread");if(unread&&unread=="yes"){decreaseNewMessagesCount()}$("skrzynkaPocztowa").innerHTML="";new Ajax.Updater($("skrzynkaPocztowa"),"/user/msgs?folder=INBOX",{method:"get",evalScripts:"true"})}})};