function WebTracker()
{
    this.__construct = function() 
    {
        this.config = {
            log             : 1,
            trackUrl        : '/images/https-common/tracker.gif',
            sessionId       : 'Z',   // an optional session id
            appName         : 'WWW', // the name of the calling application
            pageName        : 'Z',   // the pageName, set from the cg variables and should match what is sent thru vs.js
            pageNameFromCgs : true,  // update the pageName sent from the current window cg variables each call
            event           : 'Z',   // the event used when not passed into send()
            eventType       : 'Z'    // the eventType used when not passed into send()
        };
        
        /**
         * Valid Events
         * @var events Object
         */ 
        this.events = {
            click   : "CLICK", 
            check   : "CHK", 
            uncheck : "UNCHK", 
            select  : "SEL", 
            type    : "TYPE", 
            start   : "STRT", 
            end     : "END", 
            display : "DSPL", 
            move    : "MOVE"
        };
        
        /** 
         * Valid Event Source Types
         * @var eventTypes Object 
         */
        this.eventTypes = {
            checkbox    : "CHKBOX", 
            radio       : "RDOBTN", 
            dropdown    : "DRPDWN", 
            textfield   : "TXTFLD", 
            chat        : "CHAT", 
            button      : "BUTTON", 
            display     : "DSPL", 
            slider      : "SLIDER", 
            calculator  : "CALC", 
            video       : "VIDEO"
        };
    }
    
    /**
     * Handles sending the GET request to the server
     *
     * @method send
     * @param string eventName The name, value, or name/value of the event.
     * @param string eventType One of the eventTypes in this.eventTypes
     * @param string event One of the events in this.events
     * @return true|false
     */
    this.send = function(vars,event,eventType)
    {
        if( typeof vars != 'object' )
            var eventName = vars
        else {
            if( typeof vars.eventName != 'undefined')
                var eventName = vars.eventName;
            if( typeof vars.userInput != 'undefned')
                var userInput = vars.userInput;
        }
        
        if( !eventType && this.eventTypes[this.config.eventType] )
            eventType = this.config.eventType;
            
        if( !event && this.events[this.config.event] )
            event = this.config.event;
            
        if( this.config.pageNameFromCgs )
            this.updatePageName();
            
        // Ensure all the proper params are set before firing the web event
        if( ! ( this.config.log && this.events[event] && this.eventTypes[eventType] ) )
        {
            alert(
                "Event Not Fired Off!\n\n" 
                + "Log: " + this.config.log 
                + "\n Page Name : " + this.config.pageName 
                + "\n Application Name : " + this.config.appName 
                + "\n Session Id : " + this.config.sessionId
                + "\n Event Name : " + eventName 
                + "\n Event Type : " + eventType 
                + "\n Event : " + event 
            );
            return false;
        } 
        
        // Create a random number to prevent caching
        var randomnumber = Math.floor( Math.random() * 100000000 );
        
        var img = document.createElement('img');
        var src = this.config.trackUrl;
        var parms = 
            {
                Log          : this.config.log, 
                pgnm         : this.config.pageName,
                appname      : this.config.appName,
                appsessionid : this.config.sessionId,
                eventtype    : this.eventTypes[eventType],
                eventname    : eventName,
                event        : this.events[event],
                rn           : randomnumber
            };
        if( typeof userInput  != 'undefined')
            parms['usrinput'] = userInput;
        var newParms = [];
        for( key in parms )
            newParms.push( key+'='+parms[key] );
        src = src + '?' + newParms.join('&');
        img.src=src;
    }
    
    /**
     * Constructs this.config.pageName from the current values of the cg variables.
     */
    this.updatePageName = function() 
    {
        this.config.pageName = window.cg1 + '_' + window.cg2 + '_' + window.cg3 + '_' + window.cg4 + '_' + window.cg5;
    }
        
    this.__construct();
}

var WebTracker = new WebTracker();
