var HOST = 'http://'+location.host+'/web/';
load_img = new Image();
load_img.src = HOST+'images/loader.gif';

img4 = new Image();
img4.src = HOST+'images/close.jpg';

document.write('<div id="gallery"></div>');
document.write('<div id="loading"><a href="javascript:close();"><img src="'+HOST+'images/loader.gif" alt="loading..." border="0" /></a></div>');
document.write('<div id="shadow"></div>');

var div = document.getElementById('gallery');
var loading = document.getElementById('loading');
var shadow = document.getElementById('shadow');

function gallery(image){

	var ScrollPosition = document.documentElement.scrollTop; 
	shadowHeight = document.body.clientHeight;
	
	if(shadowHeight < document.documentElement.clientHeight){
		shadowHeight = document.documentElement.clientHeight;
	}
	
	shadow.style.height = shadowHeight + "px";
	shadow.style.display = 'block';
  	
	img = new Image();
 	img.src = image;
	
	if(navigator.appName == 'Netscape' || navigator.appName == 'Opera'){
		ScreenHeight_half = Math.round(window.innerHeight/2);
	}
	else if(navigator.appName == 'Microsoft Internet Explorer'){
		ScreenHeight_half = Math.round(document.documentElement.clientHeight/2);
	}
	else{
		ScreenHeight_half = Math.round(window.innerHeight/2);
	}
	
	loading.style.top = ScreenHeight_half + ScrollPosition - 8 + 'px';
	loading.style.display = 'block';
		
	var n=0;
	
	function galleryAlpha(){
		n += 0.1;
		div.style.opacity = n;
		div.style.filter = "alpha(opacity=" + n*100 + ")";
		
		if(n>1){
			
			if(meter != "undefined"){
				clearInterval(meter);
			}

		}
	}
	
	var object = document.getElementsByTagName('object');
	for(i=0;i<object.length;i++){
		object[i].style.visibility = 'hidden';
	}

	function ShowImage(){
	
		var ImgWidth  = img.width+20;
		var ImgHeight = img.height;
		var ImgBorder = 10;
			
		ImgWidth_half  = Math.round(ImgWidth/2);
		ImgHeight_half = Math.round(ImgHeight/2);
		
		div.style.top = ScreenHeight_half + ScrollPosition - ImgHeight_half - ImgBorder + 'px';
		
		div.style.marginLeft = '-'+ImgWidth_half+'px';
	 
		div.innerHTML = '<a href="javascript:close();"><img class="g_image" src="'+image+'" /></a>';
		
		div.innerHTML += '<a class="gallery_close" href="javascript:close();"><img border="0" src="'+HOST+'images/close.jpg" alt="close" /></a>';
		
		loading.style.display = 'none';
	
		div.style.display = 'block';
		
		meter = setInterval(galleryAlpha,50);

	}
	
	if(img.complete){
		
		ShowImage();
	
	}
	else{
		
		img.onload = function(){
		
			ShowImage();
		
		}
	}
}

function close(){
/*	n = 1;
	function galleryAlpha2(){
		n -= 0.1;
		div.style.opacity = n;
		div.style.filter = "alpha(opacity=" + n*100 + ")";
		
		m = n - 0.4;
		
		if(m>=0){
		
			shadow.style.opacity = m;
			shadow.style.filter = "alpha(opacity="+ m*100 + ")";
		
		}
		
		if(n<0){
	
			div.innerHTML = '';
			loading.style.display = 'none';	
			div.style.display = 'none';
			shadow.style.display = 'none';
			div.style.opacity = 0;
			div.style.filter = "alpha(opacity=0)";
			shadow.style.opacity = 0.6;
			shadow.style.filter = "alpha(opacity=60)";
			
			var object = document.getElementsByTagName('object');
			for(i=0;i<object.length;i++){
				object[i].style.visibility = 'visible';
			}
		
		}
		
		if(n<0){
			
			if(interval != "undefined"){
				clearInterval(interval);
			}

		}
	}
	
	interval = setInterval(galleryAlpha2,300);
*/	
	div.innerHTML = '';
	loading.style.display = 'none';	
	div.style.display = 'none';
	shadow.style.display = 'none';
	div.style.opacity = 0;
	div.style.filter = "alpha(opacity=0)";
	shadow.style.opacity = 0.6;
	shadow.style.filter = "alpha(opacity=60)";
	
	var object = document.getElementsByTagName('object');
	for(i=0;i<object.length;i++){
		object[i].style.visibility = 'visible';
	}

}

