/***********************************************************
* search.js
***********************************************************/
var myTime  = new Date();				// System Time
var myYear  = myTime.getFullYear();
var myMonth = myTime.getMonth() + 1;
var myDay   = myTime.getDate();
var strMonth;							// Month
var nMonth;								// Month
var strDay;								// Day
var nDay;								// Day

// Form
document.write("<form name=\"search_form\" method=\"get\" action=\"http://www2.489ban.net/v4/client/plan/search/customer/iyaonsen\">");

// Month
document.write("<select name=\"year_month\" class=\"left\">");

for (nMonth = myMonth; nMonth <= myMonth + 5; nMonth++)
{
	if((nMonth-1)/12 >= 1)
	{
		strMonth = parseInt(nMonth) - 12;
		strYear = myYear + parseInt((nMonth-1)/12);
	}
	else
	{
		strMonth = nMonth;
		strYear = myYear;
	}

	strMonth = strMonth.toString();
	strYear = strYear.toString();

	if (strMonth.length < 2)
	{
		strMonth = "0" + strMonth;	
	}
	
	if(nMonth == myMonth)
	{
		document.write("<option value=\"" + strYear + "-" + strMonth +"\" selected>" + strYear + "年" + strMonth + "月</option>");
	}
	else
	{
		document.write("<option value=\"" + strYear + "-" + strMonth +"\">" + strYear + "年" + strMonth + "月</option>");
	}
}
document.write("</select>");

document.write("&nbsp;&nbsp;");

// Day
document.write("<select name=\"day\" class=\"right\">");

for (nDay = 1; nDay <= 31; nDay++)
{
	strDay = nDay.toString();
	
	if (strDay.length < 2)
	{
		strDay = "0" + strDay;	
	}
	
	if(nDay == myDay)
	{
		document.write("<option value=\"" + strDay +"\" selected>" + nDay + "日</option>");
	}
	else
	{
		document.write("<option value=\"" + strDay +"\" >" + nDay + "日</option>");
	}
	
}

document.write("</select>");

// Search Button
document.write("<input type=\"button\" class=\"button\" value=\"検索\" onclick=\"search()\"/>\n"); 

// Hidden
document.write("<input type=\"hidden\" id =\"date\" name=\"date\" />")
document.write("<input type=\"hidden\" name=\"priceL\" value=\"0\" />");
document.write("<input type=\"hidden\" name=\"priceH\" value=\"99999999\" />");
document.write("<input type=\"hidden\" name=\"category\" value=\"0\" />");
document.write("<input type=\"hidden\" name=\"room\" value=\"1\" />");
document.write("<input type=\"hidden\" name=\"stay\" value=\"1\" />");
document.write("<input type=\"hidden\" name=\"is_calc_nop\" value=\"0\" />");

document.write("</form>\n"); 

// Search function
document.write("<script type=\"text/javascript\">");
document.write("function search(){");
document.write("	var year_month_string = document.search_form.year_month.options[document.search_form.year_month.selectedIndex].value;");
document.write("	var day_string = document.search_form.day.options[document.search_form.day.selectedIndex].value;");
document.write("	document.getElementById('date').value = year_month_string + '-' + day_string;");
document.write("	window.open(\"\",\"planview\");");
document.write("	document.search_form.target = \"planview\";");
document.write("	document.search_form.submit();");
document.write("}");
document.write("</script>");
