
function exMenu(tName)
{
	tMenu = document.getElementById(tName).style;
	if (tMenu.display == 'block'){
		tMenu.display = "none";
	}else{
		tMenu.display = "block";
	}
}

/**
 * 確認ボックス
 *
 * 通常は削除時に使うが、確認メッセージも変更可能
 *
 * ex: <a href="url" onclick="return checkDelete('ID : 1');">削除</a>
 * ex2: <a href="url" onclick="return checkDelete('ID : 1', '追加しますか？');">追加</a>
 *
 * @return Boolean
 */
function checkDelete(detail, message)
{
	if (typeof detail == 'undefined')
	{
		detail = "";
	}

	if (typeof message == 'undefined')
	{
		message = "本当に削除しますか？";
	}

	var text = message + "\n\n" + detail;

	if(confirm(text))
	{
		return(true);
	}

	return(false);
}

function showDelMsg(obj) {
	if(obj.checked && !confirm("削除してよろしいですか？")){
		obj.checked = false;
	}
}

/**
 * 親windowのinputに値を投げ込む
 *
 * @param {String} value
 * @param {String} input_name
 * @return void
 */
function sendParent(value, input_name)
{
	if (typeof input_name == 'undefined')
	{
		input_name = "parent_input_name";
	}

	var input_obj = opener.document.getElementsByName(input_name);
	input_obj[0].value = value;
	window.close();
}

/**
 * クリックしたinputのvalueをクリアする
 *
 * @return void
 */
function inputClear(input_name)
{
	//var inpObj = document.getElementById(input_name);
	//addListener(inpObj, "", );
}


/**
 * 新しい窓でURLを開く
 *
 * 指定したサイズが無い場合、
 * URL先が画像なら画像のサイズで、
 * そうでなければ480*360で開く
 *
 * @param {Object} url
 * @param {Object} window_name
 * @param {Object} width
 * @param {Object} height
 *
 * @return void
 */
function popup_window(url, width, height, window_name)
{
	if (typeof window_name == 'undefined')
	{
		window_name = "window";
	}

	//URL先が画像の時用
	var img_obj = new Image();
	img_obj.src = url;

	//窓を画像のサイズに合わせるとスクロールバーが出るので余白を持たせる
	var margin = 40;


	//指定幅が無い場合
	if (typeof width == 'undefined')
	{
		if (typeof img_obj.src != 'undefined')
		{
			width = img_obj.width + margin;
		}
		else
		{
			width = 480;
		}
	}

	if (typeof height == 'undefined')
	{
		if (typeof img_obj.src != 'undefined')
		{
			height = img_obj.height + margin;
		}
		else
		{
			height = 360;
		}
	}

	window.open(url, window_name, 'width='+width+',height='+height+', status=yes, scrollbars=yes, resizable=yes');
}
function showDelMsg(obj) {
	if(obj.checked && !confirm("削除してよろしいですか？")){
		obj.checked = false;
	}
}
function checkLength(obj, len) {
	val = obj.value;
	strlen = f_getStringLen(val);
	if(len < strlen) {
		alert('文字が多すぎます。');
		this.focus();
	}

}
function f_getStringLen(str) {

	var str_len = 0 ;

	for (var i = 0; i < str.length ; i++ ) {
	//文字数が１の場合はASCII文字のため、2バイトとカウント
	if (escape(str.charAt(i)).length == 1 ){
	str_len++ ;
	//文字数が２以上の場合はShift_JIS文字のため、2バイトとカウント
	}else if (escape(str.charAt(i)).length > 2 ) {
	str_len = str_len + 2 ;
	}
	}
	//文字の長さを戻す
	return str_len ;
}function URLencode(str){ // Unicode to URL encoded UTF-8 var i, encoded_str, char_code, padded_str;         encoded_str = "";         for (i = 0; i < str.length; i++){             char_code = str.charCodeAt(i);             if (char_code == 0x20){                // space -> "+"                encoded_str += "+";}             else { // else 1                  if (((0x30 <= char_code) && (char_code <= 0x39)) || ((0x41 <= char_code) && (char_code <= 0x5a)) || ((0x61 <= char_code) && (char_code <= 0x7a))){		     // [0-9a-z-A-Z]                     // no escape                     encoded_str += str.charAt(i);                  }		  else if ((char_code == 0x2a) || (char_code == 0x2e) || (char_code == 0x2d) || (char_code == 0x5f)) {		     // [.-_]                     // no escape                     encoded_str += str.charAt(i);		  }                  else { // else 2                       // for internal unicode to UTF-8		       // Ref. http://homepage3.nifty.com/aokura/jscript/utf8.html		       // Ref. http://homepage1.nifty.com/nomenclator/unicode/ucs_utf.htm                       if ( char_code > 0xffff ) {                          encoded_str += "%" + ((char_code >> 18) | 0xf0).toString(16).toUpperCase();                          encoded_str += "%" + (((char_code >> 12) & 0x3f) | 0x80).toString(16).toUpperCase();			  encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();		       }                       else if ( char_code > 0x7ff ) {                          encoded_str += "%" + ((char_code >> 12) | 0xe0).toString(16).toUpperCase();			  encoded_str += "%" + (((char_code >> 6) & 0x3f) | 0x80).toString(16).toUpperCase();			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();                       }                       else if ( char_code > 0x7f ) {		          encoded_str += "%" + (((char_code >> 6) & 0x1f) | 0xc0).toString(16).toUpperCase();			  encoded_str += "%" + ((char_code & 0x3f) | 0x80).toString(16).toUpperCase();                       }                       else {                          // for ascii                          padded_str = "0" + char_code.toString(16).toUpperCase();                          encoded_str += "%" + padded_str.substr(padded_str.length - 2, 2);                       }                    } // else 2                } // else 1        } // for        return encoded_str;} 
