/*  
 * $Id: QvSparkline.js,v 1.1 2006-09-18 11:00:02 jdeken Exp $       
 */
var QvSparkline = {
/*
 */
_sparklinePopin:null, 
_originalColor: null,
_lastSelection: null,
/*
 */
onClick: function(id) {
   this._showPopin(id);
},

/*
 */
_showPopin: function(id){
    this._hidePopin();
    var popinId = id + "_popin";
    this._sparklinePopin = $(popinId);
    Element.Methods.show(this._sparklinePopin);
    // Timeout
    setTimeout((function() {this._hidePopin();}).bind(this),5 * 1000);
}, 
/*
 */
_hidePopin: function() {
    if (this._sparklinePopin != null) {
        Element.Methods.hide(this._sparklinePopin);
    }
},

/*
 */
onMouseOver:function(id) {
    var o = document.getElementById(id);

    if(this._lastSelection != null)
    {
        this.onMouseOut(this._lastSelection);
    }
    if(o != null && o.style.backgroundColor != null) {
        var rgbColor = new RGBColor(o.style.backgroundColor);
        this._originalColor = rgbColor.toRGB();
        o.style.backgroundColor = this._highlightColor(rgbColor);
        this._lastSelection = id;
        var dim = Element.Methods.getDimensions(o);
        o.style.width = (dim.width + 5)  + "px;";
       // o.style.height = (dim.height + 5)  + "px;";
    }
    
    var content = $(id + "_hidden_text").innerHTML;
    if(content != null)
    {
        Element.Methods.update("qv_sparkline_current_text", content);
    }
    //this._showPopin(id);
},
/* 
 */
onMouseOut:function(id) {
    var o = document.getElementById(id);

    if(o != null && o.style.backgroundColor != null && this._originalColor != null) {
        o.style.backgroundColor = this._originalColor;
        var dim = Element.Methods.getDimensions(o);
        o.style.width = (dim.width - 5) + "px;";
      //  o.style.height = (dim.height - 5) + "px;";
    }
    Element.Methods.update("qv_sparkline_current_text", "");

},
/*
 */
_highlightColor:function(rgbColor) {
    rgbColor.reverse();
    //rgbColor.brighter();
    var newColor = rgbColor.toRGB();
    return newColor;
}
  
};


