jQuery.noConflict();
jQuery(document).ready(function() {		
	
	//Execute the slideShow
	slideShow();

});

function slideShow() {

	//Marca la opacidad de todas las imágenes en 0
	jQuery('#banner a').css({opacity: 0.0});
	
	//Toma la primera imagen y la despliega con opacidad 0
	jQuery('#banner a:first').css({opacity: 1.0});
	
	//Set the caption background to semi-transparent
	jQuery('#banner .caption').css({opacity: 0.7});

	//Resize the width of the caption according to the image width
	jQuery('#banner .caption').css({width: jQuery('#banner a').find('img').css('width 370')});
	
	//Get the caption of the first image from Title attribute and display it
	jQuery('#banner .content').html(jQuery('#banner a:first').find('img').attr('title'))
	.animate({opacity: 1}, 400);
	
	//Call the banner function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('banner()',5000);
	
}

function banner() {
	
	//if no IMGs have the show class, grab the first image
	var current = (jQuery('#banner a.show')?  jQuery('#banner a.show') : jQuery('#banner a:first'));

	//Get next image, if it reached the end of the slideshow, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('caption'))? jQuery('#banner a:first') :current.next()) : jQuery('#banner a:first'));	
	
	//Get next image caption
	var caption = next.find('img').attr('title');	
	
	//Set the fade in effect for the next image, show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
	//Set the opacity to 0 and height to 1px
	jQuery('#banner .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });	
	
	//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
	jQuery('#banner .caption').animate({opacity: 0.60},10 ).animate({height: '40px'},500 );
	
	//Display the content
	jQuery('#banner .content').html(caption);
	
	
}
