/* Copyright (C) YOOtheme GmbH, http://www.gnu.org/licenses/gpl.html GNU/GPL */

(function(b){var f=function(){};b.extend(f.prototype,{name:"Comment",options:{cookiePrefix:"zoo-comment_",cookieLifetime:15552E3,msgCancel:"Cancel"},initialize:function(c,e){this.options=b.extend({},this.options,e);var d=this,a=c.find("#respond");a.find("a.facebook-connect").bind("click",function(){d.setLoginCookie("facebook")});a.find("a.facebook-logout").bind("click",function(){d.setLoginCookie("")});a.find("a.twitter-connect").bind("click",function(){d.setLoginCookie("twitter")});a.find("a.twitter-logout").bind("click",
function(){d.setLoginCookie("")});a.find("input:text").placeholder();c.find(".comment").each(function(){var c=b(this);c.find(".reply > a").bind("click",function(e){e.preventDefault();a.find(".comment-cancelReply").remove();b("<a>"+d.options.msgCancel+"</a>").addClass("comment-cancelReply").attr("href","#respond").bind("click",function(d){d.preventDefault();a.find(".comment-cancelReply").remove();a.appendTo(b("#comments"));a.find("input[name=parent_id]").val(0)}).appendTo(a.find(".actions"));a.appendTo(c);
a.find("input[name=parent_id]").val(b(this).closest(".comment").attr("id").replace(/comment-/i,""))})})},setLoginCookie:function(c){b.cookie(this.options.cookiePrefix+"login",c,{expires:this.options.cookieLifetime/86400,path:"/"})}});b.fn[f.prototype.name]=function(){var c=arguments,e=c[0]?c[0]:null;return this.each(function(){var d=b(this);if(f.prototype[e]&&d.data(f.prototype.name)&&"initialize"!=e)d.data(f.prototype.name)[e].apply(d.data(f.prototype.name),Array.prototype.slice.call(c,1));else if(!e||
b.isPlainObject(e)){var a=new f;f.prototype.initialize&&a.initialize.apply(a,b.merge([d],c));d.data(f.prototype.name,a)}else b.error("Method "+e+" does not exist on jQuery."+f.name)})}})(jQuery);
(function(b){var f=function(){};b.extend(f.prototype,{name:"BrowseComments",options:{url:"index.php?option=com_zoo&controller=comment",id:"edit-comment-editor"},initialize:function(c,e){this.options=b.extend({},this.options,e);var d=this;this.form=c;c.delegate("tr.comment-row .actions-links .edit, tr.comment-row .actions-links .reply","click",function(a){a.preventDefault();a=b(this).attr("class");d.modifyEvent(b(this).closest("tr.comment-row"),a)});c.delegate("tr.comment-row .actions-links span",
"click",function(a){a.preventDefault();switch(b(this).attr("class")){case "no-spam":a="approve";break;case "delete":a="remove";break;default:a=b(this).attr("class")}d.stateEvent(b(this).closest("tr.comment-row"),a)})},modifyEvent:function(c,e){var d=this;b.ajax({url:this.options.url,data:{task:e,format:"raw",cid:c.find('input[name^="cid["]').val()},success:function(a){d.removeEditor();d.insertEditor(c,a);"edit"==e&&c.hide();d.form.unbind("save").unbind("cancel").bind("save",function(a,f){d.removeEditor();
"edit"==e?c.replaceWith(f):b(f).insertAfter(c);d.stripe()}).bind("cancel",function(){d.removeEditor()})}})},stateEvent:function(c,e){b('<input type="hidden" name="cid">').val(c.find('input[name^="cid["]').val()).appendTo(this.form);this.form.find("input[name=task]").val(e);this.form.submit()},insertEditor:function(c,e){var d=this,a=c.after(e).next();a.find(".actions .save").bind("click",function(a){a.preventDefault();var c={};b.each(d.form.serializeArray(),function(a,b){c[b.name]=b.value});b.ajax({type:"POST",
url:d.options.url,data:b.extend(c,{task:"save",format:"raw"}),success:function(a){d.form.triggerHandler("save",a)}})});a.find(".actions .cancel").bind("click",function(a){a.preventDefault();d.form.triggerHandler("cancel")});a.find(".content textarea").focus()},removeEditor:function(){b("#"+this.options.id,this.form).prev("tr").show();b("#"+this.options.id,this.form).remove()},stripe:function(){b("table.stripe tbody tr").removeClass("odd even").each(function(){b(this).addClass(b(this).is("tr:odd")?
"odd":"even")})}});b.fn[f.prototype.name]=function(){var c=arguments,e=c[0]?c[0]:null;return this.each(function(){var d=b(this);if(f.prototype[e]&&d.data(f.prototype.name)&&"initialize"!=e)d.data(f.prototype.name)[e].apply(d.data(f.prototype.name),Array.prototype.slice.call(c,1));else if(!e||b.isPlainObject(e)){var a=new f;f.prototype.initialize&&a.initialize.apply(a,b.merge([d],c));d.data(f.prototype.name,a)}else b.error("Method "+e+" does not exist on jQuery."+f.name)})}})(jQuery);
