 # ui.R
  h.sp <- function(n) 
    pasteR("&nbsp;", n)



X <- '  <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>'

JS.example <- '
  <link rel="stylesheet" href="/resources/demos/style.css" />
  <script>
  $(function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "JaJa Binks",
      "HERE WE GO",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme",
      "New"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  });
  </script>
 
<div class="ui-widget">
  <label for="tags">Tags: </label>
  <input id="tags" />
</div>
'


JS_pre  <- "\n  <link rel=\"stylesheet\" href=\"/resources/demos/style.css\" />\n  <script>\n"
JS_post <- "\n  </script>\n \n<div class=\"ui-widget\">\n  <label for=\"tags\">Tags: </label>\n  <input id=\"tags\" />\n</div>\n"


# Then I added following function in ui.R of shiny webapp before shinyUI() is called

inputTextarea <- function(inputId, value="", nrows, ncols) {
    tagList(
#        singleton(tags$head(tags$script(src = "JS_Example.js"))),
          tags$div(class="ui-widget",
            tags$label( "WORD"),
            tags$id(id="tags")
            )
          )
}

inputTextarea2 <- function(inputId, value="", nrows, ncols) {
    tagList(
        div(class="ui-widget", # "these are some divs", label="tags", id="tags"
          HTML ('<label for="tags"> SEARCH: </label>
                                <input id="tags" />')

#          tags$label( "WORD"),
#          tags$id(id="tags")
          )
        )
}


# 
#  doc <- tags$html(
#    tags$head(
#      tags$title('My first page')
#    ),
#    tags$body(
#      h1('My first heading'),
#      p('My first paragraph, with some ',
#        strong('bold'),
#        ' text.'),
#      div(id='myDiv', class='simpleDiv',
#          'Here is a div with some attributes.')
#    )
#  )
#  cat(as.character(doc))
#  
#  ##




#  source("global.r", local=FALSE)

#  ingestAllRDS(getwd())

shinyUI(pageWithSidebar(


#  headerPanel(HTML(paste0("<H2>", h.sp(7), "xFaceBook Marketing Spend & Return</H2><H3><CENTER>(April through September 2013)</CENTER></H3>")), windowTitle="Orchard FB Marketing"),
  
  sidebarPanel(
    selectInput( inputId="dataset"
               , label="How would you like to breakdown the data?\n"
               , choices = c( Overview  = "Overview"      # "fb_agg_date"
                            , Label = "Label"      # "fb_agg_date_label"
                            , Campaign  = "Campaign"      # "fb_agg_date_campaign"
                            , Age = "Age"      # "fb_agg_date_age"
                            , Gender  = "Gender"      # "fb_agg_date_gender"
                          )
               , selected="Campaign"

      )

    , helpText("\n\n"),

    
#    checkboxGroupInput("vals", "Breakdown By:",
#                   c("Campaign" = "CampaignID",
#                     "Age" = "Age",
#                     "Gender" = "Gender")
#      ),
#    helpText("We can look at the data by any of the above categories.",
#      "\nUnSelect them all to view overall totals.",
#      "\nPro-Tip: Don't select all at once."),


    , tagList( tags$head(HTML(X)),
      HTML(paste0("<H2>", h.sp(7), "xFaceBook Marketing Spend & Return</H2><H3><CENTER>(April through September 2013)</CENTER></H3>")) )


    , submitButton(text = "Update Graph")
    , helpText("\nSelect your options then click update.\n\n")


    , helpText(pasteR("\n", 6))
    , selectInput('CID', "Get More Info On A Campaign (select ID)",C.DT[, unique(c("-", as.character(CampaignID)))] )

#, htmlOutput("JSList")
   , helpText(pasteR("\n", 6), "-------\n")
   , inputTextarea2('exampleTextarea', '')

#`   , htmlOutput("JSUI")
#   , htmlOutput(paste0( JS_pre,  htmlOutput("JSList"), JS_post))
   , helpText(pasteR("\n", 1), "-------\n\n")

 #  , helpText(HTML(paste0( JS_pre,  htmlOutput("JSList"), JS_post  )))


   ),
  mainPanel(
    htmlOutput("GVis")
  , verbatimTextOutput("InspectThese")
  , verbatimTextOutput("CInfo")
  )
))

