
Main.CambiarIdioma = function (iLng)
{
	var Ajax = new TAjax ()
	
	Ajax.onCargar  = function (oPeticion) { window.location = oPeticion.asText (); }
	Ajax.Vars.Lng  = iLng
	Ajax.Vars.Path = window.location.pathname;
	Ajax.Cargar ('/fuentes/cambiaridioma.php');
}


Main.Idioma = function (iLng, sEs, sEn, sFr)
{
	if (iLng == 3 && sFr) return (sFr);
	else if (iLng == 2 && sEn) return (sEn);
	return (sEs);
}


Main.InitMenus = function  (aURL)
{
	if (aURL.length == 1 && aURL [0] == '') Main.$ ('idMen_inicio', 'className', 'Seleccionado');
	for (var i = aURL.length - 1; i >= 0; i--)
	 Main.$ ('idMen' + (i ? i : '') + '_' + aURL [i], 'className', 'Seleccionado');
}


Main.Noticia = function (iId, iLng)
{
	var Ventana = new TWindow ();
	
	Ventana.ClickVelo = true;
	Ventana.Vars.Id   = iId;
	Ventana.Vars.Lng  = iLng;
	Ventana.Scrolls   = false;
 	Ventana.Cargar ('/fuentes/noticia.php');
}


Main.Video = function (iId)
{
	var Ventana = new TWindow ();
	
	Ventana.ClickVelo = true;
	Ventana.Vars.Id   = iId;
	Ventana.Scrolls   = false;
 	Ventana.Cargar ('/fuentes/video.php');
}


function Main ()
{
}


//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////

function AvisoLegal ()
{
	var Ventana = new TVentana ();

	Ventana.Ancho       = 550;
	Ventana.Alto        = 400;
	Ventana.Nombre      = 'AvisoLegal';
	Ventana.URL         = '/fuentes/avisolegal.php';
	Ventana.Open (true);
}


function Lopd ()
{
	var Ventana = new TVentana ();

	Ventana.Ancho       = 550;
	Ventana.Alto        = 300;
	Ventana.Nombre      = 'AvisoLegal';
	Ventana.URL         = '/fuentes/avisolegal.php?Lopd=1';
	Ventana.Open (true);
}






function VerEnlace (Enlace)
{
	var Ventana = new TVentana;

	Ventana.Ancho         = 550;
	Ventana.Alto          = 400;
	Ventana.Redimensionar = true;
	Ventana.Nombre        = 'Informacion';
	Ventana.URL           = Enlace;
	Ventana.Open (true);
}


function EnviarOferta (oFormulario)
{
	var Ajax = new TAjax ();
	var Pais = RadioValue (oFormulario.PaisOferta).asInteger ();

	if (Formulario.Validar (oFormulario))
	{
		if (Pais == 1 && oFormulario.slcProvinciaEs.value.asInteger () <= 0)
		{	alert ('Tiene que indicar una provincia.');
			oFormulario.slcProvinciaEs.focus ();
		} else if ((Pais == 2) && (oFormulario.slcProvinciaFr.value.asInteger () <= 0))
		{	alert ('Tiene que indicar una provincia.');
			oFormulario.slcProvinciaFr.focus ();
		} else
		{	Ajax.onCargar = function () 
												{ 
													window.location = '/fuentes/oferta.php?Articulo=' + oFormulario.Articulo.value + '&ok=1&Lng=' + Lng;
												}
			Ajax.Formulario (oFormulario);
			Ajax.Cargar ('/fuentes/enviaroferta.php');
		}
	}


}

function SolicitarDocumentacion (oFormulario)
{
	var Ajax = new TAjax ();

	if (Formulario.Validar (oFormulario))
	{
		Ajax.onCargar = function () { Main.$ ('idEnvio', 'style.display', 'none'); Main.$ ('idEnvioOK', 'style.display', 'block'); }
		Ajax.Formulario (oFormulario);
		Ajax.Cargar ('/fuentes/enviarsolicitud.php');
	}
}


function Idioma (Lng, Esp, Fr, Ing)
{
	Main.Idioma (Lng, Esp, Fr, Ing);
}


Main.Contacto = function (oFormulario, iLng)
{
	var Ajax = new TAjax ();

	if (Formulario.Validar (oFormulario))
	{	if (oFormulario.Lopd.checked)
		{	Ajax.onCargar = function () 
											{ 
												window.location = window.location + '/ok';
											}
			Ajax.Formulario (oFormulario);
			Ajax.Cargar ('/fuentes/contacto.php');
		} else alert (Main.Idioma (iLng, 'Tiene que aceptar la política de privacidad y confidencialidad', 
			                               'You must accept the privacy and confidentiality', 
			                               'Vous devez accepter la vie privée et la confidentialité'));
	}
}

Main.$ = function ()
{
	var Aux  = document.getElementById (arguments [0]);
	var Pars = null;
	
	switch (arguments.length)
	{	case 1: return Aux;
		case 2: return Aux ? Aux [arguments [1]] : null;
		case 3: 
			if (Aux) 
			{	Pars = arguments [1].split ('.');
				for (var i = 0; i < Pars.length - 1; i++) Aux = Aux [Pars [i]];
			  Aux [Pars [i]] = arguments [2]; 
			}
			break;
		default: alert ('$, número de parámetros incorrectos.');
	}
}


Main.FactorServicio = function (iLng)
{
	var Ventana = new TWindow ();
	
	Ventana.ClickVelo = true;
	Ventana.Vars.Lng  = iLng;
	Ventana.Scrolls   = false;
 	Ventana.Cargar ('/fuentes/factorservicio.php');
}

