function rounded(r_id, r_image, r_preset, r_w, r_h)
{
  var r_img_id = r_id + "_image";
  var imagecache_path = "/files/imagecache/" + r_preset + "/" + r_image;

  r_w = r_w || 0;
  r_h = r_h || 0;

  var j_image = new Image();
  j_image.onload = function(){return rounded_loaded(j_image, r_id, r_img_id, imagecache_path, r_w, r_h);}
  j_image.src = imagecache_path;
}
function rounded_jloaded(j_image, r_id, r_img_id, imagecache_path)
{
  if (null != j_image.height && 0 != j_image.height)
  {
    r_obj = document.getElementById(r_id);
    if (r_obj)
    {
      r_obj.style.backgroundImage = "url('"+imagecache_path+"')";
      r_obj.style.height = (j_image.height -20) + 'px';
      r_obj.style.width  = j_image.width + 'px';
      r_obj.style.margin = '10px 0px 10px 0px';
      r_obj.style.position = 'relative';
      r_obj.className = 'round_image';
    }
    r_img_obj = document.getElementById(r_img_id);
    if (r_img_obj)
    {
      r_img_obj.style.height = j_image.height + 'px';
      r_img_obj.style.width  = j_image.width + 'px';
      r_img_obj.style.margin = '0px 0px 0px 0px';
      r_img_obj.style.position = 'absolute';
    }
  }
}
function rounded_loaded(j_image, r_id, r_img_id, imagecache_path, r_w, r_h)
{
//IE botches to force width and height
if (r_w) j_image.width  = r_w;
if (r_h) j_image.height = r_h;
if (j_image.height < 20) j_image.height = 40;

    settings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true,
      autoPad: false
    }
  r_obj = document.getElementById(r_id);
  if (r_obj)
  {
    if (null === r_obj.style.height || 0 == r_obj.style.height)
    {
      r_obj.style.backgroundImage = "url('"+imagecache_path+"')";
      r_obj.style.height = (j_image.height - 20) + 'px';
      r_obj.style.width  = (j_image.width + 0) + 'px';
      r_obj.style.margin = '10px 0px 10px 0px';
      r_obj.style.position = 'relative';


      var cornersObj = new curvyCorners(settings, r_obj);
      cornersObj.applyCornersToAll(); 
    }
  }
  r_img_obj = document.getElementById(r_img_id);
  if (r_img_obj)
  {
    if (null === r_img_obj.style.height || 0 == r_img_obj.style.height)
    {
      r_img_obj.style.height = j_image.height + 'px';
      r_img_obj.style.width  = j_image.width + 'px';
      r_img_obj.style.margin = '-10px 0px 0px 0px';
      r_img_obj.style.position = 'absolute';
      r_img_obj.style.zIndex = '1';
    }
  }
/*
  r_b_id = r_id + "_border";
  r_b_obj = document.getElementById(r_b_id);
  if (r_b_obj)
  {
    r_b_obj.style.background = 'transparent';
    r_b_obj.style.height = (j_image.height -18) + 'px';
    r_b_obj.style.width  = (j_image.width + 0) + 'px';
    r_b_obj.style.margin = '10px 0px 10px 0px';
    r_b_obj.style.position = 'relative';
    r_b_obj.style.top    = '-1px';
    r_b_obj.style.border = '1px solid #ccc';
    var cornersObj2 = new curvyCorners(settings, r_b_obj);
    cornersObj2.applyCornersToAll(); 
  }
*/

}
function rounded_bottom(r_id, r_image, r_preset)
{

  var imagecache_path = "/files/imagecache/" + r_preset + "/" + r_image;

  var j_image = new Image();
  j_image.onload = function(){return rounded_bottom_loaded(j_image, r_id);}
  j_image.src = imagecache_path;
}

function rounded_bottom_loaded(j_image, r_id)
{
    settings = {
      tl: { radius: 6 },
      tr: { radius: 6 },
      bl: { radius: 14 },
      br: { radius: 14 },
      antiAlias: true,
      autoPad: false
    }
  r_obj = document.getElementById(r_id);
  if (r_obj)
  {
    r_obj.style.height = j_image.height + 'px';
    r_obj.style.width  = j_image.width + 'px';


    var cornersObj = new curvyCorners(settings, r_obj);
    cornersObj.applyCornersToAll();
  }
}
function set_dimensions(r_id, r_image, r_preset)
{
  var r_img_id = r_id + "_image";
  var imagecache_path = "/files/imagecache/" + r_preset + "/" + r_image;

  var j_image = new Image();
  j_image.src = imagecache_path;

  r_obj = document.getElementById(r_id);
  if (r_obj)
  {
    r_obj.style.height = j_image.height + 'px';
    r_obj.style.width  = j_image.width + 'px';
  }
}
function rounded_rel(r_id, r_image, r_preset)
{

  var r_img_id = r_id + "_image";
  var imagecache_path = "/files/imagecache/" + r_preset + "/" + r_image;

  var j_image = new Image();
  j_image.onload = function(){return rounded_rel_loaded(j_image, r_id, r_img_id, imagecache_path);}
  j_image.src = imagecache_path;
}
function rounded_rel_loaded(j_image, r_id, r_img_id, imagecache_path)
{
    settings = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true,
      autoPad: false
    }
  r_obj = document.getElementById(r_id);
  if (r_obj)
  {
    r_obj.style.backgroundImage = "url('"+imagecache_path+"')";
    r_obj.style.height = (j_image.height - 28) + 'px';
    r_obj.style.width  = j_image.width + 'px';
    r_obj.style.margin = '22px 0px 22px 0px';
    /*r_obj.style.position = 'relative';*/

    var cornersObj = new curvyCorners(settings, r_obj);
    cornersObj.applyCornersToAll();
  }
  /*
  r_img_obj = document.getElementById(r_img_id);
  if (r_img_obj)
  {
    r_img_obj.style.height = j_image.height + 'px';
    r_img_obj.style.width  = j_image.width + 'px';
    r_img_obj.style.margin = '-14px 0px 22px 0px';
    r_img_obj.style.position = 'absolute';
  }
*/
}