//Highlight form element- © Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and TOS,
//visit http://www.dynamicdrive.com

var highlightcolor2="orange"
var ns6=document.getElementById&&!document.all
var previous=''
var eventobj
var classToAvoid='button'
var classToSwitch='inputbox'

//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){
//	alert(which.style.name)
	if ((which.className != classToAvoid) && 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, lightcolor){
if (!lightcolor || lightcolor=='' || lightcolor==' ') {
	highlightcolor = highlightcolor2 
	} else {
	highlightcolor = lightcolor
	}
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
//previous.className=classToSwitch
previous.style.backgroundColor='#ffffff'
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}