jQuery(document).ready( function () {
	
	// CSS Addons
	jQuery('ol li:nth-child(1)').prepend('<span>.1</span>');
	jQuery('ol li:nth-child(2)').prepend('<span>.2</span>');
	jQuery('ol li:nth-child(3)').prepend('<span>.3</span>');
	jQuery('ol li:nth-child(4)').prepend('<span>.4</span>');
	jQuery('ol li:nth-child(5)').prepend('<span>.5</span>');
	jQuery('ol li:nth-child(6)').prepend('<span>.6</span>');
	
	jQuery('.current-menu-item a, .current-menu-parent > a').addClass('active');
	jQuery('nav[role="navigation"] li ul').hover( function() {
		jQuery(this).parent().find('a').addClass('active');
		jQuery('nav[role="navigation"] li li a').removeClass('active');
	}, function() {
		if (jQuery('nav[role="navigation"] > li').find('.active').length != 1) {
			jQuery(this).parent().find('a').removeClass('active');
		}
	});
	
	// Main Slider
	jQuery('#slider-imgs').cycle({ 
		fx:     'fade', 
		timeout: 5500, 
		pager:  '#slider-controls' 
	});
	
	// Single Portfolio Slider
	jQuery('#portfolio-slider div').after('<div id="portfolio-rotator"></div>').cycle({ 
		fx:     'fade', 
		timeout: 5000, 
		pager:  '#portfolio-rotator' 
	});
	
});

jQuery(window).load(function(){  
	// Slider Shortcode
	function onAfter(curr, next, opts, fwd) {
		jQuery(this).find('p').each( function() {
			if ( jQuery(this).html() == '' ) {
				jQuery(this).remove();
			}
		});
		var $ht = jQuery(this).height();
		jQuery(this).parent().animate({height: $ht});	
	}
	jQuery('.celta-slide').cycle({ 
		fx:     'fade', 
		timeout: 5000, 
		next:   '.celta-next', 
		prev:   '.celta-prev',
		height: 'auto',
		before: onAfter,
		cleartypeNoBg: true,
		cleartype: true,
		slideResize:   0
	});
});

(function($){

$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 884;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
	// Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
	// Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  }
	
	// Tabs Blog, Twitter, Facebook
	$('.tab_content').hide();
	$('ul.tabs li:first').addClass('active').show();
	$('.tab_content:first').show();

	$('ul.tabs li').click(function()
       {
		$('ul.tabs li').removeClass('active');
		$(this).addClass('active');
		$('.tab_content').hide();

		var activeTab = $(this).find('a').attr('href');
		$(activeTab).fadeIn();
		return false;
	});

});
})(jQuery);


(function($){
$(document).ready(function () {
  $('#clientes').bxCarousel({
		display_num: 2,
		move: 1,
		speed: 2500,
		auto: true,
		controls: false,
		margin: 0,
		auto_hover: true
    });
  });
})(jQuery);
