function PartyLoot_OnEvent()
	if (event == "VARIABLES_LOADED" or event == "PLAYER_ENTERING_WORLD" or event == "PARTY_MEMBERS_CHANGED" or event == "PARTY_LOOT_METHOD_CHANGED") then
		PartyLoot_UpdateUI();
		return;
	end
end

function PartyLoot_OnLoad()
   	this:RegisterEvent("VARIABLES_LOADED")
	this:RegisterEvent("PLAYER_ENTERING_WORLD")
	this:RegisterEvent("PARTY_MEMBERS_CHANGED");
	this:RegisterEvent("PARTY_LOOT_METHOD_CHANGED");    
   
	PartyLootFrame:SetBackdropBorderColor(0, 0, 0, 0);
	PartyLootFrame:SetBackdropColor(0.15, 0.15, 0.15, 0);
   
	PartyLoot_UpdateUI();
end

function PartyLoot_UpdateUI()
	if (GetPartyMember(1)) then    
		PartyLootFrame:Show();
		local LootMethod = UnitLootMethod[GetLootMethod()];
		PartyLoot_LootMethod:SetText(LootMethod.text);
	        local color = ITEM_QUALITY_COLORS[GetLootThreshold()];
		PartyLoot_LootMethod:SetVertexColor(color.r, color.g, color.b);
	else
		PartyLootFrame:Hide();
	end
end

function PartyLoot_OnMouseDown(button)
	if (button == "LeftButton") then
		PartyLootFrame:StartMoving();
	end
end

function PartyLoot_OnMouseUp(button)
	if (button == "LeftButton") then
		PartyLootFrame:StopMovingOrSizing();
	end
end

function PartyLoot_PositionReset()
	PartyLootFrame:ClearAllPoints();
	PartyLootFrame:SetPoint("TOPLEFT", "UIParent", "TOPLEFT", 0, -100);
end