

function submitSpellcheck(f) {
  f.doSpellCheck.value = 'true';
  f.submit();
}
function openEmoticonWin(formName) {
    window.open("/emoticons.jsp?formName="+formName, "emoticons", "menubar=no,location=no,personalbar=no,scrollbars=no,width=30,height=330");
}
function preview(f) {
  var content = f.body.value;
  var left = screen.availWidth-450;
  var w = window.open("","popup","width=450,height=350,directories=no,menubar=no,status=no,toolbar=no,resizable=yes,scrollbars=yes,screenY=0,top=0,screenX=" + left + ",left=" + left);
  w.document.writeln("<html><title>Preview</title><body>");
  w.document.writeln(content);
  w.document.writeln('<hr><form><center><input type="submit" value="Close Window" onClick="window.close();return false;"></center></form>');
  w.document.writeln("</body></html>");
  w.document.close();
}

function insertAtCursor(myField, myValue) {
	//IE support
	if (document.selection) {
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == "0") {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
			+ myValue
			+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
}

function placeImage(imgName, body) {
	insertAtCursor(body, '[img src="'+imgName+'"]');
}

function embedPhoto(imgURL, body) {
	insertAtCursor(body, '<img src="'+imgURL+'">');
}

function embedPhotoGui(imgURL, body) {
	var inst = tinyMCE.selectedInstance;
	inst.getWin().focus();
	tinyMCE.themes['advanced']._insertImage(imgURL, "", 0, "", "", null, null, "");
}

function clearText(field, otherName) {
	if (field.value != null && field.value.length > 0)
		document.attachForm[otherName].value = "";
}

function clearFile(field, fileID) {
	if (field.value != null && field.value.length > 0) {
		document.getElementById(fileID).innerHTML = 
			document.getElementById(fileID).innerHTML;
	}
}
