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(B,C){var A=$(C);if(A.innerHTML!=""){A.firstChild.style.display=""}new Ajax.Updater(A,B,{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(B,C,A){contentPane=$("messagesContent");msgContent=$("msg.content."+C);listMsg=$("list.msg."+C);folder=msgContent.getAttribute("folder");contentPane.innerHTML="";new Ajax.Request("/user/msgs/"+folder+"/deleteMessages",{method:"POST",parameters:"msgIds="+C+"&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"})}})}