
var flag = false;
window.onload = function()
{
	var mapobj = document.getElementById("pmap");
	var areaobj = mapobj.getElementsByTagName("area");
	var area_len = areaobj.length;

	var tmp = "";
	for(var i=0; i<area_len; i++)
	{
		areaobj[i].onmouseover = function(event){
			showPop(event);
		}
		areaobj[i].onmousemove = function(event){
			movePop(event);
		}
		areaobj[i].onmouseout = function(){
			popDel();
		}
		areaobj[i].onclick = function(event){
			if(this.href) this.imguri = this.href;
			this.removeAttribute("href");
			showPhoto(event, this.imguri);
			return false;
		}
	}
}
function showPhoto(e, uri)
{
	if(document.all) e = event;
		var x = e.clientX;
		var y = document.all ? 
				document.compatMode && document.compatMode.match(/CSS/i) ? 
				document.documentElement.scrollTop+e.clientY : document.body.scrollTop+e.clientY : e.pageY ? 
				e.pageY : e.y;
	if(document.getElementById("photoimg")) document.getElementsByTagName("body")[0].removeChild(document.getElementById("photoimg"));
	var photo = document.createElement("img");
	photo.src = uri;
	photo.setAttribute("id", "photoimg");
	photo.setAttribute("title", "画像クリックで消えます");
	photo.style.position = "absolute";
	photo.style.top = "-500px";
	photo.style.left = "-500px";
	photo.onclick = function(){document.getElementsByTagName("body")[0].removeChild(this);}
	document.getElementsByTagName("body")[0].appendChild(photo);
	photo.style.top = (y-(photo.height/2)>0?y-(photo.height/2):0) + "px";
	photo.style.left = (x-(photo.width/2)>0?x-(photo.width/2):0) + "px";
	popDel();
}


function showPop(e)
{
	if(!flag && !document.getElementById("popimg"))
	{	
		if(document.all) e = event;
		var x = e.clientX;
		var y = document.all ? 
				document.compatMode && document.compatMode.match(/CSS/i) ? 
				document.documentElement.scrollTop+e.clientY : document.body.scrollTop+e.clientY : e.pageY ? 
				e.pageY : e.y;
		var pop = document.createElement("img");
		pop.setAttribute("id", "popimg");
		pop.src = "./resources/js_popupsign.gif";
		pop.style.position = "absolute";
		pop.style.left = (x-36) +"px";
		pop.style.top = (y+22) +"px";
		pop.style.zIndex = 100;
		document.getElementsByTagName("body")[0].appendChild(pop);
		flag = true;
	}
}

function movePop(e)
{
	if(flag && document.getElementById("popimg"))
	{
		if(document.all) e = event;
		var x = e.clientX;
		var y = document.all ? 
				document.compatMode && document.compatMode.match(/CSS/i) ? 
				document.documentElement.scrollTop+e.clientY : document.body.scrollTop+e.clientY : e.pageY ? 
				e.pageY : e.y;
		var pop = document.getElementById("popimg");
		pop.style.left = (x-36) +"px";
		pop.style.top = (y+22) +"px";
	}
}
function popDel()
{
	if(flag && document.getElementById("popimg"))
	{
		document.getElementsByTagName("body")[0].removeChild(document.getElementById("popimg"));
		flag =false;
	}
}