$( function() {
  if( ! ( $.browser.msie && getIEVersion() < 7 ) ) {
    $( "div.thinBoxed" ).each( function() {
      var container = $( "<div></div>" )
        .css( "top", 0 )
        .css( "right", 0 )
        .css( "bottom", 0 )
        .css( "left", 0 )
        .css( "padding", 5 )
        .css( "border", "1px solid #000850" );
        
      var titleDiv = $( this ).find( "#title" ).remove();
      
      container.append( $( this ).html() );
      
      if( $( this ).css( "position" ) == "absolute" )
        container.css( "position", "absolute" )
          .css( "overflow", "auto" );
          
      if( $( this ).css( "position" ) == "static" )
        $( this ).css( "position", "relative" );
        
      $( this )
        .empty();
        
      if( titleDiv.length > 0 ) {
        var title = $( "<div>" + titleDiv.html() + "</div>" )
          .css( "position", "relative" )
          .css( "top", 0 )
          .css( "right", 0 )
          .css( "left", 0 )
          .css( "padding", 5 )
          .css( "border", "1px solid #000850" )
          .css( "border-bottom", "none" )
          .css( "text-align", "center" )
          .css( "font-weight", "bold" )
          .css( "letter-spacing", "0.075em" )
          .addClass( "title" )
          .appendTo( this );
          
        container.css( "top", 23 );
          
        if( $( this ).filter( ".blueTitled" ).length ) {
          title.css( "background-color", "#000850" )
            .css( "color", "white" );
          title.find( "a" ).css( "color", "white" );
        } else {
          container.css( "border-top", "1px solid #0018F2" );
          title.find( "a" ).css( "color", "#404040" );
        }
      }
      
      $( this )
        .append( container )
        .append( "<img class=\"northWest\" src=\"images/nwThin.gif\"/>" )
        .append( "<img class=\"northEast\" src=\"images/neThin.gif\"/>" )
        .append( "<img class=\"southEast\" src=\"images/seThin.gif\"/>" )
        .append( "<img class=\"southWest\" src=\"images/swThin.gif\"/>" );
    } );
  } else if( $.browser.msie ) {
    $( "div.thinBoxed" ).each( function() {
      $( this ).find( "#title" )
        .css( "border-bottom", "1px solid #404040" )
        .css( "text-align", "center" )
        .css( "font-weight", "bold" )
        .css( "letter-spacing", "0.075em" )
        .css( "padding-bottom", 3 )
        .addClass( "title" );
        
      $( this ).children( ":nth(1)" )
        .css( "margin-top", 3 );
    } );
  }
  
  $( "#menu a, #search a" ).hover( function() {
    var img = $( this ).find( "img" );
    img.attr( "src", img.attr( "src" ).replace( /\.gif$/, "_highlight.gif" ) );
  }, function() {
    var img = $( this ).find( "img" );
    img.attr( "src", img.attr( "src" ).replace( /_highlight\.gif$/, ".gif" ) );
  } );
} );
