$(document).ready(function() {

  // Show dropdown
  $("#nav li").hover(function() {
    $(this).children(".children").filter(':not(:animated)').slideDown(200);

    $(".children").hover(function() {
      $(this).siblings("#nav li > a").addClass("current_page_item");
    }, function() {
      $(this).siblings("#nav li > a").removeClass("current_page_item");
    });

  }, function() {
    $(this).children(".children").slideUp(150);
  });

  $('#slider-container').coinslider({
    width:606,
    height:329,
    effect: 'random',
    delay: 8000,
    sDelay: 50
  });

  $(".image-slider-container").cycle({
    pager: ".slider-pager",
    fit: 1,
    fx: 'fade',
    pauseOnPagerHover: 1,
    slideExpr: 'img, div#jwplayer-2-div',
    delay: 4000
  }).children('p').remove();

  $(".product-thumbnails").each(function(index) {
    var size = $(this).find("li").size();

    if(size > 5) {
      $(this).infiniteCarousel();
      $(this).parent(".product-gallery").addClass("carouseled");
    }
  });

  $("div#jwplayer-2-div").hover(function(){
    $(".image-slider-container").cycle('stop');
  });

  //Product Gallery
  $('.product').each(function() {
    var product = $(this).attr('id'),
        imageContainers = $('#' + product + ' div.product-gallery .visor .product-images-container > div');
    $('#' + product + ' .product-gallery .thumbs a').click(function () {
          imageContainers.hide().filter(this.hash).fadeIn(500);

          $('#' + product + ' div.product-gallery ul a').removeClass('selected');
          $(this).addClass('selected');

          return false;
      }).filter(':first').click();
  });

  // Show offer form
  $('.information h3 a[href="#solicitar-info"]').each(function() {
    $(this).fancybox();
  });                   
  
  // General Fancybox
  $(".fancybox").fancybox();

  // Show terms box
  $("#terminos").fancybox({
    'width' : 550,
    'ajax' : {
      type  : "GET"
    }
  });  
  
  DD_roundies.addRule('.roundify', '15px');
});

Cufon.replace('h1,h2,h3,h4,h5,h6,.contact-form th, .contact-form .wpcf7-submit, .cufon');

