	var interrupt;
function getImage(id,iName,w,h) {	
	//prevent more than one  images being open at the same time and interruption of funtion by clicking on an another  
	//image before first image is fully displayed, but let function take its course if an image is clicked twice
	if(interrupt && interrupt!=id){
		closeImage(interrupt);
	}
	interrupt=id;
	document.images[id].src=iName;
	FadeInImage(id,w,h);
}
function FadeInImage(id,w,h) {
	image = document.getElementById(id);
	image.style.display = (image.style.display == "block") ? "none":"block" ;
	div = document.getElementById(id +'d');
	div.style.display = (div.style.display == "block") ? "none":"block" ;
	if (image.style.display == "block"){		
		if(!w){
			var w=image.width;
		}
		if(!h){
			var h=image.height;
		}
		var i=0;
		var bh=browserHeight();
		var bw=browserWidth();
		//get position of top of window after scrolling
		if (navigator.appName == "Microsoft Internet Explorer"){
			var scrolledTo=document.documentElement.scrollTop;
		}else{
			var scrolledTo=window.pageYOffset;
		}
		//image is centered horizontally, and, if page height is less than window height
		//top of image is at top of window, othwerise it is centered vertically in the window
		var W=(bw-w)/2;	
		if (h<bh){
			var T =((bh-h)/2)+scrolledTo;
		}else{ 
			var T=scrolledTo;
		}
		var n=Math.floor(Math.random()*2);
		scaleIn(T,W,i,w,h,n);
		setOpacity(image,0);
		fadeIn(id,0);
	}
	if(i==100){interrupt='';}
}
function scaleIn(T,W,i,w,h,n){
	if (i <= 99) {
		i++;
		imgWidth=i*w*0.01;
		imgHeight=i*h*0.01;
		var bodyw=738;
		j=((bodyw-w)/2)+(w/2*(100-i)/100);				
		k=T+(h/2*(100-i)/100);
		div.style.marginLeft=j + "px";			
		div.style.marginTop=k+ "px";
		switch (n){
			case 0:
				image.style.width=imgWidth + "px";		
				image.style.height=imgHeight + "px";
				div.style.width=imgWidth + "px";		
				div.style.height=imgHeight + "px";
			break;
			case 1:
				image.style.width=imgWidth + "px";		
				div.style.width=imgWidth + "px";		
		}
		setTimeout("scaleIn("+T+","+W+","+i+","+w+","+h+","+n+")",5);	
	}
}
//My thanks to Richard Rutter: clagnut.com/sandbox/imagefades.php/ for the following two functions.
function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity ++;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 5);
		}
	}
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}
function closeImage(id){
	image = document.getElementById(id);
	div = document.getElementById(id +'d');
	div.style.display = "none";
	image.style.display =  "none";
}
function browserWidth() {
  var bw = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    bw = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth) ) {
    //IE 6+ in 'standards compliant mode'
    bw = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth ) ) {
    //IE 4 compatible
    bw = document.body.clientWidth;
  }
  return bw;
}
function browserHeight() {
  var bh = 0;
  if( typeof( window.innerHeight) == 'number' ) {
    //Non-IE
    bh = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientHeight) ) {
    //IE 6+ in 'standards compliant mode'
    bh = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientHeight ) ) {
    //IE 4 compatible
    bh = document.body.clientHeight;
  }
  return bh;
}
