/****************************************************
 *　ページデザイン用基本関数ライブラリ（DOM＋CSS）　　　　　　*
 *　 2006/10/22 (c) Ohsako, Junichi　　　　　　　　　　 *
 ****************************************************/

//////////  関数定義  //////////

//
// 名称：toggle ()
// 機能：要素の表示／非表示を切り替える
// 引数：targetId = 適用要素のid属性
// 用法：toggle ("id");
//

function toggle (targetId) {
	var target = document.getElementById (targetId);
	if (target.style.display == "block") {
		target.style.display = "none";
	} else {
		target.style.display = "block";
	}
	return;
}



//
// 名称：openWin ()
// 機能：ツールバー無しの新規ウィンドウ生成
// 引数：name = 生成されるウィンドウのオブジェクト名
// 　　：location = 生成されたウィンドウがロードするURL
// 用法：openWin ("name", "location");
//

function openWin(name, location) {
  var scriptWin = window.open(location, name, 'toolbar=no, location=no, scrollbars=no, resizable=yes, status=no');
}



//
// 名称：openWinFull ()
// 機能：ツールバー有りの新規ウィンドウ生成
// 引数：name = 生成されるウィンドウのオブジェクト名
// 　　：location = 生成されたウィンドウがロードするURL
// 用法：openWin ("name", "location");
//

function openWinFull(name, location) {
  var scriptWin = window.open(location, name, 'toolbar=yes, menubar=yes, location=yes, scrollbars=yes, resizable=yes, status=no');
}



//
// 名称：openWinFix ()
// 機能：ツールバー無し、固定サイズの新規ウィンドウ生成
// 引数：name = 生成されるウィンドウのオブジェクト名
// 　　：location = 生成されたウィンドウがロードするURL
// 　　：w = 横ピクセル数
// 　　：h = ウィンドウの縦
// 用法：openWin ("name", "location"，"w", "h");
//

function openWinFix(name, location, w, h) {
  var param = 'toolbar=no, location=no, status=no, menubar=no, scrollbars=no, width=' + w + ', height=' + h;
  window.open(location, name, param);
}



//
// 名称：openWinHalfFix ()
// 機能：ツールバー無し、横幅のみ固定サイズの新規ウィンドウ生成
// 引数：name = 生成されるウィンドウのオブジェクト名
// 　　：location = 生成されたウィンドウがロードするURL
// 　　：w = 横ピクセル数
// 用法：openWin ("name", "location"，"w");
//

function openWinHalfFix(name, location, w) {
  var param = 'toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=' + w;
  window.open(location, name, param);
}



//
// 名称：toNormal ()
// 機能：通常表示に切り替える
// 引数：id = 要素のid
// 用法：toNormal ("id");
//

function toNormal (targetId) {
	var target = document.getElementById (targetId);
	if (target.style.borderBottomColor != "#78bac8") {
		target.style.borderBottomColor = "#78bac8";
	}
	return;
}



//
// 名称：toEnphasis ()
// 機能：強調表示に切り替える
// 引数：id = 要素のid
// 用法：toEnphasis ("id");
//

function toEnphasis (targetId) {
	var target = document.getElementById (targetId);
	if (target.style.borderBottomColor != "#0056ff") {
		target.style.borderBottomColor = "#0056ff";
	}
	return;
}



// URL引数を1つ取得し、サニタイズ
// 返り値：URL引数
function getArg() {
  // 引数を代入
  var arg = location.search.substring(1);
  if (arg != false) {
    arg = decodeURI(arg);
    arg = arg.replace(/;/g,"&#059;");
    arg = arg.replace(/&/g,"&amp;");
    arg = arg.replace(/!/g,"&#033;");
    arg = arg.replace(/"/g,"&quot;");
    arg = arg.replace(/'/g,"&#039;");
    arg = arg.replace(/</g,"&lt;");
    arg = arg.replace(/>/g,"&gt;");
    return arg;
  } else {
    return false;
  }
}



// URL引数を1つ取得し、サニタイズ・分割
// 返り値：URL引数
function getArg2() {
  // 引数を代入
  var arg = location.search.substring(1);
  if (arg != false) {
    arg = decodeURI(arg);
    arg = arg.replace(/;/g,"!#059;");
    arg = arg.replace(/&/g,"&amp;");
    arg = arg.replace(/!#059;/g,"&#059;");
    arg = arg.replace(/"/g,"&quot;");
    arg = arg.replace(/'/g,"&#039;");
    arg = arg.replace(/</g,"&lt;");
    arg = arg.replace(/>/g,"&gt;");
    var arg2 = new Array (arg.substring(0, 4), arg.substring(4, 8));
    return arg2;
  } else {
    return false;
  }
}
