$(document).ready(function(){
	
	$('.imagen-ocultar').css('cursor', 'pointer');

	function mostrarCaption(){

/*		$('.nivo-caption').css( 'background-color','black');*/
		$('.nivo-caption').css( 'background-color','transparent');
/*	PARA MOSTRAR SÓLO UN CACHO DE FONDO ABAJO	*/
/*		$('.nivo-caption').css( 'background-image','url('+base_url+'js/carrusel/bg_low.png)');
		$('.nivo-caption').css( 'background-position','bottom');
		$('.nivo-caption').css( 'background-repeat','repeat-x');*/
		$('.nivo-caption .imagen-ocultar').html('&#60;');
		$('.nivo-caption .imagen-ocultar').css('padding-right', '0.5em');
		$('.nivo-caption .imagen-ocultar').css('padding-left', '0.5em');
		$('.nivo-caption .imagen-ocultar').css('color', '#999999');
		$('.nivo-caption .imagen-ocultar').css('background-color', 'inherit');
	}


	function ocultarCaption(){
		$('.nivo-caption').animate({
			width: '20px'
		}, 1000, function(){
			$('.nivo-caption').css( 'background-color','transparent');
			$('.nivo-caption .imagen-ocultar').html('&#62;');
			$('.nivo-caption .imagen-ocultar').css('padding-right', '0.2em');
			$('.nivo-caption .imagen-ocultar').css('padding-left', '0.2em');
			$('.nivo-caption .imagen-ocultar').css('position', 'relative');
			$('.nivo-caption .imagen-ocultar').css('left', '0.2em');
			$('.nivo-caption .imagen-ocultar').css('color', 'black');
			$('.nivo-caption .imagen-ocultar').css('background-color', '#999999');
		});
		
	}


    
	$('#slider').nivoSlider({
		effect:'random', //Specify sets like: 'fold,fade,sliceDown'
		slices:15,
		animSpeed:500,
		pauseTime:3000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next &#038; Prev
		directionNavHide:false, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsFromRel:false, //Use image rel for thumbs
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:true, //Use left &#038; right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:true, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){mostrarCaption();},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
    
    
    
	$(".imagen-ocultar").live("click", function(){//$('.imagen-ocultar').click(function(){
		$(this).parent().find('ul').toggle();
        
		if  ($('.nivo-caption').css('width') == '20px' )
			mostrarCaption();
		else
			ocultarCaption();
	});
});
