function fadeIn( elem , timer , rate) {
var j = 0;
setOpacity (elem,j);
    var interval = setInterval(function() {
        if (j <= 75) {
          setOpacity (elem,j);
          j += rate;
        }
        else {
          clearInterval(interval);
          setOpacity(elem,75);

        }
    },timer);
}

function fadeOut( elem , timer , rate) {
var j = 75;
setOpacity (elem,j);
    var interval = setInterval(function() {
        if (j >= 0) {
          setOpacity (elem,j);
          j -= rate;
        }
        else {
          clearInterval(interval);
          setOpacity(elem,0);
          elem.style.display = "none";
          var container = document.getElementById("lightboxImageContainer");
          container.style.display = "none";
          var imgBox = document.getElementById("lightboxImage");
          imgBox.style.width = "200px";
          imgBox.style.height = "200px";
          imgBox.style.backgroundImage = "url(http://crewandhowell.com/sliderSlideShow/graphics/ajax-loader.gif)";
          document.getElementById("close").style.display = "none";
          var caption = document.getElementById("caption");
          caption.style.display = "none";
          caption.innerHTML = "";
          return;
        }
    },timer);
}

function setOpacity( elem, level ) {
    elem.style.filter = "alpha(opacity="+level+")";
    elem.style.opacity = level / 100;
}

function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) {
//Generic Animation Step Value Generator By www.hesido.com
    var delta = maxValue - minValue;
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta);
    return Math.ceil(stepp)
    }

// powr >  = easi in ; powr < 1 = ease out ; powr = 1 linear
function changeWidth(elem,startWidth,endWidth,steps,intervals,powr) {
    var actStep = 0;
    widthChangeTimer = setInterval(
	function() {
	  setWidth(elem,easeInOut(startWidth,endWidth,steps,actStep,powr));
	  actStep++;
	  if (actStep > steps){
      clearInterval(widthChangeTimer);
	  }
	}
	,intervals)
}

// powr >  = easi in ; powr < 1 = ease out ; powr = 1 linear
function changeHeight(elem,startHeight,endHeight,steps,intervals,powr,obj) {
    var actStep = 0;
    heightChangeTimer = setInterval(
	function() {
	  setHeight(elem,easeInOut(startHeight,endHeight,steps,actStep,powr));
	  actStep++;
	  if (actStep > steps){
      clearInterval(heightChangeTimer);
      var lightboxImg = document.getElementById("lightboxImage");
      lightboxImg.style.backgroundImage = "url("+obj.imgName+")";
      var caption = document.getElementById("caption");
      caption.style.display = "block";
      caption.innerHTML = obj.caption;
      document.getElementById("close").style.display = "block";
      caption.style.width = (parseInt(obj.imgWidth) + 20)+"px";
	  }
	}
	,intervals)
}


function setWidth (elem, wid) {
  elem.style.width = wid + "px";
}

function setHeight (elem, Hit) {
  elem.style.height = Hit+ "px";
}

function setLeftPos(elem,pos) {
  elem.style.left = pos +"px";
}

function scrollXLeft() {
  var de = document.documentElement;
  return self.pageXOffset ||
       ( de && de.scrollLeft ) ||
       document.body.scrollLeft;
}


function scrollYTop() {
   var de = document.documentElement;
    return self.pageYOffset ||
        ( de && de.scrollTop ) ||
        document.body.scrollTop;
}

// returns the width of the viewport
function viewport_width()
{
 if (typeof window.innerWidth != 'undefined') {
      viewportwidth = window.innerWidth;
      }
   else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0) {
     viewportwidth = document.documentElement.clientWidth;
   }
  else {
  viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
  }
return viewportwidth;
}

// returns the height of the viewport
function viewport_height()
{
 if (typeof window.innerHeight != 'undefined') {
      viewportheight = window.innerHeight;
      }
   else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientHeight !=
     'undefined' && document.documentElement.clientHeight != 0) {
     viewportheight = document.documentElement.clientHeight;
   }
  else {
  viewportheight = document.getElementsByTagName('body')[0].clientHeight;
  }
return viewportheight;
}

// find the height of the entire document
function document_height()
{
 var bodyheight = document.body.scrollHeight;
 return bodyheight;
}

// find the width of the entire document
function document_width()
{
 var bodywidth = document.body.scrollWidth;
 return bodywidth;
}


