/*
  コストシミュレーション 用
*/

// ready
//  DOM構築後に実行するべき処理
$().ready(function search(){
  var func_disabled = function(){
    var _target,_this=$(this);
    if(_this.parent().attr("id")=="activate-2"){
      _target = $("td:nth-child(3)",_this.parents("table"));
    }else{
      _target = $("td:nth-child(4)",_this.parents("table"));
    }
    if(!_this.attr("checked")){
      $("input:text",_target).attr({"disabled":"disabled"});
      _target.addClass("disabled");
    }else{
      $("input:text",_target).attr({"disabled":""});
      _target.removeClass("disabled");
    }
  }

  $("table.cost-simulation-1 input:checkbox").each(function(){
    func_disabled.call(this);
  });
  $("table.cost-simulation-1 input:checkbox").click(function(){
    func_disabled.call(this);
  });

  var func_radio_select = function(isClick){
    var _target,_this=$(this),_parents_tr=_this.parents("tr");
    if(isClick){
      $("tbody input[@name='"+_this.attr("name")+"']").parents("tr").addClass("disabled");
      _parents_tr.removeClass("disabled");
      $("input:text",_this.parents("th").next()).select();
    }else if(!_this.attr("checked")){
      _parents_tr.addClass("disabled");
    }
  
  
  }
  $("table input:radio").click(function(){
    func_radio_select.call(this,true);
  });
  $("table input:radio").each(function(){
    func_radio_select.call(this);
  });

});


