/*function insertAtCaret(areaId, text) {
	var txtarea = document.getElementById(areaId);
	var scrollPos = txtarea.scrollTop;
	var strPos = 0;
	var br = ((txtarea.selectionStart || txtarea.selectionStart == '0') ? 
		"ff" : (document.selection ? "ie" : false ) );
	if (br == "ie") { 
		txtarea.focus();
		var range = document.selection.createRange();
		range.moveStart ('character', -txtarea.value.length);
		strPos = range.text.length;
	}
	else if (br == "ff") strPos = txtarea.selectionStart;
	
	var front = (txtarea.value).substring(0,strPos);  
	var back = (txtarea.value).substring(strPos,txtarea.value.length); 
	txtarea.value=front+text+back;
	strPos = strPos + text.length;
	if (br == "ie") { 
		txtarea.focus();
		var range = document.selection.createRange();
		range.moveStart ('character', -txtarea.value.length);
		range.moveStart ('character', strPos);
		range.moveEnd ('character', 0);
		range.select();
	}
	else if (br == "ff") {
		txtarea.selectionStart = strPos;
		txtarea.selectionEnd = strPos;
		txtarea.focus();
	}
	txtarea.scrollTop = scrollPos;
}*/

function getY(oElement) {
   var iReturnValue = 0;
   while( oElement != null ) {
   iReturnValue += oElement.offsetTop;
   oElement = oElement.offsetParent;
   }
   return iReturnValue;
}

function getX(oElement) {
   var iReturnValue = 0;
   while( oElement != null ) {
   iReturnValue += oElement.offsetLeft;
   oElement = oElement.offsetParent;
   }
   return iReturnValue;
}

function toggleDiv(sDivId) {
   var oNewRecipient =
      document.getElementById(sDivId);
   oNewRecipient.style.display =
      oNewRecipient.style.display == 'none' ?
         '' : 'none';
}

function showHelp(oLink, e, helpStr) {
   var oHelpText =
      document.getElementById('helpText');
   oHelpText.style.display =
      'block';
   oHelpText.style.position =
      'absolute';
   oHelpText.style.left =
      getX(oLink) + 'px';
   oHelpText.style.top =
      getY(oLink) + 'px';
      
   oHelpText.innerHTML = 
      helpStr;
}

 

function ShowItem(pnlTrainingCourseFields){
   alert(pnlTrainingCourseField);
}


function insertAtCaret(txtarea, text) {
 	
	 //IE support
  if (document.selection) {
    txtarea.focus();
    sel = document.selection.createRange();
    sel.text = text;
  }
  //MOZILLA/NETSCAPE support
  else if (txtarea.selectionStart || txtarea.selectionStart == '0') {
   var strText = txtarea.value;
    var startPos = txtarea.selectionStart;
    var endPos = txtarea.selectionEnd;
     
    txtarea.value = strText.substring(0, startPos)
                  + text
                  + strText.substring(endPos, strText.length);
                  
  } else {
    txtarea.value += text;
  }
}
