Ext.ns("SP.msg");SP.msg={poll:true,pollInterval:45,markRead:function(id0,success0){SP.link.ajaxAction("msg","msgActions","markRead",{params:{id:id0},success:success0})},markDeleted:function(id0,success0){SP.link.ajaxAction("msg","msgActions","markDeleted",{params:{id:id0},success:success0})},markUnread:function(id0,success0){SP.link.ajaxAction("msg","msgActions","markUnread",{params:{id:id0},success:success0})},onNewMessage:Ext.emptyFn,onNewPresence:Ext.emptyFn,newMsgCount:0,lastUpdate:0};
if(SP.isMember())Ext.onReady(function(){if(SP.active.lastUpdate>0)SP.msg.lastUpdate=SP.active.lastUpdate;Ext.QuickTips.init();function beforePoll(poller){poller.baseParams.lastUpdate=SP.msg.lastUpdate;return SP.msg.poll}function afterPoll(poller){var d=new Date;SP.msg.lastUpdate=d.getTime()}var pollA=new Ext.direct.PollingProvider({type:"polling",interval:SP.msg.pollInterval*1E3,baseParams:{action:"poll",lastUpdate:0},url:SP.link.pURL("msg","action/poll?action=poll")});Ext.Direct.addProvider(pollA);
pollA.on("beforepoll",beforePoll);pollA.on("data",afterPoll);Ext.Direct.on("update",function(e){if(e.newMsgCount>SP.msg.newMsgCount){var numNew=e.newMsgCount-SP.msg.newMsgCount;SP.msg.newMsgCount=e.newMsgCount;SP.msg.onNewMessage(e,numNew)}})});Ext.ns("SP.msg");
SP.msg.sendMsgBox=function(props){var url=SP.link.pURL("msg","action/msgActions");var instructions="Enter your message below";if(props.instructions)instructions=props.instructions;var fp=new Ext.FormPanel({frame:true,labelWidth:50,items:[{html:instructions},{xtype:"hidden",name:"destID",value:props.destID},{xtype:"textfield",fieldLabel:"Subject",name:"subj",width:300,allowBlank:false},{xtype:"textarea",fieldLabel:"Body",name:"msg",width:300,allowBlank:false}],buttons:[{text:"Send",handler:function(){if(fp.getForm().isValid())fp.getForm().submit({url:url+
"?action="+props.action,waitMsg:"Sending your message...",failure:function(fp,o){Ext.Msg.alert("Error","Your message failed, please alert an administrator or try again.")},success:sH})}},{text:"Cancel",handler:function(){w.hide()}}]});var windowProps={title:"Send Message",autoShow:true,width:400,modal:true,plain:true,maximizable:false,minimizable:false,resizable:false,draggable:false,items:[fp]};var w=new Ext.Window(Ext.apply(windowProps,props.windowProps));var sH=function(fp,o){if(o.result.success==
"false")Ext.Msg.alert("Error","Your message failed, please alert an administrator or try again: "+o.result.message);else{if(props.success)props.success(props,o.result);w.hide()}};w.show();fp.getForm().findField("subj").focus("",true)};Ext.ns("SP.msg");SP.msg.types=[["1","Personal"],["2","Site Notification"],["3","Notification"],["4","Broadcast Followers"],["5","Content Alert"],["6","Company Invite"],["7","Company Broadcast"],["8","Site Specific Broadcast"]];Ext.ns("SP.msg");SP.msg.typeSelect=Ext.extend(Ext.form.ComboBox,{initComponent:function(){Ext.apply(this,{store:new Ext.data.ArrayStore({fields:["value","title"],data:SP.msg.types}),displayField:"title",valueField:"value",editable:false,triggerAction:"all",typeAhead:false,mode:"local",forceSelection:true,listWidth:150,width:150});SP.msg.typeSelect.superclass.initComponent.call(this)}});Ext.reg("msgtypeselect",SP.msg.typeSelect);

