$(document).ready(function(){

    //showWeeklyEvents();

    var first_hour = $('table.week tbody.by_hour tr.start_of_day th');

     if($.browser.msie){
      $('table#calendar_week').wrap("<div class='week_container'></div>");
      $('table#calendar_week tbody.by_hour').removeClass('week_container');
      $('.week_container').before("<table id='calendar_week_header' class='week'></table>");
      $('#calendar_week_header').append($('table#calendar_week thead'));
      $('#calendar_week_header').append($('table#calendar_week tbody.all_day'));
      $('table#calendar_week_header').wrap("<div class='week_header_container'></div>");
      $('.week_header_container, .week_header').css('backgroundColor', '#729fcf');
      $('.week_header_container').css({ paddingLeft: '0em'});
      $('table#calendar_week_header').css({ 
                                     marginBottom: '.75em'});
      $('table#calendar_week_header thead td').append(
        '<img alt="spacer" src="/images/spacer_51x1.png" />');

      $('table.week thead tr, table.week tbody.all_day tr td').css('borderRight', 'none'); 
      $('table.week thead th, table.week td.day, table.week tbody.all_day td').css({ width: '14%' } );
      $('.week_container').scrollTo(first_hour, 800).scroll(function(){
           $("#cluetip-close").click();
         });
    }
    else{
      $('table.week tbody.by_hour').scrollTo(first_hour, 800).scroll(function(){
           $("#cluetip-close").click();});
    };
 
        
});

function showWeeklyEvents(){
  $('table.week .by_hour h5.calendar_event a').each(function(i){
    var e = $(this).attr('rel');  
    e = e.replace('event', 'event_short');
    if($.browser.msie){
      $(e).css({ display: 'block', 
               top: $(this).parents('td.day').position().top});
    }
  });
}


