Array.prototype.apply=function(func,args){

	var a=[];

	var len=this.length;

	for(var i=0;i<len;i++){

		var v=func(this[i],args);

		if(v!=null)a[a.length]=v;

	};

	return a;

};

Array.prototype.deleteDup=function(t){

	var a=[];

	if(t==1){

		var len=this.length;

		for(var i=0;i<len;i++){

			var v=this[i];

			if(v!=null)a[a.length]=v;

			for(var j=i+1;j<len;j++){

				if(this[j]==v){

					this[j]=null;

				}

			}

		}

	}else{

		this.sort();

		var len=this.length;

		var v1=null;

		for(var i=0;i<len;i++){

			var v2=this[i];

			if(v2!=v1){

				v1=a[a.length]=v2;

			}

		}

	};

	return a;

};

Array.prototype.clean=function(){

	var a=[];

	var len=this.length;

	for(var i=0;i<len;i++){

		if(this[i])a[a.length]=this[i];

	};

	return a;

};

Array.prototype.toString=function(f){

	var result="";

	var prefix=(f==1||f==2)?"[":"";

	var suffix=(f==1||f==2)?"]":"";

	var q=(f==1||f==3);

	var join=(f==4)?"\n":",";

	var v;

	for(var i=0;i<this.length;i++){

		if(result)result+=join;v=this[i];

		if(q&&typeof v=="string")v='"'+v+'"';

		result+=v;

	};

	return prefix+result+suffix;

};

Array.prototype.toList=function(){

	var result="";

	for(var i=0;i<this.length;i++){

		result+=this[i]+"<BR>\n";

	};

	return result;

};

Array.prototype.add=function(o){

	this[this.length]=o;

};

Array.prototype.IsContains=function(o){

	for(var i=0,l=this.length;i<l;i++)if(this[i]==o)return true;

	return false;

};

Array.prototype.toUL=function(htmlOptions,moreLength){

	if(this.length==0)return"";

	if(!htmlOptions)htmlOptions="";

	if(!moreLength)moreLength=5;

	var result="<UL"+((htmlOptions)?" "+htmlOptions:"")+">\n";

	for(var i=0;i<this.length;i++){

		if(i==moreLength&&i>0){

			result+="</UL>\n<span class=click onclick='EVENT.showNext(this)'>"

					+(this.length-i)

					+" 项更多...</span><br>\n"

					+"<UL class=hidden>\n";

		};

			result+=" <LI>"+this[i]+"</LI>\n";

	};

	return result+"</UL>\n";

};

var moreCache={};

function toggleMoreCache(sid,cell){

	var cellstr=cell.toString(1);

	moreCache[sid][cellstr]=moreCache[sid][cellstr]?false:true;

	var sdo=PORTALPAGE.S[sid];

	var ins=cell[0];

	var out=cell[1];

	if(cell.length==2){

		var obj=o.source(out,sdo.ido[ins]);

		delete obj.__v;

		delete obj.__vTime;

		if(obj._DefaultV){

			delete obj._DefaultV.__v;

			delete obj._DefaultV.__vTime;

		}

	};

	PORTALPAGE.S[sid].UI.body.refresh();

	VIEW.resizeAll();

};

Array.prototype.flip=function(){

	if(!this)return;

	var temp=[];

	for(var i=0;i<this.length;i++){

		for(var j=0;j<this[i].length;j++){

			if(!temp[j])temp[j]=[];

			temp[j][i]=this[i][j];

		}

	};

	return temp;

};

Array.prototype.toTABLE=function(htmlOptions,headerRows,headerCols){

	if(!headerRows)headerRows=0;

	if(!headerCols)headerCols=0;

	var item;

	var result="<TABLE"+((htmlOptions)?" "+htmlOptions:"")+">\n";

	var th1="  <TH>";

	var th2="</TH>\n";

	var td1="  <TD>";

	var td2="</TD>\n";

	for(var i=0;i<this.length;i++){

		result+=" <TR>\n";

		item=this[i];

		if(item&&typeof item=="object"&&item.length){

			for(var j=0;j<item.length;j++){

				if(i<headerRows||j<headerCols){

					result+=th1+item[j]+th2

				}else{

					result+=td1+item[j]+td2

				}

			}

		}else{

			if(i<headerRows){

				result+=th1+item+th2

			}else{

				result+=td1+item+td2

			}

		};

		result+=" </TR>\n";

	};

	return result+"</TABLE>\n";

};

Array.prototype.strip=function(){

	var i,j,k;

	var s;

	var r;

	var a=this;

	for(var i=0;i<arguments.length;i++){

		for(var j=0;j<a.length;j++){

			if(typeof a[j]=="string"){

				a[j]=a[j].replaceAll(arguments[i],"");

			}else for(k=0;k<a[j].length;k++){

					a[j][k]=a[j][k].replaceAll(arguments[i],"");

				  }

			}

		};

		return a;

};

Array.prototype._apply=function(func,arg1,arg2,arg3,arg4,arg5,arg6){

	var a=[];

	var len=this.length;

	var v;

	for(var i=0;i<len;i++){

		if(typeof this[i]=="string"){

			var s=this[i];

			v=s[func](arg1,arg2,arg3,arg4);

			if(v!=null)a[a.length]=v;

		}else{

			a[a.length]=[];

			for(var j=0;j<this[i].length;j++){

				var s=this[i][j];

				v=s[func](arg1,arg2,arg3,arg4,arg5,arg6);

				if(v!=null)a[a.length-1][j]=v;

			}

		}

	};

	return a;

};

Array.prototype.ltrim=function(){

	return this._apply("ltrim");

};

Array.prototype.rtrim=function(){

	return this._apply("rtrim");

};

Array.prototype.trim=function(){

	return this._apply("trim");

};

Array.prototype.titleCase=function(){

	return this._apply("titleCase");

};

Array.prototype.Range=function(prefix,suffix,withPrefix,withSuffix){

	return this._apply("Range",prefix,suffix,withPrefix,withSuffix);

};

Array.prototype.Before=function(match,prefix,suffix,count){

	return this._apply("Before",match,prefix,suffix,count);

};

Array.prototype.DeleteR=function(prefix,suffix){

	return this._apply("DeleteR",prefix,suffix);

};

Array.prototype.DeleteTag=function(tagName){

	return this._apply("DeleteTag",tagName);

};

Array.prototype.Match=function(match,matchCount,matchIndex){

	return this._apply("Match",match,matchCount,matchIndex);

};

Array.prototype.Tag=function(sTag,matchCriteria,omitCriteria,bInner,bNoNest){

	return this._apply("Tag",sTag,matchCriteria,omitCriteria,bInner,bNoNest);

};

Array.prototype.TagInner=function(sTag){

	return this._apply("TagInner",sTag);

};

Array.prototype.replaceAll=function(filter,text){

	return this._apply("replaceAll",filter,text);

};

Array.prototype.text=function(type){

	return this._apply("text",type);

};

Array.prototype.filter=function(filterCriteria){

	return this._apply("filter",filterCriteria);

};;
