var _status=window.IPBoard;_status.prototype.status={_updateClicked:false,forMemberId:0,maxReplies:0,smallSpace:0,myLatest:0,skin_group:'profile',events:{'page':false,'normal':false},init:function()
{Debug.write("Initializing ips.status.js");document.observe("dom:loaded",function(){ipb.status.initEvents();});},initEvents:function()
{Debug.write('Status init');ipb.delegate.register(".__showAll",ipb.status.showAllComments);ipb.delegate.register(".__showform",ipb.status.showForm);$$('.__submit').each(function(suBo)
{id=suBo.identify();$(id).observe('click',ipb.status.addReply.bindAsEventListener(this,id.replace('statusSubmit-','')));});ipb.delegate.register(".__sDR",ipb.status.deleteReply);ipb.delegate.register(".__sD",ipb.status.deleteStatus);ipb.delegate.register(".__sL",ipb.status.lockStatus);ipb.delegate.register(".__sU",ipb.status.unlockStatus);ipb.delegate.register(".__sT",ipb.status.showFeedback);ipb.delegate.register(".__sTO",ipb.status.hideFeedback);if($('statusUpdate_page')&&ipb.status.events['page']===false)
{try
{ipb.status.forMemberId=parseInt($('statusUpdate_page').readAttribute('data-for-member-id'));}
catch(e){}
if(!ipb.status.forMemberId)
{$('statusUpdate_page').defaultize(ipb.lang['global_status_update']);}
else
{$('statusUpdate_page').defaultize(ipb.lang['global_leave_msg']);}
ipb.status.events['page']=$('statusSubmit_page').on('click',ipb.status.updateSubmit.bindAsEventListener(this,'statusUpdate_page'));}},showForm:function(e,elem)
{Event.stop(e);var id=$(elem).id.replace('statusReplyFormShow-','');if(Object.isUndefined(id)||!$('statusReplyForm-'+ id)){return;}
$(elem).hide();$('statusReplyForm-'+ id).show();$('statusText-'+ id).focus();},updateSubmit:function(e,field)
{Event.stop(e);$('statusSubmitGlobal').stopObserving('click');if($(field).value.length<2||$(field).value==ipb.lang['prof_update_default'])
{return false;}
var su_Twitter=$('su_Twitter')&&$('su_Twitter').checked?1:0;var su_Facebook=$('su_Facebook')&&$('su_Facebook').checked?1:0;new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=new&md5check="+ ipb.vars['secure_hash']+'&smallSpace='+ ipb.status.smallSpace+'&skin_group='+ ipb.status.skin_group+'&forMemberId='+ ipb.status.forMemberId,{method:'post',evalJSON:'force',parameters:{content:$(field).value.encodeParam(),su_Twitter:su_Twitter,su_Facebook:su_Facebook},onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON))
{alert(ipb.lang['action_failed']);return;}
if(t.responseJSON['error'])
{alert(t.responseJSON['error']);}
else
{try{$('status_wrapper').innerHTML=t.responseJSON['html']+ $('status_wrapper').innerHTML;if(ipb.status.myLatest)
{if($('statusWrap-'+ ipb.status.myLatest))
{$('statusWrap-'+ ipb.status.myLatest).hide();}}
$(field).blur();$(field).value='';ipb.menus.closeAll(e);ipb.status.initEvents();}
catch(err)
{Debug.error('Logging error: '+ err);}}}});},deleteStatus:function(e,elem)
{Event.stop(e);if(!confirm(ipb.lang['delete_confirm']))
{return false;}
var status=$(elem).className.match('__d([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error showing all comments");return;}
var status_id=status[1];new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=deleteStatus&status_id="+ status_id+"&md5check="+ ipb.vars['secure_hash'],{method:'get',onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON)||t.responseJSON.error)
{alert(ipb.lang['action_failed']);return;}
else
{$('statusWrap-'+ status_id).remove();}}});},showFeedback:function(e,elem)
{Event.stop(e);var status=$(elem).className.match('__t([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error");return;}
var status_id=status[1];if($('statusReplyFormShow-'+ status_id))
{$('statusReplyFormShow-'+ status_id).hide();}
if($('statusReplyForm-'+ status_id))
{$('statusReplyForm-'+ status_id).show();}
$('statusFeedback-'+ status_id).show();$('statusToggle-'+ status_id).hide();$('statusToggleOff-'+ status_id).show();if($('statusText-'+ status_id))
{$('statusText-'+ status_id).focus();}},hideFeedback:function(e,elem)
{Event.stop(e);var status=$(elem).className.match('__to([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error");return;}
var status_id=status[1];$('statusFeedback-'+ status_id).hide();$('statusToggle-'+ status_id).show();$('statusToggleOff-'+ status_id).hide();},lockStatus:function(e,elem)
{Event.stop(e);if(!confirm(ipb.lang['delete_confirm']))
{return false;}
var status=$(elem).className.match('__l([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error");return;}
var status_id=status[1];new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=lockStatus&status_id="+ status_id+"&md5check="+ ipb.vars['secure_hash']+'&skin_group='+ ipb.status.skin_group,{method:'get',onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON)||t.responseJSON.error)
{alert(ipb.lang['action_failed']);return;}
else
{$('statusUnlock-'+ status_id).show();$('statusLock-'+ status_id).hide();$('statusLockImg-'+ status_id).show();}}});},unlockStatus:function(e,elem)
{Event.stop(e);if(!confirm(ipb.lang['delete_confirm']))
{return false;}
var status=$(elem).className.match('__u([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error");return;}
var status_id=status[1];new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=unlockStatus&status_id="+ status_id+"&md5check="+ ipb.vars['secure_hash']+'&skin_group='+ ipb.status.skin_group,{method:'get',onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON)||t.responseJSON.error)
{alert(ipb.lang['action_failed']);return;}
else
{$('statusUnlock-'+ status_id).hide();$('statusLock-'+ status_id).show();$('statusLockImg-'+ status_id).hide();}}});},deleteReply:function(e,elem)
{Event.stop(e);if(!confirm(ipb.lang['delete_confirm']))
{return false;}
var status=$(elem).className.match('__dr([0-9]+)-([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error showing all comments");return;}
var status_id=status[1];var reply_id=status[2];new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=deleteReply&status_id="+ status_id+"&reply_id="+ reply_id+"&md5check="+ ipb.vars['secure_hash']+'&skin_group='+ ipb.status.skin_group,{method:'get',onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON)||t.responseJSON.error)
{alert(ipb.lang['action_failed']);return;}
else
{$('statusReply-'+ reply_id).remove();}}});},showAllComments:function(e,elem)
{Event.stop(e);var status=$(elem).className.match('__x([0-9]+)');if(status==null||Object.isUndefined(status[1])){Debug.error("Error showing all comments");return;}
var status_id=status[1];new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=showall&status_id="+ status_id+"&md5check="+ ipb.vars['secure_hash']+'&skin_group='+ ipb.status.skin_group,{method:'get',onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON))
{alert(ipb.lang['action_failed']);return;}
if(t.responseJSON['error'])
{alert(t.responseJSON['error']);}
else
{try{$('statusMoreWrap-'+ status_id).hide();$('statusReplies-'+ status_id).update(t.responseJSON['html']);if(t.responseJSON['status_replies']>20)
{$('statusReplies-'+ status_id).addClassName('status_replies_many');}}
catch(err)
{Debug.error(err);}}}});},addReply:function(e,status_id)
{Event.stop(e);if($('statusText-'+ status_id).value.length<2)
{return false;}
new Ajax.Request(ipb.vars['base_url']+"app=members&section=status&module=ajax&do=reply&status_id="+ status_id+"&md5check="+ ipb.vars['secure_hash']+'&skin_group='+ ipb.status.skin_group,{method:'post',evalJSON:'force',parameters:{content:$('statusText-'+ status_id).value.encodeParam()},onSuccess:function(t)
{if(Object.isUndefined(t.responseJSON))
{alert(ipb.lang['action_failed']);return;}
if(t.responseJSON['error'])
{alert(t.responseJSON['error']);}
else
{try{$('statusReplyBlank-'+ status_id).show().innerHTML+=t.responseJSON['html'];$('statusText-'+ status_id).value='';}
catch(err)
{Debug.write(err);}}}});}};ipb.status.init();
