//yysimple3.js Ver 1.03

// Ver 1.03 [2002/06/08]細部を修正
// Ver 1.02 [2002/01/07]コメントの半角文字列系の長さを制限できるようにしました。
// Ver 1.01 [2002/01/06]ちょっぴりNN6.2とIE5でクロスブラウザ＾＾；


//ヘッダ部分のメニューを隠したり出したり用(爆)
var Sub_Menu_Flag = 0;
function Sub_Menu2(id, id2){

	if(Sub_Menu_Flag == 0){
		Sub_Menu_Flag = 1;
		K = "";
		K2 = "none";
	}
	else{
		Sub_Menu_Flag = 0;
		K = "none";
		K2 = "";
	}

	if(document.getElementById){
        	document.getElementById(id).style.display = K;
        	document.getElementById(id2).style.display = K2;
	}
	else if(document.all){
        	document.all(id).style.display = K;
        	document.all(id2).style.display = K2;
	}
}

//日付部分に各情報を出力する
function CH(id, s){
	if(document.getElementById){
        	document.getElementById(id).innerHTML = "<span class='Res_Date'>" +s+ "</span>";
	}
	else if(document.all){
        	document.all(id).innerHTML = "<span class='Res_Date'>" +s+ "</span>";

	}
}

var Color1;
var BgColor1;
var Color2;
var BgColor2;
//プレビューを実行する
function Send(ch, C1, B1, C2, B2, imgsrc){

	var TEMP, P;
	Color1 = C1;
	BgColor1 = B1;
	Color2 = C2;
	BgColor2 = B2;

	if(ch == 1){
		P = F1.comment.value;
		if(P != ""){

			if(document.getElementById){
	                	document.getElementById("Comment_1").style.display = "none";
        	        	document.getElementById("Comment_2").style.display = "none";
                		document.getElementById("Comment_3").style.display = "none";
                		document.getElementById("Preview").style.display = "";
				TEMP = "<input title='書き込みをサーバーへ送信します' type=submit value='送信' class='submit' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>　<input type=reset value='修正' class='submit' onClick='Send(0, Color1, BgColor1, Color2, BgColor2)' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>";
				document.getElementById("Send").innerHTML = TEMP;

				//document.all["Preview_Icon"].innerHTML = "<img src='./imgsrc/" + F1.icon.options[F1.icon.selectedIndex].value + "'>";
				document.getElementById["Preview_Comment"].innerHTML = P.replace(/\n/g, "<br>");
			}
			else if(document.all){
	                	document.all("Comment_1").style.display = "none";
        	        	document.all("Comment_2").style.display = "none";
                		document.all("Comment_3").style.display = "none";
                		document.all("Preview").style.display = "";
				TEMP = "<input title='書き込みをサーバーへ送信します' type=submit value='送信' class='submit' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>　<input type=reset value='修正' class='submit' onClick='Send(0, Color1, BgColor1, Color2, BgColor2)' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>";
				document.all["Send"].innerHTML = TEMP;

				//document.all["Preview_Icon"].innerHTML = "<img src='./imgsrc/" + F1.icon.options[F1.icon.selectedIndex].value + "'>";
				document.all["Preview_Comment"].innerHTML = P.replace(/\n/g, "<br>");
			}
		}
	}
	else{
		if(document.getElementById){
			document.getElementById("Preview").style.display = "none";
             		document.getElementById("Comment_1").style.display = "";
             		document.getElementById("Comment_2").style.display = "";
             		document.getElementById("Comment_3").style.display = "";
			TEMP = "<a href=\"JavaScript:Send2(1);\"><span title=\"プレビューモード\" class=\"submit\">Preview</span></a>";
			document.getElementById("Send").innerHTML = TEMP;
	}
		else if(document.all){
                	document.all["Preview"].style.display = "none";
                	document.all["Comment_1"].style.display = "";
                	document.all["Comment_2"].style.display = "";
                	document.all["Comment_3"].style.display = "";

			TEMP = "<a href=\"JavaScript:Send2(1);\"><span title=\"プレビューモード\" class=\"submit\">Preview</span></a>";
			document.all["Send"].innerHTML = TEMP;
		}
	}    
}

//プレビューを実行する
function Send2(ch, C1, B1, C2, B2, imgsrc){

	var TEMP, P, myReg, cReg=0;
	Color1 = C1;
	BgColor1 = B1;
	Color2 = C2;
	BgColor2 = B2;

	if(ch == 1){

		P = document.F1.comment2.value;
		if(P != ""){

		//半角文字等でテーブルの横幅が崩されるのを防ぐ為に、半角，半角スペースを３５文字で制限してます
		//制限数を変えたい場合は−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−↓ここを変えて下さい
		myReg = /[a-zA-Z0-9' '!"#$%&'()=-~^|\`@{}*:+;_?>.<,][a-zA-Z0-9' '!"#$%&'()=-~^|\`@{}*:+;_?>.<,]{35,}/

		if(myReg.test(P)){ 
			alert("半角文字列の長が制限数を越えました！Σ(￣▽￣;)");
		} else{

			if(document.getElementById){

	                	document.getElementById("Comment_1").style.display = "none";
        	        	document.getElementById("Comment_2").style.display = "none";
                		document.getElementById("Comment_3").style.display = "none";
                		document.getElementById("Preview").style.display = "";
				document.F1.comment.value = P;
				document.getElementById("Preview_Comment").innerHTML = P.replace(/\n/g, "<br>");
				TEMP = "<input type=submit value='送信' class='submit' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>　<input type=reset value='修正' class='submit' onClick='Send2(0, Color1, BgColor1, Color2, BgColor2)' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>";
				document.getElementById("Send").innerHTML = TEMP;
			} if(document.all){

	                	document.all("Comment_1").style.display = "none";
        	        	document.all("Comment_2").style.display = "none";
                		document.all("Comment_3").style.display = "none";
                		document.all("Preview").style.display = "";
				document.F1.comment.value = P;
				document.all("Preview_Comment").innerHTML = P.replace(/\n/g, "<br>");
				TEMP = "<input type=submit value='送信' class='submit' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>　<input type=reset value='修正' class='submit' onClick='Send2(0, Color1, BgColor1, Color2, BgColor2)' onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'>";
				document.all("Send").innerHTML = TEMP;
			}
		}
		}
	}
	else {
			if(document.getElementById){

                		document.getElementById("Preview").style.display = "none";
	                	document.getElementById("Comment_1").style.display = "";
        	        	document.getElementById("Comment_2").style.display = "";
                		document.getElementById("Comment_3").style.display = "";

				TEMP = "<div title=\"プレビューモード\" class=\"submit\" onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'><a href=\"JavaScript:Send2(1, Color1, BgColor1, Color2, BgColor2);\">Preview</a></div>";
				document.getElementById("Send").innerHTML = TEMP;
			} if(document.all){

                		document.all("Preview").style.display = "none";
	                	document.all("Comment_1").style.display = "";
        	        	document.all("Comment_2").style.display = "";
                		document.all("Comment_3").style.display = "";

				TEMP = "<div title=\"プレビューモード\" class=\"submit\" onmouseover='this.style.color=Color1; this.style.backgroundColor=BgColor1;' onmouseout='this.style.color=Color2; this.style.backgroundColor=BgColor2;'><a href=\"JavaScript:Send2(1, Color1, BgColor1, Color2, BgColor2);\">Preview</a></div>";
				document.all("Send").innerHTML = TEMP;
			}
	}
}

//セレクトのcolorを取得反映
function SelectColorSet(id, color){
	if(document.getElementById){
		document.getElementById(id).style.color = color;
	} else if(document.all) {
		document.all(id).style.color = color;
	}
}