
function CheckAnswer(num) {
  var value=num;
  total=0;
  for (i=0;i<document.forms.Question.elements.length;i++) {
    var type = document.forms.Question.elements[i].type;
    if ((type == "text") && (document.forms.Question.elements[i].name != "total")) {
      temp = Math.round(document.forms.Question.elements[i].value *10)/10;
      total = total+temp;
      total = Math.round(total*10)/10;	   
    }
    totalString=" "+total+" of 100";
    document.forms.Question.total.value=totalString;
  }
}	


function Check_radio(CRnr, CRtextnr, CRsetting) {
  with (document.forms.Question) {
    if ((elements[CRnr].type == 'radio') || (elements[CRnr].type == 'checkbox')) {
      if (CRsetting == 1) //'Textfield OnClick'
	elements[CRnr].checked = true;

      if (CRsetting == 2) //'Textfield OnBlur'
	if (elements[CRtextnr].value == '')
	  elements[CRnr].checked = false;
	else
	  elements[CRnr].checked = true;

      if (CRsetting == 3) //'Radio/Checkbox OnBlur'
	if (elements[CRnr].checked == false)
	  elements[CRtextnr].value = '';
	else
	  if (elements[CRtextnr].value == '')
            elements[CRnr].checked = false;      
    }
  }
}
	
function textCounter(field,cntfield,maxlimit) 
{
	if (field.value.length > maxlimit) // if too long...trim it!
	field.value = field.value.substring(0, maxlimit);
	// otherwise, update 'characters left' counter
	else
	cntfield.value = maxlimit - field.value.length;
}

	function storeCaret (textEl)
	{	
		if (textEl.createTextRange) 
		{	
			textEl.caretPos = document.selection.createRange().duplicate();
		}
	}

function insertAtCaret (textEl, text)
{	
	if (textEl.createTextRange && textEl.caretPos)
	{	
		var caretPos = textEl.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	}
	else
	{
		textEl.value  = text;
	}
	textEl.focus();
}
