/* SYSTEM/BROWSER FONT DETECTOR */
function testFont(name) {
  name = name.replace(/['"<>]/g,'');
  var body  = document.body,
  test  = document.createElement('div'),
  installed = false,
  template =
    '<b style="display:inline !important; width:auto !important; font:normal 10px/1 \'X\',sans-serif !important">ii</b>'+
    '<b style="display:inline !important; width:auto !important; font:normal 10px/1 \'X\',monospace !important">ii</b>',
  ab;

  if (name) {
    test.innerHTML = template.replace(/X/g, name);
    test.style.cssText = 'position: absolute; visibility: hidden; display: block !important';
    body.insertBefore(test, body.firstChild);
    ab = test.getElementsByTagName('b');
    installed = ab[0].offsetWidth === ab[1].offsetWidth;
    body.removeChild(test);
  }
  return installed;
}

$('document').ready(function() {
  var hasSegoe;
  var testSegoeUI = testFont('Segoe UI');
  var testSegoeUILight = testFont('Segoe UI Light');
  if (testSegoeUI === false || testSegoeUILight === false) {
    hasSegoe = 'no';
  } else {
    hasSegoe = 'yes';
  }
  $.ajax({
    type: "POST",
    url: "/logic/setFonts.php",
    data: "hasSegoe="+hasSegoe
  });
});
