﻿mX = 0;
mY = 0;

function createHttpRequest()
{
	if (window.ActiveXObject){
		try {
			return new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e2) {
				return null;
			}
		}
	} else if(window.XMLHttpRequest){
		return new XMLHttpRequest();
	} else {
		return null;
	}
}

function setPosition(){ 
	window.document.onmousemove = function(e){ 
		mX = getMousePosition(e).x; 
		mY = getMousePosition(e).y; 
	} 
} 

function getMousePosition(e) { 
	var obj = new Object(); 
  
	if(e) { 
		obj.x = e.pageX; 
		obj.y = e.pageY; 
	} else { 
		obj.x = event.x + document.body.scrollLeft; 
		obj.y = event.y + document.body.scrollTop; 
	} 
  
	return obj; 
} 

function showfaq(file){

	q = "";
	a = "";
	ojq = createHttpRequest();
	oja = createHttpRequest();

	qfile  = "/loadfile.asp?f=" + file + "q"+ "&sd=" + ((new Date()).getTime());
	afile  = "/loadfile.asp?f=" + file + "a"+ "&sd=" + ((new Date()).getTime());

	ojq.open("GET", qfile);
	ojq.onreadystatechange = function(){
		if (ojq.readyState == 4){
			q = ojq.responseText;
			if (q != "" && a != "") writefaq(q, a);
		}
	}
	ojq.send("");

	oja.open("GET", afile);
	oja.onreadystatechange = function(){
		if (oja.readyState == 4){
			a = oja.responseText;
			if (q != "" && a != "") writefaq(q, a);
		}
	}
	oja.send("");

	document.getElementById("jppopup").style.top  = mY - 40 + document.documentElement.scrollTop;
	document.getElementById("jppopup").style.left = mX + 40;

}

function writefaq(q, a){

	q = q.replace(RegExp("<img ", "g"), "[画像]<!img");
	a = a.replace(RegExp("<img ", "g"), "[画像]<!img");
	q = q.replace(RegExp("<object ", "g"), "[オブジェクト]<!object");
	a = a.replace(RegExp("<object ", "g"), "[オブジェクト]<!object");
	q = q.replace(RegExp("<embed ", "g"), "<!embed");
	a = a.replace(RegExp("<embed ", "g"), "<!embed");
	document.getElementById("jppopup").innerHTML = "<div class=\"jpclickfaq\">この質問の内容を参照する場合は、今マウスカーソルが乗っているリンクをクリックしてください。</div><div id=\"jppopupq\">" + q +"</div><div id=\"jppopupa\">"+ a + "</div>";

	document.getElementById("jppopup").style.visibility = "visible";
}

function hidefaq(){
	document.getElementById("jppopup").style.visibility = "hidden";
}

