

var highlightcolor="#e1f0fe"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements /INPUT|TEXTAREA|SELECT|OPTION/
var intended=/INPUT|TEXTAREA/

//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
}
}

function checkUncheckAll(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){
if(theForm[z].type == 'checkbox' && theForm[z].name != 'chk_phone' && theForm[z].name != 'checkall'){
theForm[z].checked = theElement.checked;
}
}
}

function checkUncheckCavs(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){
if(theForm[z].type == 'checkbox' && theForm[z].name != 'chk_phone' && theForm[z].name != 'checkall' && theForm[z].id.indexOf('LEM_') && theForm[z].id.indexOf('QLA_')){
	theForm[z].checked = theElement.checked;
}
}
}

function checkUncheckLEM(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){
if(theForm[z].type == 'checkbox' && theForm[z].name != 'chk_phone' && theForm[z].name != 'checkall' && theForm[z].id.indexOf('Cavs_') && theForm[z].id.indexOf('QLA_')){
	theForm[z].checked = theElement.checked;
}
}
}

function checkUncheckQLA(theElement) {
var theForm = theElement.form, z = 0;
for(z=0; z<theForm.length;z++){
if(theForm[z].type == 'checkbox' && theForm[z].name != 'chk_phone' && theForm[z].name != 'checkall' && theForm[z].id.indexOf('Cavs_') && theForm[z].id.indexOf('LEM_')){
	theForm[z].checked = theElement.checked;
}
}
}

function use_phone(frm){
if(frm.chk_phone.checked){
frm.Mobile_Area_Code.value = frm.Area_Code.value;
frm.Mobile_Phone_1.value = frm.Phone_1.value;
frm.Mobile_Phone_2.value = frm.Phone_2.value;
}
else{
tag = document.getElementsByTagName('input');
for(x=0; x<tag.length; x++){
if(tag[x].name.indexOf('Mobile') != -1){
tag[x].value = '';
}
}
}
}
