// ajaxの基本
// http://www.openspc2.org/JavaScript/Ajax/Page/index.html

// サーバ上のhtmlファイルを読み込み表示させる
// 利用方法は
/*
<form>
<input type="button" value="1ページ" onClick="getPage('1.html')">
<input type="button" value="2ページ" onClick="getPage('2.html')">
<input type="button" value="3ページ" onClick="getPage('3.html')">
</form>
<div id="disp"></div>
*/
function getPage(pageURL) {
xmlhttp = createXMLHttp();
if (xmlhttp)
{
xmlhttp.onreadystatechange = setPageData;
xmlhttp.open('GET', pageURL);
xmlhttp.send(null);
}else{
//alert("XMLHttpRequest失敗");
alert("ページが取得できませんでした。");
}
}
function setPageData()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("disp").innerHTML = xmlhttp.responseText;
}
}
// XMLHttpsオブジェクト作成
function createXMLHttp()
{
try {
return new ActiveXObject ("Microsoft.XMLHTTP");
}catch(e){
try {
return new XMLHttpRequest();
}catch(e) {
return null;
}
}
return null;
}

function Trim(strTemp)
{
	var strRet, strFinal;
	//LTRIM
	strRet = LTrim(strTemp);
	//RTRIM
	strFinal = RTrim(strRet);
	//結果表示
	return strFinal;
}
function RTrim(strTemp)
{
	var nLoop = 0;
	var strReturn = strTemp;
	while (nLoop < strTemp.length)
	{
		if ((strReturn.substring(strReturn.length - 1, strReturn.length) == " ") || (strReturn.substring(strReturn.length - 1, strReturn.length) == "　"))
		{
			strReturn = strTemp.substring(0, strTemp.length - (nLoop + 1));
		}
		else
		{
			break;
		}
		nLoop++;
	}
	return strReturn;
}
function LTrim(strTemp)
{
	var nLoop = 0;
	var strReturn = strTemp;
	while (nLoop < strTemp.length)
	{
		if ((strReturn.substring(0, 1) == " ") || (strReturn.substring(0, 1) == "　"))
		{
			strReturn = strTemp.substring(nLoop + 1, strTemp.length);
		}
		else
		{
			break;
		}
		nLoop++;
	}
	return strReturn;
}


function simulate(obj) {
	obj.method="post";
	obj.target= "result_frame";
	obj.submit();
	return true;
}

function change_option(obj,id,sw) {
	document.getElementById(id).disabled = sw;
}


function popup(obj, id) {
    var elm = document.getElementById(id);
    elm.style.display='block';
    elm.style.position='absolute';
    /* 吹き出しの横軸を設定 */
    elm.style.left = obj.offsetLeft + "px";
    /* 吹き出しの縦軸を設定, 吹き出し自体の高さを引いて設定 */
    elm.style.top = (obj.offsetTop - elm.style.height.substring(0,elm.style.height.length-2)) + "px";
//    alert(obj.offsetTop+"/"+elm.style.height);
}

function popdown(id) {
    document.getElementById(id).style.display='none';
}


function openImg(img,w,h) {
	SubWindow = window.open(img,'imagewindow','height='+h+',width='+w+',status=no,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no');
}

