// common scripts for images
function getClientWidth(){
	if(self.innerWidth){
		return self.innerWidth;
	} else if(d.documentElement && d.documentElement.clientWidth){
		return d.documentElement.clientWidth;
	} else if(d.body){
		return d.body.clientWidth;
	}
}

function getClientHeight(){
	if(self.innerHeight){
		return self.innerHeight;
	} else if(d.documentElement && d.documentElement.clientHeight){
		return d.documentElement.clientHeight;
	} else if(d.body){
		return d.body.clientHeight;
	}
}

function getScrollY(){
	if(d.documentElement && typeof d.documentElement.scrollTop != "undefined"){
		return d.documentElement.scrollTop;
	} else if(d.body && typeof d.body.scrollTop != "undefined"){
		return d.body.scrollTop;
	} else if(typeof window.pageYOffset != "undefined"){
		return window.pageYOffset;
	}
	return 0;
}

var d = document;
var imgPop = null;

imagePop = function (e, path, w, h, pos){
	if(imgPop==null){
		imgPop = d.createElement("IMG");
		imgPop.src = path;
		with (imgPop.style){
			position = "absolute";
			mgn = 10;
			if(pos == "right"){
				left = (getClientWidth() - w - mgn) + "px";
			}else if(pos == "left"){
				left = mgn + "px";
			}else{
				left = Math.round((getClientWidth()-w) / 2) + "px";
			}
			top = Math.round((getClientHeight()-h) / 2 + getScrollY()) + "px";
			margin = "0";
			zIndex = 1000;
			border = "3px solid Teal";
			display = "none";
		}
		d.body.appendChild(imgPop);
		if(imgPop.complete){
			imgPop.style.display = "block";
		} else window.status = "Loading Image Data...";
		imgPop.onload = function(){imgPop.style.display="block"; window.status="";}
		imgPop.onclick = function(){d.body.removeChild(imgPop);imgPop=null;}
		imgPop.title = "マウスクリックで閉じます";
	}
}
