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

Zoo.AliasEdit=new Class({initialize:function(b){this.setOptions({edit:false,edit_field_name:"alias"},b);var a=this;this.trigger=$E("a.trigger","name-edit");this.panel=$E("div.panel","name-edit");this.text=$E('input[name="'+this.options.edit_field_name+'"]',"name-edit");this.options.edit||$E('input[name="name"]',"name-edit").addEvent("blur",function(){var c=Zoo.String.slugify(this.getValue());if(c!=""){a.text.value=c;a.trigger.setText(c);this.removeEvents()}});this.trigger.addEvent("click",function(){this.setStyle("display",
"none");a.panel.addClass("active");a.text.focus();a.text.addEvent("keydown",function(c){c=new Event(c);c.key=="enter"&&a.setAlias();c.key=="esc"&&a.remove()});$E("input.accept","name-edit").addEvent("click",function(){a.setAlias()});$E("a.cancel","name-edit").addEvent("click",function(){a.remove()})})},setAlias:function(){var b=Zoo.String.slugify(this.text.getValue());if(b=="")b=(b=Zoo.String.slugify($E('input[name="name"]',"name-edit").getValue()))?b:"42";this.text.value=b;this.trigger.setText(b);
this.remove()},remove:function(){this.trigger.removeProperty("style");this.panel.removeClass("active")}});Zoo.AliasEdit.implement(new Options); 
