<Ui xmlns="http://www.blizzard.com/wow/ui/" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd">
	<Frame name="StatRingsEnemyHealth" parent="WorldFrame" inherits="StatRingsRingTemplate">
		<Size>
			<AbsDimension x="200" y="200"/>
		</Size>
		<Anchors>
			<Anchor point="CENTER" relativeTo="StatRingsAnchor">
				<Offset>
					<AbsDimension x="0" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				StatRings_RegisterRing(this, "Enemy Health");
      			StatRingsRingTemplate_OnLoad();
      			
				this:SetAlpha(0.1);
        		
				this:RegisterEvent("PLAYER_ENTERING_WORLD");
				this:RegisterEvent("UNIT_HEALTH");
				this:RegisterEvent("UNIT_MAXHEALTH");
				this:RegisterEvent("PLAYER_TARGET_CHANGED");
    			
				this:UpdateColor({["r"] = 0.3, ["g"] = 0.4, ["b"] = 1});
				this:SetMax(100);
				this:SetValue(UnitHealth("target"));

				function this:UpdateAlpha()
					if this.startValue &lt; this.maxValue then
						StatRingsTest_SetAlpha(self, 0.6);
					elseif this.startValue == this.maxValue then
						StatRingsTest_SetAlpha(self, 0.05);
					end
				end
				this:AddUpdateFunction(this:UpdateAlpha);
			</OnLoad>
			<OnEvent>
				if (event == "PLAYER_ENTERING_WORLD") then
					this:UpdateColor({["r"] = 0.3, ["g"] = 0.4, ["b"] = 1});
					this:SetValue(UnitHealth("target"));
					return;
				elseif event == "PLAYER_TARGET_CHANGED" then
					if UnitCanAttack("player","target") then
						local x = (UnitLevel("target")>0) and UnitLevel("target") or 99;
						color = GetDifficultyColor(x);
						this:UpdateColor(color);
					elseif not UnitCanAttack("player", "target") and UnitExists("target") then
						this:UpdateColor({["r"] = 0.3, ["g"] = 0.4, ["b"] = 1});
					end
					StatRingsTest_SetAlpha(this, 0.6, 1);					
					this.alphaState = -1;
					this:SetMax(UnitHealthMax("target"));
					this:SetValue(UnitHealth("target"));
				elseif (event == "UNIT_MAXHEALTH" and arg1 == "target") then
					this:SetMax(UnitHealthMax("target"));
				elseif (event == "UNIT_HEALTH" and arg1 == "target") then
					this:SetValue(UnitHealth("target"));
				end
			</OnEvent>
		</Scripts>
	</Frame>
</Ui>