function ie6ButtonFix(which) {
  $(which).siblings().attr("disabled", true);
}

$(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;
        });
      }
    }
  });
  
  //button events
  $("button")
    .mouseover(function(){ $(this).addClass("hover") })
    .mouseout(function(){ $(this).removeClass("hover") })
    .each(function(){
      html = $.trim($(this).html());
      html = html.split(' ').join('&nbsp;');
      $(this).html(html);
    })
    .wrapInner("<span class='main'></span>")
    .prepend("<span class='end'>&nbsp;</span>");
  $("button:disabled").addClass("disabled");
  
  //input selections
  $("input")
    .focus(function(){ $(this).addClass('focus'); $(this).prevAll('label:first').addClass('focus'); })
    .blur(function(){ $(this).removeClass('focus'); $(this).prevAll('label:first').removeClass('focus'); });
  
  //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; }
  });
  
  //fix checkbox/radio inputs
  $("input[type='checkbox']").addClass("checkbox");
  $("input[type='radio']").addClass("radio");
  
  //select parent nav of selected nav
  $("#content_3 li li.selected").parent().parent().addClass("selected");
  
  //special case nav for registration process
  if( $(".nav-78").hasClass('selected') ){
    selectedLink = $(".nav-78 ul").find("li.selected");
    if (!selectedLink.length) { //select the first link if none are selected
      $(".nav-78 ul li:first").addClass("selected");
    }
    $(".nav-78 ul").css({ display: 'block' });
    //if completed page (disable links before)
    if( $(".nav-83").hasClass('selected') ){
      $(".nav-78 li.selected").prevAll().find('a').removeAttr('href').addClass('disabled');
    //other page (disable links after)
    }else{
      $(".nav-78 li.selected").nextAll().find('a').removeAttr('href').addClass('disabled');
    }
  }
  
  //init lightbox
  $("p.lightbox a").lightBox();
  
});