// function replaceSingle - replace selected string with tag encapsled string

// variables:
// - htmlTag


function replaceSingle(htmlTag){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);

  var ReplaceString = "<"+htmlTag+">"+SelectedString+"</"+htmlTag+">";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceDouble(htmlBegin, htmlEnd){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);

  var ReplaceString = "<"+htmlBegin+">"+SelectedString+"</"+htmlEnd+">";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceEmail(){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);

  var ReplaceString = "<a href='mailto:"+SelectedString+"'>"+SelectedString+"</a>";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceHttp(httpTarget){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);

  var ReplaceString = "<a href='http://"+SelectedString+"' target='"+httpTarget+"'>"+SelectedString+"</a>";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceList(listType){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);

  var ReplaceString = "<"+listType+"><li>"+SelectedString+"</li></"+listType+">";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceFont(){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);
  
  //alert(document.form1.font.value);
  
  var ReplaceString = "<span class='"+document.form1.font.value+"'>"+SelectedString+"</span>";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceFontSize(){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);
  
  //alert(document.form1.font.value);
  
  var ReplaceString = "<font size='"+document.form1.fontsize.value+"'>"+SelectedString+"</font>";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}


function replaceFontColor(){

  var SelectedString = document.selection.createRange().text;
  //alert(SelectedString);
  
  //alert(document.form1.font.value);
  
  var ReplaceString = "<font color='"+document.form1.fontcolor.value+"'>"+SelectedString+"</font>";
  //alert(ReplaceString);
  
  document.selection.createRange().text = ReplaceString;
}

function openBrWindow(theURL,winName,features) { 
  window_to_popup=window.open(theURL,winName,features);
// get the x and y values passed in features
  window_x_pos=features.search(",");
  window_x_value=features.slice(6,window_x_pos);
  window_y_value=features.slice(window_x_pos+8,features.length);
// resize the window and give focus in case that it already existed
  window_to_popup.resizeTo(window_x_value,window_y_value);
  window_to_popup.focus();
}
