var OOS_unsuitableMedia={url:"/services/unsuitable-media",selector:"a.unsuitable-media",initialize:function(){var links=$$(this.selector);if(links.size()===0){return false;}links.invoke("observe","click",this.renderForm.bindAsEventListener(this));},renderForm:function(e){e.stop();var elto=e.element();var that=this;var title=elto.readAttribute("title");var dialog=new Box("unsuitable-media-dialog",title);var req=new Ajax.Request(that.url,{method:"get",parameters:elto.readAttribute("href").toQueryParams(),onSuccess:function(transport){dialog.setContents(transport.responseText);dialog.getForm().observe("submit",that.submitForm.bindAsEventListener(that,dialog));}});},submitForm:function(e,dialog){e.stop();if(dialog.getForm().select("textarea").first().getValue().blank()){return false;}var req=new Ajax.Request(this.url,{method:"post",parameters:dialog.getForm().serialize(),onSuccess:function(transport){dialog.setContents(transport.responseText);}});}};function prefetch(src){var img=new Image();img.src=src;}document.observe("dom:loaded",function(){if(typeof (next)==="string"){prefetch(next);}if(typeof (prev)==="string"){prefetch(prev);}var shareLinks=$$("a.share, .share-options .oos a"),sharers=[];for(var i=0;i<shareLinks.length;i++){if(shareLinks[i]!=null){sharers.push(new OOS.Share(shareLinks[i]));}}OOS_unsuitableMedia.initialize();var emb=$("to_emb");if(emb){emb.observe("click",function(e){var input=e.element();input.focus();input.select();});}var comment_form=$$('form[action="/services/add-comment"]').first();if(comment_form){comment_form.select('input[type="submit"]').first().enable();comment_form.observe("submit",function(){this.select('input[type="submit"]').first().disable();});}var img=new Element("img",{src:"/static/imgs/ajax_activity_indicator_silver.gif"});var rotate_form=$$('form[action="/services/rotate"]').first();if(rotate_form){var submit_button=rotate_form.select('input[type="submit"]').first();var link=new Element("a",{className:"action",href:"#"}).update(submit_button.getValue());link.observe("click",function(e){e.stop();rotate_form.submit();this.hide();var parent=this.up();parent.insert(img);parent.insert('<span style="margin-left:5px;">'+_("girando foto...")+"</span>");});submit_button.hide();rotate_form.insert(link);}OOS.Utils.add_one();});
