$(document).ready(function(){
  settings = {
    tl: { radius: 10 },
    tr: { radius: 10 },
    bl: { radius: 10 },
    br: { radius: 10 },
    antiAlias: true,
    autoPad: true
  }
  settings2 = {
    tl: { radius: 5 },
    tr: { radius: 5 },
    bl: { radius: 5 },
    br: { radius: 5 },
    antiAlias: true,
    autoPad: true
  }
  var divObj = document.getElementById("contentbox");
  var cornersObj = new curvyCorners(settings, divObj);
  cornersObj.applyCornersToAll();
  var divObj = document.getElementById("menucolumn");
  var cornersObj = new curvyCorners(settings, divObj);
  cornersObj.applyCornersToAll();
  var divObj = document.getElementById("menusystem");
  var cornersObj = new curvyCorners(settings2, divObj);
  cornersObj.applyCornersToAll();
  
  //make print buttons curvy
  $("div.button.print").each(function(){
    var cornersObj = new curvyCorners(settings2, this);
    cornersObj.applyCornersToAll();
  });
  //make other buttons curvy
  $("div.button").each(function(){
    if(!$(this).hasClass("print")){
      var cornersObj = new curvyCorners(settings2, this);
      cornersObj.applyCornersToAll();
    }
  });
  
  //fix button div clicks in non-ie browsers
  if(!$.browser.msie){
    var divClick = true;
    $("div.button button")
      .mouseover(function(){ divClick = false; })
      .mouseout(function(){ divClick = true; });
    $("div.button").click(function(){
      if(divClick && !$(this).hasClass("print")){
        $(this).find("button").trigger("click");
      }
    });
  }
  
  //$("#results tr:has(td.data)")
    //.mouseover(function(){ $(this).find("td.data").addClass("hover"); })
    //.mouseout(function(){ $(this).find("td.data").removeClass("hover"); })
    if($.browser.msie && $.browser.version <= 6){
    $("#results tr:has(td.data)")
      .mouseover(function(){ $(this).find("td.data").addClass("hover"); })
      .mouseout(function(){ $(this).find("td.data").removeClass("hover"); })
    }
    $("#results tr:has(td.data)")
    .click(function(){
      if(confirm('Print a tag for this transaction?')){
        printTag(this);
        //wait 4 seconds for the user to print, then return the return rows to normal
        setTimeout('$("body *").removeClass("print-hide");$("body *").removeClass("hide-tr");', 4000);
      }
    });
});

function printTag(e){
    $("h1, h2, h3, h4, p, ul, caption, tr, th, td, table").addClass("print-hide");
    $("tr").addClass("hide-tr");
    
    $("#results th").removeClass("print-hide");
    $(e).parents('table').removeClass('print-hide');
    $(e).parents('tdbody').removeClass('print-hide');
    $(e).children().removeClass("print-hide");
    $(e).removeClass("print-hide");
    $(e).removeClass("hide-tr");
    window.print();
}
