/**
 * @author Igor
 */

	ValidationManager = Class.create();
	
	ValidationManager.prototype  ={
		initialize:function(container)
		{
			this.el = $(container);
			this.initInputs();			
		},
		initInputs:function()
		{
		
			this.inputElems =$A(this.el.getElementsByTagName("input"));
			this.inputValidators = new Array();
			var me = this;
			 this.inputElems.each(function(input)
			 { 
			   if(input.type =="text")
			   {
				me.inputValidators.push(new InputValidator(input));
			   }				
			 }
			);					
		},		
		valide:function()
		{
			var result =true;
			this.inputValidators.each(function(validator)
			{
				
				if(!validator.valide()) result = false;		
			}
			);	
			return result;	
		}
		
		
	}
	
	
	InputValidator = Class.create();
	InputValidator.prototype  ={
		initialize:function(el)
		{
			this.el = $(el);
			this.notValideClass ="notValidInput";
			this.el.onkeypress  =this.onkey.bindAsEventListener(this);  
				   		
		},
		onkey:function()
		{
			this.el.removeClassName(this.notValideClass);
			
		},
		valide:function()
		{
			this.notEmpty = this.el.getAttribute("notEmpty");
			if(this.notEmpty=="")
			{
				if(this.el.value=="") {this.el.addClassName(this.notValideClass);		
				return false;	}	
			}	
			return true;		
		}
   }