var lolfeatures = {

   fields : null,
   
	 init : function() {
	    if (!document.getElementsByTagName) { return; }
			lolfeatures.fields = document.getElementsByTagName('td');
			lolfeatures.highlights();
			var form = document.getElementsByTagName('form')[0];
			lolfeatures.addEvent(form,'submit',lolfeatures.validation);
   },

	 validation : function(e){
	    var message = '';
	    var inputs = document.getElementsByTagName('input');
			var textArea = document.getElementsByTagName('textarea');
			for (var i=0; i<inputs.length; i++){
			   if ((inputs[i].getAttribute('name') == 'name') && (inputs[i].value == '')){
				    message += 'Please enter your name.\n';
				 }
				 if ((inputs[i].getAttribute('name') == 'email') && (inputs[i].value == '')){
				    message += 'Please enter your email address.\n';
				 }
			}
		  if (message){
			   alert(message);
				 lolfeatures.stopDefault(e);
			}
	 },
	 
	 highlights : function(){
      for (var i=0; i<lolfeatures.fields.length -1; i++) {
         lolfeatures.addEvent(lolfeatures.fields[i].firstChild, 'focus', lolfeatures.addHighlight);
         lolfeatures.addEvent(lolfeatures.fields[i].firstChild, 'blur',lolfeatures.removeHighlight);
      }
	 },
	 
	 addHighlight : function(){
	    this.className = 'highlight';
	 },
	 
	 removeHighlight : function(){
	    this.className = '';
	 },
	 	
	 addEvent : function(obj, type, func) {
      if (obj.addEventListener) {obj.addEventListener(type, func, false);}
      else if (obj.attachEvent) {
         obj["e" + type + func] = func;
         obj[type + func] = function() {obj["e" + type + func] (window.event);}
         obj.attachEvent("on" + type, obj[type + func]);
      }
      else {obj["on" + type] = func;}
   },
	 
	 stopDefault : function(e){
	    if (!e) {e = window.event;}
			if (!e.preventDefault){
			   e.preventDefault = function(){this.returnValue = false;}
			}
			e.preventDefault();
			return false;
	 }
}

lolfeatures.addEvent(window, 'load', lolfeatures.init);