
window.onerror = function(errorMsg, url, lineNumber){
  sketchup.pute("\nJavaScript error:\n"+url+" (line "+lineNumber+"): "+errorMsg);
  return true;
}

window.onblur = function (e) {
  if (typeof (sketchup) === "undefined") {
    window.location = "skp:blur";
  } else {
    sketchup.blur();
  }
}

function send_loaded_notification(event) {
   if (typeof (sketchup) === "undefined") {
      window.location.href = "skp:ready";
   } else {
      sketchup.ready();
   }
}

window.addEventListener('DOMContentLoaded', send_loaded_notification(event), false); // NB **not** 'onload'

function slider_update(val) {
   // var s = document.getElementById("txt");
   document.getElementById("txt").innerHTML = val;
   if (typeof (sketchup) === "undefined") {
      window.location.href = "skp:slider_updated@" + val;
   } else {
      sketchup.slider_updated(val);
   }
}

function checkbox_update(b) {
   if (typeof (sketchup) === "undefined") {
      window.location.href = "skp:checkbox_updated@" + b;
   } else {
      sketchup.checkbox_updated(b);
   }
}

function update_ui(val, st) {
   document.getElementById("txt").innerHTML = val;
   document.getElementById("north_angle").value = val;
   document.getElementById("shadows").checked = (st === "true" || st === true);
   // cb.setAttribute("checked", st);
}
