function slideSwitch() {
    var $active = $('#slideshow img.active');

    if ( $active.length == 0 ) $active = $('#slideshow img:last');
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow img:first');
	var $fondo = $next.attr('id').substr(1);
	$('.img').removeClass('on');
	$('#t' + $fondo).addClass('on');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
}

 $(function(){

 // Datepicker
 $('#fecha').datepicker({
 inline: true,

 monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
 dayNamesMin: ['Do', 'Lu', 'Ma', 'Mi', 'Ju', 'Vi', 'Sa'],
  dateFormat:'d/m/yy',
 buttonImage: 'images/icoCalendar.gif'
 });


$('.img').click(function(){
	var $fondo = $(this).attr('id').substr(1);

	$('#slideshow img').removeClass('active');
	
	$('#f' + $fondo).addClass('active');
	$('.img').removeClass('on');
	$('#t' + $fondo).addClass('on');
	
	//alert('#t' + $fondo);
	clearInterval(divswap);
	return false;
	
	/*
		$('#f' + $fondo).addClass('active').css({opacity: 0.0})
	        .addClass('active')
			.animate({opacity: 1.0}, 1000, function() {
            $('#slideshow img').not('#f' + $fondo).removeClass('active');
        });
	*/
});

    var divswap = setInterval( "slideSwitch()", 7000 );
 });
