function mBold(from_user){
	var magic_t = ae$('magic_text');
	magic_t.value += '[B]'+from_user+'[/B]';
	magic_t.focus();
	setCaretToEnd(magic_t);
	return;
}

function mLink1(from_user){
	var magic_t = ae$('magic_text');
	magic_t.value += '[URL='+from_user+']';
	ae_prompt(mLink2,"Enter text to display for link", "");
	return;
}

function mLink2(from_user){
	var magic_t = ae$('magic_text');
	magic_t.value += from_user+'[/URL]';
	magic_t.focus();
	setCaretToEnd(magic_t);
	return;
}

function mHeadline(from_user){
	var magic_t = ae$('magic_text');
	magic_t.value += '[H]'+from_user+'[/H]';
	magic_t.focus();
	setCaretToEnd(magic_t);
	return;
}

function mItalic(from_user){
	var magic_t = ae$('magic_text');
	magic_t.value += '[I]'+from_user+'[/I]';
	magic_t.focus();
	setCaretToEnd(magic_t);
	return;
}


function headlineIt(){
	ae_prompt(mHeadline,"Enter headline text", '');
	return;
}

function italicIt(){
	ae_prompt(mItalic,"Enter text to italicize", '');
	return;
}

function boldIt(){
	ae_prompt(mBold,"Enter text to bold", '');
	return;
}

function linkIt(){
	ae_prompt(mLink1,"Enter link address", 'http://');
	return;
}

 function setCaretToEnd (control) {
  if (control.createTextRange) {
    var range = control.createTextRange();
    range.collapse(false);
    range.select();
  }
  else if (control.setSelectionRange) {
    control.focus();
    var length = control.value.length;
    control.setSelectionRange(length, length);
  }
}
	
// Prompt function to get around IE security "feature:
// This is variable for storing callback function
var ae_cb = null;
 
// this is a simple function-shortcut
// to avoid using lengthy document.getElementById
function ae$(a) { return document.getElementById(a); }
 
// This is a main ae_prompt function
// it saves function callback 
// and sets up dialog
function ae_prompt(cb, q, a) {
	ae_cb = cb;
	ae$('aep_t').innerHTML = document.domain + ' question:';
	ae$('aep_prompt').innerHTML = q;
	ae$('aep_text').value = a;
	ae$('aep_ovrl').style.display = ae$('aep_ww').style.display = '';
	ae$('aep_text').focus();
	ae$('aep_text').select();
}
 
// This function is called when user presses OK(m=0) or Cancel(m=1) button
// in the dialog. You should not call this function directly.
function ae_clk(m) {
	// hide dialog layers 
	ae$('aep_ovrl').style.display = ae$('aep_ww').style.display = 'none';
	if (!m)  
		ae_cb(null);  // user pressed cancel, call callback with null
	else
		ae_cb(ae$('aep_text').value); // user pressed OK 
}