function startFlash(str,title)
{
	document.getElementById("flash1").onJavascript(str);
	location.href = "#main"; 
	var newtitle = title;
	$('#sendck').html('<span class="clink" onmouseover="bc_set(this);" onmouseout="bc_clr(this);" onclick="myAddCookie(\'ytbid\',\'' + str + '\',\'' + newtitle + '\',\'3650\');">＋</span>' + decodeURIComponent(title));
	var h3rt = $('#h3rt').attr('title');
	if (h3rt) {
		reRead(str, 0, encodeURIComponent(h3rt));
	} else {
		reRead(str, 0, '');
	}
	xmlhttp2 = new XMLHttpRequest();
	xmlhttp2.open('GET', 'http://www.ryuutuu.net/rss/rss_yt_amazon_side.php?vq=' + title, true);
	xmlhttp2.onreadystatechange = function()
		{
			if (xmlhttp2.readyState == 4  && xmlhttp2.status == 200)
			{
				$('#tresult').html(xmlhttp2.responseText);
			} else {
				$('#tresult').html("Loading...");
			}
		}
	xmlhttp2.send(null);
}
function getdataf(keyword, no)
{
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'http://www.ryuutuu.net/yt/yt_html.php?vq=' + keyword + '&stindex=' + no, true);
	xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4  && xmlhttp.status == 200)
			{
				flakey(xmlhttp.responseText, keyword,no);
			} else {
				$('#resultf').html("Loading...");
			}
		}
	xmlhttp.send(null);
}
function flakey(str, keyword, no)
{
	var keyword2 = decodeURIComponent(keyword);
	$('#resultf').html(str);
	$('#k_flaid').val(keyword2);
	var reimg = $('#resultf > li > img');
	if (reimg.length > 0 && no == 0) {
		startFlash($('#resultf > li').eq(1).attr('title'),reimg.eq(0).attr('title'));
	}
}
function ch_input(no)
{
	dbCount('key', $('#k_flaid').val(), $('#k_flaid').val());
	getdataf(encodeURIComponent($('#k_flaid').val()), no);


}
function db_input(no)
{
	var getse=[];
	var chfouc = $('#dbSearch > ul > li > input:checkbox[@name*="sedb"]:checked');
	if (chfouc.length > 0) {
		for(i=0; i < chfouc.length; i++) {
			getse.push(chfouc.eq(i).val());
		}
		var post = '&sedb%5B%5D=' + getse.join('&sedb%5B%5D=');
	} else {
		var post = '&sedb%5B%5D=title&sedb%5B%5D=user&sedb%5B%5D=tag';
	}
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'http://www.ryuutuu.net/yt/db_search.php?vq=' + encodeURIComponent($('#k_dbid').val()) + '&stindex=' + no + post, true);
	xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4  && xmlhttp.status == 200)
			{
				$('#dresult').html(xmlhttp.responseText);
			} else {
				$('#dresult').html("Loading...");
			}
		}
	xmlhttp.send(null);
}
function se_input(vq,type,no)
{
	var keyword = decodeURIComponent(vq);
	$('#k_dbid').val(keyword);
	$('#dbSearch > ul > li > input:checkbox[@name*="sedb"]').val([type]);
	if (no == 0) {
		dbCount(type, keyword, keyword);
	}
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'http://www.ryuutuu.net/yt/yt_search.php?vq=' + vq + '&type=' + type + '&stindex=' + no, true);
	xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4  && xmlhttp.status == 200)
			{
				$('#dresult').html(xmlhttp.responseText);
			} else {
				$('#dresult').html("Loading...");
			}
		}
	xmlhttp.send(null);
}
function cmAdd(dbno,flg,nowno){
	if (flg == 0) {
		$('#cmform').html('<dd><label for="cuser">なまえ</label><input id="cuser" name="cuser" type="text" size="20" value="" /></dd><dd><label for="ctext">コメント</label><textarea id="ctext" name="ctext" rows="3" cols="30" ></textarea></dd><input type="button" value="投稿確認" onclick="cmAdd(' + dbno + ',1,' + nowno + ')" />');
	} else if (flg == 1) {
		if ($("#ctext").val() == "") {
			cmAdd(dbno,0,nowno);
			return false;
		}
		if ($("#cuser").val() == "") {
			$("#cuser").val('名無しさん');
		}
		var txtVal = $("#ctext").val();
		var txtRe = txtVal.replace(/\r\n/g, "<br />");
		txtRe = txtRe.replace(/(\n|\r)/g, "<br />");
		$('#cmarea').prepend('<h4 class="inh4">' + $("#cuser").val() + '</h4><p>' + txtRe + '</p>');
		$('#cmform').html('<input id="comminp" type="hidden" value="' + txtVal + '" /><dd><span class="focus">以下の内容で宜しければ確定ボタンを押してください。</span></dd><dd><input type="button" value="投稿を確定する" onclick="cmAdd(' + dbno + ',2,' + nowno + ')" /><input type="button" value="キャンセル" onclick="cmAdd(' + dbno + ',11,' + nowno + ')" /></dd>');
	} else if (flg == 2) {
		$('#cmarea').load("http://www.ryuutuu.net/yt/db_comment.php",{title: $('#cmarea').children('h4').eq(0).text(), comm: $("#comminp").val(), stindex: nowno, no: dbno}, function(text, status) {if (status == 'success') {$('#cmform').html('<dd><span class="focus">投稿が完了しました。</span></dd><dd><input type="button" value="コメントフォーム" onclick="cmAdd(' + dbno + ',0,' + nowno + ')" />（コメントを投稿する場合はクリック）</dd>');} else if (status == 'error') {'不明のエラーです。改善しない場合は不具合報告をお願いします。'};});
		$("#comminp").remove();
	} else if (flg == 11) {
		$('#cmarea').children('h4').eq(0).remove();
		$('#cmarea').children('p').eq(0).remove();
		$("#comminp").remove();
		$('#cmform').html('<dd><span class="focus">投稿をキャンセルしました。</span></dd><dd><input type="button" value="コメントフォーム" onclick="cmAdd(' + dbno + ',0,' + nowno + ')" />（コメントを投稿する場合はクリック）</dd>');
	} else if (flg == 99) {
		$('#cmarea').load("http://www.ryuutuu.net/yt/db_comment.php",{stindex: nowno, no: dbno});
	}
}
function reRead(str, no, h3re)
{
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'http://www.ryuutuu.net/yt/yt_related.php?guid=' + str + '&stindex=' + no + '&prev=' + h3re , true);
	xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4  && xmlhttp.status == 200)
			{
				$('#related').html(xmlhttp.responseText);
			} else {
				$('#related').html("Loading...");
			}
		}
	xmlhttp.send(null);
}
function dbranking(rid, type, no, num){
	xmlhttp = new XMLHttpRequest();
	xmlhttp.open('GET', 'http://www.ryuutuu.net/yt/db_ranking.php?type=' + type + '&stindex=' + no + '&mresult=' + num + '&id=' + rid , true);
	xmlhttp.onreadystatechange = function()
		{
			if (xmlhttp.readyState == 4  && xmlhttp.status == 200)
			{
				$('#' + rid).html(xmlhttp.responseText);
			} else {
				$('#' + rid).html("Loading...");
			}
		}
	xmlhttp.send(null);
}