// JavaScript Document
// Clase creada por: Juan Carlos Choque Quispe - juan_c_c_q@yahoo.es

function validator()
{
	this.num_elems = 0;							//variable que indica el numero de elementos del array
	this.elements = new Array(1);				//creamos el array de los elementos
	this.show_d = show_dates;
	this.red_array = redim_array;				//funcion que redimensiona el array para agregar datos
	this.add_elem = add_elem;
	this.ini_array = initialize_array;			//funcion que inicializa el array
	this.show_array = show_array;				//funcion que muestra los elementos del array
	this.ini_array();							//llamada a la funcion que inicializa el array
	this.validate = validate_form;				//funcion que valida el contenido del formulario
	this.set_force = set_force;
	this.msg = msg;
	
	this.point_comma = 0;						//var to indicate the separator of decimals '.'--',' use 0='.' --- 1=','
	this.nd_decimals = 2;						//indicate the number of the decimal digits
	this.force_to_send = false;
	
	//colection
	this.colection_elems = 0;					//indica la cantidad de elementos que tiene la colección
	this.colection = new Array(1);				//array que maneja las colecciones
	this.show_all = show_all;
	
	
	this.add_col = add_col;
	//this.add_colection = add_colection;		//funcion que agrega un elemento a la colección	
	this.ini_colection = ini_colection;			//funcion que inicializa la coleccion	
	this.red_col_array = red_col_array;			//funcion que redimensiona el array
	this.permitedExtensions = new Array();
	this.compruebaExtension = compruebaExtension;
	this.ini_colection();
	this.messages = [];
	this.iniMessagesAndVars = iniMessagesAndVars;
	this.iniMessagesAndVars();
}

function iniMessagesAndVars()
{
	this.messages['the following errors have occurred'] = 'The following errors have occurred';
	this.messages['the value of the element'] = 'The value of the element';
	this.messages['is required'] = 'is required';
	this.messages['must be a valid email address'] = 'must be a valid email address';	
	this.messages['must be between'] = 'must be between';		
	this.messages['and'] = 'and';
	this.messages['must be a valid number'] = 'must be a valid number';
	this.messages['must be a real number valid'] = 'must be a real number valid';
	this.messages['must be a valid direction URL'] = 'must be a valid direction URL';	
	this.messages['must be select an option of'] = 'Must be select an option of';
	this.messages['select an option from the list'] = 'Select an option from the list';
	this.messages['must be a valid date'] = 'must be a valid date';	
	this.messages['must be a valid date and time'] = 'must be a valid date and time';
	
	this.messages['the field'] = 'The field';
	this.messages['must contain a valid file path'] = 'must contain a valid file path';
	this.messages['must contain a file with extensions'] = 'must contain a file with extensions';
	this.messages['You must accept the privacy policy and legal information']='Debe aceptar la pol\u00EDtica de privacidad';
	/*iniciamos los valores de las variables*/
	this.permitedExtensions	= Array(".gif", ".jpg", ".doc", ".pdf");
}


function msg(m)
{
	alert(m);
}

/*funcion que inicializa la coleccion*/
function ini_colection()
{	
	this.colection = new Array(1);

	var i;
	for(i = 0; i < this.colection.length; i++)
		this.colection[i] = new Array(3);
}

function show_all(asd,as1,as2)
{
	var a = 1;
	a = asd;
}

function add_col(id,name,type)
{
	var position;
	if(this.colection_elems != 0)
	{
		this.colection_elems++;
		this.red_col_array();
	}
	else
		this.colection_elems = 1;
	
	position = this.colection.length - 1;
	//cargamos los datos en el array
	//alert('pos '+position);
	this.colection[position][0] = id;
	this.colection[position][1] = name;
	this.colection[position][2] = type;
}

/*funcion que agrega un elemento a la colección
function add_colection(id,name,type)
{
	var position;
	if(this.colection_elems != 0)
	{
		this.colection_elems++;
		this.red_col_array();
	}
	else
		this.colection_elems = 1;
	
	position = this.colection.length - 1;
	//cargamos los datos en el array
	//alert('pos '+position);
	this.colection[position][0] = id;
	this.colection[position][1] = name;
	this.colection[position][2] = type;
}*/

/*funcion que redimensiona el array*/
function red_col_array()
{
	var i;
	var j;
	var local_array = new Array(this.colection.length);
	var begin = this.colection.length;
	if(this.colection_elems > this.colection.length)
	{
		//alert(this.colection.length);	
		//realizamos una copia del array
		for(i = 0; i < local_array.length; i++)
			local_array[i] = new Array(3);

		for(i = 0; i < this.colection.length; i++)
		{
			for(j = 0; j < 3; j++)
				local_array[i][j] = this.colection[i][j];
		}
		
		//agregamos un elemento
		//alert(this.colection.length+'--'+this.colection_elems);
		this.colection.length = this.colection_elems;
		
		for(i = (begin - 1); i < this.colection_elems; i++)
			this.colection[i] = new Array(3);
		
		//retornamos los valores
		for(i = 0; i < local_array.length; i++)
		{
			for(j = 0; j < 3; j++)
				this.colection[i][j] = local_array[i][j];
		}
	}
}

/*funcion que inicializa el array y lo carga con otros arryas*/
function initialize_array()
{
	var i;
	for(i = 0; i <= (this.elements.length - 1); i++)
		this.elements[i] = new Array(5);
}

/*funcion que agrega un elemento al array*/
function add_elem(id_elem,name,required,type,rank)
{
	var i;
	var j;
	
	if(this.num_elems != 0)
	{	
		this.num_elems++;
		this.red_array();
	}
	else
		this.num_elems = 1;
		
	position = this.elements.length - 1;
	//cargamos los datos en el array
	if(type == 'colection')
	{
		this.elements[position][0] = id_elem;
		this.elements[position][1] = name;
		this.elements[position][2] = required;
		this.elements[position][3] = type;
		this.elements[position][4] = new Array(this.colection_elems);		
		
		for(i = 0; i < this.colection_elems; i++)
			this.elements[position][4][i] = new Array(3);
			
		for(i = 0; i < this.colection_elems; i++)	
		{
			for(j = 0; j < 4; j++)
				this.elements[position][4][i][j] = this.colection[i][j];				
		}
		
		this.ini_colection();
		this.colection_elems = 0;
	}	
	else
	{
		this.elements[position][0] = id_elem;
		this.elements[position][1] = name;
		this.elements[position][2] = required;
		this.elements[position][3] = type;
		this.elements[position][4] = rank;
	}
	//this.show_array();
}

/*funcion que redimensiona el array para agregar los nuevos datos*/
function redim_array()
{	
	var begin = this.elements.length;
	var end = this.num_elems;
	var i;
	var j;
	var local_elem = new Array(this.elements.length);
	
	if(this.num_elems > this.elements.length)
	{		
		//realizamos una copia del array
		for(i = 0; i <= (local_elem.length -1); i++)
			local_elem[i] = new Array(5);	
		
		for(i = 0; i <= (this.elements.length - 1); i++)
		{
			for(j = 0; j < 5; j++)
				local_elem[i][j] = this.elements[i][j];
		}
		
		//agregamos un nuevo elemento
		this.elements.length = this.num_elems;
		for(i = (begin - 1); i <= (end - 1); i++)
			this.elements[i] = new Array(5);
			
		//retornamos los valores 
		for(i = 0; i <= (local_elem.length - 1); i++)
		{
			for(j = 0; j < 5; j++)
				this.elements[i][j] = local_elem[i][j];
		}
	}	
}

/*funcion que muestra el contenido del array*/
function show_array()
{
	var i;
	var j;
	var k;
	var l;
	var result = '';
	for(i = 0; i <= (this.elements.length - 1); i++)
	{
		result = result + "pos "+i+"\n";
		for(j = 0; j < 5; j++)
		{
			if(j == 3)
			{
				if(this.elements[i][3] != 'colection')
					result = result + "sub pos "+j+" = "+this.elements[i][j]+"\n";
				else
				{
					result = result + "sub pos "+j+" = "+this.elements[i][j]+"\n";
					alert('colection');
					for(k = 0; k < this.elements[i][4].length; k++)
					{
						
						result = result + "components "+k+" = "+this.elements[i][4][k]+"\n";
						for(l = 0; l < 3; l++)
							result = result + "components pos "+l+" = "+this.elements[i][4][k][l]+"\n";
					}
				}
			}
			else
				result = result + "sub pos "+j+" = "+this.elements[i][j]+"\n";
		}
	}
	//document.write(result);
	alert(result);
}

/*funcion que devuelve el indentificador del elemento*/
function getObject(objectId) 
{
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) 
		return document.getElementById(objectId); // W3C DOM
	else if(document.all && document.all(objectId)) 
		return document.all(objectId);	// MSIE 4 DOM
	else if(document.layers && document.layers[objectId]) 
		return document.layers[objectId];		// NN 4 DOM.. note: this won't find nested layers
	else 
		return false;
}

/*fuincion que valida una dirección de email*/
function validarEmail(email, required) 
{	
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

/*funcion que devuelve todos los caracteres válidos*/
function allValidChars(email) {
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}

/*funcion que verifica si valor es un numero*/
function isNumeric(valor)
{			
	var str_cad = valor.toString();
	var num = 0;
	var count = 0;
	for(i = 0; i< str_cad.length; i++)
	{
		num = str_cad.charAt(i);
		if(num < "0" || num > "9")
			return false;
	}
	return true;
}

function validaUrl(url)
{ 

	var urlRegxp = /^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([\w]+)(.[\w]+){1,2}$/;
	//var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;  
	if (urlRegxp.test(url) == true)
		return true;
	else
		return false;
}

function isDigit(sChr,extra_code)
{	
	var sCod = sChr.charCodeAt(0);
	var ret;
	var ext_c = new Array();		
	
	ret = ((sCod > 47) && (sCod < 58));
	
	if(extra_code.length > 0)
	{
		ext_c = extra_code.split(',');
		
		for(i = 0; i < ext_c.length; i++)
		{
			ret = ret || (sCod == parseInt(ext_c[i]));
		}
	}
	
	return ret;
}

function valSeparator(oTxt)
{
	var bOk = false;
	bOk = bOk || ((oTxt.charAt(2) == "/") && (oTxt.charAt(5) == "/"));
	//bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
	return bOk;
}

function valMes(oTxt)
{
	var bOk = false;
	var nMes = parseInt(oTxt.substr(3, 2), 10);
	bOk = bOk || ((nMes >= 1) && (nMes <= 12));
	
	return bOk;
}

function valAnho(oTxt)
{
	var bOk = true;
	var nAno = oTxt.substr(6,4);
	//bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
	
	if (bOk)
	{
		for (var i = 0; i < 4; i++)
		{
			bOk = bOk && isDigit(nAno.charAt(i),0);			
		}	
	}
	
	return bOk;
}

/*check separator time ":"*/
function valSepTime(val)
{		
	var bOk = false;
	bOk = bOk || ((val.charAt(10) == " ") && (val.charAt(13) == ":"));
	
	return bOk;
}

/*verify time hour*/
function valHour(val)
{
	var bOk = true;
	var hour = parseInt(val.substr(11,2),10);
	bOk = bOk || ((hour >= 0) && (hour <= 23));
	
	return bOk;
}

/*verify time min*/
function valMin(val)
{
	var bOk = true;
	var mins = parseInt(val.substr(14,2),10);
	bOk = bOk || ((mins >= 0) && (mins <=59));
	
	return bOk;
}
 
/*function to verify date*/ 
function valFecha(oTxt)
{	
	var bOk = true;
	var ret = false;
	
	if (oTxt.value != "")
	{
		bOk = bOk && (valAnho(oTxt));
		bOk = bOk && (valMes(oTxt));		
		bOk = bOk && (valSeparator(oTxt));			
		
		if(bOk == true)
			ret = true;
		else
			ret = false;
	}
	return ret;	
}  
  
/*function to verify date-time*/  
function valDateTime(val)
{
	var bOk = true;
	var ret = false;
	
	if(val.value != "")
	{			
		bOk = bOk && (valAnho(val));		
		bOk = bOk && (valMes(val));
		bOk = bOk && (valSeparator(val));
		//alert('asasa'+valSepTime(val));
		bOk = bOk && (valSepTime(val));
		bOk = bOk && (valHour(val));
		bOk = bOk && (valMin(val));
		
		if(bOk == true)
			ret = true;
		else
			ret = false;
	}	
	return ret;
}

/*function to round decimals*/
function redondear(cantidad, decimales) 
{
	var cantidad = parseFloat(cantidad);
	var decimales = parseFloat(decimales);
	decimales = (!decimales ? 2 : decimales);
	//alert(Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales));
	return Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);
} 


/*function to validate number float*/
function validate_real(val,point_comma)
{
	var exp_reg;
	var ret = false;
	var separator;
	var sub_cad = '';
	var ini;
		
	if(point_comma == 0)
	{		
		//exp_reg = /^[+-]?((\d+|\d{1,3}(\,\d{3})+)(\.\d*)?|\.\d+)$/;	//separator '.'		
		//exp_reg = /^[+-]?((\d+|\d{1,3}(\.\d{3})+)(\,\d*)?|(\.\d*)?|\,\d+|\.\d+)$/;	//separator ','		
		exp_reg = /^\d+(\.?|\,?)\d*$/;
		separator = '.';
	}
	else
	{
		//exp_reg = /^[+-]?((\d+|\d{1,3}(\.\d{3})+)(\,\d*)?|(\.\d*)?|\,\d+|\.\d+)$/;	//separator ','		
		exp_reg = /^\d+(\.?|\,?)\d*$/;
		//exp_reg = /^[+-]?((\d+|\d{1,3}(\,\d{3})+)(\.\d*)?|\.\d+)$/;	//separator '.'		
		separator = ',';
	}
	/*
	if(exp_reg.test(val) == true)	
	{
		ini = val.indexOf(separator);
		alert(ini);
		if(ini != -1)
		{
			sub_cad = val.substr(ini+1);
			if(sub_cad.length > 2)
				
		}
	}*/
	ret = exp_reg.test(val);
	
	return ret;
}

function compruebaExtension(archivo,extensionsAllowed)
{	
   	typeError = 0;

	extensionsAllowed = extensionsAllowed.split(',');
	   	
	if(archivo.length == 0)
   	{
    	//Si no tengo archivo, es que no se ha seleccionado un archivo en el formulario
       	typeError = 1;
   	}
	else
	{
    	//recupero la extensión de este nombre de archivo
      	extension = (archivo.substring(archivo.lastIndexOf("."))).toLowerCase();

      	//compruebo si la extensión está entre las permitidas
      	permitida = false;
		
      	for(var i = 0; i < extensionsAllowed.length; i++) 
		{
			currentExtension = "." + extensionsAllowed[i];
			//-----alert('conparacion '+ currentExtension+' == '+extension);
        	if(currentExtension == extension) 
			{
         		typeError = 3;		//todo salio bien
				permitida = true;
			}
      	}
      	
	  	if(!permitida)
        	typeError = 2;		//la extension no es correcta
   	}
	
   	//si estoy aqui es que no se ha podido submitir
   	return typeError;
} 

function set_force()
{
	this.force_to_send = true;
}
  
/*funcion que valida el contenido del formulario*/
function validate_form()
{	
	var i;
	var current_elem;
	var c_elem;
	var message = '';
	var extra_msg = new Array();
	var ranks = new Array(2);
	var flag = false;
	var count = 0;
	//alert('hola');
	
	if(this.force_to_send == true)
	{
		this.force_to_send = false;
		return true;
	}
		
	for(i = 0; i < this.elements.length; i++)	
	{	
		switch(this.elements[i][3])		//verificamos el tipo del elemento
		{
			case 'text':	//para texto								
				if(this.elements[i][2] == 1)	//verificamos si es requerido
				{
					current_elem = getObject(this.elements[i][0]);
					if(current_elem.disabled == '')
					{
						if(current_elem.value.length == 0)
							message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['is required'] + ".\n";
					}
				}
			break;
			
			case 'email':	//para direcciones de email							
				current_elem = getObject(this.elements[i][0]);
				
				if(this.elements[i][2] == 1)	//verificamos si es requerido
				{								
					if(current_elem.value.length == 0)
						message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['is required'] + ".\n";
					else if(validarEmail(current_elem.value,true) == false)
						message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a valid email address'] + ".\n";
				}
				else
				{
					if(current_elem.value.length > 0)
					{
						if(validarEmail(current_elem.value,true) == false)
							message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a valid email address'] + ".\n";	
					}
				}
			break;
			
			case 'numeric':	//para campos numericos				
				current_elem = getObject(this.elements[i][0]);
				
				if(this.elements[i][2] == 1)	//vwrificamos si es requerido
				{
					if(current_elem.value.length == 0)
						message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['is required'] + ".\n";
					else 
					{
						if(this.elements[i][4].length > 0)	//verificamos si se ha establecido un rango
						{
							ranks = this.elements[i][4].split("-");							
							if(isNumeric(current_elem.value) == true)
							{
								if(current_elem.value < ranks[0] || current_elem.value > ranks[1])	//vwrificamos el valor con los rangos
									message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['must be between'] + " " + ranks[0] + " " + this.messages['and'] + " " + ranks[1] + ".\n";
							}
							else
								message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['must be a valid number'] + ".\n";							
						}
						else
						{
							if(isNumeric(current_elem.value) == false)
								message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['must be a valid number'] + ".\n";							
						}
					}
				}
				else
				{
					if(current_elem.value.length > 0)	
					{
						if(isNumeric(current_elem.value) == false)
							message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['must be a valid number'] + ".\n";
					}
				}				
			break;
			
			case 'real':	//for the real, float values
				current_elem = getObject(this.elements[i][0]);
				
				if(this.elements[i][2] == 1)
				{
					if(current_elem.value.length == 0)	
						message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['is required'] + ".\n";
					else
					{
						if(validate_real(current_elem.value,this.point_comma) == false)
							message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a real number valid'] + ".\n";							
					}
				}
				else
				{
					if(current_elem.value.length > 0)
					{
						if(validate_real(current_elem.value,this.point_comma) == false)
							message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a real number valid'] + ".\n";							
					}
				}
			break;
			
			case 'url':	//para direcciones url
				current_elem = getObject(this.elements[i][0]);
				
				if(this.elements[i][2] == 1)	//verificamos si es requerido
				{
					if(current_elem.value.length == 0)
						message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['is required'] + ".\n";
					else
					{
						if(validaUrl(current_elem.value) == false)
							message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a valid direction URL'] + ".\n";
					}	
				}
				else
				{
					if(current_elem.value.length > 0)
					{
						if(validaUrl(current_elem.value) == false)
							message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a valid direction URL'] + ".\n";
					}
				}
			break;
			
			case 'colection':	//para colecciones tipo checkbox y radio button						
				if((this.elements[i][4][0][2] == 'checkbox') || (this.elements[i][4][0][2] == 'radiobutton'))	//si la coleccion es checkbox
				{					
					flag = false;
					
					for(j = 0; j < this.elements[i][4].length; j++)
					{
						current_elem = getObject(this.elements[i][4][j][0]);
						
						if(current_elem.checked == true)
							flag = true;
							
						extra_msg[count++] = this.elements[i][4][j][1];						
					}
					
					if(flag == false)
						message = message + "- " + this.messages['must be select an option of'] + " : " + this.elements[i][1] + "\n";
				}
			break;
			
			case 'combobox':	//para elementos combobox
			
				current_elem = getObject(this.elements[i][0]);
			//	alert(current_elem.name + "***"+current_elem.value + "** " + this.elements[i][4]);
				if(current_elem.value == this.elements[i][4] || current_elem.value==0)
				{	message = message + "- " + this.messages['select an option from the list'] + " : '" + this.elements[i][1] + "'\n";					
					//alert('ddd');
				}
			break;
			
			case 'listbox':		//para elementos listbox
				current_elem = getObject(this.elements[i][0]);
				if(current_elem.selectedIndex == -1)
					message = message + "- " + this.messages['select an option from the list'] + " : " + this.elements[i][1] + "\n";	
			break;
			
			case 'date':		//para tipos de datos fecha
				current_elem = getObject(this.elements[i][0]);			
				//alert(current_elem.value+' '+valFecha(current_elem.value));
				if(valFecha(current_elem.value) == false)
					message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " + this.messages['must be a valid date'] + " (dd/mm/yyyy).\n";	
			break;
			
			case 'datetime':	/*for the dates datetime*/
				current_elem = getObject(this.elements[i][0]);	
				if(current_elem.disabled == '')
				{
					if(valDateTime(current_elem.value) == false)
						message = message + "- " + this.messages['the value of the element'] + " : " + this.elements[i][1] + " " + this.messages['must be a valid date and time'] + " (dd-mm-yyyy hh:ss).\n";
				}
			break;
			
			case 'file':		/*for the files*/				
				current_elem = getObject(this.elements[i][0]);

				switch(this.compruebaExtension(current_elem.value,this.elements[i][4]))
				{
					case 1:
						message = message + "- " + this.messages['the value of the element'] + " : '" + this.elements[i][1] + "' " +  this.messages['must contain a valid file path'] + ".\n";
					break;
					
					case 2:
						message = message + "- " + this.messages['the field'] + " : '" + this.elements[i][1] + "' " + this.messages['must contain a file with extensions'] + " '" + this.elements[i][4] + "'.\n";
					break;
					
				}	
			break;
		}
	}
	//not_validate();
	
	var fecha_e= getObject('anse_fechamese_fechadise_fecha');
	if(fecha_e)
	  {	  
		if(fecha_e.value=='01/01/2000')
			{message = message + "- Fecha es requerida"; }
	  }
	var nm_paiss= getObject('nm_pais');
	if(nm_paiss)
	  {	  
		if(nm_paiss.value=='')
			{message = message + "- País es requerido"; }
	  }
	
	var check_very = getObject('commitent_verif');
	if(check_very)
	  {	  
		if(check_very.checked == false)
			{message = message + "- " + this.messages['You must accept the privacy policy and legal information']; }
	  }
	if(message.length > 0)
	{
		alert(this.messages['the following errors have occurred']+':\n'+message);
		return false;
	}
	else
		return true;
}

function show_dates()
{
	alert(this.elements.length);
	this.elements[0] = "";
	this.elements[1] = "";
	alert(this.elements[0]+"--"+this.elements[1]);
	this.elements.length = 10;
	alert(this.elements.length);
	alert(this.elements[0]+"--"+this.elements[1]);
}