$(document).ready(function(){

    var i = "1";
    var j = "1";


    $('#events').cycle({ 
      pager:  '.news_items',
      timeout:  5000,
      before: onBefore
    });

function onBefore() {    
       
    link_text = this.title;
    alt_text = this.alt;
    
    link_html = '<a href="' + link_text + '">' + alt_text + '</a>';
    
    $('#title').html(link_html); 

    if (j != "3") {
      j = i - 1;
    } else {
      j = 4;
    }

    $('#thumb' + j).removeClass("current");   
    $('#thumb' + i).addClass("current");
    
    
    if (j == "4") {
      j = "1";
    }

    if (i == "4") {
      i = "1";
    } else {
      i++;
    }  

};

      
});
