function ajustarAltoImagenesLaterales()
{
	var height = document.getElementById('izquierda').clientHeight - 0;
	document.getElementById('lateralizq').height = height;
	document.getElementById('lateralder').height = height;
}	

function Enfocar (Campo,Forma) 
{ 
	document.forms[Forma].elements[Campo].focus(); 
} 

function Validacion (Campo, Mensaje, Forma, Tipo, Cantidad, Longitud)
{
	switch (Tipo) 
	{
		case 'Combo': 
			if (document.forms[Forma].elements[Campo].selectedIndex == 0)
			{
				alert( 'Se debe seleccionar ' + Mensaje);
				Enfocar(Campo,Forma);
				return false;
			}
			break;
		case 'Opcion': 
			Marcado = false;
			for (i=0; i<Cantidad; i++)
			{
				if (document.forms[Forma].elements[Campo][i].checked)
					
				{
					Marcado = true;
				}
			}
			if (!(Marcado))	
			{
				alert('Se debe indicar ' + Mensaje);
				return false;
			}	
			break;
		case 'Marca': 
			Marcado = false;
			for (i=0; i<Cantidad; i++)
			{
				if (document.forms[Forma].elements[Campo][i].checked)
					
				{
					Marcado = true;
				}
			}
			if (!(Marcado))	
			{
				alert('Se debe indicar ' + Mensaje);
				return false;
			}	
			break;
		case 'Texto': 
			if (document.forms[Forma].elements[Campo].value == "" || document.forms[Forma].elements[Campo].value.length == 0)
			{
				alert( 'Se debe indicar ' + Mensaje);
				Enfocar(Campo,Forma);
				return false;
			}
			break;
		case 'TextoHtmlArea': 
			if (document.forms[Forma].elements[Campo].value == "")
			{
				alert( 'Se debe indicar ' + Mensaje);
				return false;
			}
			break;
		case 'TextoLongitudMayor':
			if (document.forms[Forma].elements[Campo].value.length < Longitud)
			{
				alert( Mensaje + ' debe ser mayor o igual que ' + Longitud);
				Enfocar(Campo,Forma);
				return false;
			}
			break;
		case 'TextoLongitudMenorHtmlArea':
			if (document.forms[Forma].elements[Campo].value.length > Longitud)
			{
				alert( Mensaje + ' debe ser menor o igual que ' + Longitud);
				return false;
			}
			break;
		case 'TextoLongitudMenor':
			if (document.forms[Forma].elements[Campo].value.length > Longitud)
			{
				alert( Mensaje + ' debe ser menor o igual que ' + Longitud);
				Enfocar(Campo,Forma);
				return false;
			}
			break;
		case 'Numero': 
			var numValor = new Number(document.forms[Forma].elements[Campo].value) ;
			var er_numero =/[0-9]+/;
			if (isNaN(numValor) || (numValor < 1) || !(er_numero.test(numValor)))
			{
				alert( Mensaje + ' debe ser un valor numérico');
				Enfocar(Campo,Forma);
				return false;
			}
			break;
		case 'Correo': 
			if (document.forms[Forma].elements[Campo].value.search("@") == -1)
			{
				alert( 'Correo electrónico NO válido');
				Enfocar(Campo,Forma);
				return false;
			}
			break;
	}
	return true;
}


function mostrarNombreMes(mes)
{
	var	nombre = '';
	switch (mes) 
	{
		case 1:
				nombre = 'Enero';
				break;
		case 2:
				nombre = 'Febrero';
				break;
		case 3:
				nombre = 'Marzo';
				break;
		case 4:
				nombre = 'Abril';
				break;
		case 5:
				nombre = 'Mayo';
				break;
		case 6:
				nombre = 'Junio';
				break;
		case 7:
				nombre = 'Julio';
				break;
		case 8:
				nombre = 'Agosto';
				break;
		case 9:
				nombre = 'Septiembre';
				break;
		case 10:
				nombre = 'Octubre';
				break;
		case 11:
				nombre = 'Noviembre';
				break;
		case 12:
				nombre = 'Diciembre';
				break;
	}

	return nombre;
}

function mostrarNombreDiaSemana(diasemana)
{
	var	nombre = '';
	switch (diasemana) 
	{
		case 0:
				nombre = 'Domingo';
				break;
		case 1:
				nombre = 'Lunes';
				break;
		case 2:
				nombre = 'Martes';
				break;
		case 3:
				nombre = 'Miércoles';
				break;
		case 4:
				nombre = 'Jueves';
				break;
		case 5:
				nombre = 'Viernes';
				break;
		case 6:
				nombre = 'Sábado';
				break;
	}

	return nombre;
}

function mostrarFechaActual()
{
	var fecha=new Date();
	var diames=fecha.getDate();
	var diasemana=mostrarNombreDiaSemana(fecha.getDay());
	var mes=mostrarNombreMes(fecha.getMonth() + 1 );
	var ano=fecha.getFullYear();
	document.write(diasemana + ' ' + diames + ' de ' + mes + ' de ' + ano);

}

function limpiarCampo(campo)
{
	campo.value ="";	
}

function mostrarCiudad()
{
	var idPais= document.getElementById("lstPaises").value;
	var ciudad = document.getElementById("ciudad");
	if (idPais != 0)
	{
		if (!(ciudad.style.visibility == "visible"))
		{
			ciudad.style.visibility = "visible";
		}
		if (idPais == 1)
		{
				document.getElementById("divLstCiudad").style.display = "block";
				document.getElementById("divTxtCiudad").style.display = "none";
		}
		else
		{
			document.getElementById("divLstCiudad").style.display = "none";
			document.getElementById("divTxtCiudad").style.display = "block";					
		}
	}
	else
	{
		ciudad.style.visibility = "hidden";
	}
}

function cambiaImagen(indice)
{
		document.getElementById("fotoGaleria").src = "images/fotos/" + arrImagenes[indice];

		indiceActual = indice;
		if (indiceActual >= totalImagenes)
		{
			document.getElementById("siguiente").style.visibility = "hidden";
		}
		else
		{
			document.getElementById("siguiente").style.visibility = "visible";			
		}			
		if (indiceActual > 0)
		{
			document.getElementById("anterior").style.visibility = "visible";
		}
		else 
		{
			document.getElementById("anterior").style.visibility = "hidden";				
		}
}

function expandirFoto()
{
	imagen = new Image();
	imagen.src ="images/fotos/" + arrImagenes[indiceActual];
	fotoSource=imagen.src;
	foto=imagen;
    newWindow=window.open(fotoSource,'newWin','toolbar=no,location=no,status=no,menubar=no,width='+foto.width+',height='+foto.height);
    newWindow.document.write('<html><head><title>Galería de Fotos<\/title><\/head><body background="'+fotoSource+'"><\/body><\/html>');
    newWindow.resizeBy(foto.width-newWindow.document.body.clientWidth,foto.height-newWindow.document.body.clientHeight);
    newWindow.focus();
}

function abrirMapaGoogle()
{
    newWindow=window.open('html/mapa_google.html','MapaGoogle','toolbar=no,location=no,status=no,menubar=no,width=500,height=250');
    newWindow.focus();
}