/** 
 * ブラウザの種類判定フラグ
 *
 */
// IE
netcommons_ie = ( (navigator.userAgent.toLowerCase().indexOf("msie") != -1) &&
		  			 (navigator.userAgent.toLowerCase().indexOf("opera") == -1) );
// NetScape
netcommons_ns = ( navigator.appName=="Netscape" );
// Opera
netcommons_op = ( navigator.userAgent.toLowerCase().indexOf("opera") != -1 );

function xoopsSetElementProp(name, prop, val) {
	var elt=$(name);
	if (elt) elt[prop]=val;
}

function xoopsSetElementStyle(name, prop, val) {
	var elt=$(name);
	if (elt && elt.style) elt.style[prop]=val;
}

function xoopsGetFormElement(fname, ctlname) {
	var frm=document.forms[fname];
	return frm?frm.elements[ctlname]:null;
}

function justReturn() {
	return;
}

function openWithSelfMain(url,name,width,height, returnwindow) {
	var options = "width=" + width + ",height=" + height + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
    new_window = window.open(url, name, options);
    window.self.name = "main";
    //JavaScriptエラーが発生するため、コメント化
    //new_window.document.clear();
    new_window.focus();
    if (returnwindow != null) {
        return new_window;
    }
}

function setElementColor(id, color){
	$(id).style.color = "#" + color;
}

function setElementFont(id, font){
	$(id).style.fontFamily = font;
}

function setElementSize(id, size){
	$(id).style.fontSize = size;
}

function changeDisplay(id){
	var elestyle = $(id).style;
	if (elestyle.display == "") {
		elestyle.display = "none";
	} else {
		elestyle.display = "block";
	}
}

function setVisible(id){
	$(id).style.visibility = "visible";
}

function setHidden(id){
	$(id).style.visibility = "hidden";
}

function makeBold(id){
	var eleStyle = $(id).style;
	if (eleStyle.fontWeight != "bold" && eleStyle.fontWeight != "700") {
		eleStyle.fontWeight = "bold";
	} else {
		eleStyle.fontWeight = "normal";
	}
}

function makeItalic(id){
	var eleStyle = $(id).style;
	if (eleStyle.fontStyle != "italic") {
		eleStyle.fontStyle = "italic";
	} else {
		eleStyle.fontStyle = "normal";
	}
}

function makeUnderline(id){
	var eleStyle = $(id).style;
	if (eleStyle.textDecoration != "underline") {
		eleStyle.textDecoration = "underline";
	} else {
		eleStyle.textDecoration = "none";
	}
}

function makeLineThrough(id){
	var eleStyle = $(id).style;
	if (eleStyle.textDecoration != "line-through") {
		eleStyle.textDecoration = "line-through";
	} else {
		eleStyle.textDecoration = "none";
	}
}

function appendSelectOption(selectMenuId, optionName, optionValue){
	var selectMenu = $(selectMenuId);
	var newoption = new Option(optionName, optionValue);
	selectMenu.options[selectMenu.length] = newoption;
	selectMenu.options[selectMenu.length].selected = true;
}

function disableElement(target){
	var targetDom = $(target);
	if (targetDom.disabled != true) {
		targetDom.disabled = true;
	} else {
		targetDom.disabled = false;
	}
}
function xoopsCheckAll(formname, switchid) {
	var ele = document.forms[formname].elements;
	var switch_cbox = $(switchid);
	for (var i = 0; i < ele.length; i++) {
		var e = ele[i];
		if ( (e.name != switch_cbox.name) && (e.type == 'checkbox') ) {
			e.checked = switch_cbox.checked;
		}
	}
}

function xoopsCheckGroup(formname, switchid, groupid) {
	var ele = document.forms[formname].elements;
	var switch_cbox = $(switchid);
	for (var i = 0; i < ele.length; i++) {
		var e = ele[i];
		if ( (e.type == 'checkbox') && (e.id == groupid) ) {
			e.checked = switch_cbox.checked;
			e.click(); e.click();  // Click to activate subgroups
									// Twice so we don't reverse effect
		}
	}
}

function xoopsCheckAllElements(elementIds, switchId) {
	var switch_cbox = $(switchId);
	for (var i = 0; i < elementIds.length; i++) {
		var e = $(elementIds[i]);
		if ((e.name != switch_cbox.name) && (e.type == 'checkbox')) {
			e.checked = switch_cbox.checked;
		}
	}
}

function xoopsSavePosition(id)
{
	var textareaDom = $(id);
	if (textareaDom.createTextRange) {
		textareaDom.caretPos = document.selection.createRange().duplicate();
	}
}

function xoopsInsertText(domobj, text)
{
	if (domobj.createTextRange && domobj.caretPos){
  		var caretPos = domobj.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) 
== ' ' ? text + ' ' : text;  
	} else if (domobj.getSelection && domobj.caretPos){
		var caretPos = domobj.caretPos;
		caretPos.text = caretPos.text.charat(caretPos.text.length - 1)  
== ' ' ? text + ' ' : text;
	} else {
		domobj.value = domobj.value + text;
  	}
}

function xoopsCodeSmilie(id, smilieCode) {
	var revisedMessage;
	var textareaDom = $(id);
	xoopsInsertText(textareaDom, smilieCode);
	textareaDom.focus();
	return;
}

function showImgSelected(imgId, selectId, imgDir, extra, xoopsUrl) {
	if (xoopsUrl == null) {
		xoopsUrl = "./";
	}
	imgDom = $(imgId);
	selectDom = $(selectId);
	imgDom.src = xoopsUrl + "/"+ imgDir + "/" + selectDom.options[selectDom.selectedIndex].value + extra;
}

function xoopsCodeUrl(id, enterUrlPhrase, enterWebsitePhrase){
	if (enterUrlPhrase == null) {
		enterUrlPhrase = "Enter the URL of the link you want to add:";
	}
	var text = prompt(enterUrlPhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		if (enterWebsitePhrase == null) {
			enterWebsitePhrase = "Enter the web site title:";
		}
		var text2 = prompt(enterWebsitePhrase, "");
		if ( text2 != null ) {
			if ( text2 == "" ) {
				var result = "[url=" + text + "]" + text + "[/url]";
			} else {
				var pos = text2.indexOf(unescape('%00'));
				if(0 < pos){
					text2 = text2.substr(0,pos);
				}
				var result = "[url=" + text + "]" + text2 + "[/url]";
			}
			xoopsInsertText(domobj, result);
		}
	}
	domobj.focus();
}

function xoopsCodeImg(id, enterImgUrlPhrase, enterImgPosPhrase, imgPosRorLPhrase, errorImgPosPhrase){
	if (enterImgUrlPhrase == null) {
		enterImgUrlPhrase = "Enter the URL of the image you want to add:";
	}
	var text = prompt(enterImgUrlPhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		if (enterImgPosPhrase == null) {
			enterImgPosPhrase = "Now, enter the position of the image.";
		}
		if (imgPosRorLPhrase == null) {
			imgPosRorLPhrase = "'R' or 'r' for right, 'L' or 'l' for left, or leave it blank.";
		}
		if (errorImgPosPhrase == null) {
			errorImgPosPhrase = "ERROR! Enter the position of the image:";
		}
		var text2 = prompt(enterImgPosPhrase + "\n" + imgPosRorLPhrase, "");
		while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) {
			text2 = prompt(errorImgPosPhrase + "\n" + imgPosRorLPhrase,"");
		}
		if ( text2 == "l" || text2 == "L" ) {
			text2 = " align=left";
		} else if ( text2 == "r" || text2 == "R" ) {
			text2 = " align=right";
		} else {
			text2 = "";
		}
		var result = "[img" + text2 + "]" + text + "[/img]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeEmail(id, enterEmailPhrase){
	if (enterEmailPhrase == null) {
		enterEmailPhrase = "Enter the email address you want to add:";
	}
	var text = prompt(enterEmailPhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		var result = "[email]" + text + "[/email]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeQuote(id, enterQuotePhrase){
	if (enterQuotePhrase == null) {
		enterQuotePhrase = "Enter the text that you want to be quoted:";
	}
	var text = prompt(enterQuotePhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		var pos = text.indexOf(unescape('%00'));
		if(0 < pos){
			text = text.substr(0,pos);
		}
		var result = "[quote]" + text + "[/quote]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeCode(id, enterCodePhrase){
	if (enterCodePhrase == null) {
		enterCodePhrase = "Enter the codes that you want to add.";
	}
	var text = prompt(enterCodePhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		var result = "[code]" + text + "[/code]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

function xoopsCodeText(id, hiddentext, enterTextboxPhrase){
	var textareaDom = $(id);
	var textDom = $(id + "Addtext");
	var fontDom = $(id + "Font");
	var colorDom = $(id + "Color");
	var sizeDom = $(id + "Size");
	var xoopsHiddenTextDomStyle = $(hiddentext).style;
	var textDomValue = textDom.value;
	var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value;
	var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value;
	var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value;
	if ( textDomValue == "" ) {
		if (enterTextboxPhrase == null) {
			enterTextboxPhrase = "Please input text into the textbox.";
		}
		alert(enterTextboxPhrase);
		textDom.focus();
	} else {
		if ( fontDomValue != "FONT") {
			textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]";
			fontDom.options[0].selected = true;
		}
		if ( colorDomValue != "COLOR") {
			textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]";
			colorDom.options[0].selected = true;
		}
		if ( sizeDomValue != "SIZE") {
			textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]";
			sizeDom.options[0].selected = true;
		}
		if (xoopsHiddenTextDomStyle.fontWeight == "bold" || xoopsHiddenTextDomStyle.fontWeight == "700") {
			textDomValue = "[b]" + textDomValue + "[/b]";
			xoopsHiddenTextDomStyle.fontWeight = "normal";
		}
		if (xoopsHiddenTextDomStyle.fontStyle == "italic") {
			textDomValue = "[i]" + textDomValue + "[/i]";
			xoopsHiddenTextDomStyle.fontStyle = "normal";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "underline") {
			textDomValue = "[u]" + textDomValue + "[/u]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "line-through") {
			textDomValue = "[d]" + textDomValue + "[/d]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		xoopsInsertText(textareaDom, textDomValue);
		textDom.value = "";
		xoopsHiddenTextDomStyle.color = "#000000";
		xoopsHiddenTextDomStyle.fontFamily = "";
		xoopsHiddenTextDomStyle.fontSize = "12px";
		xoopsHiddenTextDomStyle.visibility = "hidden";
		textareaDom.focus();
	}
}

function xoopsValidate(subjectId, textareaId, submitId, plzCompletePhrase, msgTooLongPhrase, allowedCharPhrase, currCharPhrase) {
	var maxchars = 65535;
	var subjectDom = $(subjectId);
	var textareaDom = $(textareaId);
	var submitDom = $(submitId);
	if (textareaDom.value == "" || subjectDom.value == "") {
		if (plzCompletePhrase == null) {
			plzCompletePhrase = "Please complete the subject and message fields.";
		}
		alert(plzCompletePhrase);
		return false;
	}
	if (maxchars != 0) {
		if (textareaDom.value.length > maxchars) {
			if (msgTooLongPhrase == null) {
				msgTooLongPhrase = "Your message is too long.";
			}
			if (allowedCharPhrase == null) {
				allowedCharPhrase = "Allowed max chars length: ";
			}
			if (currCharPhrase == null) {
				currCharPhrase = "Current chars length: ";
			}
			alert(msgTooLongPhrase + "\n\n" + allowedCharPhrase + maxchars + "\n" + currCharPhrase + textareaDom.value.length + "");
			textareaDom.focus();
			return false;
		} else {
			submitDom.disabled = true;
			return true;
		}
	} else {
		submitDom.disabled = true;
		return true;
	}
}


/** 
 * イメージの表示を切り替える処理
 *
 * @param   id		イメージID
 * @param   image1	切り替えるイメージ１
 * @param   image2	切り替えるイメージ２
 * @return  true:正常,false:異常
 **/
function netcommonsChangeImage(id, image1, image2)
{
	if ( window.document.images[id].src == image1 ) {
		window.document.images[id].src = image2;
	} else {
		window.document.images[id].src = image1;
	}
}

/** 
 * 添付ファイル追加の入力チェック処理
 * 汎用入力フォーム画面で添付ファイルが存在する場合に使用する
 *
 * @param   id                    	入力テキストエリア名称文字列
 * @param   enterAttachmentPhrase	メッセージ内容
 * @return  true:正常,false:異常
 **/
function netcommonsCodeAttachmentById(id, enterAttachmentPhrase)
{
	var attachmentDom = $(id + "Attachment");

	if ( attachmentDom.value == "" ) {
		if (enterAttachmentPhrase == null) {
			enterAttachmentPhrase = "Please input attachement file into the textbox.";
		}
		alert(enterAttachmentPhrase);
		attachmentDom.focus();
		return false;
	}
	return true;
}

/** 
 * 汎用入力フォーム入力位置の保持
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @return  none
 **/
function netcommonsSavePosition(frm, e)
{
	var textareaDom = frm.elements[e];
	if (textareaDom.createTextRange) {
		textareaDom.caretPos = document.selection.createRange().duplicate();
	}
}

/** 
 * 汎用入力フォームURL文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterUrlPhrase		メッセージ内容（URL入力）
 * @param   enterWebsitePhrase	メッセージ内容（サイト名入力）
 * @return  none
 **/
function netcommonsCodeSmilie(frm, e, smilieCode) {
	var revisedMessage;
	var textareaDom = frm.elements[e];
	xoopsInsertText(textareaDom, smilieCode);
	textareaDom.focus();
	return;
}

/** 
 * 汎用入力フォームURL文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterUrlPhrase		メッセージ内容（URL入力）
 * @param   enterWebsitePhrase	メッセージ内容（サイト名入力）
 * @return  none
 **/
function netcommonsCodeUrl(frm, e, enterUrlPhrase, enterWebsitePhrase){
	if (enterUrlPhrase == null) {
		enterUrlPhrase = "Enter the URL of the link you want to add:";
	}
	var text = prompt(enterUrlPhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		if (enterWebsitePhrase == null) {
			enterWebsitePhrase = "Enter the web site title:";
		}
		var text2 = prompt(enterWebsitePhrase, "");
		if ( text2 != null ) {
			if ( text2 == "" ) {
				var result = "[url=" + text + "]" + text + "[/url]";
			} else {
				var pos = text2.indexOf(unescape('%00'));
				if(0 < pos){
					text2 = text2.substr(0,pos);
				}
				var result = "[url=" + text + "]" + text2 + "[/url]";
			}
			xoopsInsertText(domobj, result);
		}
	}
	domobj.focus();
}

/** 
 * 汎用入力フォーム画像URL文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterImgUrlPhrase	メッセージ内容（URL入力）
 * @param   enterImgPosPhrase	メッセージ内容（画像位置）
 * @param   imgPosRorLPhrase	メッセージ内容（左右）
 * @param   errorImgPosPhrase	メッセージ内容（エラー）
 * @return  none
 **/
function netcommonsCodeImg(frm, e, enterImgUrlPhrase, enterImgPosPhrase, imgPosRorLPhrase, errorImgPosPhrase){
	if (enterImgUrlPhrase == null) {
		enterImgUrlPhrase = "Enter the URL of the image you want to add:";
	}
	var text = prompt(enterImgUrlPhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		if (enterImgPosPhrase == null) {
			enterImgPosPhrase = "Now, enter the position of the image.";
		}
		if (imgPosRorLPhrase == null) {
			imgPosRorLPhrase = "'R' or 'r' for right, 'L' or 'l' for left, or leave it blank.";
		}
		if (errorImgPosPhrase == null) {
			errorImgPosPhrase = "ERROR! Enter the position of the image:";
		}
		var text2 = prompt(enterImgPosPhrase + "\n" + imgPosRorLPhrase, "");
		while ( ( text2 != "" ) && ( text2 != "r" ) && ( text2 != "R" ) && ( text2 != "l" ) && ( text2 != "L" ) && ( text2 != null ) ) {
			text2 = prompt(errorImgPosPhrase + "\n" + imgPosRorLPhrase,"");
		}
		if ( text2 == "l" || text2 == "L" ) {
			text2 = " align=left";
		} else if ( text2 == "r" || text2 == "R" ) {
			text2 = " align=right";
		} else {
			text2 = "";
		}
		var result = "[img" + text2 + "]" + text + "[/img]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォームメール送信文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterEmailPhrase	メッセージ内容
 * @return  none
 **/
function netcommonsCodeEmail(frm, e, enterEmailPhrase){
	if (enterEmailPhrase == null) {
		enterEmailPhrase = "Enter the email address you want to add:";
	}
	var text = prompt(enterEmailPhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		var result = "[email]" + text + "[/email]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォームクォート文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterQuotePhrase	メッセージ内容
 * @return  none
 **/
function netcommonsCodeQuote(frm, e, enterQuotePhrase){
	if (enterQuotePhrase == null) {
		enterQuotePhrase = "Enter the text that you want to be quoted:";
	}
	var text = prompt(enterQuotePhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		var pos = text.indexOf(unescape('%00'));
		if(0 < pos){
			text = text.substr(0,pos);
		}
		var result = "[quote]" + text + "[/quote]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォームコード文字追加処理
 *
 * @param   frm             対象フォームオブジェクト
 * @param   e               入力テキストエリア名称文字列
 * @param   enterCodePhrase	メッセージ内容
 * @return  none
 **/
function netcommonsCodeCode(frm, e, enterCodePhrase){
	if (enterCodePhrase == null) {
		enterCodePhrase = "Enter the codes that you want to add.";
	}
	var text = prompt(enterCodePhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		var result = "[code]" + text + "[/code]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォームTex表記文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   enterTexPhrase		メッセージ内容
 * @return  none
 **/
function netcommonsCodeTex(frm, e, enterTexPhrase, path){
	if (enterTexPhrase == null) {
		enterTexPhrase = "Enter the tex code that you want added:";
	}
	var text = prompt(enterTexPhrase, "");
	var domobj = frm.elements[e];
	if ( text != null && text != "" ) {
		var pos = text.indexOf(unescape('%00'));
		if(0 < pos){
			text = text.substr(0,pos);
		}
		var result = "[tex path=" + path + "]" + text + "[/tex]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォームTex表記文字追加処理(ID用)
 *
 * @param   id                 	対象オブジェクトID
 * @param   enterTexPhrase		メッセージ内容
 * @return  none
 **/
function netcommonsCodeTexForID(id, enterTexPhrase, path){
	if (enterTexPhrase == null) {
		enterTexPhrase = "Enter the email address you want to add:";
	}
	var text = prompt(enterTexPhrase, "");
	var domobj = $(id);
	if ( text != null && text != "" ) {
		var result = "[tex path=" + path + "]" + text + "[/tex]";
		xoopsInsertText(domobj, result);
	}
	domobj.focus();
}

/** 
 * 汎用入力フォーム特殊文字追加処理
 *
 * @param   frm                 対象フォームオブジェクト
 * @param   e                   入力テキストエリア名称文字列
 * @param   hiddentext          サンプル文字列ID
 * @param   enterTextboxPhrase	メッセージ内容
 * @return  none
 **/
function netcommonsCodeText(frm, e, hiddentext, enterTextboxPhrase){
	var textareaDom = frm.elements[e];
	var textDom = frm.elements["Addtext"];
	var fontDom = frm.elements["Font"];
	var colorDom = frm.elements["Color"];
	var sizeDom = frm.elements["Size"];
	var xoopsHiddenTextDomStyle = $(hiddentext).style;
	var textDomValue = textDom.value;
	var fontDomValue = fontDom.options[fontDom.options.selectedIndex].value;
	var colorDomValue = colorDom.options[colorDom.options.selectedIndex].value;
	var sizeDomValue = sizeDom.options[sizeDom.options.selectedIndex].value;
	if ( textDomValue == "" ) {
		if (enterTextboxPhrase == null) {
			enterTextboxPhrase = "Please input text into the textbox.";
		}
		alert(enterTextboxPhrase);
		textDom.focus();
	} else {
		if ( fontDomValue != "FONT") {
			textDomValue = "[font=" + fontDomValue + "]" + textDomValue + "[/font]";
			fontDom.options[0].selected = true;
		}
		if ( colorDomValue != "COLOR") {
			textDomValue = "[color=" + colorDomValue + "]" + textDomValue + "[/color]";
			colorDom.options[0].selected = true;
		}
		if ( sizeDomValue != "SIZE") {
			textDomValue = "[size=" + sizeDomValue + "]" + textDomValue + "[/size]";
			sizeDom.options[0].selected = true;
		}
		if (xoopsHiddenTextDomStyle.fontWeight == "bold" || xoopsHiddenTextDomStyle.fontWeight == "700") {
			textDomValue = "[b]" + textDomValue + "[/b]";
			xoopsHiddenTextDomStyle.fontWeight = "normal";
		}
		if (xoopsHiddenTextDomStyle.fontStyle == "italic") {
			textDomValue = "[i]" + textDomValue + "[/i]";
			xoopsHiddenTextDomStyle.fontStyle = "normal";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "underline") {
			textDomValue = "[u]" + textDomValue + "[/u]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		if (xoopsHiddenTextDomStyle.textDecoration == "line-through") {
			textDomValue = "[d]" + textDomValue + "[/d]";
			xoopsHiddenTextDomStyle.textDecoration = "none";
		}
		xoopsInsertText(textareaDom, textDomValue);
		textDom.value = "";
		xoopsHiddenTextDomStyle.color = "#000000";
		xoopsHiddenTextDomStyle.fontFamily = "";
		xoopsHiddenTextDomStyle.fontSize = "12px";
		xoopsHiddenTextDomStyle.visibility = "hidden";
		textareaDom.focus();
	}
}


/** 
 * 添付ファイル追加の入力チェック処理
 * 汎用入力フォーム画面で添付ファイルが存在する場合に使用する
 *
 * @param   frm                     対象フォームオブジェクト
 * @param   e                     	入力テキストエリア名称文字列
 * @param   enterAttachmentPhrase	メッセージ内容
 * @return  true:正常,false:異常
 **/
function netcommonsCodeAttachment(frm, e, enterAttachmentPhrase)
{
	var attachmentDom = frm.elements[e + "Attachment"];

	if ( attachmentDom.value == "" ) {
		if (enterAttachmentPhrase == null) {
			enterAttachmentPhrase = "Please input attachement file into the textbox.";
		}
		alert(enterAttachmentPhrase);
		attachmentDom.focus();
		return false;
	}
	return true;
}

/** 
 * 表示、非表示切替関数
 *
 * @param   id   対象ID
 * @return  none
 **/
function netcommonsChangeDisplay(id, display,tableflag){
	var elestyle = $(id).style;
	if (display == undefined || display=="") {
		if(netcommons_ie || tableflag == undefined){
			display = "block";
		}else{
			display = "table-row";
		}
	}
	
	if (elestyle.display == display || elestyle.display == "") {
		elestyle.display = "none";
	} else {
		elestyle.display = display;
	}
}

function netcommonsChangeDisplayRadiobtn(id, display,tableflag){
	var elestyle = $(id).style;
	if (display == undefined || display=="") {
		if(netcommons_ie || tableflag == undefined){
			display = "block";
		}else{
			display = "table-row";
		}
	}
	
	if (elestyle.display == "") {
		elestyle.display = "none";
	} else {
		elestyle.display = display;
	}
}
/** 
 * 表示、オブジェクト表示関数
 *
 * @param   id   対象ID
 * @return  none
 **/
function netcommonsDisplayBlock(id,display){
	if (display == undefined) {
		display = "block";
	}
	var elestyle = $(id).style;
	elestyle.display = display;
}
/** 
 * 表示、オブジェクト非表示関数
 *
 * @param   id   対象ID
 * @return  none
 **/
function netcommonsDisplayNone(id){
	var elestyle = $(id).style;
	elestyle.display = "none";
}

/** 
 * 表示、非表示切替再帰的呼び出し関数
 * 掲示板用 (display_block_id_parent_id_seq)
 * @param   name(接頭語),block_id(ブロックID), parent_id（親記事ID） ,seq(連番)
 *          minus:マイナス画像フルパス,plus:プラス画像フルパス
 * @return  none
 **/
function netcommonsbbsChangeDisplay(name,block_id,parent_id, seq,minus,plus,display){
	
	var id = name + "_" + block_id + "_" + parent_id + "_" + seq;
	if ($(id) == undefined) {
			 return;
	}else{
		  var id_text = block_id + "_" + parent_id + "_" + seq;
			 if ($(id_text) != undefined) {
			 	//子のノードを再帰的にまわす
			 	var news_id=$(id_text).name;
			 	if (news_id != undefined) {
			 		netcommonsbbsChangeDisplay(name,block_id,news_id, 1,minus,plus,"none");
			 	}
			 }
	}
	var elestyle = $(id).style;
	var node_name = "node_" + block_id + "_" + parent_id + "_" + seq;
	var node_id=$(node_name);
	
	if (display == undefined) {
		if(netcommons_ie){
				display = "block";
		}else{
				display = "table-row";
		}
	}
	
	if (elestyle.display == "block" || elestyle.display == "table-row" || elestyle.display == "") {
		
		elestyle.display = "none";
		if (node_id != undefined) {
			window.document.images[node_name].src = plus;
		}
	}else{
		 elestyle.display = display;
		 if (node_id != undefined) {
		 	if(elestyle.display=="none"){
		 		window.document.images[node_name].src = plus;
		 	}else{
		 		window.document.images[node_name].src = minus;
		 	}
		 }
	}
	
	//同レベルのノードを再帰的にまわす
	netcommonsbbsChangeDisplay(name,block_id,parent_id, (seq+1),minus,plus,display);
}

/** 
 * 表示、非表示切替再帰的呼び出し関数(並列型：小テスト用)
 * 掲示板用 (display_block_id_question_id)
 * @param   name(接頭語),block_id(ブロックID), question_id（質問ID）
 * @return  none
 **/
function netcommonsquizChangeDisplay(name,block_id,question_id,display,tableflag){
	
	var id = name + "_" + block_id + "_" + question_id;
	
	if ($(id) == undefined) {
			 return;
	}
	
	var elestyle = $(id).style;
	if(display == undefined || display == "") {
		if(elestyle.display == "none"){
			if(netcommons_ie || tableflag == undefined){
				display = "block";
			}else{
				display = "table-row";
			}
		}else{
			display = "none";
		}
	}
	elestyle.display = display;
	
	//同レベルのノードを再帰的にまわす
	netcommonsquizChangeDisplay(name,block_id,(parseInt(question_id)+1),display,tableflag);
}
/** 
 * 再帰的に表示中かどうかをStringにセットする関数(並列型：小テスト用)
 * 掲示板用 (display_block_id_question_id)
 * @param   name(接頭語),block_id(ブロックID), question_id（質問ID）,get_string:Get引数文字列：表示するものだけ連結させる
 * @return  none
 **/
function netcommonsquizDisplayCheck(name,block_id,question_id,get_string){
	
	var id = name + "_" + block_id + "_" + question_id;
	
	if ($(id) == undefined) {
		return get_string;	
	}
	
	var elestyle = $(id).style;
	
	if(elestyle.display == "block" || elestyle.display == "table-row"){
		if(get_string == undefined) {
			get_string = "&"+name+"_id"+question_id+"=1";
		}else{
			get_string += "&"+name+"_id"+question_id+"=1";
		}
	}
	//同レベルのノードを再帰的にまわす
	get_string = netcommonsquizDisplayCheck(name,block_id,(parseInt(question_id)+1),get_string);
	if(get_string == undefined){
			return '';
	}else{
			return get_string;
	}
}


/** 
 * プルダウンメニューレイヤ対象ID、内容HTML保持用グローバル変数
 *
 */
var globalLayerHTML = "";
var globalLayerElementId = "";

/** 
 * プルダウンメニューレイヤの表示関数
 *
 * @param   id   対象ID
 * @return  none
 **/
function setLayerVisibility(id)
{
	var eleLayer = $("layer");

	// 内容を戻す
	if ( globalLayerElementId != "" ) {
		var eleTaget = $(globalLayerElementId);
		globalLayerHTML = eleLayer.innerHTML;
		eleTaget.innerHTML = globalLayerHTML;
	}		

	// 対象エレメントの内容を移す
	// 直接移すと定義されているオブジェクトが重複してしまうため、元の内容は破棄する
	var eleTaget = $(id);
	globalLayerElementId = id;
	if(eleTaget == ''){
		return '';	
	}
	
	globalLayerHTML = eleTaget.innerHTML;
	eleTaget.innerHTML = "";
	eleLayer.style.visibility = "visible";
	eleLayer.innerHTML = globalLayerHTML;
	
	// レイヤのx座標、y座標をマウス座標にセット
	if ( netcommons_ie ) {
		var Xpos = window.event.clientX + document.documentElement.scrollLeft - eleLayer.offsetWidth;
		var Ypos = window.event.clientY + document.documentElement.scrollTop;
		
		if ( Xpos < 0 ) {
			Xpos = 0;
		}
		eleLayer.style.left = Xpos + "px";
		eleLayer.style.top = Ypos + "px";

	} else if ( netcommons_ns || netcommons_op ) {

		eleLayer.style.width = eleTaget.offsetWidth + "px";
		
		var Xpos = globalX  - eleLayer.offsetWidth;
		var Ypos = globalY;
		
		if ( Xpos < 0 ) {
			Xpos = 0;
		}
		eleLayer.style.left = Xpos +  "px";
		eleLayer.style.top = Ypos + "px";


	}

	// IEの場合、特定のエレメントがレイヤより前面に出てしまうため、
	// レイヤと重なる場合、対象のエレメントを非表示にする
	hideShowCovered(eleLayer);

	document.onmouseup = setLayerHidden;	// レイヤを非表示にするイベントハンドラを設定
}

/** 
 * プルダウンメニューレイヤの非表示関数
 *
 * @param   id   対象ID
 * @return  none
 **/
function setLayerHidden() {
	var eleLayer = $("layer");
	eleLayer.style.visibility = "hidden";
	hideShowCovered(eleLayer);
	document.onmouseup = null;
}

// NetScapeの場合イベント関数を定義
if ( netcommons_ns || netcommons_op ) {
	var globalX = 0;
	var globalY = 0;

	function setNSPos(e) {
		var eleLayer = $("layer");
		globalX = e.pageX;
		globalY = e.pageY;
	}
	document.onclick = setNSPos;
	document.onmouseover = setNSPos;
}

/** 
 * レイヤと重なった特定エレメントの表示切替関数
 *
 * @param   el   対象エレメント
 * @return  none
 **/
function hideShowCovered(el)
{
	// レイヤより前面に出てしまうエレメント配列
	var tags = new Array("applet", "iframe", "select", "object");

	// レイヤの座標を設定
	var p = getAbsolutePos(el);
	var EX1 = p.x;
	var EX2 = el.offsetWidth + EX1;
	var EY1 = p.y;
	var EY2 = el.offsetHeight + EY1;

	for (var k = tags.length; k > 0; ) {
		// 対象エレメントの配列を取得
		var target_ar = document.getElementsByTagName(tags[--k]);

		for (var i = target_ar.length; i > 0;) {
			var target = target_ar[--i];
			if(el.style.zIndex < target.style.zIndex) {
				continue;
			}
			// 対象エレメントの座標を設定
			p = getAbsolutePos(target);
			var CX1 = p.x;
			var CX2 = target.offsetWidth + CX1;
			var CY1 = p.y;
			var CY2 = target.offsetHeight + CY1;

			// レイヤの座標と対象エレメントの座標が重なっているかチェック
			if (el.style.visibility == "hidden" || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
				if (target.id.substring(0,9) == 'plan_flg_') {	
					target.style.visibility = "hidden";
				} else {
					target.style.visibility = "visible";
				}
			} else {
				//ポップアップダイアログに削除するエレメントがあれば削除しない
				if(target.id != undefined && target.id != '') {
					var children = el.getElementsByTagName('*') || document.all;
					var chk_flag = true;
					for (var j = 0; j < children.length; j++) {
						var child = children[j];
						if(child.id == target.id) {
							chk_flag = false;
							break;
						}
					}
					if(chk_flag)
						target.style.visibility = "hidden";
					else{
					
						target.style.visibility = "visible";
					}
				} else
					target.style.visibility = "hidden";
			}
		}
	}
}

/** 
 * エレメントの絶対座標を返す
 *
 * @param   el   対象エレメント
 * @return  座標配列
 **/
function getAbsolutePos(el) 
{
	// 相対座標を配列に保持
	var r = { x: el.offsetLeft, y: el.offsetTop };

	// 親エレメントがある場合は、親エレメントの相対座標を加算する
	if (el.offsetParent) {
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}


/** 
 * フォーム内の指定チェックボックスを全てON/OFFにする
 *
 * @param   frm		対象フォームオブジェクト
 * @param	e		チェックボックス名称文字列
 * @param	value	チェックボックスの値
 * @return  none
 **/
function netcommonsAllChecked(frm, e, value) {
		if ( frm.elements[e] == undefined ) {
				frm.elements[e].checked = value;
	 }else{
    var n = frm.elements[e].length;
    
    if ( n == undefined ) {
    	frm.elements[e].checked = value;
    } else {
	    for (i = 0; i < n ; i++) {
	        frm.elements[e][i].checked = value;
	    }
    }
		}
}

/** 
 * フォーム内の指定チェックボックスの値をチェックする
 *
 * @param   frm		対象フォームオブジェクト
 * @param	e		チェックボックス名称文字列
 * @return  none
 **/
function netcommonsIsChecked(frm, e) {
	 if ( frm.elements[e] == undefined ) {
	 }else{
	    var n = frm.elements[e].length;
	    if ( n == undefined ) {
			if ( frm.elements[e].checked ) return true;
	    } else {
		    for (i = 0; i < n ; i++) {
		        if ( frm.elements[e][i].checked ) return true;
		    }
	    }
	 }
  return false;
}

/** 
 * フォーム内の指定セレクトオブジェクトを全て非選択状態にする
 *
 * @param   frm		対象フォームオブジェクト
 * @param	e		セレクトオブジェクト名称文字列
 * @return  none
 **/
function netcommonsAllReleaseList(frm, e) { 
    frm.elements[e].selectedIndex = -1;
}

/** 
 * フォーム内の指定セレクトオブジェクトを全て選択状態にする
 *
 * @param   frm		対象フォームオブジェクト
 * @param	e		セレクトオブジェクト名称文字列
 * @return  none
 **/
function netcommonsAllSelectList(frm, e) {
		if ( frm.elements[e] == undefined ) {
	 }else{
    var n = frm.elements[e].length;
    for (i = 0; i < n ; i++) {
        frm.elements[e].options[i].selected = true;
    }
		}
}

/** 
 * フォーム内の指定セレクトオブジェクトで選択されている項目を
 * 別のセレクトオブジェクトに移動する
 *
 * @param   frm		対象フォームオブジェクト
 * @param	efrom	セレクトオブジェクト名称文字列
 * @param	eto		セレクトオブジェクト名称文字列
 * @return  none
 **/
function netcommonsTransValue(frm, efrom, eto) {
    var ef = frm.elements[efrom];
    var et = frm.elements[eto];
    while (ef.selectedIndex != -1) {
        et.length = et.length + 1;
        et.options[et.length - 1].value = ef.options[ef.selectedIndex].value;
        et.options[et.length - 1].text = ef.options[ef.selectedIndex].text;
        ef.options[ef.selectedIndex] = null;
    }
}

/** 
 * フォーム内の指定ラジオボタンを全てONにする
 *
 * @param   frm		対象フォームオブジェクト
 * @param	value	対象ラジオボタンの値
 * @return  none
 **/
function netcommonsAllSelectRadio(frm, value) {
    for ( i=0; i < frm.elements.length; i++ ){
        if ( frm.elements[i].type == 'radio' ){
			if(frm.elements[i].value == value) {
				frm.elements[i].checked = true;
			}
        }
    }
}

/** 
 * フォーム内の指定セレクトオブジェクトの項目を移動する
 *
 * @param   frm		対象フォームオブジェクト
 * @param	e		セレクトオブジェクト名称文字列
 * @param	move	移動方向（上下、最上部、最下部）
 * @return  none
 **/
function netcommonsMoveListBox(frm, e, move){
	var selectindx = frm.elements[e].selectedIndex;
	if (selectindx != -1){
		if (move == 1) {
			for( i = 0; i < frm.elements[e].length; i++ ){
				if( frm.elements[e].options[i].selected ){
					if( i <= 0 ) { 
						continue;
					}
					var optText = frm.elements[e].options[i].text;
    				var optValue = frm.elements[e].options[i].value;
					frm.elements[e].options[i].text = frm.elements[e].options[i-1].text;
					frm.elements[e].options[i].value = frm.elements[e].options[i-1].value;
					frm.elements[e].options[i-1].text = optText;
					frm.elements[e].options[i-1].value = optValue;
					frm.elements[e].options[i-1].selected=true;
					frm.elements[e].options[i].selected=false;
				}
			}
		} else if (move > 1) {
			//最上部へ移動
			var j=0;
			for( i = 0; i < frm.elements[e].length; i++ ){
				if( frm.elements[e].options[i].selected ){
					if( i <= 0 ) { 
						continue;
					}
					var optText = frm.elements[e].options[i].text;
    				var optValue = frm.elements[e].options[i].value;
					var eleOption = document.createElement("option");
					eleOption.value = optValue;
					eleOption.text = optText;
					frm.elements[e].options[i] = null;
					if (!document.all && document.getElementById){
						frm.elements[e].insertBefore(eleOption,frm.elements[e].options[j]);
					}else{
						frm.elements[e].options.add( eleOption, j );
					}
					frm.elements[e].options[j].selected=true;
					j++;
				}
			}
		} else if (move == -1) {
			for( i = frm.elements[e].length-1; i >= 0; i-- ){
				if( frm.elements[e].options[i].selected ){
					if( i >= frm.elements[e].length-1 ) { 
						continue;
					}
					var optText = frm.elements[e].options[i].text;
    				var optValue = frm.elements[e].options[i].value;
					frm.elements[e].options[i].text = frm.elements[e].options[i+1].text;
					frm.elements[e].options[i].value = frm.elements[e].options[i+1].value;
					frm.elements[e].options[i+1].text = optText;
					frm.elements[e].options[i+1].value = optValue;
					frm.elements[e].options[i+1].selected=true;
					frm.elements[e].options[i].selected=false;
				}
				
			}
		} else if (move < -1) {
			var j=frm.elements[e].length - 1;
			for( i = frm.elements[e].length-1; i >= 0; i-- ){
				if( frm.elements[e].options[i].selected ){
					if( i >= frm.elements[e].length-1 ) { 
						continue;
					}
					var optText = frm.elements[e].options[i].text;
    				var optValue = frm.elements[e].options[i].value;
					var eleOption = document.createElement("option");
					eleOption.value = optValue;
					eleOption.text = optText;
					frm.elements[e].options[i] = null;
					if (!document.all && document.getElementById){
						frm.elements[e].insertBefore(eleOption,frm.elements[e].options[j]);
					}else{
						frm.elements[e].options.add( eleOption, j );
					}
					frm.elements[e].options[j].selected=true;
					j--;
				}
			}
		}
	}
}

////
// 動作可能なブラウザ判定
//
// @sample        if(chkAjaBrowser()){ location.href='nonajax.htm' }
// @sample        oj = new chkAjaBrowser();if(oj.bw.safari){ /* Safari code */ }
// @return        ライブラリが動作可能なブラウザだけtrue  true|false
//
//  Enable list (v038現在)
//   WinIE 5.5+ 
//   Konqueror 3.3+
//   AppleWebKit系(Safari,OmniWeb,Shiira) 124+ 
//   Mozilla系(Firefox,Netscape,Galeon,Epiphany,K-Meleon,Sylera) 20011128+ 
//   Opera 8+ 
//

function chkAjaBrowser()
{
	var a,ua = navigator.userAgent;
	this.bw= { 
	  safari    : ((a=ua.split('AppleWebKit/')[1])?a.split('(')[0]:0)>=124 ,
	  konqueror : ((a=ua.split('Konqueror/')[1])?a.split(';')[0]:0)>=3.3 ,
	  mozes     : ((a=ua.split('Gecko/')[1])?a.split(" ")[0]:0) >= 20011128 ,
	  opera     : (!!window.opera) && ((typeof XMLHttpRequest)=='function') ,
	  msie      : (!!window.ActiveXObject)?(!!createHttpRequest()):false 
	}
	return (this.bw.safari||this.bw.konqueror||this.bw.mozes||this.bw.opera||this.bw.msie)
}

////
// XMLHttpRequestオブジェクト生成
//
// @sample        oj = createHttpRequest()
// @return        XMLHttpRequestオブジェクト(インスタンス)
//
function createHttpRequest()
{
	if(window.XMLHttpRequest){
		 //Win Mac Linux m1,f1,o8 Mac s1 Linux k3 & Win e7用
		return new XMLHttpRequest() ;
	} else if(window.ActiveXObject){
		 //Win e4,e5,e6用
		try {
			return new ActiveXObject("Msxml2.XMLHTTP") ;
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP") ;
			} catch (e2) {
				return null ;
 			}
 		}
	} else  {
		return null ;
	}
}

////
// 送受信関数
//
// @sample         sendRequest(onloaded,'&prog=1','POST','./about2.php',true,true)
// @sample         sendRequest(onloaded,{name:taro,id:123,sel:1},','POST','./about3.php',true,true)
// @sample         sendRequest({onload:loaded,onbeforsetheader:sethead},'',','POST','./about3.php',true,true)
// @param {string} callback 受信時に起動する関数名 
// @param {object} callback 受信時に起動する関数名とヘッダ指定関数名{onload:関数名,onbeforsetheader:関数名} 
// @param {array}  callback 受信時に起動する関数名とヘッダ指定 ary["onload"]=関数名;ary["onbeforsetheader"]=関数名 
// @see                    http://jsgt.org/ajax/ref/head_test/header/Range/004/sample.htm
// @param {string} data	   送信するデータ stringの場合(&名前1=値1&名前2=値2...)
// @param {object} data	   送信するデータ objectの場合{名前1:値1,名前2:値2,...}
// @param {array}  data	   送信するデータ arrayの場合は連想配列 ary["名前1"]=値1;ary["名前2"]=値2
// @param {string}method   "POST" or "GET"
// @param {string}url      リクエストするファイルのURL
// @param {string}async	   非同期ならtrue 同期ならfalse
// @param {string}sload	   スーパーロード trueで強制、省略またはfalseでデフォルト
// @param {string}user	   認証ページ用ユーザー名
// @param {string}password 認証ページ用パスワード
// @param {}option    コールバック関数の戻り値に引数をセットする(この関数に渡された値をそのまま、コールバック関数の引数となる。)
//
function sendRequest(callback,data,method,url,async,sload,user,password,callback_param)
{
	sendRequest.prototype.README	 = {
		url		: "http://jsgt.org/mt/archives/01/000409.html",
		name	: "sendRequest", 
		version	: 0.50, 
		license	: "Public Domain",
		author	: "Toshiro Takahashi http://jsgt.org/mt/01/",memo:""}

	//XMLHttpRequestオブジェクト生成
	var oj = createHttpRequest();
	if( oj == null ) return null;
	
	//強制ロードの設定
	var sload = (!!sendRequest.arguments[5])?sload:false;
	if(sload || method.toUpperCase() == 'GET')url += "?";
	if(sload)url=url+"t="+(new Date()).getTime();
	
	//ブラウザ判定
	var bwoj = new chkAjaBrowser();
	var opera	  = bwoj.bw.opera;
	var safari	  = bwoj.bw.safari;
	var konqueror = bwoj.bw.konqueror;
	var mozes	  = bwoj.bw.mozes ;
	var msie	  = bwoj.bw.msie ;
			
	//callbackを分解
	//{onload:xxxx,onbeforsetheader:xxx}
	if(typeof callback=='object'){
		var callback_onload = callback.onload
		var callback_onbeforsetheader = callback.onbeforsetheader
	} else {
		var callback_onload = callback;
		var callback_onbeforsetheader = null;
	}

	//受信処理
	//operaはonreadystatechangeに多重レスバグがあるのでonloadが安全
	//Moz,FireFoxはoj.readyState==3でも受信するので通常はonloadが安全
	//Win ieではonloadは動作しない
	//Konquerorはonloadが不安定
	//参考http://jsgt.org/ajax/ref/test/response/responsetext/try1.php
	if(opera || safari || mozes){
		oj.onload = function () {
			if (callback_param == undefined) {
				callback_onload(oj);
			} else {
				callback_onload(oj, callback_param);
			}
		}
	} else {
		oj.onreadystatechange =function () 
		{
			if ( oj.readyState == 4 ){
				//alert(oj.status+"--"+oj.getAllResponseHeaders());
				if (callback_param == undefined) {
					callback_onload(oj);
				} else {
					callback_onload(oj, callback_param);
				}
			}
		}
	}

	//URLエンコード
	data = uriEncode(data,url)
	if(method.toUpperCase() == 'GET') {
		url += data
	}
	
	//open メソッド
	oj.open(method,url,async,user,password);

	
	//リクエストヘッダカスタマイズ用コールバック
	//使う場合は、呼び出しHTML側のwindow直下へグローバルな関数setHeadersを
	//記述し、その中でsetRequestHeader()をセットしてください
	//@sample function setHeaders(oj){oj.setRequestHeader('Content-Type',contentTypeUrlenc)}
	//
	if(!!callback_onbeforsetheader)callback_onbeforsetheader(oj)

	//デフォルトヘッダapplication/x-www-form-urlencodedセット
	setEncHeader(oj)
	
	// IE以外は、Refereをセットしていないため、自分自身をセットしてあげる。
	if (!msie) {
		if(!window.opera){
			oj.setRequestHeader('Referer',url);
		} else {
			if((typeof oj.setRequestHeader) == 'function')
				oj.setRequestHeader('Referer',url);
		}	
	}
	
	//デバック
	//alert("////jslb_ajaxxx.js//// \n data:"+data+" \n method:"+method+" \n url:"+url+" \n async:"+async);
	
	//send メソッド
	oj.send(data);

	//URIエンコードヘッダセット
	function setEncHeader(oj){

		//ヘッダapplication/x-www-form-urlencodedセット
		// @see  http://www.asahi-net.or.jp/~sd5a-ucd/rec-html401j/interact/forms.html#h-17.13.3
		// @see  #h-17.3
		//   ( enctype のデフォルト値は "application/x-www-form-urlencoded")
		//   h-17.3により、POST/GET問わず設定
		//   POSTで"multipart/form-data"を指定する必要がある場合はカスタマイズしてください。
		//
		//  このメソッドがWin Opera8.0でエラーになったので分岐(8.01はOK)
		var contentTypeUrlenc = 'application/x-www-form-urlencoded; charset=UTF-8';
		if(!window.opera){
			oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		} else {
			if((typeof oj.setRequestHeader) == 'function')
				oj.setRequestHeader('Content-Type',contentTypeUrlenc);
		}	
		return oj
	}

	//URLエンコード
	//引数dataは、stringかobjectで渡せます
	function uriEncode(data,url){
		var encdata =(url.indexOf('?')==-1)?'?dmy':'';
		if(typeof data=='object'){
			for(var i in data)
				encdata+='&'+encodeURIComponent(i)+'='+encodeURIComponent(data[i]);
		} else if(typeof data=='string'){
			if(data=="")return "";
			//&と=で一旦分解しencode
			var encdata = '';
			var datas = data.split('&');
			for(var i=1;i<datas.length;i++)
			{
				var dataq = datas[i].split('=');
				encdata += '&'+encodeURIComponent(dataq[0])+'='+encodeURIComponent(dataq[1]);
			}
		} 
		return encdata;
	}

	return oj
}

function addLink(css_name, media){
	for(var i=0; (nLink = document.getElementsByTagName("LINK")[i]); i++) {
		if(nLink.href == css_name) {
			//既に追加済
			return true;
		}
	}
	if(document.all) {
		document.createStyleSheet(css_name);
		// stylesheet object createStyleSheet([sURL] [, iIndex])
		// iIndexは省略可。省略するとスタイルシート集合の最後に追加。 
	} else if(document.styleSheets){
		var nLink=document.createElement('LINK');
		nLink.rel="stylesheet";
		nLink.type="text/css";
		nLink.media= (media ? media : "screen");
		nLink.href=css_name;
		var oHEAD=document.getElementsByTagName('HEAD').item(0);
		oHEAD.appendChild(nLink);
	}
	return true;
}

function wait(a,func){
	var check = 0;
	try{
		eval("check = " + a);
	}catch(e){
	}
	if(check){
		func()
	}else{
		var f = function(){wait(a,func)};
		setTimeout(f,100);
	}
}
