if (typeof(kiwee) == "undefined") { kiwee = {}; }
if (typeof(kiwee.toolbar) == "undefined") { kiwee.toolbar = {}; }

kiwee.toolbar.ToolbarInfo = {
    toolbar: null,
    create: function() {
        if (this.toolbar) {
            return this.toolbar;
        }
        if (window.ActiveXObject) {
            try {
                var o = new ActiveXObject("KiweeIEToolbar.ToolbarInfo");
                if (o && typeof(o.enabled) != "undefined") {
                    this.toolbar = o;
                }
            } catch(e) { }
        }
        /*
            // This isn't working currently
        var o = document.createElement("object");
        o.setAttribute("height", "0");
        o.setAttribute("width", "0");
        o.setAttribute("classid", "clsid:6E15D3C4-C6FC-4F02-B130-77CC5B1F09DB");
        o.setAttribute("codeType", "application/x-oleobject");
        o.setAttribute("id", "KiweeToolbarInfo");
        document.body.appendChild(o);
        if (typeof(o) != "undefined" && typeof(o.enabled) != "undefined") {
            this.toolbar = o;
        }
        */
        return this.toolbar;
    },
    user_has_toolbar: function() {
        this.create();
        if (this.toolbar) {
            return (this.toolbar && typeof(this.toolbar.enabled) != "undefined");
        }
    },
    is_enabled: function() {
        this.create();
        if (this.toolbar) {
            return this.toolbar.enabled;
        }
    },
    enable: function() {
        this.create();
        if (this.toolbar) {
            this.toolbar.enabled = true;
        }
    },
    get_tbid: function() {
        this.create();
        if (this.toolbar) {
            return this.toolbar.tbid;
        }
    },
    get_version: function() {
        this.create();
        if (this.toolbar) {
            return this.toolbar.tbversion;
        }
    },
    get_search_cohort: function() {
        this.create();
        if (this.toolbar) {
            return this.toolbar.searchcohort;
        }
    },
    get_campaign: function(viral) {
        this.create();
        if (this.toolbar) {
            if (viral) {
                return this.toolbar.viralcampaign;
            } else {
                return this.toolbar.campaign;
            }
        }
    },
    get_language: function() {
        this.create();
        if (this.toolbar) {
            return this.toolbar.userlang;
        }
    },
    set_language: function(language) {
        this.create();
        if (this.toolbar) {
            this.toolbar.userlang = language;
        }
    }
}

kiwee.toolbar.create_toolbar_info = function() {
    kiwee.toolbar.ToolbarInfo.create();
}

//setEventHandler(window, "load", kiwee.toolbar.create_toolbar_info);

