// Copyright (c) 2008 Martin Sevcik | www.detepak.cz | all rights reserved
// based on ms_slideshow v. 1.0.1


var msSldStepAlpha = 5; // step for viewing image [%]
var msSldStepMilisecond = 35; // step for viewing image [1/1000 second]
var msSldDirName = "../gallery/";
var msSldAlpha = 100;
var msSldHCorr = 100;
var msSldWCorr = 0;
var msSldFileName = "";
var msSldDivname = "gallerybigimage";

function ms_photoshow(imgname) {
  msSldAlpha = 0;
  msSldFileName = imgname;
  ms_portfolio2pm_imgshow();
  document.getElementById(msSldDivname).innerHTML = ms_portfolio2pm_text();
  ms_portfolio2pm_position();
}

function ms_portfolio2pm_text() {
  return "<img id=\"gallerybigimagesrc\" src='" + msSldDirName + msSldFileName + "' />";
}

function ms_portfolio2pm_position() {
  img = new Image();
  img.src = msSldDirName + msSldFileName;
  var corrH = Math.floor((ms_portfolio2pm_getHeight() - msSldHCorr - img.height) / 2);
  var corrW = Math.floor((ms_portfolio2pm_getWidth() - msSldWCorr - img.width) / 2);
  if ((corrH < 0) || (img.height == null) || (img.height == 0)) corrH = 0;
  if ((corrW < 0) || (img.width == null) || (img.width == 0)) corrW = 0;
  document.getElementById(msSldDivname).style.position = "absolute";
  document.getElementById(msSldDivname).style.left = corrW + "px";
  document.getElementById(msSldDivname).style.top = corrH + "px";
  img = null;
  corrH = null;
  corrW = null;
}

function ms_portfolio2pm_getHeight() {
   if (window.innerHeight)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerHeight */
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientHeight;
   else
      return null;
}

function ms_portfolio2pm_getWidth() {
   if (window.innerWidth)
      /* NN4 a kompatibilní prohlížeče */
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      /* MSIE6 v std. režimu - Opera a Mozilla
      již uspěly s window.innerWidth */
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      /* starší MSIE + MSIE6 v quirk režimu */
      return document.body.clientWidth;
   else
      return null;
}

function ms_portfolio2pm_imgshow() {
  if (msSldAlpha > 100) {
    msSldAlpha = 100;
  } else if (msSldAlpha % 10 == 0) {
    ms_portfolio2pm_position();
  }
  if (msSldAlpha < 100) {
    msSldAlpha += msSldStepAlpha;
    document.getElementById(msSldDivname).style.opacity = msSldAlpha / 100;
    document.getElementById(msSldDivname).style.filter = "alpha(opacity=" + msSldAlpha + ")";
  }
}

setInterval("ms_portfolio2pm_imgshow()", msSldStepMilisecond);
