function selOn(ctrl)
{
	ctrl.style.borderColor = '#000000';
  ctrl.style.backgroundColor = '#B5BED6';
  ctrl.style.cursor = 'hand';
}

function selOff(ctrl)
{
  ctrl.style.borderColor = 'rgb(238, 239, 243)';
  ctrl.style.backgroundColor = 'rgb(238, 239, 243)';
}

function selDown(ctrl)
{
  ctrl.style.backgroundColor = '#8492B5';
}

function selUp(ctrl)
{
  ctrl.style.backgroundColor = 'rgb(238, 239, 243)';
}

function doBold()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('bold', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('bold', false, null);
  }
}

function doItalic()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('italic', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('italic', false, null);
  }
}

function doUnderline()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('underline', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('underline', false, null);
  }
}

function doLeft()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('justifyleft', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('justifyleft', false, null);
  }
}

function doCenter()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('justifycenter', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('justifycenter', false, null);
  }
}

function doRight()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('justifyright', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('justifyright', false, null);
  }
}

function doOrdList()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('insertorderedlist', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('insertorderedlist', false, null);
  }
}

function doBulList()
{
  if (browser.isIE5up)
	{
    iView.document.execCommand('insertunorderedlist', false, null);
    iView.focus();
  }
	else
	{
    document.getElementById('iView').contentWindow.document.execCommand('insertunorderedlist', false, null);
  }
}

function doForeCol()
{
  var fCol = showModalDialog("/text/palette.html", " ", "dialogWidth:320px;dialogHeight:200px;status:no;help:no;resizable:yes;");

  if(fCol != null)
	{
    if (browser.isIE5up)
		{
      iView.document.execCommand('forecolor', false, fCol);
    }
		else
		{
      document.getElementById('iView').contentWindow.document.execCommand('forecolor', false, fCol);
    }
  }
  iView.focus();
}

function doBackCol()
{
  var bCol = showModalDialog("/text/palette_back.html", " ", "dialogWidth:320px;dialogHeight:200px;status:no;help:no;resizable:yes;");

  if(bCol != null)
	{
    iView.document.execCommand('backcolor', false, bCol);
  }
  iView.focus();
}

function doLink()
{
  iView.document.execCommand('createlink');
  iView.focus();
}

function doImage()
{
  //var imgSrc = prompt('Enter image location', '');
  //
  //if(imgSrc != null)
  // iView.document.execCommand('insertimage', false, imgSrc);

  iView.focus();
}

function doRule()
{
  iView.document.execCommand('inserthorizontalrule', false, null);
  iView.focus();
}

function doFont(fName)
{
  if(fName != '')
	{
    iView.document.execCommand('fontname', false, fName);
    iView.focus();
  }
	else
	{
    iView.document.execCommand('fontname', false, defaultFontName);
    iView.focus();
  }
}

function doSize(fSize)
{
  if(fSize != "")
	{
    iView.document.execCommand('fontsize', false, fSize);
    iView.focus();
  }
	else
	{
    iView.document.execCommand('fontsize', false, 3);
    iView.focus();
  }
}

function doToggleView()
{
  if(viewMode == 1)
  {
    iHTML = iView.document.body.innerHTML;
    iView.document.body.innerText = iHTML;

    // Hide all controls
    tblCtrls.style.display = 'none';
    selFont.style.display = 'none';
    selSize.style.display = 'none';
    iView.focus();

    viewMode = 2; // Code
  }
  else
  {
    iText = iView.document.body.innerText;
    iView.document.body.innerHTML = iText;

    // Show all controls
    tblCtrls.style.display = 'inline';
    selFont.style.display = 'inline';
    selSize.style.display = 'inline';
    iView.focus();

    viewMode = 1; // WYSIWYG
  }
}

function doColor()
{
    var color = showModalDialog("modules/Forum/ColorSet.html", " ", "font-family:Verdana;font-size:12;dialogWidth:28em;dialogHeight:21em");
		if (color) {
      // EditorFormat("forecolor", color);
      iView.document.execCommand('forecolor', '', color);
		}
		else {

			htmledit.focus();
		}
}

function doSize(select)
{
    iView.document.execCommand('fontsize', '', select[select.selectedIndex].value);
    select.selectedIndex = 0;
}

