﻿var compatibleSelection = Class.create();
compatibleSelection.prototype = {	
	// コンストラクタ
	initialize: function() {
	},
	compatibleSelectionForm : "compatibleSelection",
	mountStyle: function() {
		// 取付方法ラジオボタンオブジェクト
		return $A($(this.compatibleSelectionForm).mountStyle).find(function(v) {return v.checked;});
	},
	mountStyleValue: function(){
		mountStyle = this.mountStyle();
		if(mountStyle){
			return this.mountStyle().value;
		}else {
			return null;	
		}		
	},
	outputshaftDirection : function(){
		return $(this.compatibleSelectionForm).outputshaft_direction_id;
	}
};

var sForm = new compatibleSelection();

function setOutputshaftDirection()
{
	mountStyle = sForm.mountStyleValue();
	if(mountStyle == null) return;
	
	mountStyleArray = mountStyle.split('_');
	if(mountStyleArray[0] == 'O'){	// 直行軸
		if(mountStyle == 'O_H_Y'){	// 直交軸ホローシャフト 
			// 軸出し方向が選択不可
			resetOutputshaftDirection(false);
		}else {		// 直交軸脚取付 直交軸フランジ取付
			resetOutputshaftDirection(true);
		}
	}else{							// 平行軸
		resetOutputshaftDirection(false);
	}
}

function resetOutputshaftDirection(aviable)	
{
	for(i=0; i<$A(sForm.outputshaftDirection()).length; i++){
		if(aviable){
			//$A(sForm.outputshaftDirection())[i].checked = false;
			$A(sForm.outputshaftDirection())[i].disabled = false;			

		}else {		// 出力軸方向を選択不可に
			//$A(sForm.outputshaftDirection())[i].checked = false;
			$A(sForm.outputshaftDirection())[i].disabled = true;			
		}
	}	
}

function setDefaultData()
{
	// 型式
	setTextBoxValue('compatible_modle', compatible_modle);		
	// メーカ
	setRadioCheck('compatible_corp_id', compatible_corp_id);	
	// 軸出方向
	setRadioCheck('mountStyle', mountStyle);	
	// 取付方式
	setRadioCheck('outputshaft_direction_id', outputshaft_direction_id);
	// 減速比
	setSelectCheck('ratio_range_id', ratio_range_id);	
	// モータ容量
	setSelectCheck('motorpower_id', motorpower_id);	
	// ブレーキ
	setRadioCheck('brake_id', brake_id);	
	// モータ・電源
	setRadioCheck('motor', motor);		
}
