document.observe('dom:loaded',function()
		{
			/*$$('a').each(function(el)
					{
						
						el.observe('click',function(ev)
								{	
									if(this.target=="")
									{
										$('ocultador').show();	
									}
								});
					});*/
			
			if($$('#cerrar_muro A'))
			{
				$$('#cerrar_muro A').each(function(el)
						{
							el.stopObserving('click');
							el.observe('click',function(ev)
							{
								ev.stop();
								$$('DIV[id$=_muro]').each(function(el)
										{
											el.hide();
										});
							});
						}
				);
			}
			
			if($('mensaje_flash'))
			{
					//alert($('flashMessage').innerHTML);
					$('enlace_cerrar_mensaje_flash').observe('click',function(ev){
						ev.stop();
						$('mensaje_flash').hide();
						$('ocultador_mensaje_flash').hide();
					});
			}
			
			if($('info_tipo'))
			{
				if($('info_tipo').getHeight()<=28)
				{
					$$('.ampliar_info')[0].hide();
				}
				else
				{
					$('desplegar_informacion').observe('click',desplegar($('info_tipo').getHeight()+20));
				}
			}
			
			if($('ver_en_pared'))
			{
				$('ver_en_pared').observe('click',function(ev)
						{
							ev.stop();
							pars = 'articulo_id=' + $('articulo_id').value;
							nueva_ventana('pared', $('url_ventana').value , pars, $('titulo_ventana').value, 700, 500, 0);
						});
			}
			
			$$('.ampliar_batik_personalizacion').each(function(el){
				el.observe('click',function(ev){
							ev.stop();
							//alert(this.readAttribute('rel'));
							nuevo_carrusel2('selector_batik','/articulos/obtener_asociados_json/' + this.readAttribute('rel'), 0, 'Album', 800, 800, 0);
				});
			});
			
			$$('.mostrar_info_tipo_producto').each(function(el)
				{
					el.observe('click', function(ev){
							ev.stop();
							nueva_ventana('mas_info', this.href, '', '', 700, 500, 1);
					});
				});
			
			$$('.mostrar_como_queda').each(function(el){
				el.observe('click', function(ev){
					ev.stop();
					nueva_ventana('como_queda', this.href, '', '', 600, 500, 1);
				});
			});
			
			$$('.titular_filtro').each(function(el)
			{
				el.observe('click',function(ev){
					ev.stop();
					//alert(el.next().id);
					//el.next().show();
					if(el.next().visible())
					{
						el.next().style.display = 'none';
						//Effect.BlindUp(el.next().id);	
					}
					else
					{
						el.next().style.display = '';
						//Effect.BlindDown(el.next().id);
					}
				});
			});
			
			$$('.show_tip').each(function(el)
			{
				var offset_x = 15;
				var alto = 0;
				el.observe('mouseover',function(ev)
				{
					//alert(this.readAttribute('rel'));
					var url = "/tips/obtener_tip/" + this.readAttribute('rel');
					new Ajax.Request(url,
							  {
							    method:'post',
							    onSuccess: function(transport)
							    	{
										$('contenido_tips').update(transport.responseText);
										alto = $('tips').getHeight();
										$('tips').show();
										$('tips').setStyle({'left': (ev.pointerX()+offset_x) + 'px', 'top': (ev.pointerY()-alto) + 'px'});
										
							    	},
								    onComplete:function()
								    {
							    		
								    }
							  });
				});
				
				el.observe('mouseout', function(ev){
					$('tips').hide();
				});
				
				el.observe('mousemove', function(ev){
					$('tips').setStyle({'left': (ev.pointerX()+offset_x) + 'px', 'top': (ev.pointerY()-alto) + 'px'});
				});
			});
			
			$$('#contenidoDinamico IMG').each(function(el){
				el.observe('click', function(ev){
					ev.stop();
					cadena = this.getAttribute('src').gsub('minis','grandes');
					$('capaImagenGrande').update('<img src="'+cadena+'" />');
					$('imagenGrande').show();
					$('ocultador').show();
				});
			});
			
			$('cerrarImagenGrande').observe('click', function(ev){
				ev.stop();
				$('imagenGrande').hide();
				$('ocultador').hide();
			});
			
			iniciar_enlaces_carrusel();
			
		});

function desplegar(ev, tamano)
{
	ev.stop();
	$$('.descripcion_tipo')[0].morph('height:'+tamano+'px;');
	this.update('Cerrar');
	this.observe('click',cerrar(ev,28));
}

function iniciar_enlaces_carrusel()
{
	$$('.galeria_fotografica').each(function(el)
			{
				el.observe('click',function(ev)
						{
							ev.stop();
							nuevo_carrusel('imagenes_producto', '', 500, 500);
						});
			});
	$$('.ampliar').each(function(el)
			{
				el.observe('click',function(ev)
				{
					ev.stop();
					//alert(this.readAttribute('rel'));
					nuevo_carrusel('imagenes_producto', '', 500, 500);
					//obtenemos las imágenes del articulo
				});
	
			});
}

