function getChildren(layt){ //takes a layout as an argument var children = []; var obj, order; //loop through all controls for (var id in _map) { obj = _map[id] //check if control is on our layout order = layt.GetChildOrder( obj ); if( order > -1 ) { //got one! //zorder propery wll persist until getChildren called again //or manually overwritten by coder obj.zorder = order; children.push( obj ); } } children.sort(function (a, b) { return a.zorder - b.zorder}); return children; }