// JavaScript Document
function stayJump( lang ) {
// https://wwwc1.dlinx.co.jp/stays/hotelsoga/reservation/index.html?rg_id=2&sel_ym1=YYYYMM&sel_d1=DD&nights=SS
// sel_ym1=YYYYMM : 西暦年と月
// sel_d1=DD      : 日
//  nights=SS     : 宿泊日数

if(lang=="EN")
	url = "https://wwwc1.dlinx.co.jp/stays/hotelsoga/eng/reservation/index.html?rg_id=2&";
else
	url = "https://wwwc1.dlinx.co.jp/stays/hotelsoga/reservation/index.html?rg_id=2&";
year = document.stay_search.form_year.value;
month = document.stay_search.form_month.value;
date = document.stay_search.form_day.value;
stay = document.stay_search.form_stay.value;

url = url + "sel_ym1=" + year + month + "&sel_d1=" + date + "&nights=" + stay;

window.open(url);

}

/**
 * 必要な桁数まで0を埋める。
 * @param number 数値
 * @param size 桁数
 */
function fillZero( number, size ) {
  var s = Math.log( number ) * Math.LOG10E;
  for( i=1,n=size-s,str="";i<n;i++ ) str += "0";
  return str+number;
}


function formSelectYear ( lang ) {
	var myDate = new Date();
	var myYear = myDate.getFullYear();
	var myMonth = myDate.getMonth();
	document.open();
	document.write("<label>\n");
	document.write("<select name='form_year' id='form_year'>\n");
	document.write("<option value='"+ myYear +"'>"+ myYear +"</option>\n");
	if(myMonth>=6)
		document.write("<option value='"+ (myYear+1) +"'>"+ (myYear+1) +"</option>\n");
	document.write("</select>\n");
	document.write("</label>\n");
	if(lang=="EN")
		document.write("Year");
	else
		document.write("年");
	document.close();
}
function formSelectMonth ( lang ) {
	var myDate = new Date();
	var myMonth = myDate.getMonth();
	document.open();
	document.write("<label>\n");
	document.write("<select name='form_month' id='form_month'>\n");
	document.write("<option value='--' >--</option>\n");
	for(var i=1;i<=12;i++) {

	document.write("<option value='"+ fillZero( i, 2 ) + "' >" + i +"</option>\n");
/*
		document.write("<option value='"+ fillZero( i, 2 ) + "'");
		if((myMonth+1) == i) {
			document.write(" selected='selected'");
		}
		document.write(" >" + i +"</option>\n");
*/
	}
	document.write("</select>\n");
	document.write("</label>\n");
	if(lang=="EN")
		document.write("Month");
	else
		document.write("月");
	document.close();
}
function formSelectDay ( lang ) {
	var myDate = new Date();
	var myDay = myDate.getDay();
	document.open();
	document.write("<label>\n");
	document.write("<select name='form_day' id='form_day'>\n");
	document.write("<option value='--' >--</option>\n");
	for(var i=1;i<=31;i++) {
		document.write("<option value='"+ fillZero( i, 2 ) + "' >" + i +"</option>\n");
/*
		document.write("<option value='"+ fillZero( i, 2 ) + "'");
		if((myMonth+1)==i) {
			document.write(" selected='selected'");
		}
		document.write(" >" + i +"</option>\n");
*/
	}
	document.write("</select>\n");
	document.write("</label>\n");
	if(lang=="EN")
		document.write("Day");
	else
		document.write("日");
	document.close();
}
function formSelectStay ( lang ) {
	document.open();
	document.write("<label>\n");
	document.write("<select name='form_stay' id='form_stay'>\n");
	document.write("<option value='--' >--</option>\n");
	for(var i=1;i<=10;i++) {
		document.write("<option value='"+ fillZero( i, 2 ) + "' >" + i +"</option>\n");
	}
	document.write("</select>\n");
	document.write("</label>\n");
	if(lang=="EN")
		document.write("");
	else
		document.write("泊");
	document.close();
}
