function FormValidator( oForm )
{
   this.form     = oForm;
   this.inputs   = new Array();
   this.criteria = new Array();
   this.error    = new Array();
   this.labels   = new Array();
   this.formOk   = false;
}

   FormValidator.prototype.Validate = function()
   {
   	this.ResetForm();

      for ( var i in this.inputs )
      {
         switch ( this.criteria[i] )
         {
            case 'checked'   : this.ValidateBoolean( this.inputs[i] );
                               break;
            case 'not empty' : this.ValidateNotEmpty( this.inputs[i].value );
                               break;
            case 'email'     : this.ValidateEmailAddress( this.inputs[i].value );
                               break;
         }

         if ( this.formOk == false )
         {
            eval( this.error[i] );
            try{this.inputs[i].select()}catch(e){}
            return false;
         }
      }
   };

   FormValidator.prototype.ResetForm = function()
   {
      for ( var i in this.labels ) 
      {
         document.getElementById( this.labels[i] ).style.fontWeight = 'normal';
         document.getElementById( this.labels[i] ).style.color      = '#000';
      }
   };

   FormValidator.prototype.HighlightLabel = function( oLabel )
   {
      if ( typeof oLabel == 'object' )
      {
         for ( var i in oLabel ) this.Highlight( document.getElementById( oLabel[i] ));
      }
      else
      {
         this.Highlight( document.getElementById( oLabel ))
      }
   };

   FormValidator.prototype.Highlight = function( oLabel )
   {
      oLabel.style.fontWeight = 'bold';
      oLabel.style.color      = '#f00';
   };

   FormValidator.prototype.ValidateBoolean = function( oInput )
   {
      this.formOk = false;

      for ( var i = 0; i < oInput.length; i++ )
      {
         if ( oInput[i].checked )
         {
            this.formOk = true;
            break;
         }
      }
   };

   FormValidator.prototype.ValidateNotEmpty = function( sInput )
   {
      this.formOk = ( sInput.length > 0 );
   };

   FormValidator.prototype.ValidateEmailAddress = function( sEmail )
   {
      this.formOk = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test( sEmail );
   };

