$(document).ready(function(){
                $('a.colorbox').colorbox();
                $('a.event').colorbox({ maxWidth: '95%', maxHeight: '90%' });
                $('#newsletter-form').submit(function(){
                        $.post('pages/email_add.php', $(this).serialize(), function(data) {
                            $('#newsletter').html(data);
                        });
                    return false;
                });
                
                if($('#headers').hasClass('slide')){
                 var cycle =	setInterval("cycleHeaders()", 10000);
                }
                
            });
            
            
function cycleHeaders(){
     var current = $("#headers li.active");

     var next = current.next('li');
     if(next.length==0){
        next = $("#headers li.header:first");
    }
    
     var next2 = next.next('li');
     
     if(next2.length==0){
         next2 = $("#headers li.header:first");
     }
     var prev = current.prev('li');
  
  if(prev.length==0){
      prev = $("#headers li.header:last");
  }

    var currentSmall = $("#bg_"+current.attr('id'));
    var nextSmall = $('#bg_'+next.attr('id'))
    var next2Small = $('#bg_'+next2.attr('id'))
    var prevSmall = $('#bg_'+prev.attr('id'))
    
    var widthB=$('#headers').width();
    var widthS = currentSmall.width();
    var widthT = $('#bg_headers').width();
    
  
        $(current).stop(false, true).animate({
            left: -widthB
        } , 2500 ).removeClass('active').css('left', 0);
                                   
        $(next).stop(false, true).css('left', widthB).animate({
            left: 0
        }, 2500 ).addClass('active');
        
        $(currentSmall).stop(false, true).css('left', widthS).animate({
            left: 0
        } , 2500 ).removeClass('active');
        
         $(nextSmall).stop(false, true).animate({
            left: widthT-widthS-widthS
        } , 2500 ).addClass('active').removeClass('next');
        
        $(next2Small).stop(false, true).hide().css('left', widthT).show().animate({
            left: widthT-widthS
        } , 2500 );
        
        $(prevSmall).stop(false, true).animate({
            left: -widthS
        } , 2500 ).removeClass('prev').css('left', widthT);
    		
   // $('.bg_header, .header').not(nextBig).removeClass('active');
   
}
