//<!--
var links=document.getElementById('allImages').getElementsByTagName('a');
var newImg = new Image(),height,width,height1,width1,height2=0,width2=0,opacity=0,opacity1=0,imgNum;
for(var i=0;i<links.length;i++){
  links[i].href="javascript:getImage("+(i)+")";
}
for(var i=0;i<imageList.length;i++){
  newImg[i]=new Image();
}
function imageClose(){
  document.getElementById('fullImg').style.visibility='hidden';
  document.getElementById('nextImg').style.visibility='hidden';
  document.getElementById('prevImg').style.visibility='hidden';
  document.getElementById('imgCount').style.visibility='hidden';
  document.getElementById('imgClose').style.visibility='hidden';
  document.getElementById('blackBack').style.visibility='hidden';
  document.getElementById('imgBack').style.visibility='hidden';
  document.getElementById('imgBack').style.width=0;
  document.getElementById('imgBack').style.height=0;
  width2=0;
  height2=0;
}
function nextImage(){
  imgNum++;
  getImage(imgNum);
}
function prevImage(){
  imgNum--;
  getImage(imgNum);
}
function getImage(image){
  document.getElementById('fullImg').style.visibility='hidden';
  opacity1=0;
  imgNum=parseInt(image);
  document.getElementById('nextImg').style.visibility='hidden';
  document.getElementById('prevImg').style.visibility='hidden';
  document.getElementById('imgCount').style.visibility='hidden';
  document.getElementById('blackBack').style.height=document.getElementById('inner').offsetHeight+'px';
  document.getElementById('blackBack').style.visibility='visible';
  newImg[imgNum].src = (path+imageList[image]);
  setOpacity();
}
function setOpacity(){
  if(opacity<100){
    opacity+=10;
    document.getElementById('blackBack').style.opacity = (opacity / 100);
    document.getElementById('blackBack').style.filter = "alpha(opacity=" + opacity + ")";
    setTimeout("setOpacity()",1);
  }else{
    getDims();
  }
}
function getDims(){
  if(newImg[imgNum].complete){
    height=newImg[imgNum].height;
    width=newImg[imgNum].width;
    var ratio=1;
    if(height>document.documentElement.clientHeight){
      ratio=(document.documentElement.clientHeight-20)/height;
    }
    document.getElementById('fullImg').src=newImg[imgNum].src
    document.getElementById('fullImg').width=(width*ratio*.9);
    document.getElementById('fullImg').height=(height*ratio*.9);
    width1=(width*ratio*.9)+20;
    height1=(height=(height*ratio*.9))+40;
    document.getElementById('imgBack').style.visibility='visible';
    setWidth();
  }else setTimeout('getDims()',50);
}
function setWidth(){
  if(width2<width1){
    setWidthUp();
  }
  else if(width2>width1){
    setWidthDown();
  }else{
    setHeight();
  }
}
function setWidthUp(){
  width2+=width1/10;
  document.getElementById('imgBack').style.marginLeft=(-width2/2)+"px";
  document.getElementById('imgBack').style.width=width2+"px";
  if(width2<width1){
    setTimeout("setWidthUp()",5);
  }else{
    width2=width1;
    document.getElementById('imgBack').style.marginLeft=(-width2/2)+"px";
    document.getElementById('imgBack').style.width=width2+"px";
    setHeight();
  }
}
function setWidthDown(){
  width2-=width1/10;
  document.getElementById('imgBack').style.marginLeft=(-width2/2)+"px";
  document.getElementById('imgBack').style.width=width2+"px";
  if(width2>width1){
    setTimeout("setWidthDown()",5);
  }else{
    width2=width1;
    document.getElementById('imgBack').style.marginLeft=(-width2/2)+"px";
    document.getElementById('imgBack').style.width=width2+"px";
    setHeight();
  }
}
function setHeight(){
  if(height2<height1){
    setHeightUp();
  }
  else if(height2>height1){
    setHeightDown();
  }else{
    setTimeout("showImage()",500);
  }
}
function setHeightUp(){
  height2+=height1/10;
  document.getElementById('imgBack').style.height=height2+"px";
  if(height2<height1){
    setTimeout("setHeightUp()",5);
  }else{
    height2=height1;
    document.getElementById('imgBack').style.height=height2+"px";
    setTimeout("showImage()",500);
  }
}
function setHeightDown(){
  height2-=height1/10;
  document.getElementById('imgBack').style.height=height2+"px";
  if(height2>height1){
    setTimeout("setHeightDown()",5);
  }else{
    height2=height1;
    document.getElementById('imgBack').style.height=height2+"px";
    setTimeout("showImage()",500);
  }
}
function showImage(){
  document.getElementById('fullImg').style.visibility='visible';
  opacity1+=100;
  document.getElementById('fullImg').style.opacity = (opacity1 / 100);
  document.getElementById('fullImg').style.filter = "alpha(opacity=" + opacity1 + ")";
  if(opacity1<100){
    setTimeout("showImage()",100);
  }else{
    document.getElementById('imgCount').innerHTML=(imgNum+1)+' of '+imageList.length;
    if(imgNum<(imageList.length-1)){
    document.getElementById('nextImg').style.visibility='visible';
    }
    if(imgNum>0){
    document.getElementById('prevImg').style.visibility='visible';
    }
    document.getElementById('imgClose').style.visibility='visible';
    document.getElementById('imgCount').style.visibility='visible';
  }
}
//-->

