

CmdUtils.CreateCommand( {
	names: [ "trueknowledge"],
	arguments: [ {role: 'object', nountype: noun_arb_text, label: 'txt'} ],
        description: "asks trueknowledge",
        icon: "http://www.trueknowledge.com/favicon.ico",
        homepage: "http://spencerwaterbed.com/soft/ubiquity/trueknowledge.html",
        author: { name: "Spencer Kelly", email: "spencerwater@gmail.com"},
        license: "GPL",


	execute: function( args ){
		
		var txt = jQuery.trim( args.object.text ); 
                var url= context.focusedWindow.document.location;
                if(txt=='this'){txt=encodeURI(url);}
                txt=txt.replace(/ /g,'_');
		Utils.openUrlInBrowser( 'http://www.trueknowledge.com/q/'+txt);
		return true;
	},


 	 preview: function(pblock, args ) {

		var txt = jQuery.trim( args.object.text );
		//url = context.focusedWindow.document.location + ""; 

  		  pblock.innerHTML = _("asking '"+txt+"'...") ;
                txt=txt.replace(/ /g,'_');
var url='http://api.trueknowledge.com/direct_answer?api_account_id=api_ubiquity&api_password=fgw235p9exlif830&question='+ encodeURI(txt);


    CmdUtils.previewGet(pblock, url,
                        function (htm) {
                var answer=$(".tk_common",htm).html();
                var image=$(".tk_object_image",htm).html();
                var about=$(".tk_urs",htm).html();
                var how=$("#tk_answer_retranslation",htm).html();                 
                var thehtml=image+answer+'<p></p>'+about+'<p></p>'+how;
                          if (answer){  pblock.innerHTML = thehtml;}
                         if (!answer){pblock.innerHTML = 'don\'t know';}                         
                        });




  }
});  
