var PLATFORM = navigator.platform;

function checkEncoding()
{
  var dom = dw.getDocumentDOM();
	var metaArray = dom.getElementsByTagName("META");
	var encoding="",content="",retVal;
	var latinEncode = "iso-8859-1"
	encoding = dom.getCharSet();
 
	if (encoding != latinEncode && encoding != "utf-8")
	{
	  if (getFormNoWarnPref() == 'ASK')
		  retVal = userConfirmAdd()
	}
}

function userConfirmAdd() {
  var retVal = false;
  var cmdName = 'AlertDS.htm';
  var cmdFile = dreamweaver.getConfigurationPath() + '/Commands/' + cmdName;
  
  var cmdDOM = dreamweaver.getDocumentDOM(cmdFile);
  if (cmdDOM) {
    var cmdWin = cmdDOM.parentWindow;
    // Pass one arg for OK/Cancel, or extra args to define btns
    cmdWin.render(MM.MSG_SpecialCharNonLatinEncode, "       "+BTN_OK+"       ");
    dreamweaver.popupCommand(cmdName);
    retVal = (MMNotes.Confirm_RESULT == "       "+BTN_OK+"       "); // Reference to confirm global result.
    if (MMNotes.Confirm_DONOTSHOW) 
      setFormNoWarn('DONTASK');
  }
  return retVal;
}

function getFormNoWarnPref () {
  var noWarn, rtnValue = 'ASK';
  var path = dreamweaver.getConfigurationPath() + '/Objects/Characters/characters.js';
  var metaFile;
  metaFile = MMNotes.open(path, false);
  if (metaFile) {
    noWarn = MMNotes.get(metaFile, 'PREF_noWarning');
    if (noWarn) rtnValue = noWarn;
    MMNotes.close(metaFile);
  }
  return rtnValue;
}

function setFormNoWarn (setValue) {
  var path = dreamweaver.getConfigurationPath() + '/Objects/Characters/characters.js';
  var metaFile;

  metaFile = MMNotes.open(path, true); // Force create the note file.
  if (metaFile) {
    if (setValue) autoAdd = MMNotes.set(metaFile, 'PREF_noWarning', setValue);
    MMNotes.close(metaFile);
  }
}

