/**
* Browser fixes for style.css. This file depends on jQuery.
*/

jQuery(document).ready(function($){
  var majorVersion = parseInt($.browser.version, 10);
  var usa = ["usa", "us", "united states", "united states of america"];

  // show the country if it's outside of the USA
  $(".calendar_events-event.calendar_events-summary .calendar_events-country").each(function(){
    if (jQuery.inArray(jQuery.trim(this.innerHTML).toLowerCase(), usa) === -1) {
      jQuery(this).css("display", "inline").prev().after(",");
    }
  });

  $(".calendar_events-event.calendar_events-summary .calendar_events-end_date").each(function(){
    if (/^[0-9]+$/.test(jQuery.trim(this.innerHTML))) {
      this.innerHTML = jQuery.trim(this.innerHTML);
      this.parentNode.removeChild(this.previousSibling);
    }
  });

/* @group Event Summaries
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

if ($.browser.msie && majorVersion < 8) {
  $(".calendar_events-event.calendar_events-summary .calendar_events-venue\
     .calendar_events-event.calendar_events-summary .calendar_events-street_address:first-child").before(" at ");
  $(".calendar_events-event.calendar_events-summary .calendar_events-locality,\
     .calendar_events-event.calendar_events-summary .calendar_events-region:first-child,\
     .calendar_events-event.calendar_events-summary .calendar_events-postal_code:first-child,\
     .calendar_events-event.calendar_events-summary .calendar_events-country:first-child").before(" in ");
  $(".calendar_events-event .calendar_events-end_date:not(:empty)").before(" - ");
  $(".calendar_events-event.calendar_events-summary .calendar_events-venue").after(" ");
  $(".calendar_events-event.calendar_events-summary .calendar_events-locality + .calendar_events-region\
     .calendar_events-event.calendar_events-summary .calendar_events-locality + .calendar_events-country").before(", ");
  $(".calendar_events-event.calendar_events-summary .calendar_events-street_address,\
     .calendar_events-event.calendar_events-summary .calendar_events-postal_code,\
     .calendar_events-event.calendar_events-summary .calendar_events-country").before(" ");
}

/* @end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

/* @group Full Event
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

if ($.browser.msie && majorVersion < 8) {
  $(".calendar_events-event.calendar_events-full .calendar_events-locality").after(", ");
  $(".calendar_events-event.calendar_events-full .calendar_events-region").after(" ");
}

/* @end
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/

});
