(function(){var Util=YAHOO.util;var Dom=Util.Dom;var Event=Util.Event;var notify=sym.widget.Notify.message;var inline=sym.widget.Notify.inline;var flash=sym.util.Effects.flash;sym.ui.Profile={_deferTimer:null,init:function(data){this.data=data;Event.addListener('editSubmit','click',sym.ui.Profile.onEditSubmitClick,sym.ui.Profile);},onEditSubmitClick:function(e,me){var editForm=$('editForm');if(!editForm){return;}
var editMsg=$('editMsg')
var querystring=[];for(var i=0;i<editForm.elements.length;i++){var el=editForm.elements[i];querystring.push(encodeURIComponent(el.name)+"="+encodeURIComponent(el.value))}
sym.util.Effects.toggleFormState(editForm);document.body.style.cursor='wait';inline(editMsg,_('SAVING'),sym.widget.Notify.Level.loading);var interval=me._deferTimer?1000:100;var callback={success:function(o){inline(editMsg,_('SAVE_COMPLETE'));sym.util.Effects.toggleFormState(editForm,true);editForm.reset();document.body.style.cursor='';},failure:function(o){var json='';try{json=eval(o.responseText);}catch(e){}
inline(editMsg,_('SAVE_FAILED')+sym.ui.Profile.renderErrors(json),sym.widget.Notify.Level.error);document.body.style.cursor='';sym.util.Effects.toggleFormState(editForm,true);}};var transaction=YAHOO.util.Connect.asyncRequest('POST',editForm.action,callback,querystring.join("&")+'&authenticity_token='+encodeURIComponent($('form_authenticity_token').innerHTML));},onUploadSubmitClick:function(uploadForm,e){document.body.style.cursor='wait';inline($('uploadMsg'),_('SAVING'),sym.widget.Notify.Level.loading);},renderErrors:function(json){var errs='';if(json&&json.length){for(var i=0;i<json.length;i++){var err=json[i];if(err.length&&err.length==2){errs+=err[0]+err[1];if(i!=json.length-1){errs+='<br>';}}}}
return errs;}}})();