function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
};
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        auto: 2,
        wrap: 'both',
        visible: 1, //Muestra la cantidad de imagenes
        initCallback: mycarousel_initCallback
    });
    $('#mycarousel').tabs({fx:{opacity: "show"}}).tabs("rotate", 5000, true);
});
$(document).ready(function() {
//ANIMATION HOME
  
  $('#AnimationTop').tabs({fx:{opacity: "show"}}).tabs("rotate", 5000, true);
  
//ANIMATION END
//Gallery of Image
  $('#GalleryImgHP').tabs({fx:{opacity: "show"}}).tabs("rotate", 6000, true);
//Gallery of Image END
//SUPERFISH
  $('ul.sf-menu').superfish();
//SUPERFISH
 //FONT SIZE RESET 
 // Reset Font Size
 var originalFontSize = $('div#Contenido').css('font-size');
   $(".resetFont").click(function(){
   $('div#Contenido').css('font-size', originalFontSize);
 });
  
 // Increase Font Size
 $(".increaseFont").click(function(){
   var currentFontSize = $('div#Contenido').css('font-size');
   var currentFontSizeNum = parseFloat(currentFontSize, 10);
   var newFontSize = currentFontSizeNum*1.2;
     $('div#Contenido').css('font-size', newFontSize);
     return false;
 });
  
 // Decrease Font Size
 $(".decreaseFont").click(function(){
   var currentFontSize = $('div#Contenido').css('font-size');
   var currentFontSizeNum = parseFloat(currentFontSize, 10);
   var newFontSize = currentFontSizeNum*0.8;
     $('div#Contenido').css('font-size', newFontSize);
     return false;
 });
  
//PIROBOX
$().piroBox_ext({
    piro_speed : 700,
    bg_alpha : 0.5,
    piro_scroll : true // pirobox always positioned at the center of the page
});
  
//GALERIA DE FOTOS
$("ul.thumb li").hover(function() {
    $(this).css({'z-index' : '10'});
    $(this).find('span.p').css({'z-index' : '11','visibility' : 'visible'}).stop().animate({
        left: '-30px',
        bottom: '-24px',
        width: '164px'
    }, 200);
    $(this).find('img.fl').addClass("hover").stop()
      .animate({
        marginTop: '-110px', 
        marginLeft: '-110px', 
        top: '50%', 
        left: '50%', 
        width: '174px', 
        height: '174px',
        padding: '20px' 
      }, 200);
    
    } , function() {
    $(this).css({'z-index' : '0'});
    $(this).find('span.p').css({'z-index' : '0','visibility' : 'hidden'}).stop().animate({
        left: '6px',
        bottom: '14px',
        width: '90px'
    });
    $(this).find('img.fl').removeClass("hover").stop()
      .animate({
        marginTop: '0', 
        marginLeft: '0',
        top: '0', 
        left: '0', 
        width: '100px', 
        height: '100px', 
        padding: '5px'
      }, 400);
});
});
//Rotator
function theRotator() {
  //Set the opacity of all images to 0
  $('div.rotator ul li').css({opacity: 0.0});
  
  //Get the first image and display it (gets set to full opacity)
  $('div.rotator ul li:first').css({opacity: 1.0});
    
  //Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
  
  setInterval('rotate()',6000);
  
}
function rotate() {  
  //Get the first image
  var current = ($('div.rotator ul li.show')?  $('div.rotator ul li.show') : $('div.rotator ul li:first'));

    if ( current.length == 0 ) current = $('div.rotator ul li:first');

  //Get next image, when it reaches the end, rotate it back to the first image
  var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotator ul li:first') :current.next()) : $('div.rotator ul li:first'));
  
  //Un-comment the 3 lines below to get the images in random order
  
  //var sibs = current.siblings();
    //var rndNum = Math.floor(Math.random() * sibs.length );
    //var next = $( sibs[ rndNum ] );
      

  //Set the fade in effect for the next image, the show class has higher z-index
  next.css({opacity: 0.0})
  .addClass('show')
  .animate({opacity: 1.0}, 1000);

  //Hide the current image
  current.animate({opacity: 0.0}, 1000)
  .removeClass('show');
  
};



$(document).ready(function() {    
  //Load the slideshow
  theRotator();
  $('div.rotator').fadeIn(1000);
    $('div.rotator ul li').fadeIn(1000); // tweek for IE
});


