function getCheckedElements(f_context){
	var farr = new Array();
	var darr = new Array();
	farr = ftGetClipboardListOfChecked(f_context);
	return farr.concat(darr);
}

function get_selected_tree_categories(check_array){
	var txt = '';
	for(var i=0;i<check_array.length;i++) {
		if(i==0)
			txt = check_array[i];
		else
			txt = txt + "," + check_array[i];
	}
	document.getElementById('cat_ids').value = txt;
	return false;
}

ftCheckError = function(context){
	if(typeof ft_components == 'undefined' || ft_components[context] == 'undefined'){
		alert('No such component');
		return false;
	}
	return ft_components[context];
}


ftGetClipboardListOfChecked = function(context){
	ft = ftCheckError(context)
	if(!ft) return false;
	var arr = new Array();
	var res = new Array();
	arr = explode(',', ft.getAllChecked());
	for(var i = 0; i < arr.length;i++){
		node = arr[i];
		res.push(ft.getUserData(node,'agg')+'_'+node+'_'+ft.getUserData(node,'pid'));
	}
	return res;
}

dhtmlXTreeObject.prototype._userCorrectCheckStates=function(dhtmlObject){
 if (!dhtmlObject)
   return;
 if(dhtmlObject.id==this.rootId) return;
 var act=dhtmlObject.childNodes;
 var flag=0;
 if(dhtmlObject.childsCount==0)	return this._userCorrectCheckStates(dhtmlObject.parentObject);
 for(var i=0;i<dhtmlObject.childsCount;i++)
	 if(act[i].checkstate!=0){
	 	flag=1;
	 }

 if(flag && dhtmlObject.checkstate!=1){
 	this._setCheck(dhtmlObject,"unsure");
 }else
 	if(dhtmlObject.checkstate!=1)
 		this._setCheck(dhtmlObject,false);

 this._userCorrectCheckStates(dhtmlObject.parentObject);
}

function ft_restoreChecked(context){
var string = jQuery.cookie('treechecked'+context);
var arr = new Array();
arr = explode(',', string);
for(var i=0;i<arr.length;i++){
	ft_components[context].setCheck(arr[i],1);
	var sNode=ft_components[context]._globalIdStorageFind(arr[i],0,1);
	ft_components[context]._userCorrectCheckStates(sNode);
}

}