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

(function(b){var a=function(){};a.prototype=b.extend(a.prototype,{name:"BrowseItems",options:{url:"index.php"},initialize:function(a,c){this.options=b.extend({},this.options,c);var d=this;this.timer=null;this.delay=1500;this.input=a;a.find("td.priority").each(function(){var e=b(this).find("input.value:first");e.bind("change",function(){d.save(this)});b(this).find("span.plus:first, span.minus:first").bind("click",function(){var a=b(this).is(".plus")?1:-1;e.attr("value",e.val().toInt()+a).trigger("change")})})},
save:function(){var a=this;this.timer&&clearTimeout(this.timer);this.timer=setTimeout(function(){var c={},d=a.input.find("table.list:first");b.each(a.input.find("input[name^=priority], input[type=hidden]").serializeArray(),function(e,b){c[b.name]=b.value});d.addClass("loader");b.ajax({url:a.options.url,type:"post",datatype:"json",data:b.extend(c,{task:"savepriority",format:"raw"}),success:function(e){d.removeClass("loader");b.Message(e,!0)}})},this.delay)}});b.fn[a.prototype.name]=function(){var f=
arguments,c=f[0]?f[0]:null;return this.each(function(){var d=b(this);if(a.prototype[c]&&d.data(a.prototype.name)&&c!="initialize")d.data(a.prototype.name)[c].apply(d.data(a.prototype.name),Array.prototype.slice.call(f,1));else if(!c||b.isPlainObject(c)){var e=new a;a.prototype.initialize&&e.initialize.apply(e,b.merge([d],f));d.data(a.prototype.name,e)}else b.error("Method "+c+" does not exist on jQuery."+a.name)})}})(jQuery);
(function(b){var a=function(){};a.prototype=b.extend(a.prototype,{name:"EditItem",initialize:function(a){$this=this;b.each(["apply","save","saveandnew"],function(e,c){b("#toolbar-"+c+" a").bind("validate.adminForm",function(b){a.find('input[name="name"]').val()==""&&(a.find("span.message-name").css("display","block"),b.preventDefault())})});var c=b("#categories"),d=b("#paramsprimary_category");c.bind("change",function(){var a=b(this).val(),a=a?a:[];d.val()in a||d.val(a.length?a.shift():"")});d.bind("change",
function(){var a=c.val(),a=a?a:[],d=b(this).val();d&&!(d in a)&&(a.push(d),c.val(a))});a.find("div.element").each(function(){b(this).delegate("div.more-options div.trigger div.button","click",function(){var a=b(this).closest("div.more-options"),c="show-"+b(this).attr("class").split(" ").shift();a.hasClass(c)?a.attr("class","more-options"):a.attr("class","more-options "+c);b(this).closest("ul").css("height",b(this).closest("ul").css("height","").height())}).find("div.row > input:text").placeholder()})}});
b.fn[a.prototype.name]=function(){var f=arguments,c=f[0]?f[0]:null;return this.each(function(){var d=b(this);if(a.prototype[c]&&d.data(a.prototype.name)&&c!="initialize")d.data(a.prototype.name)[c].apply(d.data(a.prototype.name),Array.prototype.slice.call(f,1));else if(!c||b.isPlainObject(c)){var e=new a;a.prototype.initialize&&e.initialize.apply(e,b.merge([d],f));d.data(a.prototype.name,e)}else b.error("Method "+c+" does not exist on jQuery."+a.name)})}})(jQuery);
