var highlightcolor="#FEF5DA"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}

<!-- Capitalize-->


function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}

<!-- Phone format-->

function phoneDisplay(i, delKey){
	if(delKey!=8 && delKey!=46 && delKey!=9 && delKey!=16 && !(delKey>36 && delKey<41)){//if the delete, backspace, tab, shift, are not the keys that caused the keyup event.
		var fieldLen = i.value.length;
		var areaCode = "";
		var exchange = "";
		var lastFour = "";
		var currVal = i.value;
		var firstParens = 1;
		var firstParens = parseInt(i.value.lastIndexOf("(")) + parseInt(1);
		var secondParens = 5;
		var secondParens = parseInt(i.value.lastIndexOf(")")) + parseInt(1);
		if(firstParens < 1){ firstParens=1; }
		if(secondParens < 1){ secondParens=5; }
		if(fieldLen==1 && currVal!="("){ areaCode = i.value; }
		if(fieldLen>1){
			areaCode = i.value.substring(firstParens,4);
		}
		if(fieldLen>4){
			exchange = i.value.substring(secondParens,8);
		}
		if(fieldLen>7){
			lastFour = i.value.substring(9,13);
		}
//alert("x" + lastFour + "y");
		if(fieldLen<4){
		i.value = "(" + areaCode ;
			i.focus();
		} else
		if(fieldLen<8){
			i.value = "(" + areaCode + ")" + exchange;
			i.focus();
		} else
		if(fieldLen<13){
			i.value = "(" + areaCode + ")" + exchange + "-" + lastFour;
			i.focus();
		}
	}//end if delete key=8,46
}

function phoneBlur(i){
 var formName = document.forms[0].name;
	if(i.value.length<5){
		i.value="";
	}
}

function phoneFocus(i){
   var formName = document.forms[0].name;
   var formLength =document.forms[0].length;
   if((i.value=="")){
	i.value="("; i.focus(); i.select();
   } else { i.select(); }
}

