<!--

//XMLHttpRequestオブジェクト生成
function createHttpRequest(){

	if(window.ActiveXObject){
		try {
			return new ActiveXObject("Msxml2.XMLHTTP")
		} catch (e) {
			try {
				return new ActiveXObject("Microsoft.XMLHTTP")
			} catch (e2) {
				return null
			}
		}
	} else if(window.XMLHttpRequest){
		return new XMLHttpRequest() //[1]'
	} else {
		return null
	}
}

//受信内容を確認してイベントを起動
function getFile( data , method , fileName , async ){

	//XMLHttpRequestオブジェクト生成
	var httpoj = createHttpRequest()
	httpoj.open( method , fileName , async )

	//受信時に起動するイベント
	httpoj.onreadystatechange = function(){
		if (httpoj.readyState==4){

			//コールバック
			on_loaded(httpoj)
		}
	}
	httpoj.send( data )
}

//コールバック関数 ( 受信時に実行されます )
function on_loaded(oj){
			dispTxt	= oj.responseText
			
			//整形して表示
			var aryIn = dispTxt.split("\n");
			dispTxt = seikei(aryIn);
			dispTxt = autolink(dispTxt);
			document.getElementById("disp").innerHTML = dispTxt;

}

function seikei(aryIn){
var dispTxt = "";var tag = "";
for (var i = 0; i < aryIn.length; i++) {
	var line = aryIn[i];
if (line == "") {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	dispTxt += "\n";
} else if (line.indexOf("***") == 0) {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	line = line.replace(/^\*+\s*/, "");
	dispTxt += "<h6>" + line + "</h6>\n";
} else if (line.indexOf("**") == 0) {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	line = line.replace(/^\*+\s*/, "");
	dispTxt += "<h5>" + line + "</h5>\n";
} else if (line.indexOf("*") == 0) {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	line = line.replace(/^\*+\s*/, "");
	dispTxt += "<h4>" + line + "</h4>\n";
} else if (line.indexOf("----") == 0) {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	dispTxt += "<hr>\n";
} else if (line.indexOf(">") == 0) {
	if (tag != "</blockquote>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</blockquote>") {
		dispTxt += "<blockquote>\n";
	}

	line = line.replace(/^\>+\s*/, "");
	dispTxt += "<p>" + line + "</p>\n";
	tag = "</blockquote>";
} else if (line.indexOf(" ") == 0) {
	if (tag != "</pre>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</pre>") {
		dispTxt += "<pre>\n";
	}

	line = line.replace(/^\s/, "");
	dispTxt += line + "\n";
	tag = "</pre>";
} else if (line.indexOf("-") == 0) {
	if (tag != "</ul>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</ul>") {
		dispTxt += "<ul>\n";
	}

	line = line.replace(/^\-\s*/, "");
	dispTxt += "<li>" + line + "</li>\n";
	tag = "</ul>";
} else if (line.indexOf("+") == 0) {
	if (tag != "</ol>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</ol>") {
		dispTxt += "<ol>\n";
	}

	line = line.replace(/^\+\s*/, "");
	dispTxt += "<li>" + line + "</li>\n";
	tag = "</ol>";
} else if (line.indexOf(":") == 0) {
	if (tag != "</dl>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</dl>") {
		dispTxt += "<dl>\n";
	}

	line = line.replace(/^\:\s*/, "");
	var strDt = line.substr(0, line.search(/\:\:/));
	dispTxt += "<dt>" + strDt + "</dt>\n";
	var aryDds = line.substr(line.search(/\:\:/)).split("::");

	for (var j = 0; j < aryDds.length; j++) {
		if (aryDds[j]) dispTxt += "<dd>" + aryDds[j] + "</dd>\n";
	}

	tag = "</dl>";

} else if (line.indexOf("\,") == 0) {
	if (tag != "</table>" && tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	if (tag != "</table>") {
		dispTxt += "<table border=0>\n";
	}

	line = line.replace(/^\,\s*/, "");
	line = line.replace(/\,\s*/g,"<\/td><td>");
	dispTxt += "<tr><td>" + line + "</td></tr>\n";
	tag = "</table>";


} else {
	if (tag != ""){
		dispTxt += tag + "\n";
		tag = "";
		}
	dispTxt += "<p>" + line + "</p>\n";
}
}
return dispTxt;
}

function autolink(dispTxt){ 
var dispTxt_regexp = "(https?://[-\\w.!~*'();/?:@&=+$,%#]+)"; 
var re = new RegExp(""); 
re.compile( dispTxt_regexp, "ig" ); 

dispTxt = dispTxt.replace( re, "<a href=\"$1\">$1</a>" );
return dispTxt;
} 

//-->
