function vsPhi_validator() {
	var resValidation = true;

	if(arguments[3] == 'required') {
		resValidation = vsPhi_ValidateRequired(arguments[1], arguments[2]);
		if(!resValidation) {
			return (vsPhiValidator_Lang.Field + ' ' + arguments[0] + ' ' + vsPhiValidator_Lang.Required);
		}
	}
	if(arguments[3] == 'minlength') {
		resValidation = vsPhi_ValidateMinLength(arguments[1], arguments[2], arguments[4]);
		if(!resValidation) {
			return (vsPhiValidator_Lang.Field + ' ' + arguments[0] + ' ' + vsPhiValidator_Lang.mhMin + ' ' + arguments[4]);
		}
	}
	if(arguments[3] == 'maxlength') {
		resValidation = vsPhi_ValidateMaxLength(arguments[1], arguments[2], arguments[4]);
		if(!resValidation) {
			return (vsPhiValidator_Lang.Field + ' ' + arguments[0] + ' ' + vsPhiValidator_Lang.mhMax + ' ' + arguments[4]);
		}
	}
	if(arguments[3] == 'email') {
		resValidation = vsPhi_ValidateEmail(arguments[1], arguments[2]);
		if(!resValidation) {
			return (vsPhiValidator_Lang.Field + ' ' + arguments[0] + ' ' + vsPhiValidator_Lang.validEmail);
		}
	}
}

function vsPhi_ValidateEmail(id_e, eType) {
	e = $('field_'+id_e);
	if(!checkMail(e.value)) {
		return false;
	} else {
		return true;
	}
}

function vsPhi_ValidateMinLength(id_e, eType, minLength) {
	e = $('field_'+id_e);
	if(eType == 'text' || eType == 'textarea') {
		if(e.value.length < minLength) {
			return false;
		} else {
			return true;
		}
	}
}

function vsPhi_ValidateMaxLength(id_e, eType, maxLength) {
	e = $('field_'+id_e);
	if(eType == 'text' || eType == 'textarea') {
		if(e.value.length > maxLength) {
			return false;
		} else {
			return true;
		}
	}
}

function vsPhi_ValidateRequired(id_e, eType) {

	e = $('field_'+id_e);

	if(eType == 'text' || eType == 'textarea' || eType == 'file') {
		tString = removeSpaces(e.value);
		if(tString.length < 1) {
			return false;
		} else {
			return true;
		}
	}
	if(eType == 'select') {
		if(e.value == -1) {
			return false;
		} else {
			return true;
		}
	}
	if(eType == 'checkbox' || eType == 'radio') {
		var lInputs = $('zone_' + id_e).getElementsByTagName('input');
		for(i=0;i<lInputs.length;i++) {
			if(lInputs[i].type == eType) {
				if(lInputs[i].checked) {
					return true;
				}
			}
		}
		return false;
	}
	return true;
}



function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(j = 0; j < splitstring.length; j++)
		tstring += splitstring[j];
	return tstring;
}

function checkMail(strEmail)
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(strEmail))
		return true;
	else
		return false;
}