/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.2.0
build: nightly
*/
YUI.add("widget-child",function(C){var B=C.Lang;function A(){C.after(this._syncUIChild,this,"syncUI");C.after(this._bindUIChild,this,"bindUI");}A.ATTRS={selected:{value:0,validator:B.isNumber},index:{readOnly:true,getter:function(){var E=this.get("parent"),D=-1;if(E){D=E.indexOf(this);}return D;}},parent:{readOnly:true},depth:{readOnly:true,getter:function(){var E=this.get("parent"),D=this.get("root"),F=-1;while(E){F=(F+1);if(E==D){break;}E=E.get("parent");}return F;}},root:{readOnly:true,getter:function(){var D=function(H){var E=H.get("parent"),F=H.ROOT_TYPE,G=E;if(F){G=(E&&(E instanceof F));}return(G?D(E):H);};return D(this);}}};A.prototype={ROOT_TYPE:null,_getUIEventNode:function(){var D=this.get("root"),E;if(D){E=D.get("boundingBox");}return E;},next:function(F){var E=this.get("parent"),D;if(E){D=E.item((this.get("index")+1));}if(!D&&F){D=E.item(0);}return D;},previous:function(G){var F=this.get("parent"),D=this.get("index"),E;if(F&&D>0){E=F.item([(D-1)]);}if(!E&&G){E=F.item((F.size()-1));}return E;},remove:function(D){var E,F;if(B.isNumber(D)){F=C.WidgetParent.prototype.remove.apply(this,arguments);}else{E=this.get("parent");if(E){F=E.remove(this.get("index"));}}return F;},isRoot:function(){return(this==this.get("root"));},ancestor:function(F){var D=this.get("root"),E;if(this.get("depth")>F){E=this.get("parent");while(E!=D&&E.get("depth")>F){E=E.get("parent");}}return E;},_uiSetChildSelected:function(E){var F=this.get("boundingBox"),D=this.getClassName("selected");if(E===0){F.removeClass(D);}else{F.addClass(D);}},_afterChildSelectedChange:function(D){this._uiSetChildSelected(D.newVal);},_syncUIChild:function(){this._uiSetChildSelected(this.get("selected"));},_bindUIChild:function(){this.after("selectedChange",this._afterChildSelectedChange);}};C.WidgetChild=A;},"3.2.0",{requires:["base-build","widget"]});