<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE widget SYSTEM "rambler.dtd"><widget xmlns:f="http://bar.yandex.ru/dev/functional" icon="icons/rambler.png" name="&rambler.name;" unique="true" xmlns="http://bar.yandex.ru/dev/gui">
    <f:setting default="5" name="update-interval" scope="widget">
        <control label="&rambler.settings.label;" label-after="&rambler.settings.label_after;" max="1000" min="0" type="textedit" value-type="int"/>
    </f:setting>
    <f:setting default="false" name="show_label" scope="widget">
        <control label="&rambler.settings.checktext;" type="checkbox"/>
    </f:setting>
    <f:variable name="update-id" scope="instance"/>
    <f:variable name="throbber-end-time" scope="instance"/>
    <f:data name="show-throbber">
        <f:not>
            <f:or>
                <f:is-empty>
                    <f:value-of name="update-id"/>
                </f:is-empty>
                <f:and>
                    <f:finished>
                        <f:value-of name="update-id"/>
                    </f:finished>
                    <f:time-arrived>
                        <f:value-of name="throbber-end-time"/>
                    </f:time-arrived>
                </f:and>
            </f:or>
        </f:not>
    </f:data>
    <f:data name="rlogin">
        <f:cookie>
            <f:value type="string">http://rambler.ru/</f:value>
            <f:value type="string">rlogin</f:value>
        </f:cookie>
    </f:data>
	<f:data name="rdomain">
        <f:cookie>
            <f:value type="string">http://rambler.ru/</f:value>
            <f:value type="string">rdomain</f:value>
        </f:cookie>
    </f:data>
	
	<f:data name="cookie">
        <f:if>
			<f:or>
                <f:is-empty>
                    <f:value-of name="rlogin"/>
                </f:is-empty>
                <f:is-empty>
                    <f:value-of name="rdomain"/>
                </f:is-empty>
            </f:or>
			<f:value type="string"/>
			<f:concat>
				<f:value-of name="rlogin"/>
				<f:value type="string">@</f:value>
				<f:value-of name="rdomain"/>
			</f:concat>
		</f:if>
    </f:data>
	
	
	
    <f:data name="rsid">
        <f:cookie>
            <f:value type="string">http://rambler.ru/</f:value>
            <f:value type="string">rsid</f:value>
            <f:value type="bool">true</f:value>
        </f:cookie>
    </f:data>
    <f:data name="export_req">
        <f:request>
            <f:param name="url">
                <f:concat>
                    <f:value type="string">http://assist.rambler.ru/script/biff.cgi?mode=if&amp;project=mail&amp;rsid=</f:value>
                    <f:value-of name="rsid"/>
                </f:concat>
            </f:param>
            <f:param name="update">
                <f:mul>
                    <f:value-of name="update-interval"/>
                    <f:value type="number">60</f:value>
                </f:mul>
            </f:param>
            <f:param name="expire">
                <f:value type="number">0</f:value>
            </f:param>
            <f:param name="hidden.login">
                <f:value-of name="cookie"/>
            </f:param>
        </f:request>
    </f:data>
    <f:data name="export">
        <f:content>
            <f:value-of name="export_req"/>
        </f:content>
    </f:data>
    <f:data name="export_error">
        <f:try>
            <f:is-empty>
                <f:value-of name="export"/>
            </f:is-empty>
            <f:param name="...">
                <f:value type="bool">true</f:value>
            </f:param>
        </f:try>
    </f:data>
    <f:data name="mail">
        <f:try>
            <f:xpath>
                <f:value type="string">/xml/project[@name="mail"]/text()</f:value>
                <f:value-of name="export"/>
            </f:xpath>
            <f:param name="...">
                <f:lastvalue/>
            </f:param>
        </f:try>
    </f:data>
    <f:data name="mail_count">
        <f:try>
            <f:regex-search>
                <f:value type="string">^\d+</f:value>
                <f:value-of name="mail"/>
            </f:regex-search>
            <f:param name="...">
                <f:lastvalue/>
            </f:param>
        </f:try>
    </f:data>
    <f:data name="is_logged">
        <f:and>
            <f:not>
                <f:is-empty>
                    <f:value-of name="rsid"/>
                </f:is-empty>
            </f:not>
            <f:not>
                <f:is-empty>
                    <f:value-of name="cookie"/>
                </f:is-empty>
            </f:not>
        </f:and>
    </f:data>
    <button>
        <url>
            <f:if>
                <f:value-of name="is_logged"/>
                <f:value type="string">&rambler.url;</f:value>
                <f:value type="string">&rambler.notlogged.url;</f:value>
            </f:if>
        </url>
        <icon>
            <f:if>
                <f:value-of name="show-throbber"/>
                <f:value type="string">xb://toolkit/images/throbber.gif</f:value>
                <f:if>
                    <f:value-of name="is_logged"/>
                    <f:value type="string">icons/rambler.png</f:value>
                    <f:value type="string">icons/ramblerlock.png</f:value>
                </f:if>
            </f:if>
        </icon>
        <text>
            <f:if>
                <f:value-of name="show_label"/>
                <f:value type="string">&rambler.button.text;&#160;</f:value>
                <f:value type="string"/>
            </f:if>
            <f:optional>
                <f:and>
                    <f:value-of name="is_logged"/>
                    <f:gt>
                        <f:value-of name="mail_count"/>
                        <f:value type="number">0</f:value>
                    </f:gt>
                </f:and>
                <style font-weight="bold">
                    <f:value-of name="mail_count"/>
                </style>
            </f:optional>
        </text>
        <f:optional>
            <f:not>
                <f:value-of name="is_logged"/>
            </f:not>
            <tooltip>
                <grid>
                    <row>
                        <cell>&rambler.tooltip.one;</cell>
                    </row>
                    <row>
                        <cell>&rambler.tooltip.two;</cell>
                    </row>
                </grid>
            </tooltip>
        </f:optional>
        <f:optional>
            <f:value-of name="is_logged"/>
            <f:optional>
                <f:not>
                    <f:value-of name="export_error"/>
                </f:not>
                <tooltip>
                    <grid>
                        <row>
                            <cell>&rambler.tooltip_good;</cell>
                        </row>
                        <row>
                            <cell>
                                <f:value-of name="cookie"/>
                            </cell>
                        </row>
                    </grid>
                </tooltip>
            </f:optional>
            <f:optional>
                <f:value-of name="export_error"/>
                <tooltip>
                    <grid>
                        <row>
                            <cell>&rambler.connect_err.one;</cell>
                        </row>
                        <row>
                            <cell>&rambler.connect_err.two;</cell>
                        </row>
                    </grid>
                </tooltip>
            </f:optional>
            <menu>
                <menuitem>
                    <text>&rambler.menu.refresh;</text>
                    <icon>icons/reload.png</icon>
                    <action>
                        <f:assign name="update-id">
                            <f:update>
                                <f:value-of name="export_req"/>
                            </f:update>
                        </f:assign>
                        <f:assign name="throbber-end-time">
                            <f:add>
                                <f:timestamp/>
                                <f:value type="number">3</f:value>
                            </f:add>
                        </f:assign>
                    </action>
                </menuitem>
                <f:optional>
                    <f:not>
                        <f:value-of name="export_error"/>
                    </f:not>
                    <separator/>
                    <menuitem>
                        <enabled>false</enabled>
                        <text>
                            <f:value-of name="cookie"/>
                        </text>
                    </menuitem>
                    <menuitem>
                        <text>&rambler.write_letter;</text>
                        <icon>icons/ramblersend.png</icon>
                        <url>&rambler.write_letter.url;</url>
                    </menuitem>
                    <menuitem>
                        <text>&rambler.read_letter;</text>
                        <url>&rambler.read_letter.url;</url>
                    </menuitem>
                    <menuitem>
                        <text>&rambler.addressbook;</text>
                        <url>&rambler.addressbook.url;</url>
                    </menuitem>
                    <separator/>
                    <menuitem>
                        <text>&rambler.yandex;</text>
                        <url>
                            <f:concat>
                                <f:value type="string">&rambler.yandex.url;</f:value>
                                <f:value-of name="cookie"/>
                            </f:concat>
                        </url>
                    </menuitem>
                </f:optional>
            </menu>
        </f:optional>
    </button>
</widget>
