$(document).ready(function() {
   
   timer = setInterval(rotate,8000);
   
   function rotate(){
     $('#jquerycount').text(parseInt( $('#jquerycount').text())+1 );     
     var href = $('.eventoption').eq(parseInt($('#jquerycount').text())).find('A').attr('href');
     var count = parseInt( $('#jquerycount').text());      
     //alert(ID);
     //alert(count);
     if( count < 7 ){
       change_event(href);                                            
     } else {
       $('#jquerycount').text(-1);
     }
   }

   $('.eventoption A').click(function(ev){
     ev.preventDefault();
     change_event($(this).attr('href'));
     clearInterval(timer);
   });
      
   /*
   function change_event(ID){
     //alert("ID: "+ID);   
     $.post('http://s46264.gridserver.com/muni/wp-content/themes/muni/ajaxcalls.php', 
     { id: ID }, 
     function(data){
       alert('complete: '+data);
       //$('#showingevent').html(data);
     });     
   }
   */
   function change_event(href){ 
    $.get(href, { ajax: "true" }, function(data) {
      //$('.result').html(data);
      $('#showingevent').html(data);
      //alert('Load was performed.');
    });
   }
      
 });
