	document.write("<div id=\"popup_background\"></div>");
	document.write("<div id=\"popup_picture\">");
	document.write("	<div id=\"popup_title\"></div>");
	document.write("	<div id=\"popup_image\" style=\"overflow:hidden; cursor:wait;\"></div>");
	document.write("</div>");
	ie5  = (document.all && document.getElementById);
	ns6 = (!document.all && document.getElementById);
	
	function openPopup(img, a){
		p_bg = document.getElementById("popup_background");
		//alert(navigator.appName + " - " + navigator.appVersion);
		if(navigator.appName == "Microsoft Internet Explorer" && !p_bg.filters){
			window.open(img);
		} else {

			selects = document.getElementsByTagName("select");
			for (i = 0; i != selects.length; i++) {
				selects[i].style.visibility = "hidden";
			}
			
			p_picture = document.getElementById("popup_picture");
			p_picture.img = img;
			p_image_source = document.getElementById("popup_image_source");
			
			x = getPageSize();

			p_bg.style.top = 0;
			p_bg.style.left = 0;
			p_bg.style.top = '0px';
			p_bg.style.height = '100%';
			p_bg.style.width = '100%';
	
			if(p_bg.filters){
				p_bg.filters.alpha.opacity = 0;
			} else {
				p_bg.style.MozOpacity = 0/100;
			}
			
			p_bg.op = 0;
			p_bg.style.visibility = "visible";

			p_picture.title = a;
			p_picture.img = img;
			p_picture.src = "";
			//p_picture.ow = w;
			//p_picture.oh = Number(h) + 27 + 27;
			p_picture.ow = 100;
			p_picture.oh = 100;
			p_picture.style.width = 1;
			p_picture.style.height = 1;
			p_picture.x0 = x[0];
			p_picture.x1 = x[1];
			p_picture.x2 = x[2];
			p_picture.x3 = x[3];
			pageScroll = getPageScroll();
			p_picture.x4 = pageScroll;
			document.getElementById("popup_image").innerHTML = "<img src='img/system/loading.gif' alt='loading...'>";
			animOpacity();
		}
	}
	document.animW = 0;
	function animOpacity(){
		p_bg = document.getElementById("popup_background");
		dif = 10;
		maxa = 70;
		if (p_bg.op + dif > maxa){
			dif = maxa - p_bg.op;
		}
		if (p_bg.op < maxa){
			p_bg.op += dif;
			if (p_bg.filters){ //IE
				p_bg.filters.alpha.opacity = p_bg.op;
			} else {
				p_bg.style.MozOpacity = p_bg.op / 100;
			}
			setTimeout("animOpacity()", 10);
		} else {
			p_picture.style.visibility = "visible";
			p_picture.style.display = "block";
			p_picture.style.borderWidth = "2px 2px 2px 2px";
			imgPreloader = new Image();
			imgPreloader.onload=function(){
				p_picture = document.getElementById("popup_picture");
				p_picture.ow = Number(imgPreloader.width);
				p_picture.oh = Number(imgPreloader.height);
				p_title = document.getElementById("popup_title");
				p_title.innerHTML = p_picture.title;	
				p_image = document.getElementById("popup_image");
				p_image.innerHTML = "";
				p_image.appendChild(imgPreloader);
				if (document.animW == 0){
					animWidth();
				}
			}
			animWidth();
			imgPreloader.src = p_picture.img;
		}
	}
	function animWidth(){

		document.animW = 1;
		p_picture = document.getElementById("popup_picture"); 
		p_image = document.getElementById("popup_image");
		
		difW = p_picture.ow - p_picture.offsetWidth;
		if (ns6){
			dif = 20;
		} else {
			dif = 60;
		}
		if (difW > dif * (p_picture.ow / p_picture.oh)){
			difW = dif * (p_picture.ow / p_picture.oh);
		}
		difH = p_picture.oh - p_picture.offsetHeight;
		if (difH > dif){
			difH = dif;
		}
		
		if (difW > 0 || difH > 0){
			cw = p_picture.offsetWidth + difW;
			ch = p_picture.offsetHeight + difH;

			p_picture.style.width = cw;
			p_image.style.width = cw;
			p_picture.style.left = (((p_picture.x0 - 20 - cw) / 2) + 'px');
			
			p_picture.style.height = ch;
			p_image.style.height = ch;
					
			//p_picture.style.top = (p_picture.x3 / 2) - (ch / 2);
			p_picture.style.top = (p_picture.x4 + ((p_picture.x3 - ch) / 2) + 'px');	
			setTimeout("animWidth()", 10);
		} else {
			document.animW = 0;
			if (document.getElementById("popup_title").innerHTML){
				p_title = document.getElementById("popup_title"); 
				p_title.style.display = "block";
			}
			p_picture.style.width = p_picture.ow;
			p_image.style.width = p_picture.ow;
			p_picture.style.height = p_picture.oh;
			p_image.style.height = p_picture.oh;
			p_picture.style.top = (p_picture.x4 + ((p_picture.x3 - p_picture.oh) / 2) + 'px');
			p_picture.style.left = (((p_picture.x0 - 20 - p_picture.ow) / 2) + 'px');
			p_image.style.cursor = "pointer";
			p_image.title = "close";
			p_image.onclick = closePopup;
		}
	}
	function closePopup(){
		p_bg = document.getElementById("popup_background");
		p_picture = document.getElementById("popup_picture");
		p_image = document.getElementById("popup_image");
		p_image.style.cursor = "none";
		p_image.title = "";
		p_image.onclick = null;
		animDownHeight();
		p_title = document.getElementById("popup_title");
		p_title.innerHTML = "";
		p_title.style.display = "none";
	}
	function animDownHeight(){
		p_picture = document.getElementById("popup_picture");
		p_image = document.getElementById("popup_image");
		p_bg = document.getElementById("popup_background");
		div = Math.round((p_picture.offsetHeight) * 0.2) - 1;
		if (div < 2){
			p_picture.style.borderWidth = "1px 0px 0px 0px";
			border = 1;
		} else if (div < 50){
			p_picture.style.borderWidth = "2px 2px 2px 2px";
			border = 4;
		} else {
			border = 6;
		}
		if (div < 1){
			div = 1;
		}
		if (p_picture.offsetHeight > 1){
			ch = p_picture.offsetHeight - div;
			if (ns6){
				ch -= border;
			}
			p_picture.style.height = ch;
			p_image.style.height = ch;
			p_picture.style.top = (p_picture.x3 / 2) - (ch) / 2;
			setTimeout("animDownHeight()", 10);
			//p_bg.style.height = p_bg.offsetHeight + (0 - p_bg.offsetHeight) * 0.2;
		} else {
			animDownWidth();
		}
	}
	function animDownWidth(){
		p_picture = document.getElementById("popup_picture");
		p_image = document.getElementById("popup_image");
		div = Math.round((p_picture.offsetWidth - 20) * 0.2);		
		if (div > 10){
			cw = p_picture.offsetWidth - div;
			p_picture.style.width = cw;
			p_image.style.width = cw;
			p_picture.style.left = (p_picture.x0 / 2) - (p_picture.offsetWidth/ 2);
			setTimeout("animDownWidth()", 10);
		} else {
			hideImageHolder();
		}
	}
	function hideImageHolder(){
		p_picture = document.getElementById("popup_picture");
		p_picture.style.visibility = "hidden";
		p_picture.style.display = "none";	
		animDownOpacity();
	}
	function animDownOpacity(){
		p_bg = document.getElementById("popup_background");
		if (p_bg.op > 0){
			p_bg.op -= 10;
			if(p_bg.filters){//IE
				p_bg.filters.alpha.opacity = p_bg.op;
			} else {
				p_bg.style.MozOpacity = p_bg.op / 100;
			}
			setTimeout("animDownOpacity()", 10);
		} else {
			p_bg = document.getElementById("popup_background");
			p_bg.style.visibility = "hidden";

			selects = document.getElementsByTagName("select");
			for (i = 0; i != selects.length; i++) {
				selects[i].style.visibility = "visible";
			}
			
		}
	}	
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
	function getPageScroll(){
		var yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
		} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
		}
		return yScroll;
	}	