function TrackingEvent(advertiser_id, type, cat, dc_server) {
    /*
    http://ad.fr.doubleclick.net/activity;src=856697;type=track_ac;cat=event_1;ord=[Random Number]?
    http://ad.fr.doubleclick.net/activity;src=856697;type=track_sa;cat=time_1;qty=1;cost=[Revenue];ord=[Random Number]?
    */
    this.advertiser_id = advertiser_id;
    this.type = type;
    this.cat = cat;
    this.dc_server = dc_server?dc_server+".":"";
    this.Ping = new Image();
}
    TrackingEvent.prototype.getDcUrl = function (){
        return "http://ad."+this.dc_server+"doubleclick.net";
    }
    TrackingEvent.prototype.getUrl = function (){
        /* Create the postclick tag URL and returns */
        return this.getDcUrl()+"/activity;src="+this.advertiser_id+";type="+this.type+";cat="+this.cat+";ord="+bw.getRandomNumber()+"?";
    }
    TrackingEvent.prototype.doPing = function (){
        this.Ping.src = this.getUrl();
    }

function TimeTrackingEvent(advertiser_id, type, cat, dc_server) {
    this.base = TrackingEvent;
    this.base(advertiser_id, type, cat, dc_server);
    this.event = new Timer();
}
    TimeTrackingEvent.prototype = new TrackingEvent;
    TimeTrackingEvent.prototype.getUrl = function (duration){
        /* Create the sales postclick tag URL and returns */
        if (total_time = this.event.getTime())
            return this.getDcUrl()+"/activity;src="+this.advertiser_id+";type="+this.type+";cat="+this.cat+";qty=1;cost="+total_time+";ord="+bw.getRandomNumber()+"?";
        else 
            return false;
    }

function Timer(){
}
    Timer.prototype.start = function (){
        this.start_time = new Date()
    }
    Timer.prototype.stop = function (){
        this.stop_time = new Date()
    }
    Timer.prototype.reset = function (){
        this.start_time = this.stop_time = false;
    }
    Timer.prototype.getTime = function (){
        var time_frame;
        if (this.stop_time)
            time_frame = this.stop_time.getTime() - this.start_time.getTime();
        else
            time_frame = this.now() - this.start_time.getTime();
        time_frame = time_frame/1000;
        return time_frame >= 1 ? time_frame : false;
    }
    Timer.prototype.now = function (){
        var now = new Date();
        return now.getTime();
    }


