<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">
    <Button name="GMGenie_Tickets_StatusTemplate" virtual="true" hidden='true'>
        <Size>
            <AbsDimension x="360" y="16"/>
        </Size>
        <Layers>
            <Layer level="BORDER">
                <FontString name="$parent_ticketId" inherits="GenieFontNormalSmall" justifyH="LEFT">
                    <Size>
                        <AbsDimension x="37" y="14"/>
                    </Size>
                    <Anchors>
                        <Anchor point="TOPLEFT">
                            <Offset>
                                <AbsDimension x="3" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </FontString>
                <FontString name="$parent_name" inherits="GenieFontNormalSmall" justifyH="LEFT">
                    <Size>
                        <AbsDimension x="77" y="14"/>
                    </Size>
                    <Anchors>
                        <Anchor point="LEFT" relativeTo="$parent_ticketId" relativePoint="RIGHT">
                            <Offset>
                                <AbsDimension x="3" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </FontString>
                <FontString name="$parent_createStr" inherits="GenieFontNormalSmall" justifyH="LEFT">
                    <Size>
                        <AbsDimension x="77" y="14"/>
                    </Size>
                    <Anchors>
                        <Anchor point="LEFT" relativeTo="$parent_name" relativePoint="RIGHT">
                            <Offset>
                                <AbsDimension x="3" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </FontString>
                <FontString name="$parent_lastModifiedStr" inherits="GenieFontNormalSmall" justifyH="LEFT">
                    <Size>
                        <AbsDimension x="77" y="14"/>
                    </Size>
                    <Anchors>
                        <Anchor point="LEFT" relativeTo="$parent_createStr" relativePoint="RIGHT">
                            <Offset>
                                <AbsDimension x="3" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </FontString>
                <FontString name="$parent_assignedTo" inherits="GenieFontNormalSmall" justifyH="LEFT">
                    <Size>
                        <AbsDimension x="77" y="14"/>
                    </Size>
                    <Anchors>
                        <Anchor point="LEFT" relativeTo="$parent_lastModifiedStr" relativePoint="RIGHT">
                            <Offset>
                                <AbsDimension x="3" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </FontString>
            </Layer>
            <Layer level="BACKGROUND">
                <Texture name="$parent_Texture" alphaMode="ADD">
                    <Size>
                        <AbsDimension x="360" y="16"/>
                    </Size>
                    <Anchors>
                        <Anchor point="TOPLEFT" >
                            <Offset>
                                <AbsDimension x="0" y="0"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </Texture>
            </Layer>
        </Layers>
        <Scripts>
            <OnLoad>
                self.ticketId = 0;
            </OnLoad>
            <OnClick>
                GMGenie.Tickets.loadTicket(self.ticketId, tonumber(string.sub(self:GetName(), 19)));
            </OnClick>
        </Scripts>
        <HighlightTexture file="Interface\FriendsFrame\UI-FriendsFrame-HighlightBar" alphaMode="ADD">
            <Size>
                <AbsDimension x="360" y="16"/>
            </Size>
            <Anchors>
                <Anchor point="TOPLEFT">
                    <Offset>
                        <AbsDimension x="0" y="0"/>
                    </Offset>
                </Anchor>
            </Anchors>
        </HighlightTexture>
    </Button>

    <Button name="GMGenie_Tickets_Main" inherits="GMGenie_Window">
        <Size>
            <AbsDimension x="370" y="235"/>
        </Size>
        <Anchors>
            <Anchor point="TOPLEFT" />
        </Anchors>
        <Scripts>
            <OnLoad>
                GMGenie.loadWindow(self, 'Tickets', true, function() GMGenie.Tickets.refresh(); end);
            </OnLoad>
            <OnDoubleClick>
                self:ClearAllPoints();
                self:SetPoint("TOPLEFT");
            </OnDoubleClick>
            <OnMouseWheel>
                if arg1 == 1 then
                GMGenie.Tickets.goToPrevious();
                else
                GMGenie.Tickets.goToNext();
                end
            </OnMouseWheel>
        </Scripts>
        <Frames>
            <Button name="$parent_ticketId" inherits="GMGenie_LeftButton" text="#">
                <Size>
                    <AbsDimension x="40" y="18"/>
                </Size>
                <Anchors>
                    <Anchor point="TOPLEFT">
                        <Offset>
                            <AbsDimension x="5" y="-19"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.changeOrder("ticketId");
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_name" inherits="GMGenie_LeftButton" text="Name">
                <Size>
                    <AbsDimension x="80" y="18"/>
                </Size>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_ticketId" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.changeOrder("name");
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_create" inherits="GMGenie_LeftButton" text="Created">
                <Size>
                    <AbsDimension x="80" y="18"/>
                </Size>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_name" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.changeOrder("createStamp");
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_lastModified" inherits="GMGenie_LeftButton" text="Modified">
                <Size>
                    <AbsDimension x="80" y="18"/>
                </Size>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_create" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.changeOrder("lastModifiedStamp");
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_assignedTo" inherits="GMGenie_LeftButton" text="Assigned To">
                <Size>
                    <AbsDimension x="80" y="18"/>
                </Size>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_lastModified" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.changeOrder("assignedTo");
                    </OnClick>
                </Scripts>
            </Button>


            <Button name="TicketStatusButton1" inherits="GMGenie_Tickets_StatusTemplate" id="1">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="$parent_ticketId" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton2" inherits="GMGenie_Tickets_StatusTemplate" id="2">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton1" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton3" inherits="GMGenie_Tickets_StatusTemplate" id="3">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton2" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton4" inherits="GMGenie_Tickets_StatusTemplate" id="4">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton3" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton5" inherits="GMGenie_Tickets_StatusTemplate" id="5">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton4" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton6" inherits="GMGenie_Tickets_StatusTemplate" id="6">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton5" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton7" inherits="GMGenie_Tickets_StatusTemplate" id="7">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton6" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton8" inherits="GMGenie_Tickets_StatusTemplate" id="8">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton7" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton9" inherits="GMGenie_Tickets_StatusTemplate" id="9">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton8" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>
            <Button name="TicketStatusButton10" inherits="GMGenie_Tickets_StatusTemplate" id="10">
                <Anchors>
                    <Anchor point="TOPLEFT" relativeTo="TicketStatusButton9" relativePoint="BOTTOMLEFT" />
                </Anchors>
            </Button>

            <Button name="$parent_Next" inherits="GMGenie_NextButton">
                <Anchors>
                    <Anchor point="BOTTOMRIGHT">
                        <Offset>
                            <AbsDimension x="-2" y="1"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.goToNext();
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_Previous" inherits="GMGenie_PreviousButton">
                <Anchors>
                    <Anchor point="BOTTOMLEFT">
                        <Offset>
                            <AbsDimension x="2" y="1"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.goToPrevious();
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_Info">
                <Size>
                    <AbsDimension x="250" y="29"/>
                </Size>
                <Anchors>
                    <Anchor point="BOTTOM">
                        <Offset>
                            <AbsDimension x="0" y="9"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Layers>
                    <Layer>
                        <FontString name="$parent_Text" inherits="GenieFontNormalSmall" text="" justifyH="CENTER">
                            <Anchors>
                                <Anchor point="TOP">
                                    <Offset>
                                        <AbsDimension x="0" y="-3"/>
                                    </Offset>
                                </Anchor>
                            </Anchors>
                        </FontString>
                        <FontString name="$parent_Page" inherits="GenieFontNormalSmall" text="" justifyH="CENTER">
                            <Anchors>
                                <Anchor point="TOP" relativeTo="$parent_Text" relativePoint="BOTTOM">
                                    <Offset>
                                        <AbsDimension x="0" y="-5"/>
                                    </Offset>
                                </Anchor>
                            </Anchors>
                        </FontString>
                    </Layer>
                </Layers>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.toggleOfflineTickets();
                    </OnClick>
                </Scripts>
            </Button>
        </Frames>
    </Button>



    <Button name="GMGenie_Tickets_View" inherits="GMGenie_Window">
        <Size>
            <AbsDimension x="230" y="235"/>
        </Size>
        <Anchors>
            <Anchor point="LEFT" relativeTo="GMGenie_Tickets_Main" relativePoint="RIGHT" />
        </Anchors>
        <Scripts>
            <OnDoubleClick>
                self:ClearAllPoints();
                self:SetPoint("LEFT", GMGenie_Tickets_Main, "RIGHT");
            </OnDoubleClick>
            <OnHide>
                GMGenie.Tickets.close();
            </OnHide>
            <OnLoad>
                GMGenie.loadWindow(self, 'Loading...', false, nil);
            </OnLoad>
        </Scripts>
        <Frames>
            <Frame name="$parent_Ticket" enableMouse="true" inherits="GMGenie_Input_TextArea">
                <Size>
                    <AbsDimension x="196" y="173" />
                </Size>
                <Anchors>
                    <Anchor point="TOPLEFT">
                        <Offset>
                            <AbsDimension x="5" y="-19"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnLoad>
                        GMGenie.loadEditBox(self);
                        getglobal(self:GetName().."_Frame_Text"):SetAutoFocus(false);
                        getglobal(self:GetName().."_Frame_Text"):SetScript("OnChar", GMGenie.Tickets.showMessage);
                    </OnLoad>
                </Scripts>
            </Frame>

            <Frame name="$parent_Sync" hidden="true">
                <Anchors>
                    <Anchor point="BOTTOM">
                        <Offset>
                            <AbsDimension x="0" y="42"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Size>
                    <AbsDimension x="220" y="23"/>
                </Size>
                <Layers>
                    <Layer>
                        <FontString name="$parent_Info" inherits="GenieFontNormalSmall" text="This ticket is also being read by" justifyH="CENTER">
                            <Anchors>
                                <Anchor point="TOP" />
                            </Anchors>
                        </FontString>
                        <FontString name="$parent_Names" inherits="GenieFontNormalSmall" text="" justifyH="CENTER">
                            <Anchors>
                                <Anchor point="TOP" relativeTo="$parent_Info" relativePoint="BOTTOM" />
                            </Anchors>
                        </FontString>
                    </Layer>
                </Layers>
            </Frame>

            <EditBox name="$parent_Comment" enableMouse="true" inherits="GMGenie_Input_Text">
                <Size>
                    <AbsDimension x="165" y="18" />
                </Size>
                <Anchors>
                    <Anchor point="BOTTOMLEFT">
                        <Offset>
                            <AbsDimension x="5" y="24"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnEnterPressed>
                        GMGenie.Tickets.setComment();
                        self:ClearFocus();
                    </OnEnterPressed>
                </Scripts>
            </EditBox>
            <Button name="$parent_SetComment" inherits="GMGenie_Button" text='Comment'>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_Comment" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.setComment();
                    </OnClick>
                </Scripts>
            </Button>

            <Button name="$parent_Delete" inherits="GMGenie_Button" text='Delete'>
                <Anchors>
                    <Anchor point="BOTTOMLEFT">
                        <Offset>
                            <AbsDimension x="5" y="5"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.delete();
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_Assign" inherits="GMGenie_Button" text='Assign'>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_Delete" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnLoad>
                        self:RegisterForClicks("LeftButtonUp","RightButtonUp");
                    </OnLoad>
                    <OnClick>
                        if (button == "RightButton") then
                        GMGenie.Tickets.assign();
                        else
                        GMGenie.Tickets.assignToSelf();
                        end
                    </OnClick>
                    <OnEnter>
                        GameTooltip:SetOwner(self, "ANCHOR_NONE");
                        GameTooltip:SetPoint("BOTTOMRIGHT", "UIParent", "BOTTOMRIGHT", -CONTAINER_OFFSET_X - 13, CONTAINER_OFFSET_Y);
                        GameTooltip:AddLine("Assign ticket");
                        GameTooltip:AddLine("Left click to assign to self.");
                        GameTooltip:AddLine("Right click to assign to someone else.");
                        GameTooltip:Show();
                    </OnEnter>
                    <OnLeave>
                        GameTooltip:Hide();
                    </OnLeave>
                </Scripts>
            </Button>
            <Button name="$parent_Unassign" inherits="GMGenie_Button" text='Unassign'>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_Assign" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.unassign();
                    </OnClick>
                </Scripts>
            </Button>
            <Button name="$parent_Spy" inherits="GMGenie_Button" text='Spy'>
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_Unassign" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.toggleSpy();
                    </OnClick>
                </Scripts>
            </Button>
        </Frames>
    </Button>




    <Button name="GMGenie_Tickets_AssignPopup" inherits="GMGenie_Window">
        <Size>
            <AbsDimension x="165" y="42"/>
        </Size>
        <Anchors>
            <Anchor point="TOP" relativeTo="GMGenie_Tickets_View" relativePoint="BOTTOM" />
        </Anchors>
        <Scripts>
            <OnLoad>
                GMGenie.loadWindow(self, 'Assign To', false, nil);
                getglobal(self:GetName().."_Title_Text"):SetText("Assign To");
            </OnLoad>
            <OnDoubleClick>
                self:ClearAllPoints();
                self:SetPoint("TOP", GMGenie_Tickets_View, "BOTTOM");
            </OnDoubleClick>
        </Scripts>
        <Frames>
            <EditBox name="$parent_GMName" enableMouse="true" inherits="GMGenie_Input_Text">
                <Size>
                    <AbsDimension x="100" y="18" />
                </Size>
                <Anchors>
                    <Anchor point="TOPLEFT">
                        <Offset>
                            <AbsDimension x="5" y="-19"/>
                        </Offset>
                    </Anchor>
                </Anchors>
                <Scripts>
                    <OnEnterPressed>
                        GMGenie.Tickets.assignTo();
                    </OnEnterPressed>
                </Scripts>
            </EditBox>
            <Button name="$parent_Send" inherits="GMGenie_Button" text="Assign">
                <Anchors>
                    <Anchor point="LEFT" relativeTo="$parent_GMName" relativePoint="RIGHT" />
                </Anchors>
                <Scripts>
                    <OnClick>
                        GMGenie.Tickets.assignTo();
                    </OnClick>
                </Scripts>
            </Button>
        </Frames>
    </Button>
</Ui>