﻿function OnClientModeChange(editor)     
{     
   var mode = editor.get_mode();     
   var doc = editor.get_document();                          
   var head = doc.getElementsByTagName("HEAD")[0];     
   var link;     
        
   switch (mode)     
   {     
      case 1: //remove the external stylesheet when displaying the content in Design mode     
        var external = doc.getElementById("external");     
        head.removeChild(external);     
        break;     
      case 2:     
          break;     
      case 4: //apply your external css stylesheet to Preview mode     
        link = doc.createElement("LINK");     
        link.setAttribute("href", "/Style Library/AMD_Devcentral_v2.css");     
        link.setAttribute("rel", "stylesheet");     
        link.setAttribute("type", "text/css");     
        link.setAttribute("id", "external");     
        head.appendChild(link);     
        break;     
  }     
} 

