function Validate(){

	//Member variables
	this.error="";
	this.i=0;
	this.total=0;
	this.focus_var=new Array();
	this.fields=new Array();
	this.isDojo=(arguments[0])?false:true;
}

//Validation method for regular expressions fields

Validate.prototype.fieldRegMess=function(field,mensaje,bol){

		var y=document.getElementById(field);
		
	//	y.disabled=false;
		this.fields[this.total]=field;
		this.total++;
		
		if(bol==false){
			this.error+=(this.isDojo)?mensaje+"<BR/><BR/>":mensaje+"\n\n";
			y.style.backgroundColor="#FFF454";			

			this.focus_var[this.i]=field;
			this.i=this.i+1;
		}
		else {
			y.style.backgroundColor="#FFFFFF";			
		}
		
		for(a=0;a<this.i;a++){
				
			if(this.focus_var[a]==field){

				y.style.backgroundColor="#FFF454";								
				break;
			} 
		}
		
	}		

	// Reset color background to normal
	Validate.prototype.Clean=function(field) {
		document.getElementById(field).style.backgroundColor="#FFFFFF";	
	}
	
	// Message method
	Validate.prototype.Mensajes=function(errorNum){
		
		if(this.error){
		
			//Index Focus() 
			var tope=this.focus_var.length-1;
			this.focus_var.reverse();
			
			for (number=0; number<=tope; number=number+1) { 
				
				if(document.getElementById(this.focus_var[number]).type=='radio'){
					try{document.getElementById(this.focus_var[number])[0].focus()}catch(e){};
				}
				
				else {
					try{document.getElementById(this.focus_var[number]).focus()}catch(e){};
					
					if(document.getElementById(this.focus_var[number]).type!='select-one'){	
						document.getElementById(this.focus_var[number]).select();
					}
				}
			}
	
			// Send alert
			if(this.isDojo){
				showAlert("Favor de corregir los campos mencionados - "+errorNum+" error(es)",this.error); 
			}
			else{
				alert("Please correct the folllowing fields - "+errorNum+" error(s)\n\n"+this.error);
			}
			
			//Reset variables
			this.error='';
			this.i=0;
			return false;
		} 
		else {

			for (i=0; i<this.fields.length; i++) {
// For disable fields over success results.
//document.getElementById(this.fields[i]).disabled=true;	
			}
			
			return true;
		}
	
	document.getElementById('Submit').value='sdsds';
	document.getElementById('Submit').disabled=true;

}
