var currentImageId = null;

function overLeadXl(elem, supersizeUrl, supersizeWidth, supersizeHeight, adId) {
  // only if supersizeUrl is empty
  if (!supersizeUrl)
  {
      //find the image
      for (var i = 0; i < elem.childNodes.length; i++) {
      if (elem.childNodes[i].nodeName.toLowerCase() == 'img') {
        var photo = elem.childNodes[i];
      }
    }
    //set the supersize defaults
    if (photo) {
      supersizeUrl = photo.src;
      supersizeWidth = photo.width * 1.5 ;
      supersizeHeight = photo.height * 1.5 ;
    }
  }
  //set the overlib lead string
  var overLead = '<img src="' + supersizeUrl + '" width="' ;
  overLead += supersizeWidth ;
  overLead += '" height="' ;
  overLead += supersizeHeight ;
  overLead += '" alt="Extra large photo!" border"=0">';

	var newImage = '<img src="http://static.racingjunk.com/jscript/overlib/images/exit.gif" alt="Click to Close" border="0">';
	var newCaption = 'Super-size photo for Ad #' + adId

   var success = overlib(overLead, CLOSETEXT, newImage, CLOSECLICK, CAPTION, newCaption, CAPBELOW, STICKY, DRAGGABLE, AUTOSTATUSCAP, REF,'largeImage', REFC,'LL', REFP,'LL', REFX,'20', REFY,'-10', WRAP, SHADOW, SHADOWOPACITY,'60', SHADOWX,'8', SHADOWY,'8')
   return success;
}

function showPic (picSource, picWidth, picHeight, thumbId, startID, supLink) {
  if (document.getElementById)
    {
    var largeImage = document.getElementById('largeImage');
    //set the image
    largeImage.src = picSource;
    largeImage.width = picWidth;
    largeImage.height = picHeight;

    if (document.getElementById('largeImageLink'))
    {
       var largeLink = document.getElementById('largeImageLink');
       largeLink.href= supLink
    }

    //hide the thumbnail
    var divId = 'thumb_' + thumbId;
    var thumbnail = document.getElementById(divId);
    thumbnail.style.display = "none";

    //show the thumbnail of the image we're swapping out
    if (this.currentImageID == null)
    {
      divId = 'thumb_' + startID;
    }
    else
    {
      divId = 'thumb_' + this.currentImageID;
    }

    this.currentImageID = thumbId;
    thumbnail = document.getElementById(divId);
    thumbnail.style.display = "inline";

    return false;
  } else {
    return true;
  }
}
