		var imgAlt;
		var imgTitle;
		var numero_comentarios;
		var tipodeflash;
		var imgDesc="";
		var clase;
		var imgDescHeight;
    var actual=0;
    var mostrandose=0;			
		
		cambiartimer = function(){
			//Animate the Teaser        
      if (actual!=mostrandose){			
			$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {			
				$(".main_image .block").html(imgDesc).animate({ opacity: 0.85,	marginBottom: "0" }, 250 );
				$(".main_image #comentariosflash").html(numero_comentarios);
				$(".main_image #tipoflash").removeClass();
				$(".main_image #tipoflash").addClass(tipodeflash);
				$(".main_image img").attr({ src: imgTitle , alt: imgAlt});
	    $("#categoriaflash").removeClass();
      $("#categoriaflash").addClass(clase); //Show Banner
		
	    $("#infoadicional").removeClass();
      $("#infoadicional").addClass(clase); //Show Banner				
			});                                                         
			mostrandose=actual;
			}
		//$(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists
		//$(this).addClass('active');  //add class of 'active' on this list only
		return false;			
    }


  jQuery.fn.flash = function( color, duration )
  {
    var current = $(this).css( 'color' );
    $(this).animate( { color: 'rgb(' + color + ')' }, duration / 2 );
    $(this).animate( { color: current }, duration / 2 );
  }


	var intervalobreve=function(){
    window.setTimeout(function() {
    cambiartimer();
    intervalobreve();
    }, 500);	
  }

   var cambiarFlash = function(){                 
		if ($(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
		  imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		  imgTitle = $(this).find('a').attr("href"); //Get Main Image URL
		  numero_comentarios = $(this).find('.numero_comentarios').html(); //Get numero de comentarios
		  tipodeflash = $(this).find('.tipodeflash').html(); //Get numero de comentarios
		  actual = $(this).find('.numero_item_flash').html(); //Get numero de comentarios
		  imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		  clase=$(this).attr('class');
		  imgDescHeight = $(".main_image").find('.block').height();	//Calculate height of block
      $(".image_thumb ul li").removeClass('active'); //Remove class of 'active' on all lists      			
		  $(this).addClass('active');  //add class of 'active' on this list only
		  
		return false;
	}
		}
		
	var intervalo=function(){
    window.setTimeout(function() {
        actual++;    	
    $("#pulsable"+(actual%4)).click();   
    intervalo();    
    }, 9000);	
  }
	

var cargartodo= function(){
	//Show Banner
    //$("#containerflash").show(); //Show Banner
	
	$(".main_image .desc").show(); //Show Banner
	$(".main_image #infoadicional").show(); //Show Banner

  
  
	$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity

	//Click and Hover events for thumbnail list
	$(".image_thumb ul li:first").addClass('active');
   
	//$(".image_thumb ul li").hover(function(){cambiarFlash});
  $(".image_thumb ul li").click(cambiarFlash);
  
  $(".image_thumb ul li").click(function(){
      $(this).animate({ opacity: 0.5}, 250 );
      $(this).animate({ opacity: 1.0}, 250 );
		});
		
  $(".image_thumb ul li").hover(function(){
		$(".capafondo",this).addClass('hover');
		$(this).click();
		}, function() {
		$(".capafondo",this).removeClass('hover');              
	});
  
  
	//Toggle Teaser
	/*$("a.collapse").click(function(){
		$(".main_image .block").slideToggle();
		$("a.collapse").toggleClass("show");
	});  */   
  //$("#pulsable0").click();
	cambiartimer();
}


$(document).ready(function() {	
    /*$(window).bind("load",function() {
    $('#containerflash').show();
    });*/       
    
     /*$("#pulsable3").load(function(){
      $('#containerflash').show()});*/
var imagenescargadas=0;
$("#containerflash img.precargaflash").load( function(){
      imagenescargadas++;
      if (imagenescargadas==7){
      $('#containerflash').show();
      }
}); // track image is loaded } });
      
cargartodo();

intervalo();
intervalobreve();

	
});//Close Function

