local TraceFrame = DEFAULT_CHAT_FRAME;

--	DBCS_HDV_stats
--		[serveur+faction]
--			[numobjet]
--				[1]	=	prix alerte
--				[2}	=	prix vente
--				[3]	=	date dernier scan
--				[4]	=	heure dernier scan
--				[5]	=	prix achat direct le + bas jamais vu
--				[6]	=	prix achat direct le + bas dernier scan
--													[7]	=	achat direct prix moyen pondéré
--													[8]	=	achat direct prix moyen pondéré dernier scan
--				[9]	=	montant enchère validée la + haute
--				[10]	=	montant enchère validée la + haute dernier scan
--				[11]	=	somme des montants des prix d'achat direct cumulés
--				[12]	=	somme des piles des prix d'achat direct cumulés
--				[13]	=	somme des montants des prix d'achat direct du dernier scan
--				[14]	=	somme des piles des prix d'achat direct du dernier scan
--				[15]	=	montant enchère la + basse pour l'ordre du temps
--				[16]	=	+ petit ordre de temps restant pour une enchère basse

DBCORPS_HDV_stats_LISTE = {};
DBCORPS_HDV_stats_LISTE_nb = 0;
DBCORPS_HDV_stats_LISTE_ordre = "niveau";
DBCORPS_HDV_stats_LISTE_sens = "DESC";
DBCORPS_HDV_stats_TRI = nil;
DBCORPS_HDV_stats_CRITERES = {};

DBCORPS_HDV_stats_serveur_faction = "";

function DBCS_HDV_stats_OnLoad()

	DBCS_HDV_stats = {};
	DBCS_HDV_stats_config = {};

end

function DBcorps_ListHDV_stats_Reset()

local item_base = "DBcorpsFrame_HDV_stats_Frame_Criteres_";

	DBcorpsFrame_HDV_stats_Frame_Criteres_Rarity_OnLoad();
	UIDropDownMenu_SetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Rarity,-1);
	_G[item_base.."Nomobjet"]:SetText("");
	_G[item_base.."Nivmin"]:SetText("");
	_G[item_base.."Nivmax"]:SetText("");
	DBcorpsFrame_HDV_stats_Frame_Criteres_Type_OnLoad();
	UIDropDownMenu_SetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Type,-1);
	DBcorpsFrame_HDV_stats_Frame_Criteres_SubType_OnLoad();
	UIDropDownMenu_SetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_SubType,-1);
	DBcorpsFrame_HDV_stats_Frame_Criteres_Equiploc_OnLoad();
	UIDropDownMenu_SetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Equiploc,-1);

end

function DBcorps_ListHDV_stats_Trier_sort(elem1,elem2)

	return DBCS_HDV_stats_Trier(elem1,elem2,DBCORPS_HDV_stats_TRI,1);

end

function DBcorps_ListHDV_stats_Update()

local criteres = {};
local item_base = "DBcorpsFrame_HDV_stats_Frame_Criteres_";

	criteres.rarity = UIDropDownMenu_GetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Rarity);
	criteres.nomobjet = _G[item_base.."Nomobjet"]:GetText();
	criteres.nivmin = tonumber(_G[item_base.."Nivmin"]:GetText());
	criteres.nivmax = tonumber(_G[item_base.."Nivmax"]:GetText());
	criteres.type = UIDropDownMenu_GetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Type);
	criteres.subtype = UIDropDownMenu_GetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_SubType);
	criteres.equiploc = UIDropDownMenu_GetSelectedValue(DBcorpsFrame_HDV_stats_Frame_Criteres_Equiploc);
	criteres.serveur_faction = DBCS_serveur.."@"..DBCS_HDV_faction.."@";
	DBCORPS_HDV_stats_serveur_faction = criteres.serveur_faction;
	criteres.dernierscan = _G[item_base.."DernierScan"]:GetChecked();
	if ( criteres.dernierscan == true ) then
		criteres.dernierscan = 1;
	else
		criteres.dernierscan = 0;
	end
	criteres.sousalerte = _G[item_base.."SousAlerte"]:GetChecked();
	if ( criteres.sousalerte == true ) then
		criteres.sousalerte = 1;
	else
		criteres.sousalerte = 0;
	end

	DBCORPS_HDV_stats_LISTE = DBCS_HDV_stats_Liste(criteres);
	DBCORPS_HDV_stats_LISTE_nb = table.getn(DBCORPS_HDV_stats_LISTE);
	
	FauxScrollFrame_SetOffset(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame,0);
	
	DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrameScrollBar:SetValue(0);

	_G["DBcorpsFrame_HDV_stats_Frame_Criteres_Elements"]:SetText(DBCORPS_HDV_stats_LISTE_nb.." trouv\195\169s.");

	DBcorps_ListHDV_stats_Trier();

end

function DBcorps_ListHDV_stats_Trier(sTRI,sINVERSER)

	--local t_ordre = {};
	local sSENS = DBCORPS_HDV_stats_LISTE_sens;
	local sARROW = "DBcorpsFrame_HDV_stats_Frame_Tri_";

	if ( sTRI == nil ) then
		sTRI = DBCORPS_HDV_stats_LISTE_ordre;
	end
	if ( sINVERSER == nil ) then
		sINVERSER = 0;
	end
	if ( sTRI == DBCORPS_HDV_stats_LISTE_ordre ) then
		if ( sINVERSER == 1 ) then
			if ( sSENS == "ASC" ) then
				sSENS = "DESC";
			else
				sSENS = "ASC";
			end
			DBCORPS_HDV_stats_LISTE_sens = sSENS;
		end
	else
		DBCORPS_HDV_stats_LISTE_ordre = sTRI;
		sSENS = "ASC";
		DBCORPS_HDV_stats_LISTE_sens = sSENS;
	end

	_G[sARROW.."Rarity_Arrow"]:Hide();
	_G[sARROW.."Nomobjet_Arrow"]:Hide();
	_G[sARROW.."Nivmin_Arrow"]:Hide();
	_G[sARROW.."Niveau_Arrow"]:Hide();
	_G[sARROW.."TimeScan_Arrow"]:Hide();
	_G[sARROW.."Prix01_Arrow"]:Hide();
	_G[sARROW.."Prix02_Arrow"]:Hide();
	_G[sARROW.."Prix05_Arrow"]:Hide();
	_G[sARROW.."Prix06_Arrow"]:Hide();
	
	DBCORPS_HDV_stats_TRI = {};
	if ( sTRI == "rarity") then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Rarity_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Rarity_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Rarity_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "rarity";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[2].sens = "ASC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nivmin";
		DBCORPS_HDV_stats_TRI[3].sens = sSENS;
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "niveau";
		DBCORPS_HDV_stats_TRI[4].sens = sSENS;
		DBCORPS_HDV_stats_TRI[5] = {};
		DBCORPS_HDV_stats_TRI[5].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[5].sens = "ASC";
	elseif ( sTRI == "nomobjet") then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Nomobjet_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Nomobjet_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Nomobjet_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nivmin";
		DBCORPS_HDV_stats_TRI[3].sens = sSENS;
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "niveau";
		DBCORPS_HDV_stats_TRI[4].sens = sSENS;
		DBCORPS_HDV_stats_TRI[5] = {};
		DBCORPS_HDV_stats_TRI[5].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[5].sens = "ASC";
	elseif ( sTRI == "nivmin" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Nivmin_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Nivmin_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Nivmin_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "nivmin";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "niveau";
		DBCORPS_HDV_stats_TRI[2].sens = sSENS;
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "rarity";
		DBCORPS_HDV_stats_TRI[3].sens = "DESC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
		DBCORPS_HDV_stats_TRI[5] = {};
		DBCORPS_HDV_stats_TRI[5].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[5].sens = "ASC";
	elseif ( sTRI == "niveau" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Niveau_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Niveau_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Niveau_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "niveau";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "nivmin";
		DBCORPS_HDV_stats_TRI[2].sens = sSENS;
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "rarity";
		DBCORPS_HDV_stats_TRI[3].sens = "DESC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
		DBCORPS_HDV_stats_TRI[5] = {};
		DBCORPS_HDV_stats_TRI[5].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[5].sens = "ASC";
	elseif ( sTRI == "timescan" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."TimeScan_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."TimeScan_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."TimeScan_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "datescan";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "heurescan";
		DBCORPS_HDV_stats_TRI[2].sens = sSENS;
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "rarity";
		DBCORPS_HDV_stats_TRI[3].sens = "DESC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
		DBCORPS_HDV_stats_TRI[5] = {};
		DBCORPS_HDV_stats_TRI[5].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[5].sens = "ASC";
	elseif ( sTRI == "prix01" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix01_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix01_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix01_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix01";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix02" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix02_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix02_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix02_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix02";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix05" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix05_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix05";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix06" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix06_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix06_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix06_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix06";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix07" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix05_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix07";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix08" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix05_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix08";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	elseif ( sTRI == "prix11" ) then
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Prix05_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Prix05_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "prix11";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "rarity";
		DBCORPS_HDV_stats_TRI[2].sens = "DESC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
		DBCORPS_HDV_stats_TRI[4] = {};
		DBCORPS_HDV_stats_TRI[4].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[4].sens = "ASC";
	else
		if ( sSENS == "ASC" ) then
			_G[sARROW.."Rarity_Arrow"]:SetTexCoord(0, 0.5625, 0, 1.0);
		else
			_G[sARROW.."Rarity_Arrow"]:SetTexCoord(0, 0.5625, 1.0, 0);
		end
		_G[sARROW.."Rarity_Arrow"]:Show();
		DBCORPS_HDV_stats_TRI[1] = {};
		DBCORPS_HDV_stats_TRI[1].champ = "rarity";
		DBCORPS_HDV_stats_TRI[1].sens = sSENS;
		DBCORPS_HDV_stats_TRI[2] = {};
		DBCORPS_HDV_stats_TRI[2].champ = "nomobjet";
		DBCORPS_HDV_stats_TRI[2].sens = "ASC";
		DBCORPS_HDV_stats_TRI[3] = {};
		DBCORPS_HDV_stats_TRI[3].champ = "numobjet";
		DBCORPS_HDV_stats_TRI[3].sens = "ASC";
	end

	table.sort(DBCORPS_HDV_stats_LISTE,DBcorps_ListHDV_stats_Trier_sort);

	DBCS_HDV_stats_Scroll_Update();

end

function DBCS_HDV_stats_Trier(HDV_stats_1,HDV_stats_2,t_ordre,niveaufonction)

local s_champ = t_ordre[niveaufonction].champ;
local s_sens = t_ordre[niveaufonction].sens;
local val1,val2;
local inumobjet1 = nil;
local inumobjet2 = nil;
local tablo1;
local tablo2;
local tenreg1;
local tenreg2;
local tobjet;

	inumobjet1 = HDV_stats_1[1];
	tobjet = DBobjets_numobjet_tableau_lire(inumobjet1);
	if ( inumobjet1 and tobjet ) then
		tablo1 = tobjet;
	else
		tablo1 = {};
	end
	if ( inumobjet1 and DBCORPS_HDV_stats_serveur_faction and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet1] ) then
		tenreg1 = DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet1];
	else
		tenreg1 = {};
	end
	inumobjet2 = HDV_stats_2[1];
	tobjet = DBobjets_numobjet_tableau_lire(inumobjet2);
	if ( inumobjet2 and tobjet ) then
		tablo2 = tobjet;
	else
		tablo2 = {};
	end
	if ( inumobjet2 and DBCORPS_HDV_stats_serveur_faction and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet2] ) then
		tenreg2 = DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet2];
	else
		tenreg2 = {};
	end

	if ( s_champ == "rarity") then
		val1 = tablo1[2];
		if ( val1 == nil ) then
			val1 = -1;
		end
		val2 = tablo2[2];
		if ( val2 == nil ) then
			val2 = -1;
		end
	elseif ( s_champ == "nomobjet" ) then
		val1 = tablo1[1];
		if ( val1 == nil ) then
			val1 = "";
		end
		val2 = tablo2[1];
		if ( val2 == nil ) then
			val2 = "";
		end
	elseif ( s_champ == "nivmin") then
		val1 = tablo1[3];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tablo2[3];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "niveau") then
		val1 = tablo1[11];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tablo2[11];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "datescan" ) then
		val1 = tenreg1[3];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[3];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "heurescan" ) then
		val1 = tenreg1[4];
		if ( val1 == nil ) then
			val1 = "";
		end
		val2 = tenreg2[4];
		if ( val2 == nil ) then
			val2 = "";
		end
	elseif ( s_champ == "prix01" ) then
		val1 = tenreg1[1];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[1];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix02" ) then
		val1 = tenreg1[2];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[2];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix05" ) then
		val1 = tenreg1[5];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[5];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix06" ) then
		val1 = tenreg1[6];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[6];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix07" ) then
		val1 = tenreg1[7];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[7];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix08" ) then
		val1 = tenreg1[8];
		if ( val1 == nil ) then
			val1 = 0;
		end
		val2 = tenreg2[8];
		if ( val2 == nil ) then
			val2 = 0;
		end
	elseif ( s_champ == "prix11" ) then
		val1 = tenreg1[11];
		if ( val1 == nil ) then
			val1 = 0;
		else
			val1 = val1 / tenreg1[12];
		end
		val2 = tenreg2[11];
		if ( val2 == nil ) then
			val2 = 0;
		else
			val2 = val2 / tenreg2[12];
		end
	else
		val1 = (HDV_stats_1[1] or 0);
		val2 = (HDV_stats_2[1] or 0);
	end

	if ( s_sens == "ASC" ) then
		if ( val1 < val2 ) then
			return true;
		elseif ( val1 == val2 ) then
		else
			return false;
		end
	else
		if ( val1 > val2 ) then
			return true;
		elseif ( val1 == val2 ) then
		else
			return false;
		end
	end
	if ( val1 == val2 ) then
		if ( table.getn(t_ordre) > niveaufonction ) then
			return DBCS_HDV_stats_Trier(HDV_stats_1,HDV_stats_2,t_ordre,niveaufonction+1);
		else
			return false;
		end
	else
		return false; -- pas normal d etre ici
	end

end

function DBCS_HDV_stats_Liste(criteres)

local tablo;
--local i;
local j;
local ibon;
local inumobjet;
local tOBJET;
local ivaleur;
local tablo1;

	tablo = {};
	j = 0;

	if ( criteres.serveur_faction and DBCS_HDV_stats[criteres.serveur_faction] ) then
		if ( criteres and criteres.dernierscan == 1 ) then
			for inumobjet, _ in pairs(DBCS_HDV_stats[criteres.serveur_faction]) do
				ibon = 1;
				tOBJET = DBobjets_numobjet_tableau_lire(inumobjet);
				if ( tOBJET ) then
					if ( tOBJET[1] == nil ) then
						ibon = 0;
					end
					if ( tOBJET[103] ) then
						ibon = 0;
					end
					if ( ibon == 1 and DBCS_HDV_stats_config["dernierscan"] and DBCS_HDV_stats_config["dernierscan"][criteres.serveur_faction] and DBCS_HDV_stats_config["dernierscan"][criteres.serveur_faction]["date"] and DBCS_HDV_stats_config["dernierscan"][criteres.serveur_faction]["heure"] ) then
						if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][3] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][4] and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][3] == DBCS_HDV_stats_config["dernierscan"][criteres.serveur_faction]["date"] ) and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][4] == DBCS_HDV_stats_config["dernierscan"][criteres.serveur_faction]["heure"] ) ) then
						else
							ibon = 0;
						end
					else
						ibon = 0;
					end
--				[1]	=	prix alerte
--				[2}	=	prix vente
--				[3]	=	date dernier scan
--				[4]	=	heure dernier scan
--				[5]	=	prix achat direct le + bas jamais vu
--				[6]	=	prix achat direct le + bas dernier scan
--													[7]	=	achat direct prix moyen pondéré
--													[8]	=	achat direct prix moyen pondéré dernier scan
--				[9]	=	montant enchère validée la + haute
--				[10]	=	montant enchère validée la + haute dernier scan
--				[11]	=	somme des montants des prix d'achat direct cumulés
--				[12]	=	somme des piles des prix d'achat direct cumulés
--				[13]	=	somme des montants des prix d'achat direct du dernier scan
--				[14]	=	somme des piles des prix d'achat direct du dernier scan
--				[15]	=	montant enchère la + basse pour l'ordre du temps
--				[16]	=	+ petit ordre de temps restant pour une enchère basse
					if ( ibon == 1 and criteres.sousalerte == 1 ) then
						if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet] 
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] > 0 )
							and (
									(
											DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6]
										and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1]
									)
								or (
											( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] == nil )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] > -1 )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
									)
								)
							) then
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.rarity > -1 ) then
						if ( tOBJET[2] and not ( tOBJET[2] >= criteres.rarity ) ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nomobjet and not ( criteres.nomobjet == "" ) ) then
						if ( tOBJET[1] ) then
							ipos, _ = strfind(strlower(tOBJET[1]),strlower(criteres.nomobjet));
							if ( not ipos ) then
								ibon = 0;
							end
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmin ) then
						if ( tOBJET[3] == nil or tOBJET[3] < criteres.nivmin ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmax ) then
						if ( tOBJET[3] and tOBJET[3] > criteres.nivmax ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.type > -1 ) then
						ivaleur = DBCS_objet_type_index[tOBJET[4]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[4];
						end
						if ( criteres.type == 0 ) then
							if ( DBCS_objet_type_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_type_name[ivaleur] == criteres.type ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.subtype > -1 ) then
						ivaleur = DBCS_objet_subtype_index[tOBJET[5]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[5];
						end
						if ( criteres.subtype == 0 ) then
							tablo1 = DBCS_objet_type_subtype_index[criteres.type];
							if ( tablo1 and tablo1[DBCS_objet_subtype_name[ivaleur]] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_subtype_name[ivaleur] == criteres.subtype ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.equiploc > -1 ) then
						ivaleur = DBCS_objet_equiploc_index_name[tOBJET[7]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[7];
						end
						if ( criteres.equiploc == 0 ) then
							if ( ivaleur == "" or DBCS_objet_equiploc_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_equiploc_name[ivaleur] == criteres.equiploc ) then
								ibon = 0;
							end
						end
					end
				else
					ibon = 0;
				end
				if ( ibon == 1 ) then
					j = j + 1 ;
					tablo[j] = {};
					tablo[j][1] = inumobjet;
				end
			end
		elseif ( criteres and criteres.dernierscan == 0 ) then
			for inumobjet, _ in pairs(DBOS01) do
				ibon = 1;
				tOBJET = DBOS01[inumobjet];
				if ( tOBJET ) then
					if ( tOBJET[1] == nil ) then
						ibon = 0;
					end
					if ( tOBJET[103] ) then
						ibon = 0;
					end
					-- si l'objet est lié quand ramassé
					if ( ibon == 1 and tOBJET[46] == 2 ) then
						ibon = 0;
					end
					if ( ibon == 1 and criteres.sousalerte == 1 ) then
						if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet]
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] > 0 )
							and (
									(
											DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6]
										and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1]
									)
								or (
											( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] == nil )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] > -1 )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
									)
								)
							)	then
						--if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] > 0 and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] ) then
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.rarity > -1 ) then
						if ( tOBJET[2] and not ( tOBJET[2] >= criteres.rarity ) ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nomobjet and not ( criteres.nomobjet == "" ) ) then
						if ( tOBJET[1] ) then
							ipos, _ = strfind(strlower(tOBJET[1]),strlower(criteres.nomobjet));
							if ( not ipos ) then
								ibon = 0;
							end
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmin ) then
						if ( tOBJET[3] == nil or tOBJET[3] < criteres.nivmin ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmax ) then
						if ( tOBJET[3] and tOBJET[3] > criteres.nivmax ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.type > -1 ) then
						ivaleur = DBCS_objet_type_index[tOBJET[4]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[4];
						end
						if ( criteres.type == 0 ) then
							if ( DBCS_objet_type_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_type_name[ivaleur] == criteres.type ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.subtype > -1 ) then
						ivaleur = DBCS_objet_subtype_index[tOBJET[5]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[5];
						end
						if ( criteres.subtype == 0 ) then
							tablo1 = DBCS_objet_type_subtype_index[criteres.type];
							if ( tablo1 and tablo1[DBCS_objet_subtype_name[ivaleur]] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_subtype_name[ivaleur] == criteres.subtype ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.equiploc > -1 ) then
						ivaleur = DBCS_objet_equiploc_index_name[tOBJET[7]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[7];
						end
						if ( criteres.equiploc == 0 ) then
							if ( ivaleur == "" or DBCS_objet_equiploc_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_equiploc_name[ivaleur] == criteres.equiploc ) then
								ibon = 0;
							end
						end
					end
				else
					ibon = 0;
				end
				if ( ibon == 1 ) then
					j = j + 1 ;
					tablo[j] = {};
					tablo[j][1] = inumobjet;
				end
			end
			for inumobjet, _ in pairs(DBOS02) do
				ibon = 1;
				tOBJET = DBOS02[inumobjet];
				if ( tOBJET ) then
					if ( tOBJET[1] == nil ) then
						ibon = 0;
					end
					if ( tOBJET[103] ) then
						ibon = 0;
					end
					-- si l'objet est lié quand ramassé
					if ( ibon == 1 and tOBJET[46] == 2 ) then
						ibon = 0;
					end
					if ( ibon == 1 and criteres.sousalerte == 1 ) then
						if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet]
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
							and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] > 0 )
							and (
									(
											DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6]
										and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1]
									)
								or (
											( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] == nil )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] > -1 )
										and ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet][15] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] )
									)
								)
							)	then
						--if ( DBCS_HDV_stats[criteres.serveur_faction][inumobjet] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] > 0 and DBCS_HDV_stats[criteres.serveur_faction][inumobjet][6] <= DBCS_HDV_stats[criteres.serveur_faction][inumobjet][1] ) then
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.rarity > -1 ) then
						if ( tOBJET[2] and not ( tOBJET[2] >= criteres.rarity ) ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nomobjet and not ( criteres.nomobjet == "" ) ) then
						if ( tOBJET[1] ) then
							ipos, _ = strfind(strlower(tOBJET[1]),strlower(criteres.nomobjet));
							if ( not ipos ) then
								ibon = 0;
							end
						else
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmin ) then
						if ( tOBJET[3] == nil or tOBJET[3] < criteres.nivmin ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.nivmax ) then
						if ( tOBJET[3] and tOBJET[3] > criteres.nivmax ) then
							ibon = 0;
						end
					end
					if ( ibon == 1 and criteres.type > -1 ) then
						ivaleur = DBCS_objet_type_index[tOBJET[4]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[4];
						end
						if ( criteres.type == 0 ) then
							if ( DBCS_objet_type_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_type_name[ivaleur] == criteres.type ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.subtype > -1 ) then
						ivaleur = DBCS_objet_subtype_index[tOBJET[5]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[5];
						end
						if ( criteres.subtype == 0 ) then
							tablo1 = DBCS_objet_type_subtype_index[criteres.type];
							if ( tablo1 and tablo1[DBCS_objet_subtype_name[ivaleur]] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_subtype_name[ivaleur] == criteres.subtype ) then
								ibon = 0;
							end
						end
					end
					if ( ibon == 1 and criteres.equiploc > -1 ) then
						ivaleur = DBCS_objet_equiploc_index_name[tOBJET[7]];
						if ( ivaleur ) then
						else
							ivaleur = tOBJET[7];
						end
						if ( criteres.equiploc == 0 ) then
							if ( ivaleur == "" or DBCS_objet_equiploc_name[ivaleur] ) then
								ibon = 0;
							end
						else
							if not ( DBCS_objet_equiploc_name[ivaleur] == criteres.equiploc ) then
								ibon = 0;
							end
						end
					end
				else
					ibon = 0;
				end
				if ( ibon == 1 ) then
					j = j + 1 ;
					tablo[j] = {};
					tablo[j][1] = inumobjet;
				end
			end
		end
	end
	return tablo;

end

function DBCS_HDV_stats_Scroll_Update()

local i,j;
local offset = FauxScrollFrame_GetOffset(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame);
local button,buttonName;
local itemChamp;
local inumobjet;
local tablo;
local tablo1;
local r,g,b,hex;
local stimescan;
local a;

	FauxScrollFrame_Update(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame, DBCORPS_HDV_stats_LISTE_nb, 10, 32);

	itime = GetTime();
	for i = 1 , 10 do
		j = offset + i;
		buttonName = "DBcorpsFrame_HDV_stats_Frame_Liste_Button"..i;
		button = _G[buttonName];
		button:Hide();
		if ( j > DBCORPS_HDV_stats_LISTE_nb ) then
		else
			inumobjet = DBCORPS_HDV_stats_LISTE[j][1];
			tablo = {};
			if ( inumobjet ) then
				tablo = DBOS_detail(inumobjet,"0:0:0:0:0:0:0:0:0:0");
			end
			tablo1 = {};
			if ( inumobjet and DBCORPS_HDV_stats_serveur_faction and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] and DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] ) then
				tablo1 = DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet];
			end
			
			itemChamp = _G[buttonName.."_Item_IconTexture"];
			itemChamp:Hide();
			itemChamp:SetTexture("Interface/Icons/INV_Misc_QuestionMark");
			itemChamp:SetTexture(tablo.texture);
			itemChamp:Show();
			itemChamp = _G[buttonName.."_Nomobjet"];
			itemChamp:SetText(tablo.nomobjet);
			if ( tablo.rarity ) then
				r,g,b,hex = GetItemQualityColor(tablo.rarity);
				itemChamp:SetTextColor(r, g, b);
			end
			itemChamp = _G[buttonName.."_Niveau"];
			itemChamp:SetText(tablo.minlevel);
			itemChamp = _G[buttonName.."_Nivreel"];
			if ( tablo.level == nil ) then
				tablo.level = 0;
			end
			itemChamp:SetText(tablo.level);
			a, _, _, _, _, _, _, _, _, _ = GetItemInfo(inumobjet);
			if ( a ) then
				if ( DBOT_linkable ) then
					--if ( DBOT_linkable[DBCS_serveur] and DBOT_linkable[DBCS_serveur]["objets"] and DBOT_linkable[DBCS_serveur]["objets"][inumobjet] == 0 ) then
					if ( DBOT_linkable_objet_linkable(inumobjet) == true ) then
						itemChamp:SetTextColor(1,1,1);		-- blanc
					else
						itemChamp:SetTextColor(1,0.5,0);	-- orange
					end
				else
					itemChamp:SetTextColor(1,1,1);			-- blanc
				end
			else
				itemChamp:SetTextColor(1,0,0);				-- rouge
			end
			itemChamp = _G[buttonName.."_TimeScan"];
			stimescan = "";
			if ( tablo1[3] ) then
				stimescan = stimescan..tablo1[3].." ";
			end
			if ( tablo1[4] ) then
				stimescan = stimescan..strsub(tablo1[4],1,2).."h"..strsub(tablo1[4],3,4).."m"..strsub(tablo1[4],5,6).."s";
			end
			itemChamp:SetText(stimescan);
			if ( tablo1[16] and tablo1[3] and tablo1[4] and tablo1[3] == DBCS_HDV_stats_config["dernierscan"][DBCORPS_HDV_stats_serveur_faction]["date"] and tablo1[4] == DBCS_HDV_stats_config["dernierscan"][DBCORPS_HDV_stats_serveur_faction]["heure"] ) then
				if ( tablo1[16] == 5 ) then
					itemChamp:SetTextColor(1,1,1);		-- blanc
				elseif ( tablo1[16] == 1 ) then
					itemChamp:SetTextColor(1,0,0);		-- rouge
				elseif ( tablo1[16] == 2 ) then
					itemChamp:SetTextColor(1,0.5,0);	-- orange
				elseif ( tablo1[16] == 3 ) then
					itemChamp:SetTextColor(1,1,0);		-- jaune
				elseif ( tablo1[16] == 4 ) then
					itemChamp:SetTextColor(1,1,1);		-- blanc
				else
					itemChamp:SetTextColor(1,1,1);		-- blanc
				end
			else
				--itemChamp:SetTextColor(1,1,1);		-- blanc
				itemChamp:SetTextColor(1,0.5,0);	-- orange
			end
			itemChamp = _G[buttonName.."_Prix01Money"];
			if ( tablo1[1] == nil or tablo1[1] == 0 ) then
				itemChamp:Hide();
			else
				itemChamp:Show();
				DBCS_MoneyFrame_Update(itemChamp:GetName(), floor((tablo1[1]*10000)+.5));
			end
			itemChamp = _G[buttonName.."_Prix02Money"];
			if ( tablo1[2] == nil or tablo1[2] == 0 ) then
				itemChamp:Hide();
			else
				itemChamp:Show();
				DBCS_MoneyFrame_Update(itemChamp:GetName(), floor((tablo1[2]*10000)+.5));
			end
			itemChamp = _G[buttonName.."_Prix05Money"];
			if ( tablo1[11] == nil or tablo1[11] == 0 ) then
				itemChamp:Hide();
			else
				itemChamp:Show();
				--DBCS_MoneyFrame_Update(itemChamp:GetName(), floor((tablo1[7]*10000)+.5));
				DBCS_MoneyFrame_Update(itemChamp:GetName(), floor(((tablo1[11]/tablo1[12])*10000)+.5));
			end
			itemChamp = _G[buttonName.."_Prix06Money"];
			if ( tablo1[6] == nil or tablo1[6] == 0 ) then
				itemChamp:Hide();
			else
				itemChamp:Show();
				DBCS_MoneyFrame_Update(itemChamp:GetName(), floor((tablo1[6]*10000)+.5));
			end
			button:Show();
		end
	end

end

function DBcorps_ListHDV_stats_Item_OnEnter(self,index)

local inumobjet = nil;
local link = nil;
local itemName;

	GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
	if ( DBCORPS_HDV_stats_LISTE and DBCORPS_HDV_stats_LISTE[index] and DBCORPS_HDV_stats_LISTE[index][1] ) then
		inumobjet = DBCORPS_HDV_stats_LISTE[index][1];
	end
	if ( inumobjet ) then
		link = "item:"..inumobjet..":0:0:0:0:0:0:0:0:0:0";
	end
	if ( link ) then
		itemName = GetItemInfo(link);
		if ( itemName ) then
			GameTooltip:SetHyperlink(link);
		else
			DBOS_SetHyperlink(inumobjet);
		end
	end

end

function DBcorps_ListHDV_stats_Item_OnClick(self,button)

local inumobjet = nil;
local index = self:GetParent():GetID() + FauxScrollFrame_GetOffset(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame);
local itemName, itemLink;
local tablo;
local activewindow;

	if ( ChatEdit_GetActiveWindow ) then
		activewindow = ChatEdit_GetActiveWindow();
	else
		activewindow = ChatFrameEditBox;
	end

	if ( DBCORPS_HDV_stats_LISTE and DBCORPS_HDV_stats_LISTE[index] and DBCORPS_HDV_stats_LISTE[index][1] ) then
		inumobjet = DBCORPS_HDV_stats_LISTE[index][1];
	end
	if ( inumobjet ) then
		itemName, itemLink, _, _, _, _, _, _, _, _ = GetItemInfo(inumobjet);
		if ( itemName ) then
			if( button == "LeftButton" ) then
				if ( IsShiftKeyDown() and activewindow and activewindow:IsVisible() ) then
					if ( itemLink ) then
						activewindow:Insert(itemLink);
					else
						activewindow:Insert(itemName);
					end
				elseif ( IsControlKeyDown() ) then
					DressUpItemLink("item:"..inumobjet..":0:0:0:0:0:0:0:0:0:0");
				end
			elseif( button == "RightButton" ) then
			end
		else
			if ( button == "LeftButton" ) then
				if ( IsShiftKeyDown() and activewindow and activewindow:IsVisible() ) then
					tablo = DBOS_detail(inumobjet,"0:0:0:0:0:0:0:0:0:0");
					if ( tablo and tablo.nomobjet ) then
						activewindow:Insert(tablo.nomobjet);
					end
				end
			end
		end
	end

end

function DBcorps_ListHDV_stats_ModifAlerte(self,index)

local inumobjet;
local smontant;
local imontant;
local ilen;

	inumobjet = DBCORPS_HDV_stats_LISTE[index][1];

	StaticPopupDialogs["DBCS_STATICPOPUPDIALOG_MODIFALERTE"] = {
		text = "Indiquez le nouveau montant de l'alerte en pc",
		button1 = TEXT(OKAY),
		button2 = TEXT(CANCEL),
		OnShow = function(self)
			smontant = self.editBox:GetText();
			if ( smontant ) then
				ilen = strlen(smontant);
				self.editBox:HighlightText(0,ilen);
			else
			end
		end,
		OnAccept = function(self)
			smontant = self.editBox:GetText();
			if ( smontant ) then
				imontant = tonumber(smontant);
				if ( imontant ) then
					if ( inumobjet and DBCORPS_HDV_stats_serveur_faction ) then
						if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] == nil ) then
							DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] = {};
						end
						if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] == nil ) then
							DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] = {};
						end
						DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet][1] = imontant / 10000;
						DBCS_HDV_stats_Scroll_Update();
					end
				elseif ( strlen(smontant) == 0 or smontant == "" ) then
					if ( inumobjet and DBCORPS_HDV_stats_serveur_faction ) then
						if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] == nil ) then
							DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] = {};
						end
						if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] == nil ) then
							DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] = {};
						end
						DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet][1] = nil;
						DBCS_HDV_stats_Scroll_Update();
					end
				end
			else
				if ( inumobjet and DBCORPS_HDV_stats_serveur_faction ) then
					if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] == nil ) then
						DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction] = {};
					end
					if ( DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] == nil ) then
						DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet] = {};
					end
					DBCS_HDV_stats[DBCORPS_HDV_stats_serveur_faction][inumobjet][1] = nil;
					DBCS_HDV_stats_Scroll_Update();
				end
			end
		end,
		hasEditBox = 1,
		timeout = 60,
		hideOnEscape = 1
	};
	StaticPopup_Show("DBCS_STATICPOPUPDIALOG_MODIFALERTE");

end

function DBcorps_ListHDV_stats_Select(self)

local i = self:GetID();
local inumobjet;

	i = i + FauxScrollFrame_GetOffset(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame);
	inumobjet = DBCORPS_HDV_stats_LISTE[i][1];
	if ( IsControlKeyDown() and IsAltKeyDown() ) then
		DBcorps_AfficherObjet(inumobjet,"0:0:0:0:0:0:0:0:0:0");
	else
		DBcorps_ListHDV_Reset();
		DBCORPS_HDV_CRITERES_numobjet = inumobjet;
		DBcorps_ListHDV_Update();
		if ( DBCORPS_HDV_LISTE_nb > 0 ) then
			PanelTemplates_SetTab(DBcorpsFrame, 9);
			DBcorps_ShowSubFrame(9);
		else
			PlaySound("igQuestFailed");
		end
	end

end

function DBCS_HDV_afficher_Auction_HDV_stats(self)

local i = self:GetParent():GetID();
local inumobjet;
local snomobjet;
local tobjet;

	i = i + FauxScrollFrame_GetOffset(DBcorpsFrame_HDV_stats_Frame_Liste_ScrollFrame);
	inumobjet = DBCORPS_HDV_stats_LISTE[i][1];
	if ( DBOS01 and DBOS02 ) then
		tobjet = DBobjets_numobjet_tableau_lire(inumobjet);
		if ( tobjet ) then
			snomobjet = tobjet[1];
			DBCS_HDV_afficher_Auction(snomobjet);
		end
	end

end

function DBcorpsFrame_HDV_stats_OnClick()

local bvalue;

	if ( DBCS_config["informer"] == nil ) then
		DBCS_config["informer"] = {};
	end
	if ( DBCS_config["informer"]["HDV_stats"] == nil ) then
		DBCS_config["informer"]["HDV_stats"] = true;
	end
	bvalue = DBcorpsFrame_HDV_stats:GetChecked();
	if ( bvalue == nil ) then
		bvalue = 0;
	end
	if ( bvalue == 0 ) then
		DBCS_config["informer"]["HDV_stats"] = false;
		DBCS_afficher_HDV_stats = false;
	else
		DBCS_config["informer"]["HDV_stats"] = true;
		DBCS_afficher_HDV_stats = true;
	end

end
