
$(document).ready(function() {

  $('a.top').click(function(){
    $.scrollTo('body',800);
    return false;
  });

  $('.send_form').click(function() {
    $('#'+$(this).parents("form").attr("id")).submit();
    evento.preventDefault();
  });

  $('.check_form').click(function(evento) {
    if(check_form()) {
      $('#'+$(this).parents("form").attr("id")).submit();
    }
    evento.preventDefault();
  });

  $('.delete_form').click(function(evento) {
    delete_form();
    evento.preventDefault();
  });

  $("a[rel='colorbox']").colorbox({});
  $("a[rel='colorbox-gal']").colorbox({});
  $("a[rel='colorbox-html']").colorbox({fixedWidth:"650",fixedHeight:"550", iframe:true});

  $("#slider").easySlider({
    controlsBefore: "<p id='controls'>",
    controlsAfter: "<\/p>",
    auto: false,
    continuous: false
  });

  $('a.tooltip').qtip({
    position: {
      corner: {
        target: 'topMiddle',
        tooltip: 'bottomMiddle'
      },
      adjust: {
        y:7
      }
    },

    style: {
      name: 'dark',
      background: '#303030',
      padding: '10px 10px',
      width: {
        max: 210,
        min: 0
      },
      tip: true
    }
  });

  if ($('#calendar').length) {
  $('#calendar').load('calendar.php', function() {
    $('a.prova').qtip({
      position: {
        corner: {
          target: 'topMiddle',
          tooltip: 'bottomMiddle'
        },
        adjust: {
          y:7
        }
      },

      style: {
        name: 'dark',
        background: '#303030',
        padding: '10px 10px',
        width: {
          max: 210,
          min: 0
        },
        tip: true
      }
    })
  });
  }

  $("a.calendar_button").live("click", function(evento){
    $('#calendar').load($(this).attr('rev'), function() {
      // Code here runs once the content has loaded
      // Put all your event handlers etc. here.
      $('a.prova').qtip({
        position: {
          corner: {
            target: 'topMiddle',
            tooltip: 'bottomMiddle'
          },
          adjust: {
            y:7
          }
        },

        style: {
          name: 'dark',
          background: '#303030',
          padding: '10px 10px',
          width: {
            max: 210,
            min: 0
          },
          tip: true
        }
      })
    });
    evento.preventDefault();
  });

  $("ul#menu_header li").hover(function(){
    $(this).addClass("hover");
    $('ul:first',this).css('visibility', 'visible');
  }, function(){
    $(this).removeClass("hover");
    $('ul:first',this).css('visibility', 'hidden');
  });

});
