function imgbox(obj,imgsrc){

	var _self = this;
	var mode = "expand";

	var backDiv = document.createElement('div');
	with (backDiv.style){
		position = "absolute";
		left = 0;
		top = 0;
		background = "#333333";
		width = document.documentElement.scrollWidth;
		height = document.documentElement.scrollHeight;
		filter = "Alpha(Opacity=50)";
		zIndex = 9;
	}
	backDiv.onclick = function(){_self.imgboxOut();}
	backDiv.id = "objPopupLayerBg";
	document.body.appendChild(backDiv);

	var div = document.createElement('div');
	with (div.style){
		position = "absolute";
		left = 0;
		top = 0;
		zIndex = 9;
		border = "5px solid #ffffff";
	}
	div.id = "objPopupLayer";
	document.body.appendChild(div);

	var icon = document.createElement('img');
	icon.style.position = "absolute";
	icon.left = "10px";
	icon.top = "10px";
	icon.id = "img_clip";
	icon.style.cursor = "pointer";
	icon.style.display = "none";
	icon.onclick = function(){_self.iconClick();}
	div.appendChild(icon);

	var img = new Image();
	img.src = (!imgsrc) ? obj.src : imgsrc;
	img.style.cursor = "pointer";
	img.onclick = function(){_self.imgboxOut();}
	img.onmouseover = function(){
		icon.src = "/js/img/btn_" + mode + ".gif";
		if (imgX!=imgX2) icon.style.display = "block";
	}
	img.onmouseout = function(){
		if (event.toElement && event.toElement.getAttribute('id')=="img_clip") return;
		icon.style.display = "none";
	}
	div.appendChild(img);

	var imgX, imgY, docX, docY, imgX2, imgY2;

	var objImagePreloader = new Image();
	objImagePreloader.onload = function() {
		imgX = objImagePreloader.width;
		imgY = objImagePreloader.height;

		docX = document.documentElement.clientWidth;
		docY = document.documentElement.clientHeight;

		imgX2 = imgX;
		imgY2 = imgY;

		if (imgX>docX-10){
			imgX2 = docX-10;
			imgY2 = imgX2 * imgY / imgX;
		}

		if (imgY>docY-10){
			imgY2 = docY-10;
			imgX2 = imgY2 * imgX / imgY;
		}
		_self.imgboxResize(imgX2,imgY2);
		//objImagePreloader.onload=function(){};
	};
	try{ objImagePreloader.src = img.src; }
	catch (e){ }
	
	this.imgboxOut = function(){
		$('objPopupLayer').removeNode(true);
		$('objPopupLayerBg').removeNode(true);
	}
	this.iconClick = function(){
		
		if (mode=="expand"){
			mode = "shrink";
			_self.imgboxResize(imgX,imgY);
		} else {
			mode = "expand";
			_self.imgboxResize(imgX2,imgY2);
		}
	}

	this.imgboxResize = function(x,y){
		img.width = x;
		img.height = y;
		var posX = (docX - x - 10) / 2;
		var posY = (docY - y - 10) / 2;

		if (posX<0) posX = 0;
		if (posY<0) posY = 0;

		posX += document.documentElement.scrollLeft;
		posY += document.documentElement.scrollTop;

		$('objPopupLayer').style.left = posX;
		$('objPopupLayer').style.top = posY;

		icon.src = "/js/img/btn_" + mode + ".gif";
	}

	try{ this.imgboxResize(imgX2,imgY2); }
	catch (e){ }
}
