<!--

function setOpacity(obj, opacity) {
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  var opOne = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opOne;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opOne;
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opOne;
}

/* Image fade */

document.write("<style type='text/css'>#image {visibility:hidden;}</style>");

var imageObj;

function initImage() {
  if (document.getElementById) {
  	imageObj = document.getElementById('image');
  	if (imageObj) {
  	  setOpacity(imageObj, 0);
  	  imageObj.style.visibility = "visible";
      fadeIn(15);
    }
  }
}
function fadeIn(opacity) {
  if (opacity <= 100) {
     setOpacity(imageObj, opacity);
     opacity += 15;
     window.setTimeout("fadeIn("+opacity+")", 75);
  } else {
    setOpacity(imageObj, 100);
  }
}

window.onload = initImage;

/* Metadata */
/*
document.write("<style type='text/css'>#metadata {display:none;z-index:999;position:absolute}</style>");

var metadata;

function details() {
    if (document.getElementById) {
      if (!metadata) {
        // lazy init
        metadata = document.getElementById("metadata");
        var image = document.getElementById("image");
        if (metadata && image) {
          var imagePos = findPos(image);
          // events
          metadata.onclick=details;
          // positioning
          metadata.style.left = imagePos[0] + 'px';
          metadata.style.top = imagePos[1] + 'px';
          metadata.style.width = image.offsetWidth + 'px';
          metadata.style.height = image.offsetHeight + 'px';
        }
    }
    if (metadata.style.display != "block") {
      setOpacity(metadata, 0);
      metadata.style.display = "block";
      fadeInMetadata(15);
    } else {
      fadeOutMetadata(85);
    }
  }
}

function fadeInMetadata(opacity) {
  if (opacity <= 85) {
    setOpacity(metadata, opacity);
    opacity += 15;
    window.setTimeout("fadeInMetadata("+opacity+")", 75);
  }
}

function fadeOutMetadata(opacity) {
  if (opacity >= 0) {
    setOpacity(metadata, opacity);
    opacity -= 15;
    window.setTimeout("fadeOutMetadata("+opacity+")", 75);
  } else {
    metadata.style.display = "none";
  }
}
*/

/* Comment form */

document.write("<style type='text/css'>#commentForm {display:none;z-index:999;position:absolute}</style>");

var commentForm;

function toggleCommentForm() {
    if (document.getElementById) {
      if (!commentForm) {
        // lazy init
        commentForm = document.getElementById("commentForm");
        var image = document.getElementById("image");
        if (commentForm && image) {
          var imagePos = findPos(image);
          // events
          // commentForm.onclick=toggleCommentForm;
          // positioning
          commentForm.style.left = imagePos[0] + 'px';
          commentForm.style.top = imagePos[1] + 'px';
          commentForm.style.width = image.offsetWidth + 'px';
          commentForm.style.height = image.offsetHeight + 'px';
        }
    }
    if (commentForm.style.display != "block") {
      setOpacity(commentForm, 0);
      commentForm.style.display = "block";
      fadeInCommentForm(15);
    } else {
      fadeOutCommentForm(85);
    }
  }
}

function fadeInCommentForm(opacity) {
  if (opacity <= 85) {
    setOpacity(commentForm, opacity);
    opacity += 15;
    window.setTimeout("fadeInCommentForm("+opacity+")", 75);
  }
}

function fadeOutCommentForm(opacity) {
  if (opacity >= 0) {
    setOpacity(commentForm, opacity);
    opacity -= 15;
    window.setTimeout("fadeOutCommentForm("+opacity+")", 75);
  } else {
    commentForm.style.display = "none";
  }
}

// http://www.quirksmode.org/js/findpos.html
function findPos(obj) {
  var curleft = curtop = 0;
  if (obj.offsetParent) {
    curleft = obj.offsetLeft
    curtop = obj.offsetTop
    while (obj = obj.offsetParent) {
      curleft += obj.offsetLeft
      curtop += obj.offsetTop
    }
  }
  return [curleft,curtop];
}

// -->