$(document).ready(function(){

  //make external links open in a new window
  $("a").each(function(){
    if( $(this).attr('href') ){
      href = $(this).attr('href');
      base = basedir.split('http://').join('').split('https://').join('');
      if( (href.match('http://') || href.match('https://') ) && !href.match(base) ){
        $(this).click(function(){
          window.open($(this).attr('href'));
          return false;
        });
      }
    }
  });
  
  //confirmation alerts
  $("button.confirm").click(function(){
    action = $(this).attr("title").substr(0,1).toLowerCase() + $(this).attr("title").substr(1);
    if( !confirm("Are you sure you want to "+action) ){ return false; }
  });
  
  //navigation
  $("#navigation a").wrapInner("<span></span>");
  
  //buttons
  $("button")
    .mouseover(function(){ $(this).addClass("hover"); })
    .mouseout(function(){ $(this).removeClass("hover"); });
  
  //activate lightbox
  if( $("#content_55").html() ){
    $("#content_55 .idx-result a.pic").lightBox();
  }
  
  //remove double headings for pages that have only one heading
  $("#center-column h3:first").remove();
  
  //remove css stuff on checkboxes/radio buttons
  $("input[type='radio'], input[type='checkbox']").css("width", "auto");
  
  //make the window no less than a certain size
  $(window).resize(function(){
    if( $(window).width() <= 1000 ){
      $("body").css("width", 1000);
    }else{
      $("body").css("width", 'auto');
    }
  });  
  $(window).trigger("resize");      
  
});
