var item_list = 0;

function stepSlideShow() {
	
	item_list = (item_list < 10) ? "0" + item_list : item_list;
	
	jQuery("#inner").removeClass().addClass("inner_" + item_list);	
	
	if(item_list > 0)
		jQuery("#inner").html('<a href="' + jQuery( "#home #menuNav li.menuNavProducto" + item_list + " a" ).attr("href") + '"></a>');
	
	jQuery("#inner").css("top","439px");
	
	jQuery("#inner").animate({"top": "0px"}, "slow");
	
	setTimeout(stepSlideShow,6000);
	
	item_list++;
}

// Funciones Ajax
jQuery.noConflict();
jQuery(document).ready(function() {
	
	// $.preloadCssImages();
	jQuery.preloadCssImages();
	
	// stepSlideShow()
	stepSlideShow();
	
	// Bind the link to toggle the slide.
	jQuery( "#home #menuNav a" ).mouseover(
		
		function( event ){
			// Prevent the default event.
			event.preventDefault();
			
			jQuery("#inner").removeClass().addClass("inner_" + jQuery( this ).attr("rel"));		
			
			jQuery("#inner").html('<a href="' + jQuery( this ).attr("href") + '"></a>');
			
			jQuery("#inner").css("top","439px");
			
			jQuery("#inner").animate({"top": "0px"}, "slow");
			
			return false;
		}
	);
	
	// TOOLTIPS
	jQuery(".tooltip").tooltip({
		track: true,
		delay: 0,
		showURL: false,
		fixPNG: true,
		showBody: " - ",
		extraClass: "consejos",
		top: -130,
		left: 5
	});
	
	// CUESTIONARIO TU BOCA ESTA SANA
	jQuery('#tu-boca-esta-sana-paso-01').click(function() {
			jQuery('#paso-01').hide();
			jQuery('#paso-02').show();
   	});
	
	jQuery('#tu-boca-esta-sana-paso-02').click(function() {
			jQuery('#paso-02').hide();
			jQuery('#paso-03').show();
   	});
	
	jQuery('#tu-boca-esta-sana-paso-03').click(function() {
			document.form_tu_boca_esta_cuidada.submit();
   	});
	
	// FICHA DETALLADA PRODUCTOS
	
	// DATOS PRODUCTO
	jQuery('#titulo_descripcion').click(function() {
			jQuery('#caracteristicas').hide();
			jQuery('#recomendaciones').hide();
			if(jQuery('#descripcion').css("display") == "none")
				jQuery('#titulo_descripcion').attr("src", "/images/productos-descripcion-a.png");
			else
				jQuery('#titulo_descripcion').attr("src", "/images/productos-descripcion.png");
			jQuery('#descripcion').toggle();
   	});
	
	jQuery('#titulo_caracteristicas').click(function() {									
			jQuery('#descripcion').hide();
			jQuery('#recomendaciones').hide();
			if(jQuery('#caracteristicas').css("display") == "none")
				jQuery('#titulo_caracteristicas').attr("src", "/images/productos-caracteristicas-a.png");
			else
				jQuery('#titulo_caracteristicas').attr("src", "/images/productos-caracteristicas.png");
			jQuery('#caracteristicas').toggle();
   	});
	
	jQuery('#titulo_recomendaciones').click(function() {									
			jQuery('#descripcion').hide();
			jQuery('#caracteristicas').hide();
			if(jQuery('#recomendaciones').css("display") == "none")
				jQuery('#titulo_recomendaciones').attr("src", "/images/productos-recomendaciones-a.png");
			else
				jQuery('#titulo_recomendaciones').attr("src", "/images/productos-recomendaciones.png");
			jQuery('#recomendaciones').toggle();
   	});
	
	// IMAGENES
	jQuery('.productos_secundaria').click(function() {
		var src = jQuery(this).attr("src");
		var ruta_principal = src.substring(0, src.lastIndexOf(".")) + "_grande.png";
		
		jQuery("#productos_principal").attr("src", ruta_principal);
	});
	
	// MUESTRAS AREA DENTISTAS
	jQuery('.producto_muestras').click(function() {
		var producto = jQuery(this).text();
		var subfamilia = jQuery(this).attr("rel");
		
		var producto_subfamilia = subfamilia + " " + producto;
		
		jQuery('#lista_muestras_elegidas').append(producto_subfamilia + "<br />");
	});
	
	jQuery('#form_base_area #submit').click(function() {
		jQuery('#hidden_lista_muestra_elegidas').attr("value", jQuery('#lista_muestras_elegidas').html());
	});
});
