
function DateInputFix(df_date)
	{
		df_date=df_date.replace(/ +/g," ");
		df_date=df_date.replace(/^ /,"");
		df_date=df_date.replace(/ $/,"");
		df_date=df_date.replace(/ *\/ */g,"/");
		df_date=df_date.replace(/ *: */,":");

		return(df_date);
	}

function StringInputFix(sf_string)
	{
		sf_string=sf_string.replace(/ +/g," ");
		sf_string=sf_string.replace(/^ /,"");
		sf_string=sf_string.replace(/ $/,"");

		return(sf_string);
	}
 
function isNumber(in_number)
	{
		var reNumber=/^\d+$/;
		in_number=in_number.replace(/ /g,"");
		if (!reNumber.test(in_number)) { return(false); }
		else { return(true); }
	}

function isValidFileExt(ivfe_filename,ivfe_ext)
	{
		var tmpValidExt=new Array;
		var tmpExt=new String;
		var tmpIndex=new Number;
		var reExt=/.*\.([^.]*)$/;
		
		ivfe_ext=ivfe_ext.replace(/ /g,"");
		ivfe_ext=ivfe_ext.toLowerCase();

		tmpValidExt=ivfe_ext.split(",");

		reExt.exec(ivfe_filename);
		tmpExt=RegExp.$1;
		tmpExt=tmpExt.toLowerCase();

		for (tmpIndex=0; tmpIndex<tmpValidExt.length; tmpIndex++) 
			{
				if (tmpValidExt[tmpIndex]==tmpExt) { return (true); }
			}
		return(false);		
	}

function isEmpty(ie_string)
	{
		ie_string=ie_string.replace(/ /g,"");
		if (ie_string=="") { return (true); }
		return(false);
	}
	
function isDate2(id_date)
	{
		var tmpDate,tmpDateParts,tmpHourParts = new String;
		var tmpDay,tmpMonth,tmpYear,tmpHour,tmpMinute = new Number;
		var hasHour=new Boolean;
		var tmpSplit=new Array;
		var months=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var reDate=/^\d+\/\d+\/\d+$/;
		var reHour=/^\d+:\d+$/;
		
		tmpDate=DateInputFix(id_date);
		tmpSplit=tmpDate.split(" ");
		
		switch(tmpSplit.length)
			{
				case 1:
					hasHour=false;
					break;
				case 2:
					hasHour=true;
					break;
				default:
					return(false);
			}
		
		if (!reDate.test(tmpSplit[0])) { return(false); }
			
		tmpDateParts=tmpSplit[0].split("/");

		if (hasHour==true)
			{
				if (!reHour.test(tmpSplit[1])) { return(false);	}
				tmpHourParts=tmpSplit[1].split(":");
				tmpHour=parseInt(tmpHourParts[0],10);
				tmpMinute=parseInt(tmpHourParts[1],10);
		
				if (tmpHour<0 || tmpHour>24 || tmpMinute<0 || tmpMinute>59) { return(false); } 
			}
		tmpDay=parseInt(tmpDateParts[0],10);
		tmpMonth=parseInt(tmpDateParts[1],10);
		tmpYear=parseInt(tmpDateParts[2],10);

		if (tmpMonth<1 || tmpMonth>12 || tmpDay>31 || tmpDay<1) { return(false); }
		if ((tmpYear % 4==0 && tmpYear % 100!=0) || tmpYear % 400==0) { months[1]=29; }
		if (tmpDay>months[tmpMonth-1]) { return(false);	}
		if (tmpYear<1900) {	return(false); }
		return(true);
	}
	
function isMail(string)
{
	if (string == "")
	{
		return(false);
	}
	else
	{
		valor = string;
		largo = valor.length;
		x = 0;
		for(i=0; i<largo; i++)
		{
			control = valor.substring(i,i+1);
			if (control == "@")
			{
				x = i;
			}
		}
		if (x == 0)
		{
			return(false);
		}
		else
		{
			valor1 = valor.substring(x + 1, valor.length);
			largo = valor1.length;
			x = 0;
			for (i=0; i<largo; i++)
			{
				control = valor1.substring(i,i+1);
				if (control == ".")
				{
						x = i;
				}
			}
			if (x == 0)
			{
				return(false);
			}
			else
			{
				if ((x+1) == largo)
				{
					return(false);
				}
				else
				{
					return(true);
				}
			}
		}
	}		
}


function isDate(id_date)
	{
		var tmpDate,tmpDateParts,tmpHourParts = new String;
		var tmpDay,tmpMonth,tmpYear,tmpHour,tmpMinute = new Number;
		var hasHour=new Boolean;
		var tmpSplit=new Array;
		var months=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
		var reDate=/^\d+\/\d+\/\d+$/;
		var reHour=/^\d+:\d+$/;
		
		Fecha1 = id_date
		if (Fecha1.substring(2,3) != "/" || Fecha1.substring(5,6) != "/" )
			{
				return(false);
			}
		
		
		tmpDate=DateInputFix(id_date);
		tmpSplit=tmpDate.split(" ");
		
		switch(tmpSplit.length)
			{
				case 1:
					hasHour=false;
					break;
				case 2:
					hasHour=true;
					break;
				default:
					return(false);
			}
		
		if (!reDate.test(tmpSplit[0])) { return(false); }
			
		tmpDateParts=tmpSplit[0].split("/");

		if (hasHour==true)
			{
				if (!reHour.test(tmpSplit[1])) { return(false);	}
				tmpHourParts=tmpSplit[1].split(":");
				tmpHour=parseInt(tmpHourParts[0],10);
				tmpMinute=parseInt(tmpHourParts[1],10);
		
				if (tmpHour<0 || tmpHour>24 || tmpMinute<0 || tmpMinute>59) { return(false); } 
			}
		tmpDay=parseInt(tmpDateParts[0],10);
		tmpMonth=parseInt(tmpDateParts[1],10);
		tmpYear=parseInt(tmpDateParts[2],10);

		if (tmpMonth<1 || tmpMonth>12 || tmpDay>31 || tmpDay<1) { return(false); }
		if ((tmpYear % 4==0 && tmpYear % 100!=0) || tmpYear % 400==0) { months[1]=29; }
		if (tmpDay>months[tmpMonth-1]) { return(false);	}
		if (tmpYear<1900) {	return(false); }
		return(true);
	}
	
	
	function comparaFecha(fechaMenor, fechaMayor)
		{
		strFecExpira = new String(fechaMayor);
		strFecPublic = new String(fechaMenor);
		ano1 = eval(strFecExpira.substr(6,4));
		mes1 = eval(strFecExpira.substr(3,2)) - 1;
  		dia1 = eval(strFecExpira.substr(0,2));
		fecExpira = new Date(ano1, mes1, dia1);
		ano2 = eval(strFecPublic.substr(6,4));
		mes2 = eval(strFecPublic.substr(3,2)) - 1;
		dia2 = eval(strFecPublic.substr(0,2));
		fecPublic = new Date(ano2, mes2, dia2);
		difMilSeg = fecExpira - fecPublic;
		if (difMilSeg < 0)
			return(false);
		else
			return(true);
		}
			

