var gl = new function(){
	this.sts = 0;
	return this;
}
function hyoka(){
	var a = $A($("hyokaFrm").getElementsByTagName("input"));
	a.each(function(e){
		if(e.type == "radio") e.onclick = _onClick;
	});
}
var _onClick = function(){
	if(this.type == "radio") return _onRadio(this);
}
var _onRadio = function(obj){
	_enableSubmitButton();
	if(_chkSubmit()) $("goHyoka").style.display = "block";
	return true;
}
function onSubmitHyoka(){
	$("goHyoka").disabled = true;
	$("goHyoka").src = "/common/images/opinion/v1_bg08.gif";
	$("goHyoka").className = "btnGray";
	gl.sts = 1;
	$("hk_href").value = (window.location.href) ? window.location.href : "";
	_send();
	return false;
}
function _send(){
	var ajax = new Ajax.Request("/common/hyoka/",
		{method:'post', postBody:Form.serialize("hyokaFrm"), onComplete:_comleteSend}
	);
}
function _comleteSend(res){
}
function _getRadioValue(radio){
	for(var i = 0 ; i < radio.length ; i++){
		if(radio[i].checked) return radio[i].value;
	}
	return false;
}
function onText(){
	_enableSubmitButton();
}
function _chkSubmit(){
	var text = $F("hk_text");
	text = text.replace(/^\s+/, "");
	text = text.replace(/\s+$/, "");
	text = text.replace(/　/, "");
	if(text.length > 0) return true;
	if(!_getRadioValue(document.hyokaFrm.hk_h1)) return false;
	if(!_getRadioValue(document.hyokaFrm.hk_h2)) return false;
	if(!_getRadioValue(document.hyokaFrm.hk_h3)) return false;
	return true;
}
function _enableSubmitButton(){
	if(gl.sts == 1) return;
	if(_chkSubmit()){
		$("goHyoka").disabled = false;
		$("goHyoka").src = "/common/images/opinion/v1_bg07.gif";
		$("goHyoka").className = "";
	}
	else {
		$("goHyoka").disabled = true;
		$("goHyoka").src = "/common/images/opinion/v1_bg11.gif";
		$("goHyoka").className = "btnGray";
	}
}

