//Script by Shawn Olson http://www.shawnolson.net

function smo_input_get_label(inputElem){
  //function created by Shawn Olson at http://www.shawnolson.net
  if(inputElem.parentNode){
  if(inputElem.parentNode.tagName=='label'){
   return inputElem.parentNode;
  }
  }
  var labels=document.getElementsByTagName("label"),i;
  for( i=0; i<labels.length;i++ ){
   if(labels[i].htmlFor==inputElem.id){
    return labels[i];
   }
  }
  return false;
}


function checkMyForm(form){

	  //get the label object with smo_input_get_label function
	  var label = smo_input_get_label(form.name);
	  //see if there is a label
      if(label){
	   //check if the value is valid and the field is required -- in most circumstances you will use
	   //a much more robust validation than a simple empty string test
	   if(form.name.value=='' && form.nameRequired.checked){
	      //change the style to something noticable
		  label.style.color='red';
		  label.style.fontWeight='bold';

		  //note that a more dynamic and optimized way to do this is to make a
		 //CSS class name (i.e. .errorClass) and apply it like this:
		 //label.style.className = 'errorClass';
		} else {
		  label.style.color='black';
		  label.style.fontWeight='normal';
		  //note that a more dynamic and optimized way to do this is to make a
		 //CSS class name (i.e. .passClass) and apply it like this:
		 //label.style.className = 'passClass';
		}
	  }

	  //get the label object with smo_input_get_label function
	  var label = smo_input_get_label(form.country);
	  //see if there is a label
      if(label){
	   //check if the value is valid and the field is required -- in most circumstances you will use
	   //a much more robust validation than a simple empty string test
	   if(form.country.value=='' && form.countryRequired.checked){
	      //change the style to something noticable
		  label.style.color='red';
		  label.style.fontWeight='bold';

		  //note that a more dynamic and optimized way to do this is to make a
		 //CSS class country (i.e. .errorClass) and apply it like this:
		 //label.style.classcountry = 'errorClass';
		} else {
		  label.style.color='black';
		  label.style.fontWeight='normal';
		  //note that a more dynamic and optimized way to do this is to make a
		 //CSS class country (i.e. .passClass) and apply it like this:
		 //label.style.classcountry = 'passClass';
		}
	  }

	return false;
}