var enccookiename = "kmencoding";

function setencoding (targetvalue) {
  if (location.href.indexOf('cms') != -1) {
    alert("Can not switch inside the CMS.");
    return false;
  }
  document.cookie = enccookiename + "=" + escape(targetvalue) + ";path=/"; 
  location.reload(true);
  return false;
}

function setunicode () {
  return setencoding("unicode");
}

function setlimon () {
  return setencoding("limon");
}

function printswitch () {
  if(document.cookie.indexOf(enccookiename+'=limon') == -1) {
    document.write('<a href="javascript://" onclick="setlimon();">Khmer Limon</a>');
  } else {
    document.write('<a href="javascript://" onclick="setunicode();">Khmer Unicode</a>');
  }
  return true;
}


if(((location.href.indexOf('khmer.cambodia.usembassy.gov') != -1)||(location.href.indexOf('staging') != -1))&&(document.cookie.indexOf(enccookiename) == -1)&&(navigator.userAgent.indexOf('Windows') != -1)) {
  if (navigator.userAgent.indexOf('Windows NT 6') == -1) {
    setlimon();
  }
}
