﻿                                              
function addImage(src, alt, align)
{    
    if (restorePoint)   
        restorePoint.select();        
            
    var text = editor.getSelectionHtml();
    editor.pasteHtml("<img src=" + src + " align=" + align +  " alt='" + alt + "' />");
    
    editor.set_Mode(2);
    window.setTimeout(function()
    {
    editor.set_Mode(1);
    }, 333);
    
}

function addDocument(href, text)
{   
    editor.pasteHtml("<a href=" + href + ">" + text + "</a>");
}

var restorePoint;

function addLink(href)
{        
    href = href.replace("../", "/");
        
    if (restorePoint)   
        restorePoint.select();        
            
    var text = editor.getSelectionHtml();
    
    if (text == "")
        text = href.split('/')[href.split('/').length-1];
        
    text = "<a href=" + href + ">" + text + "</a>";    
    
            
    editor.PasteHtml(text);
}


function rteClientLoad(rte_editor, args)
{ 
    editor = rte_editor;  
    
    var element = document.all ? editor.get_document().body : editor.get_document();
    
        
    Telerik.Web.DomElement.addExternalHandler(element, "mouseup", function(e)
    {
        restorePoint = editor.createRestorePoint();
                
    });  

}