function injectScript(file, node) {
    var th = document.getElementsByTagName(node)[0];
    var s = document.createElement('script');
    s.setAttribute('type', 'text/javascript');
    s.setAttribute('src', file);
    th.appendChild(s);
}
function injectStyle(file, node) {
    var th = document.getElementsByTagName(node)[0];
    var s = document.createElement('link');
    s.setAttribute('type', 'text/css');
    s.setAttribute('href', file);
    s.setAttribute('rel', "stylesheet");
    th.appendChild(s);
}

injectScript(chrome.extension.getURL("js/page-scripts.js"), "body");
injectStyle(chrome.extension.getURL("css/page-styles.css"), "body");
injectStyle("https://fonts.googleapis.com/css?family=Oxygen:400,700,300", "body");

chrome.storage.sync.get("backImgTog", function(storage) {
  if (storage.backImgTog == undefined || !storage.backImgTog) {
    $.get("https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US", function(response) {
      var url = "https://www.bing.com" + response.images[0].url;
      $(window).trigger('resize');
      $("#authenticate").css("background-image", "url(" + url + ")");
    });
  }
});

$(document).ready(function() {
  $("form[name=authenticate] fieldset input[type=submit]").val("Login");
  console.log("SchedulesPlus Ready!");
});