
<!--
//**************************************************/
//  © 1997-2002  Nortia Technologies.   All rights reserved.
//
//	File:			incTextArea.js		
//	Author(s):		rc
//  Created:		9/3/2002	
//	Description:	<TEXTAREA> object manipulation functions.
//	Dependencies:
//	functions:		Public function setCaretToEnd()
//						Usage:	Set the caret position to the end of the text.
//
//					Public function storeCaret()
//						Usage:	Store the current caret position.
//
//					Public function refresh()
//						Usage:	Clear all text in the text area.
//
//					Public function insertAtCaret()
//						Usage:	Insert text at the current caret position.
//
//					Public function replaceAllText()
//						Usage:	Replace all the text in the text area.
//
//					Public function incTextArea_InvalidTextField(objField, strMsg, blnClearField)
//						Usage:	Alert the user of the invalid text field value.
//	Notes:
//	TODO:		
//	History:
//		
//**************************************************/

//--------------------------------------------------------------------------------------
//Public function setCaretToEnd()
//Usage:	Set the caret position to the end of the text.
//
//Input:	objTextArea - The text area object.	
//Output:	None
//Notes:				
//---------------------------------------------------------------------------------------*/
function setCaretToEnd(objTextArea) {
	objTextArea.focus();
	
	if (objTextArea.createTextRange) {
		var range = objTextArea.createTextRange();
		range.collapse(false);
		range.select();
	}
}


//--------------------------------------------------------------------------------------
//Public function storeCaret()
//Usage:	Store the current caret position.
//
//Input:	objTextArea - The text area object.	
//Output:	None	
//Notes:				
//---------------------------------------------------------------------------------------*/
function storeCaret(objTextArea) {
	if (objTextArea.createTextRange) {
	   objTextArea.caretPos = document.selection.createRange().duplicate();
	}
}


//--------------------------------------------------------------------------------------
//Public function refresh()
//Usage:	Clear all text in the text area.
//
//Input:	objTextArea - The text area object.	
//Output:	None	
//Notes:				
//---------------------------------------------------------------------------------------*/
function refresh(objTextArea) {
   objTextArea.value='';
}


//--------------------------------------------------------------------------------------
//Public function insertAtCaret()
//Usage:	Insert text at the current caret position.
//
//Input:	objTextArea - The text area object.	
//			sText		- The text string to insert.
//
//Output:	None	
//Notes:				
//---------------------------------------------------------------------------------------*/
function insertAtCaret(objTextArea, sText) {
   if (objTextArea.createTextRange && objTextArea.caretPos) {
      var caretPos = objTextArea.caretPos;
      caretPos.text = sText;
   }else{
      objTextArea.value  = sText;
   }
}


//--------------------------------------------------------------------------------------
//Public function replaceAllText()
//Usage:	Replace all the text in the text area.
//
//Input:	objTextArea - The text area object.	
//			sText		- The text string to replace with.
//
//Output:	None	
//Notes:				
//---------------------------------------------------------------------------------------*/
function replaceAllText(objTextArea, sText) {
	var oRange;

	oRange = objTextArea.createTextRange();
	oRange.text = sText;
}


//--------------------------------------------------------------------------------------
//Public function incTextArea_InvalidTextField(objField, strMsg, blnClearField)
//Usage:	Alert the user of the invalid text field value.
//			Clear the text field if required.
//			Set the focus to the text field.
//--------------------------------------------------------------------------------------
function incTextArea_Invalid(objField, strMsg, blnClearField)
{
	if (strMsg != "")
		alert(strMsg);
	
	if(!(blnClearField == false))
		objField.value = "";
			
	objField.focus();
}


//-->

