var maxHeight = 660;
function setMenu(){
 var myElems=document.getElementsByName('menuItem')
 for (i=0; i< myElems.length; i++) {
  if (myElems[i].innerHTML == pageName){
   myElems[i].className = 'myovermenu';
  }
 }
}
function menuOver(me){
 me.className = 'myovermenu';
}
function menuOut(me){
 if (pageName != me.innerHTML){
  me.className = 'myoutmenu';
 }
}
function menuOverR(me){
 me.className = 'myovermenu floatright';
}
function menuOutR(me){
 if (pageName != me.innerHTML){
  me.className = 'myoutmenu floatright';
 }
}
function makeStrong(me){
 me.className = 'strongbox';
}
function makeFaint(me){
 me.className = 'faintbox';
}
function getPageWidth(){
 myElem  = document.getElementById('templatelayer');
 if(myElem.offsetWidth){
  mywidth = myElem.offsetWidth - 2;
 } else if (myElem.style.pixelWidth){
  mywidth = myElem.style.pixelWidth - 2;
 }
 myheight = window.innerHeight;
 if (typeof myheight == 'undefined') {
  myheight = document.documentElement.clientHeight;
 }
 myheight = parseInt(myheight) - 30;
}
function homeSlideShow(){
 getPageWidth();
 strImage = 'gal/' + homeArray[intImage];
 resizeImage();
 var myID = setInterval("nextImage()",6000);
}
function nextImage(){
 intImage++;
 if (intImage>homeArray.length-1){
  intImage=1;
 }
 strImage = 'gal/' + homeArray[intImage];
 resizeImage();
}
function resizeImage(){
 var img = new Image();
 img.onload = function() {
  var sizeFactor = getSizeFactor(this.width,this.height);
  if (sizeFactor > 1.1){
   sizeFactor = 1.1;
  }
  newWidth  = parseInt(this.width * sizeFactor);
  newHeight = parseInt(this.height * sizeFactor);
  var myImage = document.getElementById(mainImage);
  myImage.src    = strImage;
  myImage.width  = newWidth; 
  myImage.height = newHeight;
  var myTop = 0;
  if (newHeight < maxHeight){
   var myTop = parseInt((maxHeight-newHeight)/2);
  }
  myImage.style.top = myTop + 'px';
 }
 img.src = strImage;
}
function resizeHome(){
 var img = new Image();
 img.onload = function() {
  var sizeFactor = getSizeFactor(this.width,this.height);
  if (sizeFactor > 1.1){
   sizeFactor = 1.1;
  }
  newWidth  = parseInt(this.width * sizeFactor);
  newHeight = parseInt(this.height * sizeFactor);
  var myImage = document.getElementById(mainImage);
  myImage.src    = strImage;
  myImage.width  = newWidth; 
  myImage.height = newHeight;
 }
 img.src = strImage;
}
function getSizeFactor(imgWidth,imgHeight){
 var intW = mywidth/imgWidth;
 var intH = myheight/imgHeight;
 if (intW < intH){
  return intW;
 }
 return intH;
}
function oldResizeImage(){
 var img = new Image();
 img.onload = function() {
  if (this.width > mywidth){
   var sizeFactor = mywidth/this.width;
   newWidth  = parseInt(this.width * sizeFactor);
   newHeight = parseInt(this.height * sizeFactor);
  } else {
   newWidth  = this.width;
   newHeight = this.height;
  }
  var myImage = document.getElementById(mainImage);
  myImage.src    = strImage;
  myImage.width  = newWidth; 
  myImage.height = newHeight; 
 }
 img.src = strImage;
}
function showInfo(){
 var myinfo = document.getElementById('infobox');
 if (myinfo){
  myinfo.className = 'strongbox';
 }
}
function hideInfo(){
 var myinfo = document.getElementById('infobox');
 if (myinfo){
  myinfo.className = 'faintbox';
 }
}
function showImage(thumbID,gal_path) {
 largeimage=gal_path.replace("'","").replace("'","");
 var myimg = document.getElementById('mypic');
 var mytn  = document.getElementById(thumbID);
 strImage = largeimage;
 resizeImage();
// alert(mytn.alt);
}
function loadImage(gallery){
 strImage = document.getElementById('mypic').src = mypicStart[gallery];
}
