
Main.Bloque = function (iId)
{
	var Efecto = idEfecto ('idBloque' + iId);
	

	Efecto.Ident = iId;
	Efecto.Vertical ();
}

function onBloque (oEfecto)
{
	var Efecto = idEfecto ('idBloque' + oEfecto.Ident);
	
	Efecto.Vertical ();
}

Main.Foto = function (iFoto, iLng)
{
	var Ventana = new TVentanas ();

	Ventana.Tipo           = 2;
	Ventana.Ancho          = 845;
	Ventana.Alto           = 610;
	Ventana.BarraScroll    = false;
	Ventana.Vars.Navegar   = false;
	Ventana.Vars.Id        = iFoto;
	Ventana.Vars.Lng       = iLng;
	Ventana.Vars.Plantilla = 'plantillas/tpls/galeriavisor.tpl';
	Ventana.onCargar       = function (oVentana) 
														{ 
															var Img  = document.createElement ('img');
															var Ajax = new TAjax ();
		
	 														$ ('idPiePanoramica', 'style.display', 'none');
															Img.id  = 'idFotoGaleria';
															Img.src = '/contenidos/fotos/' + iFoto + '-1.jpg';
															$ ('idVisorGaleria').appendChild (Img);

															$ ('idTituloCargando', 'style.display', '');	
															$ ('idTituloFoto', 'innerHTML', '');
	
															Ajax.onCargar = function (oPeticion)
															{
																$ ('idTituloCargando', 'style.display', 'none');	
																$ ('idTituloFoto', 'innerHTML', oPeticion.asText ());
															}
															Ajax.Vars.Id  = iFoto;
															Ajax.Vars.Lng = iLng;
															Ajax.Cargar ('/fuentes/piefoto.php');
														}
	Ventana.Cargar ();
}


Main.Idioma  = function (iLng, sEsp, sIng)
{ 
	if (iLng == 2 && sIng) return sIng;
	return sEsp;
}


Main.InfoCallejero = function (sURL, iId, sDescr)
{
	window.location = sURL + '/' + iId + '/' + sDescr;
}


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


Main.Localizador = function (iCat, iPan)
{
	switch (iCat)
	{	case 0:  return iPan ? GM.PANORAMICA : GM.FOTO;
		case 1:  return GM.ALOJAMIENTO;
		case 2:  return GM.RESTAURANTE;
		case 3:  return GM.DEPORTE;
		case 4:  return GM.CULTURA;
		case 5:  return GM.INTERES;
		case 6:  return GM.SERVICIOS;
		case 7:  return GM.OCIO;
		case 8:  return GM.COMERCIO;
		default: return GM.LOCALIZADOR;
	}
}


Main.Lopd = function (iLng)
{
	var Ventana = new TVentanas ();

	Ventana.Tipo           = 2;
	Ventana.Ancho          = 700;
	Ventana.Alto           = 400;
	Ventana.BarraScroll    = true;
	Ventana.Vars.Plantilla = iLng == 2 ? 'plantillas/en/otros/ventanalopd.tpl' : 'plantillas/es/otros/ventanalopd.tpl';
	Ventana.Cargar ();
}


Main.MapaServicio = function (sTitulo, fLongitud, fLatitud)
{
	var Ventana = new TVentanas ();

	Ventana.Tipo        = 2;
	Ventana.Ancho       = 540;
	Ventana.Alto        = 540;
	Ventana.BarraScroll = false;

	Ventana.onCargar   = function (oVentana)
												{		
											 		var Mapa = new GMMap (oVentana.Contenedor);
											 		
												 	Mapa.Zoom = 16;
													if (fLongitud && fLatitud)
													{	Mapa.Longitud = fLongitud;
														Mapa.Latitud  = fLatitud;
														Mapa.onCargar = function (oMap) { oMap.Marca (new GMMarca (fLatitud, fLongitud)); }
													}
													Mapa.Cargar ();
												}
	Ventana.Cargar  ();
}


Main.MapaServiciosOn = function (oMap, iCategoria, sURL)
{
	var Ajax = new TAjax ();

	Ajax.onCargar       = function (oPeticion)
												{	
													var Datos = DataSet (oPeticion.asText (), 'DATOS');

													Datos.First ();
													while (! Datos.Eof ())
													{	Marca          = new GMMarca ();
														Marca.Latitud  = Datos.asFloat ('Latitud');
														Marca.Longitud = Datos.asFloat ('Longitud');
														Marca.HTML     = Datos.ByName ('Descripcion');
														Marca.Icono    = iCategoria ? Main.Localizador (iCategoria) : Main.Localizador (iCategoria, Datos.asInteger ('Panoramica'));
														if (iCategoria)
															Marca.HTML = '<div style="height: 150px;"><img src="/contenidos/servicios/' + Datos.ByName ('Foto') +
		               												 '" height="95"><br /><strong>' + Datos.ByName ('Descripcion') + '</strong><br /><br />' +
		               												 '<a href="javascript:Main.InfoCallejero (\'' + sURL + '\',' + Datos.asInteger ('Id') + ',\'' + 
		               												 Datos.ByName ('Descripcion').replace ('\'', '\\\'') + '\')">+ informaci&oacute;n</a><br /></div>';
														else
															Marca.HTML = '<div style="height: 150px;" align="center">' +
			                                     '<a href="javascript:Main.VerFoto (' + Datos.asInteger ('Id') + ')"><img src="/contenidos/fotos/' + Datos.ByName ('Foto') +
		                                       '" height="125"></a></div>';

														oMap.Marca (Marca);
														Datos.Next ();
													}
												}
	Ajax.Vars.Categoria = iCategoria ? iCategoria : -1;
	Ajax.Cargar ('/fuentes/callejero.php');
}


Main.Panoramica = function (iFoto, iLng)
{
	var Ventana = new TVentanas ();

	Ventana.Tipo           = 2;
	Ventana.Ancho          = 845;
	Ventana.Alto           = 610;
	Ventana.BarraScroll    = false;
	Ventana.Vars.Navegar   = false;
	Ventana.Vars.Id        = iFoto;
	Ventana.Vars.Idioma    = iLng;
	Ventana.Vars.Plantilla = 'plantillas/tpls/galeriavisor.tpl';
	Ventana.onCargar       = function (oVentana) 
														{ 
	 														var oPano = new TPano ();
	 														var Ajax  = new TAjax ();
	 														$ ('idPiePanoramica', 'style.display', '');
	 		
	 														oPano.Ancho      = 800;
	 														oPano.Alto       = 535;
	 														oPano.Panoramica = '/contenidos/panoramicas/' + iFoto + '.xml';
	 														oPano.Cargar ('idVisorGaleria');

															$ ('idTituloCargando', 'style.display', '');	
															$ ('idTituloFoto', 'innerHTML', '');
	
															Ajax.onCargar = function (oPeticion)
															{
																$ ('idTituloCargando', 'style.display', 'none');	
																$ ('idTituloFoto', 'innerHTML', oPeticion.asText ());
															}
															Ajax.Vars.Id  = iFoto;
															Ajax.Vars.Lng = iLng;
															Ajax.Cargar ('/fuentes/piefoto.php');
														}
	Ventana.Cargar ();
}


function Main ()
{
}

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


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

	Ventana.Ancho       = 600;
	Ventana.Alto        = 400;
	Ventana.Nombre      = 'Regístrate';
	Ventana.URL         = '/es/plantillas/login.html';
	Ventana.Open (true);
}


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

	Ventana.Ancho       = 600;
	Ventana.Alto        = 400;
	Ventana.Nombre      = 'Regístrate';
	Ventana.URL         = '/es/plantillas/registrate.html';
	Ventana.Open (true);
}


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

	if (ValidarFormulario (oFormulario))
	{ if (oFormulario.Lopd.checked) {
			Ajax.onCargar = function () { $ ('idFormulario', 'style.display', 'none'); $ ('idEnvioOK', 'style.display', 'block'); }
			Ajax.Formulario (oFormulario);
			Ajax.Cargar ('/fuentes/enviarcontacto.php');
	  } else alert ('Debe aceptar la política de privacidad y confidencialidad.');
	}
}


function EnviarAmigo (iLng)
{
	var Ventana = new TVentanas ();
	
	Ventana.Tipo  = 2;
	
 	Ventana.Ancho = 460;
 	Ventana.Alto  = 350;
 	Ventana.Vars.Plantilla = '/plantillas/tpls/agenda/enviaramigo.tpl';
	Ventana.Vars.Par1 = iLng;
	Ventana.Cargar ();
}


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

	if (Formulario.Validar (oFormulario))
	{	if (! oFormulario.Lopd.checked) 
			alert (Main.Idioma (oFormulario.Idioma.value, 'Debe aceptar la política de privacidad y confidencialidad.', 'You must agree to the privacy and confidentiality policy.'));
		else
		{	Ajax.onCargar = function (oPeticion) 
										{ TVentanas.Cerrar ();
											alert (Main.Idioma (oFormulario.Idioma.value, 'Su invitación ha sido enviada.' , 'Your invitation has been sent.'));
										}
			Ajax.Formulario (oFormulario);
			Ajax.Vars.Enlace = window.location;
			Ajax.Cargar ('/fuentes/enviaramigo.php');
		}
	}
}
   

