/** Title:			CTRSRequestParam.js
 *  Description:
 *		Define TRSRequestParam Object
 *  Copyright: 		www.trs.com.cn
 *  Company: 		TRS Info. Ltd.
 *  Author:			CH
 *  Created:		2004-11-24 08:38
 *  Vesion:			1.0
 *  Last EditTime:	2004-11-24/2004-11-24
 *	Update Logs:
 *		CH@2004-11-24 Created File
 *	Note:
 *		
 *	Depends:
 *		CTRSHashtable.js
 *
 *	Examples:
 *			
 */

function CTRSRequestParam(){
	this.hParameters = null;

	this.init				= function(){
		if(this.hParameters != null)return;

		try{
			this.hParameters = new CTRSHashtable();				
		}catch(e){
			CTRSAction_alert("Please include CTRSHashtable.js!");
		}		
	}
	
	this.setParameter		= function(_sParameterName, _sValue){
		this.init();
		return this.hParameters.put(_sParameterName, _sValue);
	}

	this.removeParameter	= function(_sParameterName){
		if(this.hParameters == null)
			return null;

		return this.hParameters.remove(_sParameterName);
	}	

	this.toURLParameters	= function(){
		var sURLParam = "trandom="+Math.random();

		if(this.hParameters == null || this.hParameters.size()<=0)
			return sURLParam;

		var nSize = this.hParameters.size();
		var arKeys = this.hParameters.keys();
		for(var i=0; i<nSize; i++){
			var sParamName = arKeys[i];
			var sValue = this.hParameters.get(sParamName);
			try{var arIds = sValue.split(",");}catch(e){}
			if(arIds && arIds.length && arIds.length > 200){
				CTRSAction_alert("\u6267\u884C\u6279\u91CF\u64CD\u4F5C\u65F6\uFF0C\u4E00\u6B21\u6027\u63D0\u4EA4\u7684\u6570\u91CF\u4E0D\u80FD\u8D85\u8FC7200\uFF01");
				return null;
			}
			if(sValue.length < 500){
				sValue = encodeURIComponent(sValue);
			}
			sURLParam += "&"+sParamName+"="+sValue;
		}		
		return sURLParam;
	}

	this.setAllParameters	= function(_oTRSRequestParam){
		if(_oTRSRequestParam.hParameters == null || _oTRSRequestParam.hParameters.size()<=0)
			return;
		//\u521D\u59CB\u5316
		this.init();
		//\u590D\u5236
		this.hParameters.putAll(_oTRSRequestParam.hParameters);
	}
	
}

var TRSRequestParam = new CTRSRequestParam();