
function fel_click(e, force){
	var opt_id = this.id.replace("opt_","");
	var a;
	if (a = document.getElementById("opt_input_"+opt_id)){
		if (whi.has_class(this,'checked_opt')){
			a.value = "";
			whi.remove_class(this,'checked_opt')
		}else{
			whi.add_class(this,'checked_opt')
			a.value = "1";
		}
	}
	return false;
}

function fel_input_focus(e){
	var tr = this.parentNode.parentNode.parentNode;
	if (!whi.has_class(tr,'checked_opt')){
		if (tr.check_input){
			tr.check_input.onclick();
		}
	}
	whi.events.stopEvent(e);
}

function fel_input_blur(e){
	var tr = this.parentNode.parentNode.parentNode;
	if (whi.has_class(tr,'checked_opt')){
		if (this.value.trim() == '' && tr.check_input){
			tr.check_input.onclick();
		}
	}
	whi.events.stopEvent(e);
}

jsRules.addRule("tr.js_check",function(){
	this.onclick = fel_click;
	var tds = this.getElementsByTagName("td");
	if (tds.length){
		tds[0].onmousedown = function(){return false; };
		tds[0].onselectstart = function(){return false; };
	}
});
jsRules.addRule("tr.js_last_check",function(){
	var tds = this.getElementsByTagName("td");
	if (tds.length){
		this.check_input = tds[0];
		tds[0].onclick = fel_click.bind(this);
		tds[0].onmousedown = function(){return false; };
		tds[0].onselectstart = function(){return false; };
	}
});
jsRules.addRule("tr.js_last_check input",function(){
	this.onfocus = fel_input_focus;
	this.onblur = fel_input_blur;
});