function descomponerfecha(fe,tipo){
//	rutina javascript que descompone y valida una fecha recibida
// si tipo=0 en formato AAAA-MM-DD, tipo=2 formato MM/DD/AAAA, tipo=1 formato DD/MM/AAAA
	if (tipo==0){
		i=fe.search("-");	resto=fe.substr(i+1); j=resto.search("-");
		ano=fe.substr(0,i);	mes=fe.substr(i+1,j); dia=resto.substr(j+1);
	};
	if (tipo==1){
		i=fe.search("/");	resto=fe.substr(i+1); j=resto.search("/");
		dia=fe.substr(0,i);	mes=fe.substr(i+1,j); ano=resto.substr(j+1);
	};
	if (tipo==2){
		i=fe.search("/");	resto=fe.substr(i+1); j=resto.search("/");
		mes=fe.substr(0,i);	dia=fe.substr(i+1,j); ano=resto.substr(j+1);
	};
	
//	if (ano<100) ano='20'+toString(ano);
	if (ano<1900||ano>2030){return "MALA";};	
	if (mes<1||mes>12){return "MALA";};	
	if (dia<1||dia>31){return "MALA";};	
	if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0)) {bisiesto = 1;}else{bisiesto = 0;};
   if ((mes == 2) && (bisiesto == 1) && (dia > 29)) {return "MALA";};
   if ((mes == 2) && (bisiesto != 1) && (dia > 28)) {return "MALA";};
   if ((dia > 31) && ((mes == "01") || (mes == "03") || (mes == "05") || (mes == "07") || (mes == "08") || (mes == "10") || (mes == "12"))) {return "MALA";};
   if ((dia > 30) && ((mes == "04") || (mes == "06") || (mes == "09") || (mes == "11"))) {return "MALA";}	
   var fecha = new Date(ano,mes-1,dia);
   //alert(fecha);
	return fecha;
}