function abre_album() {
	if ($('div.ampliar').css('display') == 'none') {
		alert_modal ('Lo sentimos. Este anuncio no dispone de fotos grandes');
		return false;
	} else {
		/* $('img.pag-sig,img.pag-ant').pngFix( { blankgif:'/images/x.gif' } ); */
		abrir_js ('light');
	}
	return false;
}

//////////////////////////////////////////////////////////////////////
// Financiación
$(function() {
	if (typeof(parametros_financiacion) != "undefined") {
		leerParametrosFinanciacion ();
		// Pinto el html de combo de meses en funcion de los valores
		$('select#meses').html(getHTMLmeses ());
		// Utilizo el número máximo de meses como valor actual
		$('select#meses').val($('select#meses>option:last').attr('value'));
		parametros_financiacion.meses_a_financiar = $('select#meses').val();
		// Prevenir comportamiento por defecto del formulario
		$('#test').submit(function(event){
			event.preventDefault();
		});
		// Establezco la función que maneja cualquier cambio en la financiación
		$('select#meses, select#quierecomision, input#entrada, select#proteccion').change(function () {
			recalcularFinanciacion();
			return false;
		});
		// Para el cálculo inicial
		recalcularFinanciacion();
		// Para audi, para poner la cuota inicial en la ficha
		$('#precioDesde').text($('#precio_cuota').text());
		// Borro la financiación si la antiguedad del coche + 12 es mayor de 108.
		if ((parseInt($('input#meses_ant').val()) + 12) > 108) {
			$('#financiacion, #boton_calcular, #desde_precio').remove();
		}
		// Activado en test 22/09/2010
		// $('#desde_precio').remove();
	}
});
//////////////////////////////////////////////////////////////////////

$(function() {
		$('ul.pestanas').pngFix( {
			blankgif : '/images/x.gif'
		});

		$('img.calcular').click(function() {
			$('div#financiacion').toggle("slow");
		});
		/*
		 * $('a#genera_cap').click(function() { genera_cap(); return false; });
		 */
		$('input#enviar_amigo').click(
				function() {
					xajax_enviar_amigo(xajax.getFormValues('light-amigo'), 'respuesta_enviar_amigo');
					return false;
				});

		$('a#link_amigo').click(function() {
			abrir_js('light-amigo');
			return false;
		});

		$('img.foto_peque').click(function() {
			var src_p = $(this).attr('src');
			var src_m = src_p.substring(4, src_p.length - 2);
			src_m = 'http' + src_m.replace('p', 'm') + 'pg';
			$('img#foto_med').attr('src', src_m);
		});

		$('img.imagen-album').click(function() {
			var src_p = $(this).attr('src');
			var src_g = src_p.substring(4, src_p.length - 2);
			src_g = 'http' + src_g.replace('p', 'g') + 'pg';
			$('img.imagen-pal').attr('src', src_g);
		});

		/* Album */
		$('img.pag-ant').click(function() {
			var cuantas = $('img.imagen-album').size();
			var fotos = new Array();
			$('img.imagen-album').map(function(index) {
				fotos[index] = this.src;
			});
			var ultima = cuantas - 1;
			var x;
			for (x = 0; x < cuantas; x++) {
				if (x == ultima) {
					$('img#foto_1').attr('src', fotos[ultima]);
				} else {
					var toca = parseInt(x) + 2;
					var src_toca = 'img#foto_' + toca;
					$(src_toca).attr('src', fotos[x]);
				}
			}
			return false;
		});

		$('img.pag-sig').click(function() {
			var cuantas = $('img.imagen-album').size();
			var fotos = new Array();
			$('img.imagen-album').map(function(index) {
				fotos[index] = this.src;
			});

			for (x in fotos) {
				if (x == 0) {
					$('img#foto_' + cuantas).attr('src', fotos[0]);
				}
				var toca = parseInt(x) + 1;
				var src_toca = 'img#foto_' + toca;
				$(src_toca).attr('src', fotos[toca]);
			}
			return false;

		});

		/* Ficha */
		$('img#fle_ant').click(function() {
			var cuantas = $('img.foto_peque').size();
			var fotos = new Array();
			$('img.foto_peque').map(function(index) {
				fotos[index] = this.src;
			});
			var ultima = cuantas - 1;
			var x;
			for (x = 0; x < cuantas; x++) {
				if (x == ultima) {
					$('img#foto_p_1').attr('src', fotos[ultima]);
				} else {
					var toca = parseInt(x) + 2;
					var src_toca = 'img#foto_p_' + toca;
					$(src_toca).attr('src', fotos[x]);
				}
			}
			return false;
		});

		$('img#fle_sig').click(function() {
			var cuantas = $('img.foto_peque').size();
			var fotos = new Array();
			$('img.foto_peque').map(function(index) {
				fotos[index] = this.src;
			});

			for (x in fotos) {
				if (x == 0) {
					$('img#foto_p_' + cuantas).attr('src', fotos[0]);
				}
				var toca = parseInt(x) + 1;
				var src_toca = 'img#foto_p_' + toca;
				$(src_toca).attr('src', fotos[toca]);
			}
			return false;
		});

		if ($('img.foto_peque').size() <= 3) {
			$('img#fle_sig,img#fle_ant').hide();
		}

		if ($('img.imagen-album').size() == 0) {
			$('div.ampliar').hide();
		}
	});

