function openEsqueceuASenha() {
  $("#btLembrar").click(function () {
    $('#esqueceu_a_senha').toggle();
    return false;
  });
}

function initNav() {
  $(".passagens,#nav_passagens").hover(
    function () {
      $('#nav_passagens').show();
    },
    function () {
      $('#nav_passagens').hide();
    }
  );

  $(".hoteis,#nav_hoteis").hover(
    function () {
      $('#nav_hoteis').show();
    },
    function () {
      $('#nav_hoteis').hide();
    }
  );

  $(".carros,#nav_carros").hover(
    function () {
      $('#nav_carros').show();
    },
    function () {
      $('#nav_carros').hide();
    }
  );

  $(".trens,#nav_trens").hover(
    function () {
      $('#nav_trens').show();
    },
    function () {
      $('#nav_trens').hide();
    }
  );

  $(".cruzeiros,#nav_cruzeiros").hover(
    function () {
      $('#nav_cruzeiros').show();
    },
    function () {
      $('#nav_cruzeiros').hide();
    }
  );

  $(".suas_ferias_aqui,#nav_suas_ferias_aqui").hover(
    function () {
      $('#nav_suas_ferias_aqui').show();
    },
    function () {
      $('#nav_suas_ferias_aqui').hide();
    }
  );
}

function initTabPais() {
  var tabContainers = $('#pais.tab > div.tab_pais');
  tabContainers.hide().filter(':first').show();

  $('#pais.tab ul.tab li a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('#pais.tab ul.tab li').removeClass('selected');
    $(this).parent().addClass('selected');
    return false;
  }).filter(':first').click();
}

function initTabDestinos() {
  var tabContainers = $('#as_melhores_tarifas.tab > div.tab_destinos');
  tabContainers.hide().filter(':first').show();

  $('#as_melhores_tarifas.tab ul.tab li a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('#as_melhores_tarifas.tab ul.tab li').removeClass('selected');
    $(this).parent().addClass('selected');
    return false;
  }).filter(':first').click();
}

function initTabContent() {
  var t = $('#itens.tab > div');
  t.hide().filter(':first').show();

  $('#itens.tab ul li a').click(function () {
    t.hide();
    t.filter(this.hash).show();
    $('#itens.tab ul li').removeClass('selected');
    $(this).parent().addClass('selected');
    return false;
  }).filter(':first').click();
}

function initTable() {
  $('.summary tbody tr').hover(
    function () {
      $(this).addClass('hover');
    },
    function () {
      $(this).removeClass('hover');
    }
  );
}

function scrollerHorizontal() {
  var posLeft, slideWidth, speed,
  scrollerContainer = $('#carrouselContainer'),
  total = $('#carrousel li').length,
  thumbWidth = 145 * total;
  
  scrollerContainer.css({'width': thumbWidth + 'px'});

  $('#carrouselLeft').hover(function (e) {
    posLeft = -parseInt(scrollerContainer.css("left"), 10);
    speed = (posLeft) * 4;
    scrollerContainer.animate({'left': '0px'}, speed)
  }, function () {
    scrollerContainer.stop();
  });

  $('#carrouselRight').hover(function (e) {
    posLeft = parseInt(scrollerContainer.css("left"), 10);
    speed = (thumbWidth + posLeft) * 4;
    slideWidth = thumbWidth - 602;
    scrollerContainer.animate({'left': -slideWidth + 'px'}, speed)
  }, function() {
    scrollerContainer.stop();
  });

  $('#carrouselLeft,#carrouselRight').click(function (e) {
    return false;        
  });
}


$(document).ready(function () {
  openEsqueceuASenha();
  initNav();
  initTabPais();
  initTabDestinos();
  initTabContent();
  initTable();
  scrollerHorizontal();
});

