$(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"); });
  
  //input events
  $("input, textarea")
    .focus(function(){ $(this).addClass("focus"); })
    .blur(function(){ $(this).removeClass("focus"); });
  
  //confirmation alerts
  $(".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");
  
});
