$(function()
{
      $('a[@rel*=lightbox]').lightBox({
        overlayBgColor: '#030900',
        overlayOpacity: 0.6,
        imageLoading: '/themes/winetrainers/images/lightbox-ico-loading.gif',
        imageBtnClose: '/themes/winetrainers/images/lightbox-btn-close.gif',
        imageBtnPrev: '/themes/winetrainers/images/lightbox-btn-prev.gif',
        imageBtnNext: '/themes/winetrainers/images/lightbox-btn-next.gif',
        containerResizeSpeed: 350,
        txtImage: 'Image',
        txtOf: 'of' });
});

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_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 + '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';
    }
  }
}
