function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;	if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//Submitボタンの2度押し対策

var isNotSubmitted = true;
function chkSubmitted() {

	if (isNotSubmitted == true) {
		isNotSubmitted = false;
		return true;
	}
	return isNotSubmitted;
}

//オープンウィンドウ
var popupWin = null;
function openWin(url, name, W, H) {
	if(popupWin != null) {
		popupWin.close();
	}
	popupWin = null;
	popupWin=window.open(url,name,'toolbar=no,status=yes,width='+W+',height='+H+',directories=no,scrollbars=yes,location=no,resizable=yes,menubar=no');
}

//親画面への値の設定
function dispCode(formName, param1, code1, param2, code2) {
	eval("window.opener.document." + formName + "." + param1 + ".value = '" + code1 + "'");
	if (param2 != null && param2 != "") {
		eval("window.opener.document." + formName + "." + param2 + ".value = '" + code2 + "'");
	}
	window.close();
}

//画面表示／非表示切り替え
function cngView(id) {

	elm = document.getElementById(id);

	// nullオブジェクトでなければ表示・非表示を変更する
	if (elm) {
		status = elm.style.display;
		if (status == 'block') {
			cng(elm, 'none');
		} else {
			cng(elm, 'block');
		}
	}
}

function cng(elm, sts) {
	elm.style.display = sts;
}

// オーバーロードできないのでメソッド名を変えるしかない
function cngDisplay(id,operation) {
	// idからオブジェクトを取得
	elm = document.getElementById(id);
	// nullでなければ表示モードを変更
	if (elm) {
		if (operation == 'close') {
			elm.style.display = 'none';
		} else {
			elm.style.display = 'block';
		}
	}
}

// 色コードをフォームにセット
function setColor(color) {
	// オープン元のフォーム名と、このウィンドウ名が一致していることが前提
	for (i = 0; i < window.opener.form1.elements.length; i++){
		if (window.opener.form1.elements[i].name == window.name) {
			window.opener.form1.elements[i].value = color;
			window.opener.form1.elements[i].style.color = color;
		}
	}
	window.close();
	return false;
}

// Webセーフカラーのテーブルを作成する
function makeColorTable() {
	codeList = new Array("00","33","66","99","CC","FF");
	colorCode = "";
	scriptStr = "";
	document.write('<table cellspacing="3" cellpadding="3" border="1">');
	// ブロック単位でループ
	for (i = 0; i < 6; i++) {
		// 行単位でループ
		for (j = 0; j < 6; j++) {
			// 行書き出し
			document.write('<tr>');
			// 列単位でループ
			for (k = 0; k < 6; k++) {
				// 色コードを作成
				colorCode = '#' + codeList[i] + codeList[k] + codeList[j%6];
				// セル書き出し
				document.write('<td bgcolor="' + colorCode + '">');
				document.write('<img src="images/sp.gif" width="20" height="20" alt=""></td>');
				scriptStr = "javaScript:setColor('" + colorCode + "');";
				document.write('<td>' + '<a href="' + scriptStr + '">' + colorCode + '</a>' + '</td>');
			}
			document.write('</tr>');
		}
	}
	document.write('</table>');
}

// 販売形態をセットする
function setSalesPattern(prefix,count) {
	// 1行目のデータを取得
	tmpValue = document.getElementById(prefix + "-1").value;

	for (i = 1; i <= count; i++ ) {
		document.getElementById(prefix + "-" + i).value = tmpValue;
	}
}
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();
	}
}
