function cargarContenido(pSeccion, pIDRegistro)
{
	if(pSeccion == null) pSeccion = "noticias";
	var iHead = document.getElementById("imgHead");
	if(iHead) iHead.src = "images/" + m_sIdioma + "/img-" + pSeccion + ".jpg";
	var dContenido = document.getElementById("divContenido");
	if(dContenido)
	{
		dContenido.innerHTML = "<div align=\"center\"><img src=\"images/ajax-loader.gif\"></div>";
		if(pIDRegistro == undefined) pIDRegistro = 0;
		x_CargarContenido(pSeccion, pIDRegistro, function(pCadena)
			{
				dContenido.innerHTML = pCadena;
			});
	}
}

function validarUsuario(pUsuario, pClave)
{
	x_ValidarUsuario(pUsuario, pClave, function(pCadena)
		{
			if(pCadena == "S")
				cargarDescargas();
			else
				alert("Usuario o Clave incorrecto, inténtelo nuevamente");
		});
}

function cargarDescargas()
{
	var dDescargas = document.getElementById("divDescargas");
	if(dDescargas)
	{
		dDescargas.innerHTML = "<div align=\"center\"><img src=\"images/ajax-loader.gif\"></div>";
		x_CargarDescargas(function(pCadena)
			{
				dDescargas.innerHTML = pCadena;
			});
	}
}

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);
}

function enviarEmail(pAsunto, pContenido, pEmail, pNombre, pArchivo, pSeccion)
{
	x_EnviarEmail(pAsunto, pContenido, pEmail, pNombre, pArchivo, pSeccion, function(pCadena) {});
}

function cargarHistoria()
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: (m_sIdioma == "es" ? "Nuestra Historia" : "Our History") + " - Maglione | Hnos. & Cía. S. A.",
			width: 900,
			height: 295,
			draggable: true,
			resizable: false,
			recenterAuto: false,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true,
			showEffect: Element.show,
			hideEffect: Element.hide
		}
	);
	oVentana.showCenter(true);
	var oFlash = new SWFObject(m_sIdioma + "/s-history.swf", "", "900", "295", "7", "", true);
	with(oFlash)
	{
		addParam("menu", "false");
		write(oVentana.getContent().id);
	}
}

function cargarMapa()
{
	var oVentana = new Window(
		{
			className: "alphacube",
			title: (m_sIdioma == "es" ? "¿Cómo llegar" : "How to arrive") + "? - Maglione | Hnos. & Cía. S. A.",
			width: 964,
			height: 818,
			draggable: true,
			resizable: true,
			recenterAuto: false,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true,
			showEffect: Element.show,
			hideEffect: Element.hide
		}
	);
	oVentana.setAjaxContent("mapa.php", {cache: true}, true, true);
}

function cargarGmaps(pDesde)
{
	if(pDesde == null)
		$("divGmaps").innerHTML = "";
	else
	{
		var oFlash = new SWFObject("loader.swf", "", "799", "482", "7", "", true);
		with(oFlash)
		{
			addParam("menu", "false");
			addVariable("sKey", GMAP_API_KEY);
			addVariable("sFrom", pDesde);
			write("divGmaps");
		}
	}
}

function rotarNoticias()
{
	var dNoticia = $("noticia-" + m_lPosicion);
	if(!dNoticia)
	{
		m_lPosicion = 1;
		dNoticia = $("noticia-" + m_lPosicion);
	}
	if(dNoticia)
	{
		Effect.Fade("divVisor",
			{
			duration: 3.0,
			afterFinishInternal: function()
				{
					$("divVisor").innerHTML = dNoticia.innerHTML;
					Effect.Appear("divVisor", {duration: 3.0});
				}
			});
		setTimeout("rotarNoticias()", 15000);
		m_lPosicion++;
	}
}

function cargarEspecificaciones(pSeccion)
{
	var sTitle = (m_sIdioma == "es" ? "Especificación de Calidad" : "Quality Standards") + " - ";
	if(pSeccion == "blancheado")
		sTitle += (m_sIdioma == "es") ? "Blancheado" : "Balched";
	else
		sTitle += "Runner";
	var oVentana = new Window(
		{
			className: "alphacube",
			title: sTitle,
			width: (pSeccion == "blancheado") ? 458 : 452,
			height: (pSeccion == "blancheado") ? 562 : 615,
			draggable: true,
			resizable: false,
			recenterAuto: false,
			minimizable: false,
			maximizable: false,
			destroyOnClose: true,
			showEffect: Element.show,
			hideEffect: Element.hide
		}
	);
	oVentana.showCenter(true);
	oVentana.getContent().innerHTML = "<img src=\"images/" + m_sIdioma + "/table-especificacion-" + pSeccion + ".png\" />";
}
