function VecImagenes()
{  
  this[1]="imagenes/foto1.jpg";
  this[2]="imagenes/foto2.jpg";
  this[3]="imagenes/foto3.jpg";
  this[4]="imagenes/foto4.jpg";
  this[5]="imagenes/foto5.jpg";
  this[6]="imagenes/foto6.jpg";
  this[7]="imagenes/foto7.jpg";
  this[8]="imagenes/foto8.jpg";
  this[9]="imagenes/foto9.jpg";
  this[10]="imagenes/foto10.jpg";
  this[11]="imagenes/foto11.jpg";  
  this[12]="imagenes/foto12.jpg";
  this[13]="imagenes/foto13.jpg";
  this[14]="imagenes/foto14.jpg";
  this[15]="imagenes/foto15.jpg";
  this[16]="imagenes/foto16.jpg";
  this[17]="imagenes/foto17.jpg";  
  this[18]="imagenes/foto18.jpg";
  this[19]="imagenes/foto19.jpg";
  this[20]="imagenes/foto20.jpg";
  this[21]="imagenes/foto21.jpg";
  this[22]="imagenes/foto22.jpg";
  this[23]="imagenes/foto23.jpg";
  this[24]="imagenes/foto24.jpg";  
}
function getImg(pos){
  var imgs=new VecImagenes();
  var hoje = new Date();
  var numero_de_imagens = 12;
  var segundos = hoje.getSeconds();
  var numero = ((segundos % numero_de_imagens)+1)*pos;    
  var div_imagenes = document.getElementById('imagenes');  
  var src_imagen = imgs[numero];
  var imagen = document.createElement('img');
  imagen.setAttribute('width','111');
  imagen.setAttribute('height','135');
  imagen.setAttribute('src',src_imagen);
  imagen.setAttribute('alt','Fotos de la clinica:'+numero);
  div_imagenes.appendChild(imagen);  
}
function Calcular() {

        var select_dia=document.getElementById('dia'); 
        var select_mes=document.getElementById('mes'); 
        var select_ano=document.getElementById('ano');    
        var dia = select_dia.value;
		var mes = select_mes.value;
		var ano = select_ano.value;
        var semanas_de_gestacion="";
  
        if ((dia!=0) && (mes!=0) && (ano!=0)) {  
        var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December"); 
	
        if (dia>getMaxDiaDelMesAo(mes-1, ano))
        semanas_de_gestacion="No se puede hacer el c&aacute;lculo de las semanas de gestaci&oacute;n porque a fecha no es v&aacute;lida en el calendario";
        else {	
        var furStr= montharray[mes-1] + " " + dia+ ", "+ano;  
        var  fur = new Date(furStr);			
        var  rason=6.5; 	  
        var  hoy = new Date();               
        var  timeold = (hoy.getTime() - fur.getTime());         
        var  sectimeold = timeold / 1000;         
        var  secondsold = Math.floor(sectimeold);         
        var  msPerDay = 24 * 60 * 60 * 1000 ;                
        var  e_daysold = timeold / msPerDay;         
        var  daysold = Math.floor(e_daysold);  	  
        if  (daysold<0) semanas_de_gestacion="No se puede hacer el c&aacute;lculo porque la fecha es mayor que la fecha actual";
        else  {	
        daysold+=1;
        if (daysold<=7) semanas_de_gestacion="Tiempo de gestacio&oacute;n:<br><br>"+daysold+" dia(s)";
        else { 		  
        var semanas=Math.floor(daysold / 7);
        var dias_de_gestacion=Math.floor(daysold-(semanas*7));	
        if (dias_de_gestacion<1) 
        var  semanas_de_gestacion ="Tiempo de gestaci&oacute;n:<br><br>"+semanas + " semana(s)";
        else  
        var  semanas_de_gestacion ="Tiempo de gestaci&oacute;n:<br><br>"+semanas + " semana(s) y "+dias_de_gestacion+" d&iacute;a(s)";		  
        }  
        }
        }
    
        }  
        document.getElementById('tiempogestacion').innerHTML = semanas_de_gestacion;  
}

function getMaxDiaDelMesAo(month, year) {
   var Dias_Mes = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
   if (Bisiesto(year)) Dias_Mes[1]=29;
     else Dias_Mes[1]=28;
   return Dias_Mes[month];
}
function Bisiesto(year) {
     if ((year % 4 == 0) && (( year % 100 != 0) || (year % 400 ==0))) return true;
     else return false;
}
function actualizarDiasMes(){
	var select_dias = document.getElementById('dia');
	var select_mes = document.getElementById('mes');
	var opciones = select_dias.getElementsByTagName('OPTION');
	for (var i=0;i<opciones.length-1;i++){
		 select_mes.removeChild();
	}
  
}
//Poner el ano actual y el anterior en el componente de calcular tiempo de gestacion
function ponerAnos(){
	var  Fecha = new Date();      
	var ano = Fecha.getYear();
	var mes = Fecha.getMonth()+1;
	var cadena_anyo = new String(ano)
	var es_IE = (document.all)? true:false;
	if (es_IE)
	 var anyo = '20' + cadena_anyo.substring(2,4)
	else var anyo = '20' + cadena_anyo.substring(1,3)
	var select_ano = document.getElementById('ano');
	var opcion = document.createElement('option');
	opcion.setAttribute('value',String(anyo));
	opcion.innerHTML = String(anyo);
	select_ano.appendChild(opcion);
	if (mes<9){
	  var opcion = document.createElement('option');
	  opcion.setAttribute('value',String(anyo-1));
	  opcion.innerHTML = String(anyo-1);
	  select_ano.appendChild(opcion);
	}
}

function FormatearHeigthTabla(){
var tabla=document.getElementById('tabla2Column'); 
if (window.innerHeight){
   //navegadores basados en mozilla
   tabla.style.height = String(window.innerHeight - 185)+"px";
}else{
   tabla.style.height = String(document.body.offsetHeight - 90)+"px";
}
}

