$(document).ready(function(){


// CUFON 	//////////////////////////////////////////////////////////

	Cufon.replace('.col h2')('h3')('#container.icon h3 a',{hover: true})('.txt-destacado')('.txt-destacado-bold')('#ficha-otros li a')('#ficha-encabezado h2')('#seccion-encabezado h2');




// TABS 	//////////////////////////////////////////////////////////

	//Default Action
	$(".tab").hide(); //Hide all content
	$("ul.tabs li:first").addClass("active").show(); //Activate first tab
	$(".tab:first").show(); //Show first tab content
	
	//On Click Event
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); //Remove any "active" class
		$(this).addClass("active"); //Add "active" class to selected tab
		$(".tab").hide(); //Hide all tab content
		var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
		$(activeTab).fadeIn(); //Fade in the active content
		return false;
	});
	


	
// SLIDER 	//////////////////////////////////////////////////////////
	
    	//$("#slider").scrollable({size: 4, clickable: false, loop: true}).autoscroll({interval: 4000}).find("div").each(function(index) {																											
	$("#videos").scrollable({size: 4,clickable: false, speed: 500, items: ".bloque", nextPage: ".siguiente", prevPage: ".anterior", disabledClass: "off"});
	
	// sin encadenar IE7 se queda frito... 
	 /*  $("#thumbnails").scrollable({
				size: 4,
				clickable: false,
				autoplay: true,
				interval: 600,
				speed: 500,
				loop: true,
				}).autoscroll(1000);*/

	//
	
	
// PRETTYPHOTO 	//////////////////////////////////////////////////////////

	$("a[rel^='pop']").prettyPhoto({
			animation_speed: 'fast', /* fast/slow/normal */
			slideshow: false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.80, /* Value between 0 and 1 */
			show_title: false, /* true/false */
			allow_resize: false, /* Resize the photos bigger than viewport. true/false */
			default_width: 748,
			default_height: 432,
			counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
			theme: 'facebook', /* light_rounded / dark_rounded / light_square / dark_square / facebook */
			horizontal_padding: 20, /* The padding on each side of the picture */
			hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
			wmode: 'opaque', /* Set the flash wmode attribute */
			autoplay: true, /* Automatically start videos: True/False */
			modal: false, /* If set to true, only the close button will close the window */
			deeplinking: false, /* Allow prettyPhoto to update the url to enable deeplinking. */
			overlay_gallery: true, /* If set to true, a gallery will overlay the fullscreen image on mouse over */
			keyboard_shortcuts: true, /* Set to false if you open forms inside prettyPhoto */
			changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
			callback: function(){}, /* Called when prettyPhoto is closed */
			ie6_fallback: true	
		
		
	});
	


// FADE 	//////////////////////////////////////////////////////////

	// List view
	$('#controles a').click(function(){
		
	// Get 'rel' variable	
	var r = $(this).attr('rel');

	// Get current display mode
	var c = $('#categorias').attr('class');
		
		// Prevent redundant actions	
		if (r != c) {
		
			// Toggle 'active' class to show selection	
			$('#controles a').removeClass('activo');
			$(this).addClass('activo');
		
			$('#categorias').fadeOut(100, function(){
			$('#categorias').removeAttr('class');
			$('#categorias').addClass(r);
		
			// Fade the container back in
			$('#categorias').fadeIn(100);
		
			});	
		}	
	});
				


// BANNERS 	//////////////////////////////////////////////////////////

	$('#banners') 
		.before('<div id="banners-nav">') 
		.cycle({ 
			fx:     'fade', 
			speed:  'normal',
			timeout: 8000,
			pause: 	 1,
    		next:   '#sig', 
    		prev:   '#ant' 
		});




// VIDEOS 	//////////////////////////////////////////////////////////

$("#videos ul li a img").fadeTo("fast", 1.0);
$("#videos ul li a img").hover(function(){
$(this).fadeTo("fast", 0.1);
},function(){
$(this).fadeTo("fast", 1.0);
 });
 
 
$("#cat-videos ul li a img").fadeTo("fast", 1.0);
$("#cat-videos ul li a img").hover(function(){
$(this).fadeTo("fast", 0.1);
},function(){
$(this).fadeTo("fast", 1.0);
 });
						  



// CSS	 	//////////////////////////////////////////////////////////
	 
	 // CSS - anyade clase .primero en algunas lista de objetos
	// $("#slider ul.bloque li:first").addClass("primero");

	 // CSS - anyade clase .ultimo en algunas lista de objetos
	 $("#slider ul.bloque li:last").addClass("ultimo");
	 $(".categoria-productos ul li:last").addClass("ultimo");
	 $("#principal ul li:first-child").addClass("primero");
	

	
	

	/*$("#idiomas li").hover(function() {
		$(this).animate({opacity: "show", top: "-75"}, "slow");
	}, function() {
		$(this).animate({opacity: "hide", top: "-85"}, "fast");
	});*/

	
	
});
	
	


