/*
 * Browser Fixes / Testing
 * fix browser related issues
 *
 * $.browser() is depreicated replaced by jQuery.support
 */

$(document).ready(function(){
  
  /* debug: see what we got here...*/
  /*jQuery.each(jQuery.browser, function(i, val) {
      $('<div>' + i + ' : <span>' + val + '</span>').appendTo(document.body);
    });*/

  /*
   * Move IE6 browser warning message below page titles
   */
  var warning = $('#warning-ie6');
  if (warning.length) {
    //$('#warning-ie6').after($('h1'));
    $('h1').after(warning);
  }

  /*
   * Browser Fixes / Testing
   * fix IE browser issues
   *
   * $.browser() is deprecated replaced by jQuery.support
   */
  if ($.browser.msie) {
    var version = jQuery.browser.version;
    
    // IE6: change the logo from png to gif
    if (version == 6) {
      var logo = $('#logo img');
      logo.attr('src', logo.attr('src').replace('.png', '.gif'));
    }

    // IE doesn't handle column widths properly when the width of the columns
    // add up to 100%. subtract a pixel to fix.
    //
    // We could use conditional stylesheets, but for now going to just grab
    // the current widths and subtract 1px while the CSS is still in
    // development  
    var objs = [
          $('.building.teaser .left'),
          $('.building.detail .left')
          ];
    $.each(objs, function(i, obj) {
      if (obj.length) {
        var margin_right = obj.css('margin-right').substr(0, 2);
        obj.css('margin-right', margin_right-1);
      }
    });
    
    // IE8 is the only browser that needs no top margin for the help tip icons
    if (version == 8) {
      $('form fieldset .help').css('margin-top', 0);
    }
  }
});