/**
 * Called by the bt_mini and bt_full swf objects
 * for web events tracking
 */
var Rewards_Widget_Tracking = function() {

    this.unloadEventAttached = false;
    this.hits=0;
    
    this.values = {min:null,max:null,last:null};
    
    this.setValue = function(value) {
        if( this.hits==0 ) {
            this.hits++;
            return;
        }
        
        this.values.last = value;

        if( this.values.last > this.values.max || this.values.max === null )
            this.values.max = this.values.last;
        if( this.values.last < this.values.min || this.values.min === null )
            this.values.min = this.values.last;
            
        this.attachUnloadEvent();
    }
    
    this.attachUnloadEvent = function()
    {
        if( ! this.unloadEventAttached )
        {
            var here = this;
            $(window).unload(function(){here.unloadEvent()});
            this.unloadEventAttached = true;
        }
    }
    
    this.unloadEvent = function()
    {
        if( this.values.max ) 
            WebTracker.send('RewardsWidget:max='+this.values.max+':min='+this.values.min+':last='+this.values.last,'end','slider');
    }
    
}

var Rewards_Widget_Tracking = new Rewards_Widget_Tracking();
