//<!-- Javscript Version Definition -->
var jsver = "1.1";
var isIE=false;		//Internet Explorer
var isNS=false;		//Netscape Navigator
var isOpera=false;		//Opera
var isFireFox=false;	//Firefox
var isSafari=false;		//Safari
var appVer;

/*
 * detect browser name and version
 * @version 1.1
*/
function browserDetect(){
	var versionIndex=0;
	//Netscape & FireFox
	if(navigator.appName=="Netscape"){	// Mozilla Group
		//FireFox
		if(navigator.userAgent.indexOf("Firefox")!=-1){		
			isFireFox = true;
			versionIndex=navigator.userAgent.indexOf("Firefox")+8;
			appVer = parseInt(navigator.userAgent.charAt(versionIndex));
		//Nescape Navigator	
		}else if(navigator.userAgent.indexOf("Navigator")!=-1){
			isNS = true;
			versionIndex = navigator.userAgent.indexOf("Navigator")+10;
			appVer = parseFloat(navigator.userAgent.charAt(versionIndex));	
		}else if(navigator.userAgent.indexOf("Safari")!=-1){
			isSafari = true;
			versionIndex = navigator.userAgent.indexOf("Version")+8;
			appVer = parseInt(navigator.userAgent.charAt(versionIndex));
		}//end if~else
		
	//IE
	}else if(navigator.appName=="Microsoft Internet Explorer"){
		isIE = true;
		var temp;
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			temp=navigator.appVersion.split("MSIE");
			appVer=parseFloat(temp[1]);
		}//end if
				
	//Opera?
	}else if(navigator.appName=="Opera"){
		isOpera = true;
		appVer = paraseFloat(navigator.appVersion);
		
	}//end　if~else
	
}//browserDetect

function ChangeFloat(inVal){
	var flg = false;
	if(inVal < 0){
		flg = true;
		Val = String(Math.abs(inVal));
			
	}else{
		Val = String(inVal);
	}
	if (Val.charAt(0) == ".") Val = "0" + Val;
	if (flg) Val = "-" + Val;
	return Val; 
}//end ChangeFloat

function FocusAlert(Val,msg){
	var obj = document.forms[0];
   if (Val == 1){
		alert(obj.common_001.value);
   }else{
		alert(obj.common_006.value + " " +msg + " " + obj.common_002.value);
   }//end if~else	
}//

function convMinMax(min, max) {

  min = ChangeFloat(CDeciPt(min, 2));
  max = ChangeFloat(CDeciPt(max, 2));
  return min + " - " + max;
}//end convMinMax

function FloatPrse(val){
	return CDeciPt(val,2);
}//end FloatPrse

function FloatPrse_k(val){
	return CDeciPt(val,3);
}//FloatPrse_k

function CDeciPt(val, pt) {
  
  var Jou = 1;
  for(i=0;i<pt;i++){
      Jou = Jou	* 10
  }

  var work = val * (Jou);
  
  if(val > 0){
	if (work - Math.floor(work) < 0.5){
		return Math.floor(work) / (Jou);
	}else{
		return (Math.floor(work) + 1) / (Jou);
	}
  }else{
	if (work - Math.floor(work) > -0.5){
		return Math.floor(work) / (Jou);
	}else{
		return (Math.floor(work) - 1) / (Jou);
	}
  }//end if~else
}//end CDeciPt


function isEmptyAlert(val, msg, item) {
  var obj = document.forms[0];	
  if (val == null || val == "") {
    item.blur();
    alert(msg + obj.common_003.value);
    item.blur();
    return true;
  }//end if
  return false;
}//end isEmptyAlert


function isEmpty(val) {
  if (val == null || val == "") {
    return true;
  }
  return false;
}//end isEmpty


function isNumeric(val, msg, item) {
  var obj = document.forms[0];
  oneDecimal = false;
  strInput = "" + val;
  var resultStr="";
   
  for (var i=0; i<strInput.length; i++) {
    var oneChar = convertZenToHan(strInput.charAt(i));
    
    // check minus & plus number
    if (i == 0 && strInput.length > 1) {
      if (strInput == "-." || strInput == "+.") {
        item.blur();
        alert(msg + obj.common_004.value);
        return false;
      }else if(oneChar =="-" || oneChar=="+"){
      	resultStr = oneChar;
        continue;
      }//end if
    }//end if
   /*
    if (oneChar == "." && !oneDecimal && strInput.length > 1) {
      oneDecimal = true;
      continue;
    }
   */
     //2007.04.06 add(全角数値対応)
	//oneChar = convertZenToHan(oneChar);    
	   
	if(oneChar !="."){	    
    	if (oneChar < "0" || oneChar > "9") {
      		item.blur();
      		alert(msg + obj.common_004.value);
      		return false;
    	}//end if
    }
    
    resultStr = resultStr + oneChar;
   
  }//end for
  
  item.value = resultStr;
  
  return true;
}//end isNumeric

//2007.04.06 add(全角で入力した場合、自動的に半角に変えるように) 全角数値対応


function convertZenToHan(val){
	
	switch(val){
 		case "０":
 			val = "0";
 			break;
 		case "１":
 			val = "1";
 			break;
 		case "２":
 			val = "2";
 			break;
 		case "３":
 			val = "3";
 			break;
 		case "４":
 			val = "4";
 			break;
 		case "５":
 			val = "5";
 			break;
 		case "６":
 			val = "6";
 			break;
 		case "７":
 			val = "7";
 			break;
 		case "８":
 			val = "8";
 			break;
 		case "９":
 			val = "9";
 			break;
 		case "．":
 			val=".";
 			break;
 		case "＋":
 			val="+";
 			break;
 		case "－":　　　　　
 			val="-";
 			break;	
 		default:
 			break;
 	}//end switch

	return val;
}//convertZenToHan

//2007.04.10 add
function convertHanNum(input){
	
		strInput = "" + input;
		var resultStr="";
		
		for (var i=0; i<strInput.length; i++) {
    		var oneChar = strInput.charAt(i);
        
    		oneChar = convertZenToHan(oneChar);    
    	  
    		resultStr = resultStr + oneChar;
   		
  		}//end for
  		
	return resultStr;
	
}//converHanNum

//2007.04.16 add( saveAna)
function convertZen(item){
		var val;
		val = convertHanNum(item.value);
		
		item.value = val;
		return val;
}//convertZen

function isNumericPlus(val, msg, item) {
  var obj = document.forms[0];
  oneDecimal = false;
  strInput = "" + val;
  resultStr = "";
  
  for (var i=0; i<strInput.length; i++) {
    var oneChar = convertZenToHan(strInput.charAt(i));
    if (i == 0 && strInput.length > 1) {
      if (strInput == "-." || strInput == "+.") {
        item.blur();
        alert(msg + obj.common_004.value);
        return false;
      }else if(oneChar =="-" || oneChar=="+") {
      	resultStr = oneChar;
        continue;
      }//end if~else
    }//end if
    /*
    if (oneChar == "." && !oneDecimal && strInput.length > 1) {
      oneDecimal = true;
      continue;
    }
    */
    //2007.04.06 add(全角数値対応)
    //oneChar = convertZenToHan(oneChar);
    
    if(oneChar !="."){	
	    if (oneChar < "0" || oneChar > "9") {
    		item.blur();
      		alert(msg + obj.common_004.value);
      		return false;
    	}//end if
    }//end if
    
    resultStr = resultStr + oneChar;
  }//end for
  
  item.value = resultStr;
  
  return true;
}//end isNumericPlus


function isProper(val, range, msg, item) {
	
  var obj = document.forms[0];	
  var min = FloatPrse(getFront(range, "-"));
  var max = FloatPrse(getEnd(range, "-"));
  
  //2007.04.06 add(全角数字対応)
  val = convertHanNum(val);
   
  var val_n = FloatPrse(val);
  
  if (min == 0 && max == 0) return true;
	
  if (val_n < min || val_n > max) {
    item.blur();
    alert( msg + obj.common_005.value);
    return false;
  }
  return true;
}//isProper


function isProper_Keykiri(val, range, msg, item) {

  var obj= document.forms[0];	
  var deplim = getDeplim_Key(); 
  var min = deplim;
  var max = FloatPrse(getEnd(range, "-"));
  var val_n = FloatPrse(val);

  if (min == 0 && max == 0) return true;

  if (val_n < min || val_n > max) {
    item.blur();
    alert(msg + obj.common_005.value);
    return false;
  }
  return true;
}


function getFront(mainStr, searchStr) {
  var Startidx = 0;
  if(mainStr.charAt(0) == searchStr) Startidx = 1;
  foundOffset = mainStr.indexOf(searchStr, Startidx);
  if (foundOffset == -1) {
    return null;
  }
  return mainStr.substring(0, foundOffset)
}//end getFront

function getEnd(mainStr, searchStr) {
  var Startidx = 0;
  if(mainStr.charAt(0) == searchStr) Startidx = 1;
  foundOffset = mainStr.indexOf(searchStr, Startidx);
  if (foundOffset == -1) {
    return null;
  }
  return mainStr.substring(foundOffset + searchStr.length, mainStr.length);
}//end getEnd

function men_list(){
  var i=0;
  this[i++] = new opt('0', '0');
  //LSシリーズのみ
  var obj = document.forms[0];
  if(obj.scode.value==115)	this[i++] = new opt('0.4','0.4');
  this[i++] = new opt('0.5', '0.5');
  this[i++] = new opt('1.0', '1.0');
  this[i++] = new opt('1.5', '1.5');
  this[i++] = new opt('2.0', '2.0');
  this[i++] = new opt('3.0', '3.0');
  this[i++] = new opt('4.0', '4.0');
  this[i++] = new opt('5.0', '5.0');
  this[i++] = new opt('6.0', '6.0');
  this[i++] = new opt('7.0', '7.0');
  this[i++] = new opt('8.0', '8.0');
  this[i++] = new opt('9.0', '9.0');
  this[i++] = new opt('10.0', '10.0');
  this[i++] = new opt('11.0', '11.0');
  this[i++] = new opt('12.0', '12.0');
  this[i++] = new opt('13.0', '13.0');
  this[i++] = new opt('14.0', '14.0');
  this[i++] = new opt('15.0', '15.0');
  this[i++] = new opt('16.0', '16.0');
  this[i++] = new opt('17.0', '17.0');
  this[i++] = new opt('18.0', '18.0');
  this[i++] = new opt('19.0', '19.0');
  this[i++] = new opt('20.0', '20.0');
  this[i++] = new opt('25.0', '25.0');
  this[i++] = new opt('30.0', '30.0');
  this[i++] = new opt('35.0', '35.0');
  this[i++] = new opt('40.0', '40.0');
  this[i++] = new opt('45.0', '45.0');
  this[i++] = new opt('50.0', '50.0');
  this[i++] = new opt('60.0', '60.0');
  this[i++] = new opt('70.0', '70.0');
  this[i++] = new opt('80.0', '80.0');
  this[i++] = new opt('90.0', '90.0');
  this[i++] = new opt('100.0', '100.0');
  this.length = i;
  return this;
}//end men_list

function opt(text,value){
  this.text  = text;
  this.value = value;
}//end opt

function loadOption(obj, opts, val_max, val_pre){
  if (jsver > 1.0){
    var flgDef = false;
    var dmDef;
    for (var i=0; i<obj.length; i++) {
      if (obj.options[i].defaultSelected) {
        dmDef = obj.options[i].value;
        flgDef = true;
        break;
      }
    }//end for
    
    if (!flgDef) {
      if (obj.options.length > 0) {
        dmDef = obj.options[obj.selectedIndex].value;
      }
    }//end if
	
	

    var ot = obj.options;
    var os = opts;
    var val_os;
    var j;
    var k = 0;
    var cflg = false;
    val_max = FloatPrse(val_max);
    val_pre = FloatPrse(val_pre);
    if (isNaN(val_max)) val_max = 0;
    if (isNaN(val_pre)) val_pre = 0;

    for (var i=0; i<os.length; i++) {

    	val_os = FloatPrse(os[i].value);
    	if (val_os > val_max) break;
    	if (cflg == false && val_os > val_pre && val_pre != 0){
        	if (val_pre == dmDef) {
	    		ot[k] = new Option(val_pre,val_pre,true,false);
      		} else {
	    		ot[k] = new Option(val_pre,val_pre,false,false);
	  		}//end if
        	cflg = true;
	  		j = i;
	  		k = k + 1;
      	}//end if
      	
      	if (os[i].value == dmDef) {
        	ot[k] = new Option(os[i].text,os[i].value,true,false);
      	} else {
        	ot[k] = new Option(os[i].text,os[i].value,false,false);
      	}//end if~else

		if (FloatPrse(ot[k].value) == val_pre){
			j = i;
			cflg = true;
		}//end if
      	k = k + 1;
    }//end for

    if (isNaN(j)) j = 0;
    obj.selectedIndex = j;
    ot.length = k;

  }//end if
}//end loadOption

function loadOption_tap(obj, opts, val_max, val_min, val_pre){
  if (jsver > 1.0){
    var flgDef = false;
    var dmDef;
    for (var i=0; i<obj.length; i++) {
      if (obj.options[i].defaultSelected) {
        dmDef = obj.options[i].value;
        flgDef = true;
        break;
      }
    }//end for
    
    if (!flgDef) {
      if (obj.options.length > 0) {
        dmDef = obj.options[obj.selectedIndex].value;
      }
    }

    var ot = obj.options;
    var os = opts;
    var val_os;
    var j;
    var k = 0;
    var cflg = false;
    val_max = FloatPrse(val_max);
    val_min = FloatPrse(val_min);
    val_pre = FloatPrse(val_pre);
    if (isNaN(val_max)) val_max = 0;
    if (isNaN(val_min)) val_min = 0;
    if (isNaN(val_pre)) val_pre = 0;

    for (var i=0; i<os.length; i++) {
      val_os = FloatPrse(os[i].value);
      if (val_os > val_max) break;
      if (os[i].value == dmDef) {
        ot[k] = new Option(os[i].text,os[i].value,true,false);
      } else {
        ot[k] = new Option(os[i].text,os[i].value,false,false);
      }//end if~else
      if (FloatPrse(ot[k].value) == val_pre){
        j = k;
        cflg = true;
      }
      k = k + 1;
    }//end for

    if (isNaN(j)) j = 0;
    obj.selectedIndex = j;
    ot.length = k;
  }//end if
}//end loadOption_tap

function saveInit(context) {
  var obj = document.forms[0];

  obj.hidLostPass.value = "True";
  
  //obj.TKK.value = "False";
/*
  obj.Zen[0].value = obj.org_le.value;
  obj.Zen[1].value = obj.org_ZenTan.value;
  obj.Zen[2].value = obj.org_d10.value;
  if(obj.FormSign.value == "12"){
    obj.Zen_CutBase.value = "1"; //2006.5.17 add
  }
  obj.Bos[0].value = obj.org_d8.value;
  obj.Bos[1].value = obj.org_d9.value;
  obj.Bos[2].value = obj.org_d10.value;
  obj.Ana[0].value = obj.org_d0.value;
  obj.Ana[1].value = obj.org_d3.value;
  obj.Ana[2].value = obj.org_d1.value;
  obj.Ana[3].value = obj.org_d4.value;
  obj.Ana[4].value = obj.org_d2.value;
  obj.Ana[5].value = obj.org_d6.value;
  obj.Ana[6].value = obj.org_d7.value;
  obj.Ana[7].value = "0";
  obj.Ana[8].value = "0";
  obj.Ana[9].value = obj.org_d7.value;
  obj.Ana[10].value = "0";
  obj.Ana[11].value = "0";
  obj.Ana[12].value = obj.org_d7.value;
  obj.Ana[13].value = "0";
  obj.Ana[14].value = "0";
  obj.Key[0].value = "0";
  obj.Key[1].value = obj.org_d11.value;
  obj.Key[2].value = obj.org_d12.value;
  obj.Key[3].value = obj.org_d13.value;
  obj.Key[4].value = obj.org_d14.value;
  obj.Key[5].value = obj.org_d26.value;
  obj.Key[6].value = obj.org_d27.value;
  obj.Key[7].value = obj.org_d11.value;
  obj.Key[8].value = obj.org_d28.value;
  obj.Tor[1].value = "3";
  obj.Tor[2].value = obj.org_d17.value;
  obj.Tor[3].value = obj.org_d16.value;
  obj.Tor[5].value = obj.org_d15.value;
  obj.Tor[6].value = obj.org_d17.value;
  obj.Tor[7].value = obj.org_d18.value;
  obj.Tor[8].value = obj.org_d19.value;
  obj.Tor[10].value = obj.org_d20.value;
  obj.Tor[11].value = obj.org_d21.value;
  obj.Tor[12].value = obj.org_d22.value;
  obj.Tor[13].value = obj.org_d23.value;
  obj.Tor[14].value = obj.org_d25.value;
  obj.Tor[16].value = "0";
  obj.Yaki[0].value = "0";
  obj.Yaki[1].value = "0";
  obj.Yaki[2].value = "48";
  obj.Yaki[3].value = "53";
  obj.Yaki[4].value = "64";
  obj.Yaki[5].value = "71";
  //2007.04.18 modified (FormSign 7, 8 --> 11)
if (obj.FormSign.value == "11" ){
  obj.Jiku[0].value = obj.org_d35.value;
  obj.Jiku[1].value = obj.org_d30.value;
  obj.Jiku[2].value = "0";
  obj.Jiku[3].value = "0";
  obj.Jiku[4].value = "0";
  obj.Jiku[5].value = "0";
  obj.Jiku[6].value = obj.org_d38.value;
  obj.Jiku[7].value = obj.org_d33.value;
  obj.Jiku[8].value = "0";
  obj.Jiku[9].vakue = "0";
}
*/
	
	obj.action = context+"/zout/createPic.do?param=init";
	obj.method = "post"
	obj.target = "_self";		
	obj.submit();
}//end saveInit();

function CheckForm(sign, item){
	//2007.04.17 画面ID変更(Tilesで統合)
	if (item == "Zen"){
		if (sign == "1" || sign =="2" || sign == "3" || sign == "12" || sign == "13" ){
			return true;
		}else{
			return false;
		}
	}else if(item == "Ana"){
		if (sign == "1" || sign == "2" || sign == "3" || sign == "4" || sign == "5" || sign == "6" || sign == "7" || sign == "8"){
			return true;
		}else{
			return false;
		}
	}else if(item =="Bos"){
		if (sign == "1" || sign == "2" || sign == "3"){
			return true;
		}else{
			return false;
		}
	}else if(item == "Key"){
		if (sign == "1" || sign == "2" || sign == "3" || sign == "5" || sign == "6" || sign == "7"){
			return true;
		}else{
			return false;
		}
	}else if(item == "Tor"){
		if (sign == "1" || sign == "2" || sign == "3" || sign == "6" || sign == "8" || sign == "9" || sign == "12" || sign == "13"){
			return true;
		}else{
			return false;
		}
	}else if(item == "Yak"){
		if (sign != "4"){
			return true;
		}else{
			return false;
		}
	}else if (item == "Jik"){
		if (sign == "11"){
			return true;
		}else{
			return false;
		}
	//2007.04.17 add hubGearModInputForm 歯部分取付穴加工	
	}else if (item == "haTor"){
		if (sign == "1"){
			return true;	
		}else{
			return false;
		}
	}//end if~else
	
}//end CheckForm

//穴径許容差の範囲指定制御
function isIntcheck(val,item,msg){
	var obj = document.forms[0];
	//(1未満－1より大きい)
	var i;
	i = Math.abs(val);
	
	if(i >= 1){
		alert(msg + obj.common_005.value);
		return true;
	}
	//小数第3位まで ->制限無しで変更(2009.04.24)
//	if(val.length >= 7){
//		alert(msg + obj.common_005.value);
//		return true;
//	}

}//end isIntcheck

//Tor_ra.js, Tor_ra4.js, Tor_ra5.js, Tor_ha.js
function GetTapDia(Yobi){
    switch(Yobi){
  case 2:
    return 1.57;
    break;
  case 3:
    return 2.46;
    break;
  case 4:
    return 3.24;
    break;
  case 5:
    return 4.13;
    break;
  case 6:
    return 4.92;
    break;
  case 8:
    return 6.65;
    break;
  case 10:
    return 8.38;
    break;
  case 12:
    return 10.01;
    break;
  case 14:
    return 11.8;
    break;
  case 16:
    return 13.8;
    break;
  case 18:
    return 15.3;
    break;
  case 20:
    return 17.3;
    break;
  default:
    alert("Error");
    return -1;
    } 
}//end function

//ブラウザのスクロールバーの幅を取るメソッドです
function getScrollerWidth() {
    var scr = null;
    var inn = null;
    var wNoScroll = 0;
    var wScroll = 0;

    // Outer scrolling div
    scr = document.createElement('div');
    scr.style.position = 'absolute';
    scr.style.top = '-200px';
    scr.style.left = '-200px';
    scr.style.width = '50px';
    scr.style.height = '50px';
    // Start with no scrollbar
    scr.style.overflow = 'hidden';

    // Inner content div
    inn = document.createElement('div');
    inn.style.width = '100%';
    inn.style.height = '100px';

    // Put the inner div in the scrolling div
    scr.appendChild(inn);
    // Append the scrolling div to the doc
    document.body.appendChild(scr);

    // Width of the inner div sans scrollbar
    wNoScroll = inn.offsetWidth;
    // Add the scrollbar
    scr.style.overflow = 'auto';
    // Width of the inner div width scrollbar
    wScroll = inn.offsetWidth;
    
    return (wNoScroll -inn.offsetWidth);

}//getScrollerWidth()

// StringクラスにTrimメソッドの追加
String.prototype.trim = function() {
	return this.replace(/^[\s\xA0]+|[\s\xA0]+$/g,"");
}
//left trim
String.prototype.ltrim = function() {
	return this.replace(/^[\s\xA0]+/,"");
}
//right trim
String.prototype.rtrim = function() {
	return this.replace(/[\s\xA0]+$/,"");
}

//error handler method
onerror=handleErr;
var txt="";

//debug function
function handleErr(msg,url,l)
{
	txt="There was an error on this page.\n\n";
	txt+="Error: " + msg + "\n";
	txt+="URL: " + url + "\n";
	txt+="Line: " + l + "\n\n";
	txt+="Click OK to continue.\n\n";
	alert(txt);
	return true;
}

//タップ深さ指定時のリスト再作成（円筒用）
function list_remake(lst){
	
	var min_idx= lst.length;
	
	for (k = 0; k < lst.length; k++){
		if (CalcTapDep(k+1) <= 0){
			min_idx = k;
			break;
		}
    }
	
	if (lst.length > min_idx){
		lst.length = min_idx;
	}

}

//タップ深さ指定時のリスト再作成（ラック用）
function list_remake_r(lst,typ){
	
	var min_idx= lst.length;
	
	for (k = 0; k < lst.length; k++){
		if (CalcTapDep(typ,k+1) <= 0){
			min_idx = k;
			break;
		}
    }
	
	if (lst.length > min_idx){
		lst.length = min_idx;
	}

}

//指定桁での切り上げ
function Ceil(val,pt){
	return Math.ceil(val * Math.pow(10,pt-1)) / Math.pow(10,pt-1);
}//end FloatPrse


//写真検索POPUP表示用
//var popupObj;

function sFa1(e,id) {
	popupObj = gObj1(id);
	sLft1(e,id);
	shw(id, true);
	fd(popupObj);
}
function hFa(id) {

	var amt = 0;
	popupObj = gObj1(id);
	popupObj.style.filter = "alpha(opacity:"+amt+")";
	popupObj.style.KHTMLOpacity = amt/100;
	popupObj.style.MozOpacity = amt/100;
	popupObj.style.opacity = amt/100;
	if(amt == 0) shw(id, false);
	return false;
}
function fd(popupObj) {
	var amt = 100;  	
	popupObj.style.filter = "alpha(opacity:"+amt+")";
	popupObj.style.KHTMLOpacity = amt/100;
	popupObj.style.MozOpacity = amt/100;
	popupObj.style.opacity = amt/100;
	popupObj.style.zIndex = amt;
	
}
function sLft1(e,id) {
	picLayer = gObj1(id);    
//    var nWinHeight = 0;
//    nWinHeight = (document.compatMode && document.compatMode == 'CSS1Compat') ? documentElement.clientHeight : document.body.clientHeight;
//alert(nWinHeight)
    picLayer.style.left = 0;
	//picLayer.style.bottom = 0;
	picLayer.style.top = 0;
//    picLayer.style.top  = nWinHeight- document.getElementById(id).offsetHeight;
}
function gObj1(id) {
	return document.getElementById(id);	
}
function shw(id, b) {
	popupObj = gObj1(id);
	(b)? popupObj.className = 'appearPopup':popupObj.className = 'hiddenPopup';	
}	

// 歯底円直径取得関数(かさ歯車)
function getRootDia_bevel() {

    var obj = document.forms[0];

	var Fcode = obj.fcode.value;		 // 形状
	var b1 = FloatPrse(obj.b1.value);	 //歯先円直径
	var c2 = FloatPrse(obj.c2.value);	 //基準円すい角
	var c3 = FloatPrse(obj.c3.value);	 //歯底円すい角
	var h = parseFloat(obj.org_h.value); //歯たけ
	var a2 = FloatPrse(obj.a2.value);	 //歯幅
	var a4 = FloatPrse(obj.a4.value);	 //全長
	var a6 = FloatPrse(obj.a6.value);	 //クラウンツーバック(歯先距離G)
	
	// 内端歯底円直径の取得(B2形状のみ計算方法異なる)
	var diaTeethBottom = 0; // 内端歯底円直径
	var theta1 = c2; 		// 基準円すい角(c2)
	var theta2 = c3; 		// 歯底円すい角(c3)
	var theta3 = 90 - theta1;	// 90 - theta1
	var theta4 = theta1 - theta2; // theta1 - theta2
	var Y1 = h * Math.sin(theta3 * Math.PI/180); // 歯たけ(h) × sin(theta3)
	var X1 = h * Math.cos(theta3 * Math.PI/180); // 歯たけ(h) × cos(theta3)
	var X2 = a4 - a6 + X1; 		// 全長-クラウンツーバック+X1
	var R1 = a2 / Math.cos(theta4 * Math.PI/180); 	// 歯幅(a2)÷cos(theta4)
	var Y2 = 0; // [B2形状] X2×tan(theta2)、[B2形状以外] R1×sin(theta2) 後で設定
	var Y3 = 0; // Y1 + Y2
	
	if(Fcode == "B2"){
		// [B2形状] 内端歯底円直径= 歯先円直径-2*Y3 ※Y3=(h*sin(90-c2))+((a4-a6+(h*cos(90-c2)))*tan(c3))
		//diaTeethBottom = b1 - 2 * (h * Math.sin((90-c2)*Math.PI/180)) + ((a4 - a6 + (h * Math.cos((90-c2)*Math.PI/180))) * Math.tan(c3*Math.PI/180));
		Y2 = X2 * Math.tan(theta2 * Math.PI/180);
	}else{
		// [B2形状以外] 内端歯底円直径= 歯先円直径-2*Y3 ※Y3=(h*sin(90-c2))+((a2/cos(c2-c3))*sin(c3))
		//diaTeethBottom = b1 - 2 * (h * Math.sin((90-c2)*Math.PI/180)) + ((a2 / Math.cos((c2-c3)*Math.PI/180)) * Math.sin(c3*Math.PI/180));
		Y2 = R1 * Math.sin(theta2 * Math.PI/180);
	}
	// Y3の取得
	Y3 = Y1 + Y2;
	
	// 内端歯底円直径の取得
	diaTeethBottom = b1 - 2 * Y3;
	
	return diaTeethBottom;

}	

