function ShowcaseSlideRight()
{
  var showcase = jQuery("#showcase");
  var imageWidth = jQuery("IMG:first", showcase).width();
  var images = jQuery("#showcase-slider").children().size();
  var position = showcase.scrollLeft() / imageWidth;
  
  if (!slideRight)
  {
    if (position > 0)
      position--;
    else
    {
      position++;
      slideRight = true;
    }
  }
  else
  {
    if (position < images - 1)
      position++;
    else
    {
      position--;
      slideRight = false;
    }
  }
    
  var margin = position * imageWidth;
  ShowcaseResize();  
  jQuery("#showcase").animate({"scrollLeft": margin}, 1000, "swing");
}

function generateShowcase()
{
  slideRight = true;
  
  var showcase = jQuery("#showcase").css("overflow", "hidden");
  var imageWidth = jQuery("IMG:first", showcase).width();
  var imageHeight = 0;
  var sliderWidth = jQuery("#showcase").children().size() * 186;
  var slider = jQuery("<div></div>").attr("id", "showcase-slider").css("width", sliderWidth + "px");
  
  jQuery("A", showcase).css("display", "block").css("float", "left").wrapAll(slider);
  
  jQuery("IMG", showcase).each(function(i)
  {
    if (jQuery(this).height() > imageHeight)
      imageHeight = jQuery(this).height();
  });

  if (sliderWidth > 0)
    window.setInterval("ShowcaseSlideRight()", 3000);
}

function ShowcaseResize()
{
  var height = 0;
  jQuery("IMG", jQuery("#showcase")).each(function()
  {
    if (jQuery(this).height() > height)
      height = jQuery(this).height();
  });

  jQuery("#showcase").css("height", height + "px");
}
      

  
jQuery(document).ready(function(e)
{
  jQuery("[rel=external]").attr("target", "_blank");
  
  jQuery("[rel^=lightbox]").lightBox();
  jQuery("[rel=ads]").lightBox();
  
  generateShowcase();
});

function openFullScreenWindow(url)
{
  var screenWidth = 800, screenHeight = 600;
  
  if (document.all)
    screenWidth = screen.width, screenHeight = screen.height;
  else if (document.layers)
    screenWidth = window.outerWidth, screenHeight = window.outerHeight;

  var options = 'directories=no';
  options += ', menubar=no';
  options += ', toolbar=no';
  options += ', location=no';
  options += ', status=no';
  options += ', scrollbars=no';
  options += ', top=0';
  options += ', left=0';
  options += ', resizable=yes';

  w = window.open(url, 'Title', options);
  w.moveTo(0, 0);
  w.resizeTo(w.screen.availWidth, w.screen.availHeight);
  w.focus();
}
