/* Copyright (C) 2007 - 2011 YOOtheme GmbH, YOOtheme Proprietary Use License (http://www.yootheme.com/license) */

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