function ValidateTextReq (ptxtText, psName, piLongMin, piLongMax)
{
	if (ptxtText.value.length<=0)
	{
		alert('The field \'' + psName + '\' is mandatory.');
		ptxtText.focus();
		return(false);
	}
	else if ((ptxtText.value.length<piLongMin) || (ptxtText.value.length>piLongMax))
	{
		alert('The format of field \'' + psName + '\' ahve to be a string from  ' + piLongMin + ' to ' + piLongMax + ' characters');
		ptxtText.focus();
		return(false);
	}
	else
	{
		return(true);
	}	
}


function ValidateNumberReq (ptxtText, psName, piMin, piMax)
{
	if (ptxtText.value.length<=0)
	{
		alert('Field \'' + psName + '\' is mandatory.');
		ptxtText.focus();
		return(false);
	}
	else if ((isNaN(ptxtText.value)) || (ptxtText.value<piMin) || (ptxtText.value>piMax))
	{
		alert('The format of field \'' + psName + '\' have to be a number between ' + piMin + ' and ' + piMax + '.');
		ptxtText.focus();
		return(false);
	}
	else
	{
		return(true);
	}
}


function ValidateEmailReq (ptxtText, psName, piLongMax)
{
	if (ptxtText.value.length<=0)
	{
		alert('The field \'' + psName + '\' is mandatory.');
		ptxtText.focus();
		return(false);
	}
	else if ((ptxtText.value.length<6) || (ptxtText.value.indexOf('@', 0)<0) || (ptxtText.value.indexOf('.', 0)<0))
	{
		alert('The format of field \'' + psName + '\' have to be a valid email.');
		ptxtText.focus();
		return(false);	
	}
	else
	{
		return(true);
	}
}


function ValidateDateReq (ptxtText, psName)
{
	if (ptxtText.value.length!=10)
	{
		alert('The field \'' + psName + '\' id mandatory.');
		ptxtText.focus();
		return(false);
	}
	else
	{	
		var dteDate=new Date(ptxtText.value.substr(0, 4), (ptxtText.value.substr(5, 2)-1), ptxtText.value.substr(8, 2));
		if ((dteDate.getDate()==ptxtText.value.substr(8, 2)) && 
			(dteDate.getMonth()==(ptxtText.value.substr(5, 2))-1) && 
			(dteDate.getFullYear()==ptxtText.value.substr(0, 4)))
		{
			return(true);
		}
		else
		{
			alert('The format for field \'' + psName + '\' have to be a correct date foramt.');
			ptxtText.focus();	
			return(false);
		}
	}
}


function ValidateComboReq (pcboCombo, psName)
{
	if (pcboCombo.selectedIndex<=0)
	{
		alert('El campo \'' + psName + '\' es obligatorio.');
		pcboCombo.focus();
		return(false);
	}
	else if (pcboCombo.options[pcboCombo.selectedIndex].value.length<1)
	{
		alert('El campo \'' + psName + '\' es obligatorio.');
		pcboCombo.focus();
		return(false);	
	}
	else
	{
		return(true);
	}
}


function ValidateText (ptxtText, psName, piLongMin, piLongMax)
{
	if (ptxtText.value.length>0)
	{
		return(ValidateTextReq(ptxtText, psName, piLongMin, piLongMax));	
	}
	else
	{
		return(true);
	}
}



function ValidateNumber (ptxtText, psName, piMin, piMax)
{
	if (ptxtText.value.length>0)
	{
		return(ValidateNumberReq(ptxtText, psName, piMin, piMax));	
	}
	else
	{
		return(true);
	}
}


function ValidateEmail (ptxtText, psName, piLongMax)
{
	if (ptxtText.value.length>0)
	{
		return(ValidateEmailReq(ptxtText, psName, piLongMax));	
	}
	else
	{
		return(true);
	}
}



function ValidateDate (ptxtText, psName)
{
	if (ptxtText.value.length>0)
	{
		return(ValidateDateReq(ptxtText, psName));
	}
	else
	{
		return(true);
	}
}


