<Ui xmlns="http://www.blizzard.com/wow/ui/">

	<Script file="InboxMailBag.lua"/>
	<Texture name="Mailbag-Slot-BG" file="Interface\Buttons\UI-Slot-Background" virtual="true">
		<Size x="39" y="39"/>
		<Anchors>
			<Anchor point="TOPLEFT" x="-2" y="2"/>
		</Anchors>
		<TexCoords left="0" right="0.640625" top="0" bottom="0.640625"/>
	</Texture>
	<ItemButton name="MailbagItemButtonGenericTemplate" virtual="true">
		<Layers>
			<Layer level="OVERLAY">
				<Texture name="$parentDeleteOverlay" parentKey="deleteOverlay" setAllPoints="true" hidden="true" alphaMode="MOD">
					<Color r="1" g="0.125" b="0.125"/>
				</Texture>
			</Layer>
			<Layer level="ARTWORK" textureSubLevel="1">
				<Texture name="$parentIconBorder" parentKey="qualityOverlay" file="Interface\Common\WhiteIconFrame" hidden="true">
					<Anchors>
						<Anchor point="TOPLEFT" relativePoint="TOPLEFT" relativeKey="$parent.icon"/>
						<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOMRIGHT" relativeKey="$parent.icon"/>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				self:RegisterForClicks("LeftButtonUp", "RightButtonUp");
			</OnLoad>
			<OnClick function="InboxMailbagItem_OnClick"/>
			<OnEnter>
				InboxMailbagItem_OnEnter(self, self:GetID());
			</OnEnter>
			<OnLeave function="GameTooltip_Hide"/>
		</Scripts>
	</ItemButton>
	<Frame name="InboxMailbagFrame" parent="MailFrame" hidden="true">
		<Size x="384" y="512"/>
		<Anchors>
			<Anchor point="TOPLEFT"/>
		</Anchors>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="$parentFrameBg" file="Interface\MailFrame\UI-MailFrameBG">
					<Size x="512" y="512"/>
					<Anchors>
						<Anchor point="TOPLEFT" x="7" y="-62"/>
					</Anchors>
				</Texture>
				<FontString name="$parentTotalMessages" inherits="GameFontNormal" justifyH="LEFT" hidden="true">
					<Anchors>
						<Anchor point="TOPLEFT" x="22" y="-70"/>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Frames>
			<EditBox name="InboxMailbagFrameItemSearchBox" inherits="BagSearchBoxTemplate" letters="15">
				<Size x="130" y="20"/>
				<Anchors>
					<Anchor point="TOPRIGHT" x="-56" y="-33"/>
				</Anchors>
			</EditBox>
			<CheckButton name="InboxMailbagFrameItemGroupStacksCheckBox" inherits="UICheckButtonTemplate">
				<Size>
					<AbsDimension x="24" y="24"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="InboxMailbagFrameItemSearchBox" relativePoint="TOPLEFT" x="-142" y="1"/>
				</Anchors>
				<Scripts>
					<OnLoad>
						_G[self:GetName() .. "Text"]:SetText(MB_GROUP_STACKS);
					</OnLoad>
					<OnShow>
						self:SetChecked(ShiGuangDB["GROUP_STACKS"]);
					</OnShow>
					<OnClick>
						ShiGuangDB["GROUP_STACKS"] = self:GetChecked();
						InboxMailbag_Consolidate();
					</OnClick>
				</Scripts>
			</CheckButton>
			<ItemButton name="InboxMailbagFrameItem1" inherits="MailbagItemButtonGenericTemplate" id="1">
				<Anchors>
					<!-- <Anchor point="TOPLEFT" relativeTo="MailFrameInset" relativePoint="TOPLEFT" x="18" y="-32"/> -->
					<Anchor point="TOPLEFT" x="22" y="-90"/>
				</Anchors>
			</ItemButton>
			<!-- The other 41 items are created in InboxMailbag_OnLoad -->
			<ScrollFrame name="InboxMailbagFrameScrollFrame" inherits="FauxScrollFrameTemplate" hidden="true">
				<Size x="273" y="305"/>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="InboxMailbagFrameItem1" relativePoint="TOPLEFT" x="-4" y="1"/>
				</Anchors>
				<Layers>
					<Layer level="BACKGROUND">
						<Texture >
							<Anchors>
								<Anchor point="TOPLEFT" relativeTo="$parentScrollBar" relativePoint="TOPLEFT" x="1" y="-4"/>
								<Anchor point="BOTTOMRIGHT" relativeTo="$parentScrollBar" relativePoint="BOTTOMRIGHT" x="-1" y="4"/>
							</Anchors>
							<Color r="0" g="0" b="0" a="0.5"/>
						</Texture>
					</Layer>
				</Layers>
				<Scripts>
					<OnVerticalScroll>
						FauxScrollFrame_OnVerticalScroll(self, offset, BAGITEMS_ICON_ROW_HEIGHT, InboxMailbag_Update);
					</OnVerticalScroll>
				</Scripts>
			</ScrollFrame>
		</Frames>
		<Scripts>
			<OnLoad function="InboxMailbag_OnLoad"/>
			<OnShow function="InboxMailbag_OnShow"/>
			<OnHide function="InboxMailbag_OnHide"/>
			<OnEvent function="InboxMailbag_OnEvent"/>
		</Scripts>
	</Frame>
	<Button name="MailFrameTabInboxMailbagTemplate" inherits="FriendsFrameTabTemplate" text="MB_BAGNAME" virtual="true">
		<Scripts>
			<OnClick function="InboxMailbagTab_OnClick"/>
		</Scripts>
	</Button>
</Ui>
