'use strict';

oml.ui.updateButton = function() {

    var that = Ox.Element({
            tooltip: Ox._('Software Update')
        })
        .css({
            marginRight: '6px'
        })
        .append(
            Ox.Button({
                style: 'symbol',
                title: 'set',
                type: 'image'
            })
            .css({
                float: 'left',
                borderRadius: 0
            })
            .bindEvent({
                click: function() {
                    oml.UI.set({page: 'update'})
                }
            })
        )
        .hide();

    check();

    function check() {
        oml.api.getVersion(function(result) {
            if (result.data.version != oml.version) {
                that.show();
            } else {
                that.hide();
            }
        });
        setTimeout(check, 3600000);
    }

    return that;

};