function setOpacity(value){
	thisObj= new getObj("image_container");
	thisObj.style.opacity = value/10;
	thisObj.style.filter = 'alpha(opacity=' + value*10 + ')';
	thisObj= new getObj("image_subscript");
	thisObj.style.opacity = value/10;
	thisObj.style.filter = 'alpha(opacity=' + value*10 + ')';
}

function loadPrevNext(id){
	currentId=id;
	previousId=id-1;
	nextId=id+1;
	total=img.length-1;
	if(previousId<1){
		previousId=total; 
	}
	if(nextId>total){
		nextId=1;
	}
	nextImage= new Image;
	nextImage.src = img[nextId];
	previousImage= new Image;
	previousImage.src = img[previousId];
}

function showNextImage(){
	setOpacity(0);
	document.images["imgbig"].src=nextImage.src;
	writeIt(subscript[nextId],"image_subscript");
	counterText=nextId+"/"+total;
	writeIt(counterText,"counter");
	fadeIncrement=0;
	fadeImage();
	loadPrevNext(nextId);
}

function showPreviousImage(){
	setOpacity(0);
	document.images["imgbig"].src=previousImage.src;
	writeIt(subscript[previousId],"image_subscript");
	counterText=previousId+"/"+total;
	writeIt(counterText,"counter");
	fadeIncrement=0;
	fadeImage();
	loadPrevNext(previousId);
}

function fadeImage(){
	if(fadeIncrement!=11){
		setOpacity(fadeIncrement);
		fadeIncrement++;
		fadeTimer=setTimeout("fadeImage()",60);
	}
	else{
		clearTimeout(fadeTimer);
	}
}

function initImageViewer(){
	fadeIncrement=0;
	loadPrevNext(1);
	fadeImage();
}

function writeIt(text,id){
  if (document.getElementById){
          x = document.getElementById(id);
          x.innerHTML = text;
  }
  else if (document.all){
          x = document.all[id];
          x.innerHTML = text;
  }
  else if (document.layers){
          x = document.layers[id];
          text2 = '<P CLASS="testclass">' + text + '</P>';
          x.document.open();
          x.document.write(text2);
          x.document.close();
  }
}

