$(document).ready(function(){

  //insert date/time flash plugin
  $('#clock').flash({
    src: basedir+'/swfs/clock.swf',
    width: 300,
    height: 85,
    wmode: "transparent"
  });
  
  //buttons
  $("button")
    .mouseover(function(){ $(this).addClass("hover") })
    .mouseout(function(){ $(this).removeClass("hover") });
  
  //text/input boxes
  $("#content, #left, #right").find("input[type='text'], input[type='password'], textarea")
    .focus(function(){ $(this).addClass("focus"); $(this).width($(this).width()-2); })
    .blur(function(){ $(this).removeClass("focus"); $(this).width($(this).width()+2); });
  //add ie6 functionality
  $("input[type='text']").addClass("input[type=text]");
  $("input[type='password']").addClass("input[type=password]");
  
  //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; }
  });

  //force external links to 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;
        });
      }
    }
  });
  
  //resize images that are too big to fit in the content
  $("#content img").load(function(){
    if($(this).width()>420){
      $(this).width(420);
    }
  }).load(); //calling it right after will handle cached images that already loaded
  
  

});