<script type="text/javascript" language="JavaScript">
<!--//

var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var g_Flash = null;
var g_cbData = "";

function InitViolet() {
  console.log('onload');
  g_Flash = document.getElementById('LectorEditorOnline');
  //g_Flash = isInternetExplorer ? LectorEditorOnline : document.LectorEditorOnline;

  console.log(LectorEditorOnline);
}

function GetClipboardItem() {
  var cbData = window.clipboardData? window.clipboardData.getData('Text'): g_cbData;
  g_Flash.SetVariable("clipboardData", cbData);
  g_Flash.SetVariable("command", "Get Text");
}

function SetClipboardItem(args) {
  if (window.clipboardData) window.clipboardData.setData('Text', args);
  else g_cbData = args;
  g_Flash.SetVariable("command", "Set OK");
}

function SetWindowTitle(fileName) {
  if (fileName == "") document.title = "Violet Online";
  else {
    var docName = fileName.substring(0, fileName.length - 4);
    document.title = "Violet Online - " + docName;
  }
}

function SetWindowState() {
  var full = (g_Flash.width == "100%");
  g_Flash.width  = full? "800": "100%";
  g_Flash.height = full? "580": "100%";
}

// Handle all the FSCommand messages in a Flash movie.
function LectorEditorOnline_DoFSCommand(command, args) {

  switch (command) {
    case "Set Title": SetWindowTitle(args); break;
    case "Get Clipboard": GetClipboardItem(); break;
    case "Set Clipboard": SetClipboardItem(args); break;
    case "Set State": SetWindowState(); break;
    case "Quit": window.open('','_self').close(); break;
    case "trace": alert(args); break;
    case "Check License": alert('Bạn chưa đăng ký sử dụng dịch vụ!'); break;
  }
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<script language=\"VBScript\"\>\n');
  document.write('On Error Resume Next\n');
  document.write('Sub LectorEditorOnline_FSCommand(ByVal command, ByVal args)\n');
  document.write('  Call LectorEditorOnline_DoFSCommand(command, args)\n');
  document.write('End Sub\n');
  document.write('</script\>\n');
}

//-->
</script>