﻿
function key_number()
{		if (event.keyCode < 48 || event.keyCode > 58 )  
		{
			event.keyCode = 0;
			return false;
		}
}
function ConvertString(strnum)
{
var num = new String(strnum);
num = num.replace(',','') ;
 	if (num.length > 3 && num.length <= 6 ) 
	{
		return   (num.substring(0 , num.length - 3)+ "," + num.substring(num.length - 3 , num.length));
	 }
	else if (num.length > 6 &&  num.length <= 9) 
	{
		return  (num.substring(0 , num.length - 6)+ "," + num.substring(num.length - 6 , num.length - 3) + "," + num.substring(num.length - 3 , num.length) ) ;
	} 
	else
	{
		return num;
	}
}
function formatNumber (num, decplaces) {
    num = parseFloat(num);
    if (!isNaN(num)) {
        var str = "" + Math.round (eval(num) * Math.pow(10,decplaces));
        if (str.indexOf("e") != -1) {
            return "Out of Range";
        }
        while (str.length <= decplaces) {
            str = "0" + str;
        }
        var decpoint = str.length - decplaces;        return str.substring(0,decpoint) +  + str.substring(decpoint,str.length);
    } else {
        return "NaN";
    }
}
<!--４９行目の数字は、らんちうバスのトップページのバンコク銀行の円・buyの数字を入れる-->
function calcValue(i_weekDay,i_weekEnd,i_van,i_car,i_caddy,i_rate){
 var tmpweek;
 var tmpCar;
 var tmpResult;
 var tmpConvert;
 var tmpPax;
 var tmpCaddy=i_caddy;
 var tmpRate=0.3613; // i_rate 
	 if (document.getElementById('txtPax').value ==""){
		alert('入力してください。 "人数".'); 
		return;
	}else{
		tmpPax=document.getElementById('txtPax').value
	}  
	if (document.getElementById('weekly1').checked==true){
		tmpweek=i_weekDay;
	} else {
		tmpweek=i_weekEnd;
	} 
	if(document.getElementById('carType').checked==true) {
		tmpCar=i_car;
	}else{
		tmpCar=i_van;
	}
 tmpResult =(((tmpweek+tmpCaddy)* tmpPax) +tmpCar) / tmpPax;
 document.getElementById('txtResult').value=ConvertString(formatNumber(tmpResult,-1));
 document.getElementById('txtConv').value=ConvertString(formatNumber(tmpResult / tmpRate,-1));
 }


function writeContent(i_weekDay,i_weekEnd,i_van,i_car,i_caddy,i_rate){
var scriptContent;
scriptContent  = "<TABLE width=\"450px\" cellspacing=\"1\" cellpadding=\"8\" border=\"0\">\n";
scriptContent = scriptContent+"<TR><TD align=LEFT style=\"BORDER-TOP: #CCC 1px solid;BORDER-LEFT: #CCC 1px solid; \">\n";
scriptContent = scriptContent+"<input type=radio name=weekly id=weekly1 value=1  checked >&nbsp;<font Style=\"font-size: 10px;color:#000;font-family: MS Sans Serif, Tahoma; \">平日</font>\n";
scriptContent = scriptContent+"</TD>\n";
scriptContent = scriptContent+"<TD  style=\"BORDER-TOP:#CCC 1px solid;\">&nbsp;</TD>\n";
scriptContent =scriptContent+ "<TD style=\"BORDER-RIGHT:#CCC 1px solid;BORDER-TOP:#CCC 1px solid;\">\n";
scriptContent =scriptContent+ "<input type=radio name=carType id=Car1 value=1 checked>&nbsp;<font Style=\"font-size:10px;color:#000;font-family: MS Sans Serif, Tahoma; \">セダン（2名様まで）</font>\n";
scriptContent =scriptContent+ "</TD>\n";
scriptContent =scriptContent+ "<TD>&nbsp;</TD>\n";
scriptContent =scriptContent+"</TR>\n";
scriptContent =scriptContent+ "<TR><TD align=LEFT style=\"BORDER-LEFT:#CCC 1px solid;\">\n";
scriptContent =scriptContent+ "<input type=radio name=weekly id=weekly2 value=2>&nbsp;<font Style=\"font-size:10px;color:#000;font-family: MS Sans Serif, Tahoma; \">土日（祝日）</font>\n";
scriptContent =scriptContent+ "</TD>\n";
scriptContent =scriptContent+  "<TD>&nbsp;</TD>\n";
scriptContent =scriptContent+ "<TD style=\"BORDER-RIGHT:#CCC 1px solid;\">\n";
scriptContent =scriptContent+ "<input type=radio name=carType  id=Car2 value=2>&nbsp;<font Style=\"font-size:10px;color:#000;font-family: MS Sans Serif, Tahoma; \">ワゴン（8名様まで）</font>\n";
scriptContent =scriptContent+ "</TD>\n";
scriptContent =scriptContent+ "<TD align=left>&nbsp;>&nbsp;<input type=\"input\" id=\"txtResult\" readonly size=8 style=\"font-size::8px;font-family: Tahoma, Arial, Helvetica, sans-serif;BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; COLOR: #333333; BORDER-BOTTOM: #333333 1px solid\">&nbsp;バーツ/人数.</TD>\n";
scriptContent =scriptContent+ "</TR>\n";
scriptContent =scriptContent+ "<TR><TD align=right style=\"BORDER-LEFT:#CCC 1px solid;BORDER-BOTTOM:#CCC 1px solid;\"><input type=\"input\" onkeypress=javascript:key_number(); id=\"txtpax\" maxlength=3  size=2 style=\"BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; COLOR: #333333; BORDER-BOTTOM: #333333 1px solid\">&nbsp;人数\n";
scriptContent =scriptContent+"</TD><TD style=\"BORDER-BOTTOM:#CCC 1px solid;\">&nbsp;</TD><TD style=\"BORDER-RIGHT:#CCC 1px solid;BORDER-BOTTOM:#CCC 1px solid;\"><input type=\"button\" value=計算 onclick=javascript:calcValue("+ i_weekDay+","+i_weekEnd+","+i_van+","+i_car+","+i_caddy+","+i_rate+");></TD>\n";
scriptContent =scriptContent+ "<TD align=left>&nbsp;>&nbsp;<input type=\"input\" id=\"txtConv\" readonly  size=8 style=\"font-size::8px;font-family: Tahoma, Arial, Helvetica, sans-serif; BORDER-RIGHT: #333333 1px solid; BORDER-TOP: #333333 1px solid; BORDER-LEFT: #333333 1px solid; COLOR: #333333; BORDER-BOTTOM: #333333 1px solid;\">&nbsp;円/人数（100円：36.13バーツ）.</TD></TR>\n";
scriptContent =scriptContent+ "</TABLE>";
<!--95行目の100円：XXバーツは、らんちうバスのトップページのバンコク銀行の円・buyの数字を入れる-->
return document.write(scriptContent);

}