	document.write("<div id=\"popup_background\" style=\"position:absolute; visibility:hidden; -moz-opacity:0; filter: alpha(opacity:100); background-color:#333333;\"></div>");
	document.write("<div id=\"popup_picture\" style=\"position:absolute; display:none; text-align:center; background-color:#963338; border:3px solid #ffffff; overflow:hidden;\">");
	document.write("	<div id=\"popup_title\" style=\"border-right:3px solid #ffffff; border-bottom:3px solid #ffffff; padding:4px; position:absolute; background-color:#963338; display:none;\" class=\"sectionTitleWhite\"></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, w, h){
		// once image is preloaded, resize image container
		p_bg = document.getElementById("popup_background");
		//alert(navigator.appName + " - " + navigator.appVersion);
		if (!w, !h){
			window.open(img);
		} else {
			if(navigator.appName == "Microsoft Internet Explorer" && !p_bg.filters){
				openPopupx(img, a, w, h);
			} else {
				
				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.height=x[1];
				p_bg.style.width=x[0] - 1;

				p_bg.style.top = 0;
				p_bg.style.left = 0;
		
				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];
				document.getElementById("popup_image").innerHTML = "<img src='img/system/lloder.gif' alt='loading...'>";
				animOpacity();
			}
		}
	}
	document.animW = 0;
	function animOpacity(){
		p_bg = document.getElementById("popup_background");
		if (p_bg.op < 80){
			p_bg.op += 20;
			if (p_bg.filters){ //IE
				p_bg.filters.alpha.opacity = p_bg.op;
			} else {
				p_bg.style.MozOpacity = p_bg.op / 100;
			}
			setTimeout("animOpacity()", 1);
		} else {
			p_picture.style.visibility = "visible";
			p_picture.style.display = "block";
			p_picture.style.borderWidth = "3px 3px 3px 3px";
			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 = Math.round((p_picture.ow - p_picture.offsetWidth) * 0.2);
		difH = Math.round((p_picture.oh - p_picture.offsetHeight) * 0.2);
		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 / 2) - (cw / 2);
			
			p_picture.style.height = ch;
			p_image.style.height = ch;
			p_picture.style.top = (p_picture.x3 / 2) - (ch / 2);

			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.x3 / 2) - (p_picture.oh / 2);
			p_picture.style.left = (p_picture.x0 / 2) - ((p_picture.ow) / 2);
			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()", 1);
			//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 -= 30;
			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";
		}
	}	
	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;
	}
