action_download: function ( e ) {
                e.preventDefault();
                e.stopPropagation();

                var me = $(e.currentTarget)
                    //availability = _bt.calculateHealth( _bt.getScrapedAvailability( this.model.get('scraped') ) ),
                    url = e.currentTarget.href,
                    downloading = $(e.currentTarget).hasClass('downloading');

                console.error('DOWNLOAD RESULT check');

                //copy it to the clipboard
                if ( ( this.app._metaKey_down || this.app._ctrlKey_down ) && this.app._shiftKey_down ) {
                    this.app.copy( url );

                    //bench it
                    _bt.track( 
                        'search',
                        'result',
                        'clip',
                        //values sent:
                        // -2 for click on link that is already downloading
                        // -1 for no availability information
                        // 0 ... n for availability 
                        0
                    );

                    return;
                }

                this.model.set({ 'downloaded': true })

                if( !downloading ){
                    var $title = this.$el.children('.title'),
                        name = $title.text();

                    this.show_as_downloading();

                    this.app.collections.torrents.add_by_url( url, name );
                }

                _bt.track( 
                    'search', 
                    'result', 
                    'download', 
                    //values sent:
                    // -2 for click on link that is already downloading
                    // -1 for no availability information
                    // 0 ... n for availability 
                    ( downloading ? -2 : 0 ) 
                );
            },
 on_search_keypress: function (e){
     //console.log('search keypress', e.which, e);
     if( e.which === 13 ) {
         //interaction statistics
         _bt.track( 'toolbar', 'submit', 'keypress', ( !this.app._shiftKey_down ? 0 : 1 ) ); //track whether it was a cached query or not
         this.submit_search( !this.app._shiftKey_down );  //holding shift ignores cached results and re-performs the search
     }
 },
            clear_history: function ( e ) {
                e.preventDefault();

                this.collection.observer.trigger('clear');
                
                //interaction statistics
                _bt.track( 'toolbar', 'history', 'clear', null );

            },
            remove: function ( delete_data ) {
                //interaction statistics
                _bt.track( 
                    'torrent', 
                    'remove',
                    //label complete or incomplete
                    ( this.get('properties').completed_on ? 'complete' : 'incomplete' ),
                    //value is time since torrent added
                    null
                );

                this.collection.observer.trigger('torrent:remove', this.id, delete_data );                
            }
            submit_search: function( cached ){
                var query = $('#search_text').val();

                console.error('submit search', cached);

                if( this.is_download_link( query ) ) {
                    _bt.track( 'toolbar', 'attempt-add-torrent', null, null );      
                    this.app.collections.torrents.add_by_url( query );
                    $('#search_text').val('').trigger('input');
                    this.app.trigger('query:url', false );
                    return;
                } else if ( this.is_potential_command( query ) ) {
                    var command = this.get_command( query );
                    if ( this.is_command( command ) ) {
                        _bt.track( 'toolbar', 'command', command, null );
                    }
                    $('#search_text').val('').trigger('input');
                    this.app.trigger('command', command );            
                    return;
                }


                //this.app.collections.search._last_query = query;

                this.collection.search( query, cached );


                //this.app.views.search.clear()

                // Bt.msg.send( Bt.events.SEARCH_SITES, {
                //     query: query,
                //     cached: cached
                // }, 'ext');

                //this.app.collections.search.start_search_timer();
            },
            pause: function () {
                //interaction statistics
                _bt.track( 
                    'torrent', 
                    'pause',
                    //label complete or incomplete
                    ( this.get('properties').completed_on ? 'complete' : 'incomplete' ),
                    //value is time since torrent added
                    null
                );  

                this.collection.observer.trigger( 'torrent:pause', this.id );
                this.get('properties').status = 233;
                this.trigger('change');                
            },
            start: function () {
                //interaction statistics
                _bt.track( 
                    'torrent', 
                    'start',
                    //label complete or incomplete
                    ( this.get('properties').completed_on ? 'complete' : 'incomplete' ),
                    //value is time since torrent added
                    null
                );

                this.collection.observer.trigger( 'torrent:start', this.id );
                //Bt.msg.send( Bt.events.START_TORRENT, this.model.id );
                this.get('properties').status = 201;
                this.trigger('change');
            },
			remove_site: function ( e ) {
		        var me = $(e.currentTarget),
		        	site = me.closest('.site'),
		        	sites = site.parent(),
		        	id = site.data('id');

		        console.error('REMOVE SITE', id);

		        //decline the site in the collection.  communicates with ext
		        //arg[0] is id to disable
		        this.collection.disable( id );

		        //remove from the list
		        site.remove();

		        //make sure there are still some sites left
		        var remaining = sites.children('.site').length;

		        _bt.track( 'dialog', 'disable_site', this.id, remaining );

		        if ( !remaining ) {
		            this.close();
		        }
			},
		    do_command: function ( command, options ) {

		        //check for btfc-taxonomy query first
		        var btfc_query;
		        if ( command.indexOf('surf:BTFC-') === 0 ) {
		            btfc_query = command.replace('surf:BTFC-', '');
		            command = 'surf:BTFC-';
		        }

		        var opts = this.commands[ command ] || this.commands[ 'surf' ];
		        //if the command is not recognized, bring up that table of commands

		        if ( this.do_command_timeout ) {
		            clearTimeout( this.do_command_timeout );
		        }

		        console.log('do command', command, opts, this);


		        if ( opts && opts.url ) {
		            this.views.dialogs.get('remote_asset').load( opts );
		            this.views.dialogs.open('remote_asset');
		        } else {

		            switch ( command ) {

		                case 'surf:engines' :
		                    console.error('do surf:engines command!', command, opts, options );
		                    this.views.dialogs.open('engines');
		                    break;

		                case 'surf:reset' :
		                    _bt.track( 'search', 'history', 'clear', null );
		                    this.observer.trigger('reset');
		                    break;

		                case 'surf:BTFC-' :
		                    console.error('BTFC COMMAND', btfc_query );

		                    _bt.track('recommendation', 'genre_query', btfc_query, null )

		                    //args are: 1) query, 2) cached, 3) btfc_adv
		                    this.collections.search.search( btfc_query, false, true );
		                    // Bt.msg.send( Bt.events.SEARCH_SITES, {
		                    //     query: btfc_query,
		                    //     cached: false,
		                    //     //bittorrent featured content advanced search
		                    //     btfc_adv: true //sets up special search of only bittorrent featured content
		                    // }, 'ext');

		                    break;

		                case 'surf:associate' :
		                    this.views.dialogs.open('association');
		                	break;

		                default :
		                    console.error('something went wrong in do_command', command, opts, command.indexOf('surf:BTCF-'));
		            }
		        }

		        if ( options && options.hide && options.hide > -1 ) {
		            console.error('set up the timeout to hide the dialog');

		            this.do_command_timeout = setTimeout( _.bind( function(){
		                if ( this.views.dialogs.is_onboarding === command ) {
		                    this.views.dialogs.close();
		                }
		            }, this ), options.hide );
		        }
		    },
 toggle_expandable: function ( e ) {
     e.preventDefault()
     _bt.track( 'search', 'result', ( this.$el.hasClass('open') ? 'collapse' : 'expand' ), null );
 },
 on_link_click: function () {
     _bt.track( 'search', 'result', 'open_link', ( this.app.views.app._metaKey_down || this.app.views.app._ctrlKey_down ? 1 : 0 ) );
 },
            on_search_submit: function(e){
                this.submit_search( false );

                _bt.track( 'toolbar', 'submit', 'button', false ); //tracks whether searching for query included looking in the cache.  when hitting the button, that is always false
            },