YAHOO.namespace("sputnik");
YAHOO.sputnik.explainer = function() {

    // helpers
	this.dom = YAHOO.util.Dom;
	this.sel = YAHOO.util.Selector;
	this.eve = YAHOO.util.Event;

    // the explainer element
    this.exp = this.sel.query(".explainer", null, true);
    if(this.exp == null) {
        this.exp = document.createElement('div');
        this.dom.addClass(this.exp, 'explainer');
        this.exp.innerHTML = '<div class="inner"><h3 class="hd"></h3><p class="bd"></p></div>';
        this.sel.query("body", null, true).appendChild(this.exp);
    }

    // classes this instance of explainer should have
    this.classes = ["explainer"];

    // x y coords
    this.x = 0;
    this.y = 0;

    // set the extra class
    this.setClass = function(classname) {
        if(classname == null) {
            this.classes = ["explainer"];
        }else{
            this.classes = ["explainer", classname];
        }
    }

    // set coordinates
    this.setXY = function(x, y) {
        this.x = x;
        this.y = y;
    }

    // header content
    this.setHeader = function(header) {
        this.sel.query("h3.hd", this.exp, true).innerHTML = header;
    }

    // body content
    this.setBody = function(body) {
        this.sel.query("p.bd", this.exp, true).innerHTML = body;
    }

    // hide the bastard
    this.hide = function() {
        this.dom.setStyle(this.exp, 'visibility', 'hidden');
        this.dom.setStyle(this.exp, 'display', 'none');
    }

    // show it to the world
    this.show = function() {
        exp = this.exp;
        this.exp.className = "";
        for(i in this.classes) this.dom.addClass(this.exp, this.classes[i]);
        this.dom.setStyle(this.exp, 'display', 'block');
        this.dom.setX(this.exp, this.x);
        this.dom.setY(this.exp, this.y);
        window.setTimeout(function() {
            YAHOO.util.Dom.setStyle(exp, 'visibility', 'visible');
        }, 400);
    }

}
