treenode.prototype.selectByLabel = function(label){
	if(this.src != null && !this.loaded){
		this.load();
		
		var self = this;
		setTimeout(function() {
			self.selectByLabel(label)
		}, 100)
		
		return;
	}			
	
	var found = false;
	for(i=0;i<this.oNodeChilds.childNodes.length;i++){
		if(this.oNodeChilds.childNodes[i].obj.label == label){
			this.oNodeChilds.childNodes[i].obj.select();
			found = true;
			break;
		}
	}
	
	if(!found){
		details = 'what happened: no childnodes found with provided label\nprovided label:'+label;
		alert('an error occured within treenode.prototype.selectByLabel: \n\ndetails:\n' + details);
	}
}
		

treenode.prototype.selectByLabelPath = function(path){
	
	var path;
	
	if(this.src && !this.loaded){
		this.load();

		var self = this;
		setTimeout(function() {
			self.selectByLabelPath(path);
		}, 100)
		return;
	}			
	
	path = path.split(",");
	
	var found = false;
	for(i=0;i<this.oNodeChilds.childNodes.length;i++){
		if(this.oNodeChilds.childNodes[i].obj.label == path[0]){
			//treeview object has no expand function
			if(this.expand){
				this.expand();
			}
			this.oNodeChilds.childNodes[i].obj.select();
			found = true;
			break;
		}
	}
	
	if(!found){
		details = 'what happened: no childnodes found with provided label\nprovided label: '+path[0];
		alert('an error occured within treenode.prototype.selectByLabelPath or treeview.prototype.selectByLabelPath: \n\ndetails:\n' + details);
	}else{
		if(path.length > 1){
			var tmp = '';
			for(i=1;i<path.length;i++){
				tmp += path[i];
				if(i<path.length-1){
				tmp += ',';
				}
			}
			path = tmp;
			selectedNode.selectByLabelPath(path);
		}
	}
}

treenode.prototype.selectByIndex = function(index){
	
	if(this.src != null && !this.loaded){
		this.load();
		
		var self = this;
		setTimeout(function() {
			self.selectByIndex(index)
		}, 100)
		
		return;
	}			
	
	if(index > this.oNodeChilds.childNodes.length-1){
		if(this.oNodeChilds.childNodes.length <= 0){
			details = 'what happened: no childnodes available to select';
		}else{
			details = 'what happened: index out of range\npassed index:'+index+'\navailable maximum index:'+this.oNodeChilds.childNodes.length+'';
		}
		alert('an error occured within treenode.prototype.selectByIndex: \n\ndetails:\n' + details);
		return;
	}
	this.oNodeChilds.childNodes[index].obj.select();
}

treenode.prototype.selectByIndexPath = function(path){
	
	var path;
	
	if(this.src != null && !this.loaded){
		this.load();

		var self = this;
		setTimeout(function() {
			self.selectByIndexPath(path);
		}, 100)
		return;
	}			
	
	path = path.split(",");
	
	if(parseInt(path[0]) > this.oNodeChilds.childNodes.length-1){
		if(this.oNodeChilds.childNodes.length <= 0){
			details = 'what happened: no childnodes available to select';
		}else{
			details = 'what happened: index out of range\npassed index:'+path[0]+'\navailable maximum index:'+this.oNodeChilds.childNodes.length+'';
		}
		alert('an error occured within treenode.prototype.selectByIndexPath: \n\ndetails:\n' + details);
		return;
	}
	this.oNodeChilds.childNodes[path[0]].obj.select();
	

	if(path.length > 1){
		var tmp = '';
		for(i=1;i<path.length;i++){
			tmp += path[i];
			if(i<path.length-1){
			tmp += ',';
			}
		}
		path = tmp;
		selectedNode.selectByIndexPath(path);
	}
}

treeview.prototype.selectByLabel = treenode.prototype.selectByLabel;
treeview.prototype.selectByLabelPath = treenode.prototype.selectByLabelPath;
treeview.prototype.selectByIndexPath = treenode.prototype.selectByIndexPath;