function imagenes(imagen){
	document.imggrande.src = "estudio/grandes/" + imagen;
}

function fecha(){	
	fech = new Date();
	calendario = fech.getDate();
	diasem = fech.getDay();
	mes = fech.getMonth();
	anio = fech.getYear();
	meses = new Array ("enero","febrero","marzo","abril","mayo","junio","julio","agosto","setiembre","octubre","noviembre","diciembre");
	dias = new Array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado")
	pongofecha.innerHTML=dias[diasem] + " " + calendario + " de " + meses[mes] + " de " + anio + "&nbsp;&nbsp;&nbsp;";
	setTimeout("fecha()",1000);	
}

  // ancho de imagen
var maxWidth=70;
  // alto de imagen
var maxHeight=70;
  
  // Tipos de archivo
var fileTypes=["bmp","gif","png","jpg","jpeg"];
  // id de la imagen de preview
var outImage="previewField";
  // imagen para mostrar en archivos no validos
var defaultPic="dot.gif";



function preview(what,cual){
  var source=what.value;
  var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
  for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
  globalPic=new Image();
  if (i<fileTypes.length) globalPic.src=source;
  else {
    globalPic.src=defaultPic;
    alert("THAT IS NOT A VALID IMAGE\nPlease load an image with an extention of one of the following:\n\n"+fileTypes.join(", "));
  }
  
  setTimeout("applyChanges("+cual+")",200);
}
var globalPic;

function applyChanges(cual){
	var item;
	item = "preview"+cual

	//alert(item)
  var field=document.getElementById(item);

  var x=parseInt(globalPic.width);
  var y=parseInt(globalPic.height);
  if (x>maxWidth) {
    y*=maxWidth/x;
    x=maxWidth;
  }
  if (y>maxHeight) {
    x*=maxHeight/y;
    y=maxHeight;
  }
  field.style.display=(x<1 || y<1)?"none":"";
  field.src=globalPic.src;
  field.width=x;
  field.height=y;
}



function validoContacto(theForm){
	error = "Se encontraron los siguientes errores : \n\n";
	ids = new Array();
	i=0;
	pass=true;

	if(theForm.txtnombre.value == ""){
		error += "-> No completó el campo Nombre y Apellido\n";
		ids[i] = "nombre";
		i++;
		pass = false;
	}
	
	if(theForm.txtcomentario.value == ""){
		error += "-> No completó el campo Comentario\n";
		ids[i] = "comentario";
		i++;
		pass = false;
	}
	
		
	if(theForm.txtemail.value == ""){
		error += "-> No completó el campo Email \n";
		ids[i] = "email";
		i++;
		pass = false;
	} else {
		var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
		
	  		if(! b.test(theForm.txtemail.value)){
	  			error += "-> Dirección de Email inválida. \n";
	  			ids[i] = "email";
	  			i++;
	  			pass = false;
		    }
		
	}
	if(theForm.tximseguridad.value == ""){
		error += "-> No completó la Imagen de seguridad\n";
		ids[i] = "txtimseguridad";
		i++;
		pass = false;
	}
	
	alert (pass);
	
	
		if(!pass){
			alert(error);
			for(j=0; j < ids.length ; j++){
				idactual = document.getElementById(ids[j]);
				idactual.className = "boxEntraMal";
			}

		} else {
			return true;
		}
		
}
