	$(document).ready(function(){
		if(Q != null)
		{
			switch (Q)
			{
				case 'franco-parenti': $("#logotipo-fitnes").fadeTo('fast', 0); $("#logotipo-franco").addClass("logotipo-unico"); break; 
				case 'fitnes-santander': $("#logotipo-franco").fadeTo('fast', 0); $("#logotipo-fitnes").addClass("logotipo-unico"); break;
			}
		}
		$(document).pngFix();
		/*
		$("#slider").easySlider({
			auto: true, 
			controlsShow: false,
			continuous: true,
			vertical: false,
			speed: 5000,
			pause: 15000
		});	
		*/
		// first-menu
		$("#first-menu>ul>li:not(.li-active)>a").hover(
			function(){ $(this).fadeTo("fast", 0.3); $(this).fadeTo("slow", 1.0); }, // This should set the opacity to 100% on hover 
			function(){ $(this).fadeTo("slow", 1); } // This should set the opacity back to 30% on mouseout
		);
		$('a.thickbox').lightBox();
		$('.lightbox').lightBox();
		$('.accordion').click(function() {
			$(this).next().toggle('slow');
			return false;
		}).next().hide();
		$('.no-fade').fadeTo('fast', 1); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$('.fade').fadeTo('slow', 0.3); // This sets the opacity of the thumbs to fade down to 30% when the page loads
		$('.fade').hover(
			function(){ $(this).fadeTo('slow', 1); }, // This should set the opacity to 100% on hover 
			function(){ $(this).fadeTo('slow', 0.3); } // This should set the opacity back to 30% on mouseout
		);
		// tooltip
		$('.tooltips[title]').tooltip('#demotip');
		$("#nosotros-nav ul").tabs("#nosotros-panel > div.articulo");
		$("#destacados a.accordion").next().toggle('slow');
		$('a.email').each(function(i) {
			var text = $(this).text();
			var address = text.replace(" _at_ ", "@");
			$(this).attr('href', 'mailto:' + address);
			$(this).text(address);
		});
		if(document.getElementById('mapa')) load();
		//if ( $('#mapa') ) load();
		if ( $('#v2-slider')) {
			slideShow();
		}
	});
	
function slideShow() {

	//Set the opacity of all images to 0
	$('#v2-slider ul li').addClass("displayNone");
	$('#v2-slider ul li:first').removeClass("displayNone").addClass("displayBlock");
	gallery();
	//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('gallery()', 8000);
	
}

function gallery() {
	// var current = ($('#gallery a.show')?  $('#gallery a.show') : $('#gallery a:first'));
	var current = ( $("#v2-slider ul li.displayBlock") ? $("#v2-slider ul li.displayBlock") : $("#v2-slider ul li:first") );
	//alert ( current.html() );
	var next = ( current.next().length ) ? current.next() : $("#v2-slider ul li:first");
	// var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));	

	//Set the fade in effect for the next image, show class has higher z-index
	next.removeClass("displayNone displayBlock")
	.addClass("displayBlock")
	.animate({
		opacity: 1.0
	}, 2000);
	
	//Hide the current image
	current.removeClass("displayNone displayBlock")
	.addClass("displayNone")
	.animate({
		opacity : 0.1
	}, 2000);
}


