ResourceActions=Class.create();ResourceActions.prototype={initialize:function(){this.bookmark=$$("a.resource-bookmark");this.bookmark.each(function(a){Event.observe(a,"click",this.toggleBookmark.bindAsEventListener(this))}.bind(this));this.vote=$$("a.resource-vote");this.vote.each(function(a){Event.observe(a,"click",this.toggleVote.bindAsEventListener(this))}.bind(this));this.calendar=$$("a.resource-calendar");this.calendar.each(function(a){Event.observe(a,"click",this.toggleCalendar.bindAsEventListener(this))}.bind(this));this.notify=$$("a.resource-notify");this.notify.each(function(a){Event.observe(a,"click",this.toggleNotify.bindAsEventListener(this))}.bind(this));this.deleteDraft=$$("a.resource-delete");this.deleteDraft.each(function(a){Event.observe(a,"click",this.confirmDeleteDraft.bindAsEventListener(this))}.bind(this));this.report=$$("a.resource-report");this.report.each(function(a){Event.observe(a,"click",this.reportToMods.bindAsEventListener(this))}.bind(this))},toggleBookmark:function(b){var c=Event.element(b).id;var a=$(c);new Ajax.Request("/discussionajax/bookmark/",{method:"get",parameters:{rsrc_id:c},onCreate:function(d){a.style.backgroundImage="url(/images/graphics/ajax-loader.gif)";a.style.backgroundPosition="0 0"},onSuccess:function(e){var d=e.responseText;if(d!=""){if(d=="true"){a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="0 -24px";a.title="Remove from Bookmarks"}else{a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="0 0";a.title="Add to Bookmarks"}}else{a.innerHTML="error"}},onFailure:function(){alert("Something went wrong...")}})},toggleVote:function(c){var g=Event.element(c).id;var b=$(g);var f=g.replace("a_vote_","");var a=null;var d=0;new Ajax.Request("/discussionajax/vote/",{method:"get",parameters:{rsrc_id:g},onCreate:function(e){b.style.backgroundImage="url(/images/graphics/ajax-loader.gif)";b.style.backgroundPosition="0 0"},onSuccess:function(h){var e=h.responseText;if(e!=""){if(e=="true"){b.style.backgroundImage="url(/images/buttons/action-buttons.png)";b.style.backgroundPosition="-48px -24px";b.title="Remove Vote";if(a=$("voteNum"+f)){d=parseInt(a.innerHTML)+1}}else{b.style.backgroundImage="url(/images/buttons/action-buttons.png)";b.style.backgroundPosition="-48px 0";b.title="Add Vote";if(a=$("voteNum"+f)){d=parseInt(a.innerHTML)-1}}}else{b.innerHTML="error"}},onComplete:function(){a.innerHTML=d},onFailure:function(){alert("Something went wrong...")}})},toggleNotify:function(b){var c=Event.element(b).id;var a=$(c);new Ajax.Request("/discussionajax/notify/",{method:"get",parameters:{rsrc_id:c},onCreate:function(d){a.style.backgroundImage="url(/images/graphics/ajax-loader.gif)";a.style.backgroundPosition="0 0"},onSuccess:function(e){var d=e.responseText;if(d!=""){if(d=="true"){a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-24px -24px";a.title="Stop emailing me about this topic"}else{a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-24px 0";a.title="Email me when someone comments about this topic"}}else{a.innerHTML="error"}},onFailure:function(){alert("Something went wrong...")}})},reportToMods:function(b){if(!confirm("Report this topic to the Yehoodistrators? By clicking OK you are sending an alert about spam, abusive post or some other type of action that goes against the Yehoodi User Agreement. Are you absolutely sure?")){Event.stop(b);return false}var c=Event.element(b).id;var a=$(c);new Ajax.Request("/discussionajax/report/",{method:"get",parameters:{rsrc_id:c},onCreate:function(d){a.style.backgroundImage="url(/images/graphics/ajax-loader.gif)";a.style.backgroundPosition="0 0"},onSuccess:function(e){var d=e.responseText;if(d!=""){if(d=="true"){a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-72px -24px";a.title="Topic Reported to Yehoodistrators!"}else{a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-72px -24px"}}else{a.innerHTML="error"}},onFailure:function(){alert("Something went wrong...")}})},toggleCalendar:function(b){var c=Event.element(b).id;var a=$(c);new Ajax.Request("/discussionajax/calendar/",{method:"get",parameters:{rsrc_id:c},onCreate:function(d){a.style.backgroundImage="url(/images/graphics/ajax-loader.gif)";a.style.backgroundPosition="0 0"},onSuccess:function(e){var d=e.responseText;if(d!=""){if(d=="true"){a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-1682px -24px"}else{a.style.backgroundImage="url(/images/buttons/action-buttons.png)";a.style.backgroundPosition="-168px 0px"}}else{a.innerHTML="error"}},onComplete:function(){},onFailure:function(){alert("Something went wrong...")}})},confirmDeleteDraft:function(a){if(!confirm("Delete this draft? (There is no undo)")){Event.stop(a);return false}}};
