function iLoading(){
	var oImg = new Image();
	var loading = '../../images_layout/loading.gif';
	oImg.src = loading;
	
	if (oImg.complete) {
		var elem, vis, whichLayer;
		//loading
		whichLayer = 'centeredDiv';
  		if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  		else if( document.all ) // this is the way old explorer versions work
      		elem = document.all[whichLayer];
 		else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  		vis = elem.style;
  		
  		vis.width = oImg.width + 'px';
  		vis.height = oImg.height + 'px';
  		
  		vis.marginTop = '-' + oImg.height/2 + 'px';
  		vis.marginLeft = '-' + oImg.width/2 + 'px';
  		
  		//image
  		elem.innerHTML = '<a href="#" onClick="iClose()"><img src="' + loading + '" NOSAVE BORDER=0></a>';
  		

		//display
		whichLayer = 'imageZoom';
  		if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  		else if( document.all ) // this is the way old msie versions work
      		elem = document.all[whichLayer];
 		else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  		vis = elem.style;
  		vis.display = 'block';
  	}
  	else {
		setTimeout('iLoading()');
	}
}


function iLoad(isrc,firstTime) {

	//print the loading
	if(firstTime){
		iLoading();
	}

	var oImg = new Image();
	//load image
	oImg.src = isrc;
	//alert('loaded');
	if (oImg.complete) {
		//window.alert(oImg.src + ' ' + oImg.width + ' x ' + oImg.height);
		var elem, vis, whichLayer;
		//change block and center
		//change dimension and position of centeredDiv
		whichLayer = 'centeredDiv';
  		if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  		else if( document.all ) // this is the way old explorer versions work
      		elem = document.all[whichLayer];
 		else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  		vis = elem.style;
  		
  		/*vis.width = oImg.width + 'px';
  		vis.height = oImg.height + 'px';
  		
  		vis.marginTop = '-' + oImg.height/2 + 'px';
  		vis.marginLeft = '-' + oImg.width/2 + 'px';*/
  		
  		
  		//the opening window has to be smaller than the window
  		if (parseInt(navigator.appVersion)>3) {
 			if (navigator.appName=="Netscape") {
 				winW = window.innerWidth-16;
  				winH = window.innerHeight-16;
 			}
 			if (navigator.appName.indexOf("Microsoft")!=-1) {
  				winW = document.body.offsetWidth-20;
  				winH = document.body.offsetHeight-20;
 			}
		}
  		
  		var imageWidth, imageHeight;
  		
  		if(winW <= oImg.width){
  			imageWidth = winW - 20;
  		}
  		else{
  			imageWidth = oImg.width;
  		}
  		if(winH <= oImg.height){
  			imageHeight = winH - 20;
  		}
  		else{
  			imageHeight = oImg.height;
  		}
  		
  		vis.width = imageWidth + 'px';
  		vis.height = imageHeight + 'px';
  		
  		vis.marginTop = '-' + imageHeight/2 + 'px';
  		vis.marginLeft = '-' + imageWidth/2 + 'px';
  		
  		//inserts image
  		elem.innerHTML = '<a href="#" onClick="iClose()"><img src="' + isrc + '" NOSAVE BORDER=0></a>';
  		
  		/*vis.width = '409px';
  		vis.height = '432px';
  		
  		vis.marginTop = '-216px';
  		vis.marginLeft = '-205px';*/
		
		
		
		//display all
		whichLayer = 'imageZoom';
  		if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  		else if( document.all ) // this is the way old msie versions work
      		elem = document.all[whichLayer];
 		else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  		vis = elem.style;
  		vis.display = 'block';
	}
	else {
		setTimeout('iLoad("' + isrc + '",false)', 10);
		//alert('retry');
	}
}

function iClose() {
		
	//hide all
	whichLayer = 'imageZoom';
  	if( document.getElementById ) // this is the way the standards work
    	elem = document.getElementById( whichLayer );
  	else if( document.all ) // this is the way old explorer versions work
      	elem = document.all[whichLayer];
 	else if( document.layers ) // this is the way nn4 works
    	elem = document.layers[whichLayer];
  	vis = elem.style;
  	vis.display = 'none';

}

function centerLoading(){
	var loading = '../../images_layout/loading.gif';
	whichLayer = 'center';
  		if( document.getElementById ) // this is the way the standards work
    		elem = document.getElementById( whichLayer );
  		else if( document.all ) // this is the way old explorer versions work
      		elem = document.all[whichLayer];
 		else if( document.layers ) // this is the way nn4 works
    		elem = document.layers[whichLayer];
  		
  		//insert image
  		elem.innerHTML = '<br><br><br><p align="center"><img src="' + loading + '" NOSAVE BORDER=0></p>';
}