//Array for txtBoxValueBlur and txtBoxValueFocus
var sTextBoxValue = new Array();

//Retrieves a value from sTextBoxValue array and places into an input text field
function txtBoxValueBlur(obj, num){
	if (obj.value == ""){
		if (sTextBoxValue[num] != null){
			
			obj.value = sTextBoxValue[num];
		}
	}
}
//Reverse of txtBoxValueBlur
function txtBoxValueFocus(obj, num){
	if (sTextBoxValue[num] == null){
		sTextBoxValue[num] = obj.value;
		obj.value = "";
	} else {
		if (obj.value = sTextBoxValue[num])
		{
			obj.value = "";
		}
	}
}
//Store the caret position for future use
function storeCaret (textAr){
	selectedInputArea = textAr;
	if (textAr.createTextRange){
		selectedRange = document.selection.createRange().duplicate();
	}
}

//To be used in conjunction with a counter object - eg.
//<textarea name="sometextarea" onKeyUp="lengthCheck(this,document.userform.chr_count, 2000);"></textarea>
function lengthCheck(obj, cobj, len){
	val =  obj.value; 
	if (val.length > len) {
	  obj.value = val.substring(0,len);
	  obj.focus()
	  alert('Sorry, you are over the limit of '+ len + ' characters');
	}
	cobj.value=len-parseInt(val.length);
}