function com_write(str){
	
	
	
	var name_ng = String($("name").value)=="";
	var info_ng = String($("info").value)=="";
	
	if(name_ng){
		if(typeof $("err").textContent != "undefined") {
			$("err").textContent = '※名前とコメントは入力必須です';
		}else{
			$("err").innerText = '※名前とコメントは入力必須です';
		}
		return;
	}
	if(info_ng){
		if(typeof $("err").textContent != "undefined") {
			$("err").textContent = '※名前とコメントは入力必須です';
		}else{
			$("err").innerText = '※名前とコメントは入力必須です';
		}
		return;
	}
	
	if(!navigator.cookieEnabled){
		alert("クッキーを有効にしてください");
		return;
	}
	
	if(CookieRead("info")==$('info').value){
		alert("スパムコメントはご遠慮ください");
		return;
	}
	
	if($('info').value.length > 150) {
		alert("コメントは150文字までです");
		return;
	}
	
	var sday = new Date();
	sday.setTime(sday.getTime() + (365 * 1000 * 60 * 60 * 24));
	s2day = sday.toGMTString();
	document.cookie = "info=" + $('info').value + ";expires=" + s2day;
	
	if(typeof $("err").textContent != "undefined") {
			$("err").textContent = '';
		}else{
			$("err").innerText = '';
		}
	
	var info = $('info').value;
	var req = "./phplib/_writecomment.php?w_id="+str+"&name="+$('name').value+"&info="+info;
	req = encodeURI(req);
	$('info').value = '';
	
	new Ajax.Request(req,
	{
		method:'get',
	
		onComplete:function(httpObj)
		{
			$("com").src = $("com").src;
			//document.frames[1].location.reload();
		}
	}
	);
}

function r_write(str)
{
	if(!navigator.cookieEnabled){
		alert("クッキーを有効にしてください");
		return;
	}
	
	if(CookieRead(str)==str){
		alert("プラネットに対して評価できるのは一度だけです");
		return;
	}
	
	sday = new Date();
	sday.setTime(sday.getTime() + (365 * 1000 * 60 * 60 * 24));
	s2day = sday.toGMTString();
	document.cookie = str+"="+str+";expires=" + s2day;
	
	var req = "./phplib/_writerank.php?w_id="+str+"&rank="+$("rank").options[$("rank").selectedIndex].value;
	$("rank_btn").disabled = true;
	$("rank_btn").className = "disabledbutton";
	req = encodeURI(req);
	new Ajax.Request(req,
	{
		method:'get',
	
		onComplete:function(httpObj)
		{
			if(typeof $("err").textContent != "undefined") {
				$("com_info").textContent = "評価が完了しました。";
			}else{
				$("com_info").innerText = "評価が完了しました。";
			}
			$("ran").src = $("ran").src;
			//document.frames[0].location.reload();
		}
	}
	);
}

function CookieRead(kword){
	if(typeof(kword) == "undefined"){
		return "";
	}
	kword = kword + "=";
	kdata = "";
	scookie = document.cookie + ";";
	start = scookie.indexOf(kword);
	if(start != -1){
		end = scookie.indexOf(";", start);
		kdata = unescape(scookie.substring(start + kword.length, end));
	}
	return kdata;
}

