// aqua-terra-vita.js

var i=0;
var images=new Array();
 images[0]='/Images/RollOvers/smallCrayfish.jpg';
 images[1]='/Images/RollOvers/smallExoticPlants.jpg';
 images[2]='/Images/RollOvers/smallFish.jpg';
 images[3]='/Images/RollOvers/smallFrogs.jpg';
 images[4]='/Images/RollOvers/smallInsects.jpg';
 images[5]='/Images/RollOvers/smallLizards.jpg';
 images[6]='/Images/RollOvers/smallSnakes.jpg';
 images[7]='/Images/RollOvers/smallSpiders.jpg';

function imageFader() {
  fadeInImage('image', images[i], 'imageDiv')
  i=i+1;
  if (i>7) i=0;
  faderTimer=setTimeout('imageFader()',2000);
}

function setOpacity(object, opacityPercent) {
  object.style.filter='alpha(opacity=' + opacityPercent + ')'; /* IE */
  object.style.MozOpacity=opacityPercent/100; /* Old Mozilla Browsers */
  object.style.opacity=opacityPercent/100; /* Modern Mozilla Browsers */
}

function changeOpacity(id, msDuration, msStart, fromO, toO) {
  var element=document.getElementById(id);
  var opacity=element.style.opacity*100;
  var msNow=(new Date()).getTime();
  opacity=fromO + (toO - fromO) * (msNow - msStart) / msDuration;
  if (opacity<0) setOpacity(element,0);
  else if (opacity>100) setOpacity(element,100);
  else{
setOpacity(element,opacity);
element.timer=window.setTimeout("changeOpacity('"+id+"',"+msDuration+","+msStart+","+fromO+","+toO+")",1);
  }
}

function fadeInImage(foregroundId,newImage,backgroundId) {
  var foreground=document.getElementById(foregroundId);
  if (backgroundId) {
var background=document.getElementById(backgroundId);
if (background) {
  background.style.backgroundImage='url('+foreground.src+')';
  background.style.backgroundRepeat='no-repeat';
}
  }
  setOpacity(foreground,0);
  foreground.src=newImage;
  if (foreground.timer) window.clearTimeout(foreground.timer); 
  var startTime=(new Date()).getTime();
  foreground.timer=window.setTimeout("changeOpacity('"+foregroundId+"',1000,"+startTime+",0,100)",10);
}

function getElementWithId(name) {
  if (document.getElementById) return(document.getElementById(name));
  if (document.all) return(document.all[name]);
}

function getWindowHeight() {
  var windowHeight=0;
  if (typeof window.innerHeight==='number') {
/***** Non-IE *****/windowHeight=window.innerHeight;
  }else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
/***** IE 6+ in 'standards compliant mode' *****/windowHeight=document.documentElement.clientHeight;
  }else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
/***** IE 4 compatible *****/windowHeight=document.body.clientHeight;
  }
  return windowHeight;
}

function setIframeHeight() { if (getWindowHeight()<650) getElementWithId('iframe').style.height='500px'; else getElementWithId('iframe').style.height=((getWindowHeight()-150)+'px'); }
