		imagenesSeg = new Array();
		imagenesSegSel = new Array();
		nombresElementosSeg = new Array();
		
		var idSegSeleccionado;
		var idEstSeleccionado;
		idSegSeleccionado = "";
		idEstSeleccionado = "";
		var cargado = 0;
		
		
		function init(idCapa)
		{
			cargado = 1;
			var slideshowImages;
			var capaSlide;
			capaSlide = document.getElementById(idCapa);
			slideshowImages = capaSlide.getElementsByTagName('img');
			for(var no=0; no<slideshowImages.length; no++){
				n = imagenesSeg.length;
				imagenesSeg[n] = slideshowImages[no].src;
				var nombreImagen = slideshowImages[no].src;
				imagenesSegSel[n] = nombreImagen.replace(".gif","_sel.gif");
				nombresElementosSeg[n] = slideshowImages[no].id;
			}
		
			desActivarTodosSegmentos('');
		}
		function activarSegmento(idImg)
		{
			for(var no=0;no<nombresElementosSeg.length;no++){
				if (idImg == nombresElementosSeg[no])
				{
					document.getElementById(idImg).src = imagenesSegSel[no];
				}
			}
		}
		function CambiarSegmento(valor, idImg)
		{
			if(cargado==1)
			{
				if (idSegSeleccionado == idImg)
				{
					idSegSeleccionado ="";
					desActivarTodosSegmentos('segmento');
					vaciarHidden('idsegmento');
				}
				else
				{
					idSegSeleccionado = idImg;
					desActivarTodosSegmentos('segmento');
					activarSegmento(idImg);
					rellenarHidden('idsegmento', valor);
				}
			}
		}
		function CambiarEstiloVida(valor, idImg)
		{
			
			if(cargado==1)
			{
				if (idEstSeleccionado == idImg)
				{
					idEstSeleccionado ="";
					desActivarTodosSegmentos('estilosvida');
					vaciarHidden('idEstilo');
				}
				else
				{
					idEstSeleccionado = idImg;
					rellenarHidden('idEstilo', valor);
					desActivarTodosSegmentos('estilosvida');
					activarSegmento(idImg);
				}
			}
		}
		
		function desActivarTodosSegmentos(nombreSeccion)
		{
			for(var no=0;no<imagenesSeg.length;no++){
				if(nombreSeccion!='')
				{
					if (nombresElementosSeg[no].indexOf(nombreSeccion)>-1)
					{
					document.getElementById(nombresElementosSeg[no]).src = imagenesSeg[no];
					}
				}
				else
				{
					document.getElementById(nombresElementosSeg[no]).src = imagenesSeg[no];
				}
				
			}
		}
		function desActivarTodo()
		{
			for(var no=0;no<imagenesSeg.length;no++){

					if (nombresElementosSeg[no].indexOf('estilosvida')>-1)
					{
					document.getElementById(nombresElementosSeg[no]).src = imagenesSeg[no];
					}
					if (nombresElementosSeg[no].indexOf('segmento')>-1)
					{
					document.getElementById(nombresElementosSeg[no]).src = imagenesSeg[no];
					}
			}
		}
		
		function rellenarHidden(idElemento, valor)
		{
			document.getElementById(idElemento).value = valor;
		}
		function vaciarHidden(idElemento)
		{
			document.getElementById(idElemento).value = 0;
		}
