var m_aTextos = {"es": [], "en": []};
m_aTextos["es"] = {
	"apellido-requerido": "Por favor, ingrese su apellido",
	"nombre-requerido": "Por favor, ingrese su nombre",
	"email-requerido": "Por favor, ingrese un emal valido",
	"pais-requerido": "Por favor, ingrese su pais",
	"mensaje-requerido": "Por favor, ingrese su mensaje",
	"contacto-mensaje": "Su mensaje ha sido enviado."
	};

m_aTextos["en"] = {
	"apellido-requerido": "Last name is required",
	"nombre-requerido": "First name is required",
	"email-requerido": "Email is invalid",
	"pais-requerido": "Country is required",
	"mensaje-requerido": "Message is required",
	"contacto-mensaje": "Your message has been sent.\n"
	};


function enviarContacto(pForm, pIdioma)
{
	with(pForm)
	{
		if(nombre.value.length > 0)
		{
			if(validarEmail(email.value))
			{
						if(mensaje.value.length > 0)
						{
							submit();
						}
						else
						{
							alert(m_aTextos[pIdioma]["mensaje-requerido"]);
							mensaje.focus();
						}
			}
			else
			{
				alert(m_aTextos[pIdioma]["email-requerido"]);
				email.focus();
			}
		}
		else
		{
			alert(m_aTextos[pIdioma]["nombre-requerido"]);
			nombre.focus();
		}
	}
	return false;
}

function enviarContactoFull(pForm, pIdioma)
{
	with(pForm)
	{
		if(apellido.value.length > 0 && nombre.value.length > 0)
		{
			if(validarEmail(email.value))
			{
				if(pais.value.length > 1)
				{
						if(mensaje.value.length > 0)
						{
							submit();
						}
						else
						{
							alert(m_aTextos[pIdioma]["mensaje-requerido"]);
							mensaje.focus();
						}
					}
					else
					{
						alert(m_aTextos[pIdioma]["pais-requerido"]);
						pais.focus();
					}
			}
			else
			{
				alert(m_aTextos[pIdioma]["email-requerido"]);
				email.focus();
			}
		}
		else
		{
			alert(m_aTextos[pIdioma]["apellido-requerido"]);
			apellido.focus();
		}
	}
	return false;
}

function validarEmail(pEmail)
{
	var oRegExp = /^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	return oRegExp.test(pEmail);
}

/***** AMPLIAR IMAGEN *****/
function abrirImagen(pIDNoticia, pArchivo, pAncho, pAlto)
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: "LTi News",
			width: pAncho,
			height: pAlto,
			left: 200,
			top: 150,
			draggable: true,
			resizable: true,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true
		}
	);
	oVentana.show();
	var sURL = "ver-imagen.php?idregistro=" + pIDNoticia + "&archivo=" + pArchivo;
	oVentana.setAjaxContent(sURL);
}

/***** MOSTRAR CAPA *****/
function mostrar(capa){
  var obj = document.getElementById(capa)
  if(obj.className== "oculto")  obj.className= "visible";
  else obj.className= "oculto";
}

/***** galeria de imagenes *****/
function visualizarImagen(pTitulo, pDescripcion)
{
	var oDestino;
	oDestino = document.getElementById("imgTitulo");
	oDestino.innerHTML = pTitulo;
	oDestino = document.getElementById("imgDesc");
	oDestino.innerHTML = pDescripcion;
}

/***** contacto *****/
function cargarContacto(pSelect)
{
  var contacto = pSelect.options[pSelect.selectedIndex].value;
  var tDestino = document.getElementById("infoContacto-"+contacto);
  var otros;
	
	for (var i = 0; i< pSelect.options.length; i++)
	{
		otros = document.getElementById("infoContacto-"+pSelect.options[i].value);
		otros.className = "oculto";
	}
	tDestino.className = "visible";
}

/***** FECHA *****/
function retornarFecha(pDestino, pIdioma)
{
	var aDias;
	if (pIdioma == "es")
		aDias = new Array("Domingo", "Lunes", "Martes", "Mi&eacute;rcoles",  "Jueves", "Viernes", "S&aacute;bado")
	else
		aDias = new Array("Sunday", "Monday", "Tuesday", "Wednesday",  "Thursday", "Friday", "Saturday");
	
	
	var dFecha = new Date();
	with(dFecha)
	{
		var lIDDia = getDay();
		var sDia = new String(getDate());
		var sMes = new String(getMonth() + 1);
		var lAno = getYear();
}

	if(sDia.length == 1) sDia = "0" + sDia;
	if(sMes.length == 1) sMes = "0" + sMes;
	if(lAno < 1900) lAno += 1900;
	
	pDestino = document.getElementById(pDestino);
	if(pDestino)
	{
		if (pIdioma == "en")
			pDestino.innerHTML = aDias[lIDDia] + ", " + sMes + "." + sDia + "." + lAno
		else
			pDestino.innerHTML = aDias[lIDDia] + ", " + sDia + "." + sMes + "." + lAno;
	}
}

/***SUBMENU ******************************************/
function mostrarSubmenu(capa){
  var obj = document.getElementById(capa)
  if(obj.style.visibility== "hidden")  obj.style.visibility= "visible";
}
function ocultarSubmenu(capa){
  var obj = document.getElementById(capa)
  if(obj.style.visibility== "visible")  obj.style.visibility= "hidden";
}
function mostrar2(capa){
  var obj = document.getElementById(capa)
  if(obj.className== "oculto")  obj.className= "visible";
}
function ocultar2(capa){
  var obj = document.getElementById(capa)
  if(obj.className== "visible")  obj.className= "oculto";
}

function esperar(espera){
	string="ocultar2('"+ espera +"');";
	setTimeout(string, 5000);
}

function jumpMenu(targ, url, selObj,restore){ //v3.0

	var direccion = "?" + url;
	if (url != "") direccion += "&";
	direccion += "lang="+selObj.options[selObj.selectedIndex].value;

  eval(targ+".location='"+direccion+"'");
  if (restore) selObj.selectedIndex=0;
}
