
function DeleteMessage( confirmationText )
{
  returnValue = confirm( confirmationText ) ;
  
  return returnValue ;
}


function CloseDialog()
{
  if( opener != null )
  {
    // Force postback on owner page.
    opener.document.forms[ 0 ].submit() ;
  }
  window.close() ;
}

function ValidateMessageBody(source, arguments)
{
  var editor = GetEditor(source.controltovalidate);
  if(editor != null && editor.GetHtml(false).length == 0) {
    arguments.IsValid=false  
  }
}

function GetEditor(controlId)
{
  if (typeof(GetRadEditor)=="function") {
    return GetRadEditor(controlId);
  }
        
  return null;
}

function InsertLink(commandName, editor, tool) {   
  var html = editor.GetSelectionHtml();
  var url = "http://";
  
  // get url from the selection
  if(html.length > 0) {
    var regex = /href=["'](.*)["']/;
    var match = regex.exec(html);
    if (match && match.length >=1 && match[1]) {
      url = match[1];
    }    
  }
  
  if(typeof(enterUrlText) == "undefined") {
    enterUrlText = "Enter a URL:";
  }
  
  url = prompt(enterUrlText, url);
  editor.PasteHtml("<a target='blank' href='" + url + "'>" + editor.GetSelectionHtml() + "</a>");
}

