<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="LVBM_StatusBarTimerTemplate" enableMouse="true" virtual="true" frameStrata="MEDIUM" hidden="true">
		<Size>
			<AbsDimension x="195" y="20"/>
		</Size>
		<Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" setAllPoints="true" tile="true">
			<EdgeSize>
				<AbsValue val="16"/>
			</EdgeSize>
			<TileSize>
				<AbsValue val="16"/>
			</TileSize>
			<BackgroundInsets>
				<AbsInset left="1" right="1" top="6" bottom="6"/>
			</BackgroundInsets>
		</Backdrop>
		<Frames>
			<StatusBar name="$parentBar" enableMouse="true">
				<Size>
					<AbsDimension x="195" y="12"/>
				</Size>
				<Anchors>
					<Anchor point="CENTER" relativePoint="CENTER"/>
				</Anchors>
				<Layers>
					<Layer level="ARTWORK">
						<FontString name="$parentText" inherits="GameFontNormalSmall" text="StatusBarTimer">
						<Size>
							<AbsDimension x="136" y="11"/>
						</Size>
							<Anchors>
								<Anchor point="CENTER">
									<Offset>
										<AbsDimension x="0" y="1"/>
									</Offset>
								</Anchor>
							</Anchors>
						</FontString>
						<FontString name="$parentTimer" inherits="GameFontNormalSmall" text="0.00">
							<Size>
								<AbsDimension x="80" y="11"/>
							</Size>
							<Anchors>
								<Anchor point="RIGHT" relativePoint="RIGHT">
									<Offset>
										<AbsDimension y="1" x="-2"/>
									</Offset>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
					<Layer level="OVERLAY">
						<Texture name="$parentSpark" file="Interface\CastingBar\UI-CastingBar-Spark" alphaMode="ADD">
							<Size>
								<AbsDimension x="32" y="32"/>
							</Size>
							<Anchors>
								<Anchor point="CENTER">
									<Offset>
										<AbsDimension x="0" y="1"/>
									</Offset>
								</Anchor>
							</Anchors>
						</Texture>
					</Layer>
					<Layer level="BACKGROUND">
						<Texture name="$parentBackground">
							<Color r="0" g="0" b="0" a="0.3" /> 
						</Texture>
					</Layer>
				</Layers>
				<BarTexture name="$parentBar" file="Interface\PaperDollInfoFrame\UI-Character-Skills-Bar"/>
				<BarColor r="1.0" g="0.7" b="0.0"/>
				<Scripts>
					<OnLoad>
						this:SetFrameLevel(this:GetFrameLevel() - 2);
					</OnLoad>
				</Scripts>
			</StatusBar>
		</Frames>
		<Scripts>
			<OnLoad>
				this.isUsed = false;
				this.usedBy = "";
				this.syncedBy = LVBM_UNKNOWN;
				this.startedBy = LVBM_UNKNOWN;
				this:SetBackdropColor(0, 0, 0, 0)
				this:SetBackdropBorderColor(0.5, 0.5, 0.5, 0.8)
			</OnLoad>
			<OnEnter>
				LVBMStatusBars_OnEnter();
			</OnEnter>
			<OnLeave>
				if GameTooltip:IsShown() and GameTooltipTextLeft1:GetText() == getglobal(this:GetName().."BarText"):GetText() then
					GameTooltip:Hide();
				end
			</OnLeave>
			<OnMouseUp>
				if arg1 == "RightButton" then
					LVBM.EndStatusBarTimer(this.usedBy, true, nil, true);
				end
			</OnMouseUp>
			<OnUpdate>
				LVBMStatusBars_OnUpdate(arg1);
			</OnUpdate>
		</Scripts>
	</Frame>
	
	<Frame name="LVBM_StatusBarTimerAnchor" parent="UIParent" frameStrata="LOW" movable="true" hidden="false">
		<Anchors>
			<Anchor point="TOP" relativeTo="UIParent" relativePoint="TOP">
				<Offset>
					<AbsDimension x="0" y="-165"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Size>
			<AbsDimension x="195" y="13"/>
		</Size>
		<Scripts>
			<OnLoad>
				this:SetUserPlaced(true);
			</OnLoad>
		</Scripts>
	</Frame>

	<Frame name="LVBM_StatusBarTimerDrag" enableMouse="true" parent="UIParent" movable="true" frameStrata="HIGH" hidden="true">
		<Size>
			<AbsDimension x="195" y="20"/>
		</Size>
		<Anchors>
			<Anchor point="CENTER" relativeTo="LVBM_StatusBarTimerAnchor" relativePoint="CENTER"/>
		</Anchors>
		<Backdrop bgFile="Interface\Tooltips\UI-Tooltip-Background" edgeFile="Interface\Tooltips\UI-Tooltip-Border" setAllPoints="true" tile="true">
			<EdgeSize>
				<AbsValue val="16"/>
			</EdgeSize>
			<TileSize>
				<AbsValue val="16"/>
			</TileSize>
			<BackgroundInsets>
				<AbsInset left="1" right="1" top="6" bottom="6"/>
			</BackgroundInsets>
		</Backdrop>
		<Frames>
			<StatusBar name="$parentBar">
				<Anchors>
					<Anchor point="CENTER" relativePoint="CENTER"/>
				</Anchors>
				<Size>
					<AbsDimension x="195" y="12"/>
				</Size>
				<Layers>
					<Layer level="ARTWORK">
						<FontString name="$parentText" inherits="GameFontNormalSmall" text="StatusBarTimer">
							<Anchors>
								<Anchor point="CENTER">
									<Offset>
										<AbsDimension x="0" y="1"/>
									</Offset>
								</Anchor>
							</Anchors>
						</FontString>
						<FontString name="$parentTimer" inherits="GameFontNormalSmall" text="0.00">
							<Size>
								<AbsDimension x="80" y="11"/>
							</Size>
							<Anchors>
								<Anchor point="RIGHT" relativePoint="RIGHT">
									<Offset>
										<AbsDimension y="1" x="-2"/>
									</Offset>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
					<Layer level="OVERLAY">
						<Texture name="$parentSpark" file="Interface\CastingBar\UI-CastingBar-Spark" alphaMode="ADD">
							<Size>
								<AbsDimension x="32" y="32"/>
							</Size>
							<Anchors>
								<Anchor point="CENTER">
									<Offset>
										<AbsDimension x="0" y="1"/>
									</Offset>
								</Anchor>
							</Anchors>
						</Texture>
					</Layer>
					<Layer level="BACKGROUND">
						<Texture name="$parentBackground">
							<Color r="0" g="0" b="0" a="0.3" /> 
						</Texture>
					</Layer>
				</Layers>
				<BarTexture name="$parentBar" file="Interface\PaperDollInfoFrame\UI-Character-Skills-Bar"/>
				<BarColor r="1.0" g="0.7" b="0.0"/>
				<Scripts>
					<OnLoad>
						this:SetFrameLevel(this:GetFrameLevel() - 2);
					</OnLoad>
				</Scripts>
			</StatusBar>
		</Frames>
		<Scripts>
			<OnLoad>
				this.isMoving = false;
				this.elapsed = 0;
				this.timer = 20;
				this:RegisterEvent("PLAYER_ENTERING_WORLD");
				getglobal(this:GetName().."Bar"):SetMinMaxValues(0, 20);
				getglobal(this:GetName().."BarText"):SetText("Drag me!");
				getglobal(this:GetName().."BarTimer"):SetText(LVBM.SecondsToTime(this.timer));
				this:SetBackdropColor(0, 0, 0, 0)
				this:SetBackdropBorderColor(0.5, 0.5, 0.5, 0.8)
			</OnLoad>
			<OnUpdate>
				this.elapsed = this.elapsed + arg1;
				if this.elapsed >= this.timer then
					this.elapsed = 0;
					this.timer = 20;
					this:Hide();
					getglobal(this:GetName().."BarTimer"):SetText(LVBM.SecondsToTime(this.timer));					
				else
					getglobal(this:GetName().."BarTimer"):SetText(LVBM.SecondsToTime(this.timer - this.elapsed));
					
					if LVBM.Options.FillUpStatusBars then
						getglobal(this:GetName().."Bar"):SetValue(this.elapsed);
					else
						getglobal(this:GetName().."Bar"):SetValue(this.timer - this.elapsed);
					end
				end				
				
				if LVBM_StatusBarTimer1:IsShown() then
					LVBM_StatusBarTimer1:SetAlpha(0);
				end
				
				local minValue, maxValue;
				minValue, maxValue = getglobal(this:GetName().."Bar"):GetMinMaxValues();				
				getglobal(this:GetName().."BarSpark"):SetPoint("CENTER", getglobal(this:GetName().."Bar"), "LEFT", ((getglobal(this:GetName().."Bar"):GetValue() / maxValue) * getglobal(this:GetName().."Bar"):GetWidth()), 0);				
			</OnUpdate>
			<OnHide>
				if this.isMoving then
					LVBM_StatusBarTimerAnchor:StopMovingOrSizing();
					this.isMoving = false;
				end
				this.elapsed = 0;
				this.timer = 20;
				getglobal(this:GetName().."BarTimer"):SetText(LVBM.SecondsToTime(this.timer));
				LVBM_StatusBarTimer1:SetAlpha(1);
			</OnHide>
			<OnEvent>
				if event == "PLAYER_ENTERING_WORLD" then
					this:SetUserPlaced(nil);
					this:ClearAllPoints();
					this:SetPoint("CENTER", "LVBM_StatusBarTimerAnchor", "CENTER");
				end
			</OnEvent>
			<OnMouseUp>
				if this.isMoving then
					LVBM_StatusBarTimerAnchor:StopMovingOrSizing();
					this.isMoving = false;
				end
				if arg1 == "RightButton" then
					this:Hide();
				end
			</OnMouseUp>			
			<OnMouseDown>
				if arg1 == "LeftButton" then
					LVBM_StatusBarTimerAnchor:StartMoving();
					this.isMoving = true;
				end
			</OnMouseDown>
		</Scripts>
	</Frame>
	<StatusBar name="LVBM_StatusBarTimer1" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="CENTER" relativeTo="LVBM_StatusBarTimerDrag" relativePoint="CENTER">
				<Offset>
					<AbsDimension x="0" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer2" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer1" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer3" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer2" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer4" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer3" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer5" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer4" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer6" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer5" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer7" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer6" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer8" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer7" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer9" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer8" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
	<StatusBar name="LVBM_StatusBarTimer10" inherits="LVBM_StatusBarTimerTemplate" parent="UIParent">
		<Anchors>
			<Anchor point="TOP" relativeTo="LVBM_StatusBarTimer9" relativePoint="BOTTOM">
				<Offset>
					<AbsDimension x="0" y="-4"/>
				</Offset>
			</Anchor>
		</Anchors>
	</StatusBar>
</Ui>