/* 確認メッセージ表示 */
function fnConfirm(message) {
	if (window.confirm(message)) {
		return true;
	} else {
		return false;
	}
}

/* ソートフォームサブミット処理 */
function fnSortFormSubmit(formname, sortkey) {
	document.getElementById(formname).sort.value = sortkey;
	document.getElementById(formname).submit();
	return false;
}

/* ページナビフォームサブミット処理 */
function fnPagenaviFormSubmit(formname, page) {
	document.getElementById(formname).page.value = page;
	document.getElementById(formname).submit();
	return false;
}

/* サブミット処理 */
function fnLinkFormSubmit(formname) {
	document.getElementById(formname).submit();
	return false;
}

/* サブミット処理 */
function fnOnEvent(element) {
	element.form.eventId.value=element.name;
}

/* サブミット処理 */
function fnOnEventSubmit(id) {
	document.update.eventId.value=id;
	document.update.submit();
}

/* サブミット処理 */
function fnOnEventFormSubmit(formname, id) {
	document.getElementById(formname).eventId.value=id;
	document.getElementById(formname).submit();
}

/* フォームのアクション先を変更し、サブミットする */
function changeFormAction(formname, action) {
	document.getElementById(formname).action = action;
	document.getElementById(formname).submit();
	return false;
}

/* 確認メッセージ表示後、フォームのアクション先を変更し、サブミットする */
function changeFormActionConfirm(formname, action, message) {
	if (window.confirm(message)) {
		document.getElementById(formname).action = action;
		document.getElementById(formname).submit();
	}
	return false;

}

/* 対象ID設定処理 */
function fnTarget(id, element) {
	element.form.targetId.value=id;
	element.form.eventId.value=element.name;
}

/* 対象ID設定処理 */
function fnTargetSubmit(id, eventId) {
	document.update.targetId.value=id;
	document.update.eventId.value=eventId;
	document.update.submit();
}

/* 差込コードの挿入 */
function fnCodeInsert(code) {
	var selection = new Selection(document.getElementById("body"));
	var s = selection.create();
	var body = document.getElementById("body").value;
	var beforeValue = body.substr(0, s.start);
	var afterValue = body.substr(s.end, body.length);
	document.getElementById("body").value = beforeValue + code + afterValue;

	var isMSIE = /*@cc_on!@*/false; 
	if (!isMSIE) { 
		var cursor = s.start + code.length;
		document.getElementById("body").setSelectionRange(cursor, cursor);		
	} 
	document.getElementById("body").focus();
}

/* 検索フィールドのクリア */
function fnClear(){
	document.getElementById("skey").value = "";
	return false;
}

/* 入力項目のクリア */
function fnFormClear(formName){
	cnt = document.forms[formName].length;
	for(i=0;i<cnt;i++){
		fm = document.forms[formName].elements[i];
		if (fm.type == "text" ) {
			fm.value = "";
		} else if (fm.type == "textarea" ) {
			fm.value = "";
		} else if (fm.type == "radio" ) {
			fm.checked = false;
		} else if (fm.type == "checkbox") {
			fm.checked = false;
		} else if (fm.type == "select-one") {
			fm.selectedIndex = 0;
		} else {
		}
	}
}
