CmdUtils.CreateCommand({
  name: "bk",
  description: "Bookmarks the current site using Google Bookmarks",
  help: "Opens up a dialog box to bookmark the current page in Google Bookmarks.  Takes tags as parameters.",
  takes: {"tags": noun_arb_text},
  execute: function(tags) {
    var document = context.focusedWindow.document;
    var a=window;
    var b=document;
    var c=encodeURIComponent;
    var d=a.open(
        "http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=" + c(b.location)
        +"&title=" + c(b.title)
        +"&labels=" + c(tags.text),
        "bkmk_popup",
        "left="+((a.screenX||a.screenLeft)+10)
        +",top="+((a.screenY||a.screenTop)+10)
        +",height=420px,width=550px,resizable=1,alwaysRaised=1");
   }
});

CmdUtils.CreateCommand({
    name: "search-bk",
    description: "Searches your Google Bookmarks",
    help: "Searches your Google Bookmarks with the provided search terms.",
    takes: {"search terms": noun_arb_text},
    execute: function(terms) {
        var doc =  Application.activeWindow.activeTab.document;
        var en=encodeURIComponent;
        var urlTerms = en(terms.text).replace(/%20/g, "+");
        // TODO handle selections
        doc.location.href = "http://www.google.com/bookmarks/find?q=" + urlTerms;
   }
});


