var selectionExists = false;

// resize editor depending on actual input
// copied from Telerik documentation

function resizeContentArea(editor)
{
    if (editor.InitialHeight == -1)
    {
        editor.InitialHeight = editor.Document.body.clientHeight;
    }
    var targetHeight = editor.Document.body.scrollHeight;
    if ( targetHeight > editor.InitialHeight )
    {
        var theIFrame = document.getElementById("RadEContentIframe" + editor.Id);
        theIFrame.style.height = parseInt(targetHeight) + "px";
    }
}

function attachResizeEvents(editor)
{
    editor.InitialHeight = -1;
    editor.GetContentArea().style.overflow = "hidden";
    editor.Document.body.scroll = "no";
    var resizeFnRef = function anon(){resizeContentArea(editor)};
    editor.AttachEventHandler("RADEVENT_SEL_CHANGED", resizeFnRef)
    editor.AttachEventHandler("keydown", resizeFnRef)
}


// hash table with alternative font names
oAlternativeFonts = Object();

// Callback when selected a font in the editor,
// checks if an alternative font should be set
function OnClientCommandExecuting(editor, commandName, oTool)
{
	if (( oTool != null ) && ( commandName == "FontName" ))
	{
		if (( oTool.SelectedValue != null ) &&
		    ( oAlternativeFonts[oTool.SelectedValue] != null ))
		{
			var strSelectedFont = oTool.SelectedValue;
			strSelectedFont = strSelectedFont + "," + oAlternativeFonts[oTool.SelectedValue];
			oTool.SelectedValue = strSelectedFont;
		}
	}
}
// Callback for fixing addtional linebreak <br />
function OnClientCommandExecuted(editor, commandName, oTool)
{
}


// set an alternative font
function SetAlternativeFont(strOrgFontName, strAltFontName)
{
	oAlternativeFonts[strOrgFontName] = strAltFontName;
}
