/*
 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
 Code licensed under the BSD License:
 http://developer.yahoo.com/yui/license.html
 version: 3.3.0
 build: 3167
 */
YUI.add('array-extras',function(Y){var L=Y.Lang,Native=Array.prototype,A=Y.Array;A.lastIndexOf=Native.lastIndexOf?function(a,val,fromIndex){return fromIndex||fromIndex===0?a.lastIndexOf(val,fromIndex):a.lastIndexOf(val);}:function(a,val,fromIndex){var len=a.length,i=len-1;if(fromIndex||fromIndex===0){i=Math.min(fromIndex<0?len+fromIndex:fromIndex,len);}
if(i>-1&&len>0){for(;i>-1;--i){if(a[i]===val){return i;}}}
return-1;};A.unique=function(a,sort){var i=0,len=a.length,results=[],item,j;for(;i<len;++i){item=a[i];for(j=results.length;j>-1;--j){if(item===results[j]){break;}}
if(j===-1){results.push(item);}}
if(sort){if(L.isNumber(results[0])){results.sort(A.numericSort);}else{results.sort();}}
return results;};A.filter=Native.filter?function(a,f,o){return a.filter(f,o);}:function(a,f,o){var i=0,len=a.length,results=[],item;for(;i<len;++i){item=a[i];if(f.call(o,item,i,a)){results.push(item);}}
return results;};A.reject=function(a,f,o){return A.filter(a,function(item,i,a){return!f.call(o,item,i,a);});};A.every=Native.every?function(a,f,o){return a.every(f,o);}:function(a,f,o){for(var i=0,l=a.length;i<l;++i){if(!f.call(o,a[i],i,a)){return false;}}
return true;};A.map=Native.map?function(a,f,o){return a.map(f,o);}:function(a,f,o){var i=0,len=a.length,results=a.concat();for(;i<len;++i){results[i]=f.call(o,a[i],i,a);}
return results;};A.reduce=Native.reduce?function(a,init,f,o){return a.reduce(function(init,item,i,a){return f.call(o,init,item,i,a);},init);}:function(a,init,f,o){var i=0,len=a.length,result=init;for(;i<len;++i){result=f.call(o,result,a[i],i,a);}
return result;};A.find=function(a,f,o){for(var i=0,l=a.length;i<l;i++){if(f.call(o,a[i],i,a)){return a[i];}}
return null;};A.grep=function(a,pattern){return A.filter(a,function(item,index){return pattern.test(item);});};A.partition=function(a,f,o){var results={matches:[],rejects:[]};A.each(a,function(item,index){var set=f.call(o,item,index,a)?results.matches:results.rejects;set.push(item);});return results;};A.zip=function(a,a2){var results=[];A.each(a,function(item,index){results.push([item,a2[index]]);});return results;};A.forEach=A.each;},'3.3.0');YUI.add('arraylist',function(Y){var YArray=Y.Array,YArray_each=YArray.each,ArrayListProto;function ArrayList(items){if(items!==undefined){this._items=Y.Lang.isArray(items)?items:YArray(items);}else{this._items=this._items||[];}}
ArrayListProto={item:function(i){return this._items[i];},each:function(fn,context){YArray_each(this._items,function(item,i){item=this.item(i);fn.call(context||item,item,i,this);},this);return this;},some:function(fn,context){return YArray.some(this._items,function(item,i){item=this.item(i);return fn.call(context||item,item,i,this);},this);},indexOf:function(needle){return YArray.indexOf(this._items,needle);},size:function(){return this._items.length;},isEmpty:function(){return!this.size();},toJSON:function(){return this._items;}};ArrayListProto._item=ArrayListProto.item;ArrayList.prototype=ArrayListProto;Y.mix(ArrayList,{addMethod:function(dest,names){names=YArray(names);YArray_each(names,function(name){dest[name]=function(){var args=YArray(arguments,0,true),ret=[];YArray_each(this._items,function(item,i){item=this._item(i);var result=item[name].apply(item,args);if(result!==undefined&&result!==item){ret.push(result);}},this);return ret.length?ret:this;};});}});Y.ArrayList=ArrayList;},'3.3.0');YUI.add('arraylist-add',function(Y){Y.mix(Y.ArrayList.prototype,{add:function(item,index){var items=this._items;if(Y.Lang.isNumber(index)){items.splice(index,0,item);}
else{items.push(item);}
return this;},remove:function(needle,all,comparator){comparator=comparator||this.itemsAreEqual;for(var i=this._items.length-1;i>=0;--i){if(comparator.call(this,needle,this.item(i))){this._items.splice(i,1);if(!all){break;}}}
return this;},itemsAreEqual:function(a,b){return a===b;}});},'3.3.0',{requires:['arraylist']});YUI.add('arraylist-filter',function(Y){Y.mix(Y.ArrayList.prototype,{filter:function(validator){var items=[];Y.Array.each(this._items,function(item,i){item=this.item(i);if(validator(item)){items.push(item);}},this);return new this.constructor(items);}});},'3.3.0',{requires:['arraylist']});YUI.add('array-invoke',function(Y){Y.Array.invoke=function(items,name){var args=Y.Array(arguments,2,true),isFunction=Y.Lang.isFunction,ret=[];Y.Array.each(Y.Array(items),function(item,i){if(isFunction(item[name])){ret[i]=item[name].apply(item,args);}});return ret;};},'3.3.0');YUI.add('collection',function(Y){},'3.3.0',{use:['array-extras','arraylist','arraylist-add','arraylist-filter','array-invoke']});
