$('#picture').cycle({ 
                      fx:     'scrollHorz', 
                      timeout: 7000,
                      speed: 500,
                      before:  onBefore,
                      after:   onAfter,
                      pager:'#pager'
                   });
 
function onBefore() { 
    //$('#text').html("Scrolling image:<br>" + this.src);
    $('.info').fadeOut(200);
}

function onAfter() { 
    //$('#text').html('<h1>' + this.alt + '</h1>') 
    //    .append('<p>' + this.id + '</p>');
    
    $('.'+this.id).fadeIn(200);
}

$(document).ready(function() {
    $('.hoverable').hover(function() {
      $(this).addClass('onhover');
    }, function() {
      $(this).removeClass('onhover');
    });
    bindMonthPager();
});



function retrieveEvents(qstring) {
  var query;
  if ($('.progress').is(':hidden')) {
    $('.progress').show();
  }
  if (qstring != null) {
	  query = qstring;
  } else {
	  query = $('#frmevents').serialize();
  }
  $.get("/evenementen/?" + query,
      function(data){
          $('#column-left').html(data);
          bindMonthPager();
            $(document).ready(function() { 
            	setTimeout( "$('.progress').hide();",  250); 
                $('select.ddui').selectmenu({style:'dropdown', width: 200, menuWidth: 202 });
                window.location.hash = '#' + query;
            });
      });
  return false;
}
function resetOffset() {
  $('#fldoffset').attr('value', 0);
}
function bindMonthPager() {
  $('.event-controls a.month-rwd').bind('click', function(event){
    var offset = parseInt($('#fldoffset').attr('value'));
    offset = offset - 1;
    $('#fldoffset').attr('value', offset);
    retrieveEvents();
    event.preventDefault();
  });
  $('.event-controls a.month-fwd').bind('click', function(event){
    var offset = parseInt($('#fldoffset').attr('value'));
    offset = offset + 1;
    $('#fldoffset').attr('value', offset);
    retrieveEvents();
    event.preventDefault();
  });
}


