// MEZZ fx //

function overwriteGalleryStyles()
{
  var o = document;
  o.writeln('<style type="text/css" media="screen, projection">');
  o.writeln('#gallery-nav { float:right; width:180px; margin-top:21px; }');
  o.writeln('#gallery-nav ul { margin:1.2em 0; }');
  o.writeln('</style>');
}

function galleryPrevious(po) {
  if (window.oSlideShow) oSlideShow.showPreviousImage();
  return;
}

function galleryNext(po) {
  if (window.oSlideShow) oSlideShow.showNextImage();
  return;
}

function SlideShow()
{
  this.sName = '';
  this.sPath = '';
  this.oImgage;
  this.oCamption;
  this.aImages = new Array();
  this.iCurrentImage = 0;
  this.dom = (document.getElementById) ? true : false;
  this.all = (document.all) ? true : false;
  this.layers = (document.layers) ? true : false;
  return;
}


SlideShow.prototype.print = function()
{
  var o = document;
  o.writeln('<div id="gallery-script">');
  
  o.writeln('<p>' + this.sName + '</p>');
  o.write('<img name="galleryimg" id="galleryimg" src="');
  o.write(this.sPath + this.aImages[0][0]);
  o.write('" width="260" height="196" alt="" border="0" />');
  o.writeln('<br />');
  if (this.layers && !this.dom) {
    o.writeln('<layer name="gallerytxt" id="gallerytxt">' + this.getCaptionHTML() + '</layer><br /><br /><br />');
  }
  else {
    o.writeln('<div name="gallerytxt" id="gallerytxt">' + this.getCaptionHTML() + '</div>');
  }
  o.writeln('<div id="gallery-buttons">');
  o.writeln('<a href="javascript:galleryPrevious();" onclick="if (this.blur) this.blur();" title="show previous image"><img src="img/button_arrow_left.jpg" width="36" height="28" alt="show previous image" border="0" /></a>');
  o.writeln('<a href="javascript:galleryNext();" onclick="if (this.blur) this.blur();" title="show next image"><img src="img/button_arrow_right.jpg" width="32" height="28" alt="show next image" border="0" /></a>');
  o.writeln('</div>');

  o.writeln('</div>');
  return;
}

SlideShow.prototype.imageObjectAvailable = function()
{
  if (typeof this.oImgage == 'undefined') this.initImageObject();
  return (typeof this.oImgage == 'undefined') ? false : true;
}

SlideShow.prototype.captionObjectAvailable = function()
{
  if (typeof this.oCaption == 'undefined') this.initCaptionObject();
  return (typeof this.oCaption == 'undefined') ? false : true;
}

SlideShow.prototype.initImageObject = function()
{
  if (this.dom) {
    this.oImgage = document.getElementById('galleryimg');
  } else if (this.all) {
    this.oImgage = document.all['galleryimg'];
  } else {
    this.oImgage = document.images['galleryimg'];
  }
  return;
}

SlideShow.prototype.initCaptionObject = function()
{
  if (this.dom) {
    this.oCaption = document.getElementById('gallerytxt');
  } else if (this.all) {
    this.oCaption = document.all['gallerytxt'];
  } else {
    this.oCaption = document.layers['gallerytxt'];
  }
  return;
}

SlideShow.prototype.showPreviousImage = function()
{
  this.changeImage(-1);
  return; 
}

SlideShow.prototype.showNextImage = function()
{
  this.changeImage(1);
  return; 
}

SlideShow.prototype.changeImage = function(pI)
{
  if (!this.imageObjectAvailable()) return;
  this.iCurrentImage = this.iCurrentImage + pI;
  if (this.iCurrentImage < 0) this.iCurrentImage = this.aImages.length - 1;
  if (this.iCurrentImage >= this.aImages.length) this.iCurrentImage = 0;
  this.oImgage.src = this.sPath + this.aImages[this.iCurrentImage][0];
  if (!this.captionObjectAvailable()) return;
  this.updateCaption();
}

SlideShow.prototype.updateCaption = function()
{
  var s = this.getCaptionHTML();
  if (this.layers && !this.dom) {
    this.oCaption.document.open();
    this.oCaption.document.write(s);
    this.oCaption.document.close();
  }
  else {
    this.oCaption.innerHTML = s;
  }
}

SlideShow.prototype.getCaptionHTML = function()
{
  var s = '<p>';
  if (this.aImages[this.iCurrentImage][1].length > 0) {
    s += this.aImages[this.iCurrentImage][1] + '<br />'
  }
  if (this.aImages[this.iCurrentImage][2] == 1) {
    s += '<a href="' + this.sPath + 'hr_';
    s += this.aImages[this.iCurrentImage][0] + '" target="_blank">';
    s += 'view high resolution version</a>'
  }
  s += '</p>';
  return s;
}

SlideShow.prototype.addImage = function(sImage, sCaption, iHighres)
{
  this.aImages[this.aImages.length] = new Array(sImage, sCaption, iHighres);
  return;
}

SlideShow.prototype.setGalleryName = function(sName)
{
  this.sName = sName;
  return;
}

SlideShow.prototype.setGalleryPath = function(sPath)
{
  this.sPath = sPath;
  return;
}

SlideShow.prototype.init = function()
{
  if(document.getElementById) {
    this.locateGalleryImageDOM();
    this.createSlideShowDataDOM();
  }
  else {
    this.locateGalleryImageNODOM();
    this.createSlideShowDataNODOM();
  }
  alert(this.oGalleryImg.src);
  
  return;
}

SlideShow.prototype.locateGalleryImageDOM = function()
{
  this.oGalleryImg = document.getElementById('galleryimg');
  return;
}

SlideShow.prototype.locateGalleryImageNODOM = function()
{
  this.oGalleryImg = document.images['galleryimg'];
  return;
}

overwriteGalleryStyles();

