var JadeUtils = {
	IsInEmployees: function(code){
		if(USER.root==1 || USER.empl_acc_all==1){ return true; }
		for(var i in EMPLOYEES){
			if(code==EMPLOYEES[i]){ return true; }
		}
		return false;
	},
	PetitionFamily: function(familia, clave, accion){
		switch(familia){
			case '0': 
				if($.Utils.Is9Digits()){ clave=$.Strings.PadLeft(clave, '0', 9); }
				if(typeof(aEmployees)!="undefined" && typeof(aEmployees[clave])!="undefined" && accion!='0'){ clave=aEmployees[clave].Text; }
				break;
			case '1': case '6':
				if(typeof(aEmployees)!="undefined" && typeof(aEmployees[clave])!="undefined"){ clave=aEmployees[clave].Text; }
				break;
		}
		var family='';
		if(familia=='0'){
			if(typeof(accion)!="undefined"){ family=Jade.Lang.Get('petition_action_'+accion)+' '+Jade.Lang.Get('petition_fam_'+familia); }
			else{ family=Jade.Lang.Get('petition_fam_1'); }
		}
		else{
			family=Jade.Lang.Get('petition_fam_'+familia);
		}
		return family+': <span class="mark">'+clave+'</span>';
	},
	PetitionLine: function(accion, familia, subfamilia, clave){
		return Jade.Lang.Get('petition_action_'+accion)+' '+Jade.Lang.Get('petition_'+familia+'_'+subfamilia);
	},
	IsSystemIncidence: function(code){
		return code.substr(0,1)=='S';
	},
	Privilege: function(code){
		if(USER.root==1) { return true; }
		return USER[code]==1;
	},
	PrivilegeValue: function(code){
		if(USER.root==1) { return 2; }
		return USER[code];
	},
	AAText: function(object, index){
		if(typeof(object)=="undefined"){
			return $.lang.Get('undefined');
		}
		else{
			if(typeof(object[index])!="undefined"){
				return object[index].Text;
			}
			else{
				return index+' - '+$.lang.Get('unknown');
			}
		}
	},
	AAUser: function(object,index){
		if(typeof(object)=="undefined"){
			return $.lang.Get('undefined');
		}
		else{
			if(typeof(object[index])!="undefined"){
				return object[index].Text;
			}
			else{
				return $.lang.Get('unknown');
			}
		}
	},
	Is9Digits: function(){
		return COMPANY.version.substr(-1)==1 || $.Convert.ToInt(COMPANY.version.replace(/\./gi, ''))>=1773; 
	}
}
Jade.LoadLibrary('Utils',JadeUtils);