var TextSelection = new Class({
	initialize:function(txt,headCharIdx,tailCharIdx,headPageIdx,tailPageIdx){
		this.text=txt;
		this.headChar=headCharIdx;
		this.tailChar=tailCharIdx;
		this.headPage=headPageIdx;
		this.tailPage=tailPageIdx;
		//this.dispa
	},
	
	/* accessor methods for the text selection's parameter */
	
	/* text parameter is read only, because a new text selection 
	 * is created after changing a parameter's value. by changing an instance's
	 * public property, the instance gets replaced by a new one with the nue parameters
	 */
	getText: function(){
		return this.text;
	},
	getHeadChar: function(){
		return this.headChar;
	},
	getTailChar: function(){
		return this.tailChar;
	},
	getHeadPage: function(){
		return this.headPage;
	},
	getTailPage: function(){
		return this.tailPage;
	},
	setHeadChar: function(headCharIdx){
		var headChar=parseInt(headCharIdx);
		if(typeof(headChar)!="number"){
			throw headChar+" is no number";
		}else if(headChar<0){
		//	throw "cannot apply negative char id "+headChar;
			this.headChar=0;
		}else if(headChar>this.tailChar){
			this.headChar=this.tailChar;
		}else{
			this.headChar=headChar;
		}
		PAC.flDoc.selectText(this.headChar,this.tailChar,this.headPage,this.tailPage);
	},
	setTailChar: function(tailCharIdx){
		var tailChar=parseInt(tailCharIdx);
		if(typeof(tailChar)!="number"){
			throw tailChar+" is no "+typeof(tailChar);
		}else if(tailChar<0){
		//	throw "cannot apply negative char id "+tailChar;
			this.tailChar=this.headChar=0;
		}else if(tailChar<this.headChar){
			this.tailChar=this.headChar;
		}else{
			this.tailChar=tailChar;
		}
		PAC.flDoc.selectText(this.headChar,this.tailChar,this.headPage,this.tailPage);
	},
	setHeadPage: function(headPageIdx){
		var headPage=parseInt(headPageIdx);
		if(typeof(headPage)!="number"){
			throw headPage+" is no "+typeof(headPage);
		}else if(headPage<1){
		//	throw "cannot apply page id smaller than 1: "+headPage;
			this.headPage=1;
		}else if(headPage>this.tailPage){
			this.headPage=this.tailPage;
		}else{
			this.headPage=headPage;
		}
		PAC.flDoc.selectText(this.headChar,this.tailChar,this.headPage,this.tailPage);
	},
	setTailPage: function(tailPageIdx){
		var tailPage=parseInt(tailPageIdx);
		if(typeof(tailPage)!="number"){
			throw tailPage+" is no number";
		}else if(tailPage<1){
		//	throw "cannot apply id smaller than 1! "+tailPage;
			this.tailPage=this.headPage=1;
		}else if(tailPage<this.headPage){
			this.tailPage=this.headPage;
		}else{
			this.tailPage=tailPage;
		}
		PAC.flDoc.selectText(this.headChar,this.tailChar,this.headPage,this.tailPage);
	}
});