function updateLabel(l_id,l_label,l_error) {
  if (getById(l_id) !== null) {
     // getById(l_id).setAttribute("class","fieldtitle");
     getById(l_id).innerHTML = (l_error)? '<span class="errorColor">' + l_label + ':<span>':'<span class="fieldtitle">'+ l_label +':<span>';
  }
}
function do_validate_getListed() {
   // trim content, re-assign to controls, validate
   var l_result=true;
   var l_telrefstring = '0123456789 -#';
   // name
   var l_name = trim(getById('lastname').value);
   getById('lastname').value = l_name;
   // telephone
   var l_tel = trim(getById('telephone').value);
   getById('telephone').value = l_tel;
   // email
   var l_email = getById('email').value;
   getById('email').value = strip_whitepace(l_email);
   // address
   var l_address = trim(getById('address').value);
   getById('address').value = l_address;
   // notes
   var l_notes = trim(getById('notes').value);
   getById('notes').value = l_notes;
   // do validation  on name and tel/email existing and reset label
   if (l_name == '') {
	  updateLabel('tdName','Name',1); 
	  l_result = false;
   } else {
      updateLabel('tdName','Name',0); 
   }
   // if both tel and email are empty mark Tel
   if (l_email =='' && l_tel == '') {
	  updateLabel('tdTel','Telephone',1); 
	  l_result = false;
   } else {
   	  updateLabel('tdTel','Telephone',0); 
   }
   // validate number
   if (l_tel !=='') {
     if (! isNumeric(l_tel, l_telrefstring)) {
	    updateLabel('tdTel','Telephone',1);
	    l_result = false;
	 } else {
       updateLabel('tdTel','Telephone',0); 
     }
   }
   // email may exist then validate
   if (l_email !=='') {
     if (! isEmail(l_email)) {
	    updateLabel('tdEmail','Email',1); 
	    l_result = false;
     } else {
      updateLabel('tdEmail','Email',0);
     }
   } else {
      updateLabel('tdEmail','Email',0);
   }	 
   // return true / false
   return (l_result);   
}
