// common.js
var max_pulldown = 6;

function setYearMonth()
{
   var write_ym = "";
   var write_m  = "";
   var todays   = new Date();

   var now_y = todays.getFullYear();
   var now_m = todays.getMonth();

   var next_todays = new Date();

   var wdayMS  = 1 * 24 * 60 * 60 * 1000;
   var DateMS  = next_todays.getTime();
   DateMS     += wdayMS;
   next_todays.setTime(DateMS);

   var next_y = next_todays.getFullYear();
   var next_m = next_todays.getMonth() + 1;

   for (m = 0; m < max_pulldown; m++)
   {
      now_m = now_m + 1;
      if (now_m > 12)
      {
         now_m  = 1;
         now_y += 1;
      }

      if (now_m < 10)
      {
         write_m = "0" + now_m;
      }
      else
      {
         write_m = now_m;
      }
      write_ym += "<OPTION value=\"" + now_y + write_m + "\"";
      if (now_m == next_m) {write_ym += " selected"};
      write_ym += ">" + now_y + "年" + write_m + "月";
      write_ym +="</OPTION>\n";
   }
   document.write(write_ym);
}

function setDay()
{
   var write_d = "";
   var disp_d  = "";
   var todays  = new Date();
   var now_day = todays.getDate();

   var next_date = new Date();
   var wdayMS  = 1 * 24 * 60 * 60 * 1000;
   var DateMS  = next_date.getTime();
   DateMS     += wdayMS;
   next_date.setTime(DateMS);
   var next_day = next_date.getDate();

   var end_day = getEndDay(next_date);

   for (i = 1; i < end_day + 1; i++)
   {
      if (i < 10)
      {
         disp_d = "0" + i;
      }
      else
      {
         disp_d = i;
      }

      write_d += "<OPTION value=\"" + disp_d + "\"";

      if (i == next_day) {write_d += " selected"};

      write_d +=">" + disp_d + "日";
      write_d +="</OPTION>\n";
   }
   document.write(write_d);
}


function getEndDay(todays)
{
   var tYear  = todays.getFullYear();
   var tMonth = todays.getMonth() + 2;
   if (tMonth >= 13)
   {
      tYear += 1;
      tMonth -= 12;
   }
   nextDate  = tYear + "/" + tMonth + "/1";

   var nDate = new Date(nextDate);
   var wdayMS  = -1 * 24 * 60 * 60 * 1000;
   var DateMS  = nDate.getTime();
   DateMS     += wdayMS;
   nDate.setTime(DateMS);
   var eDate  = nDate.getDate();

   return eDate;

}

function DateChange(mode)
{

    if (mode == "calendar"){
        frm = window.opener.document.forms[0];
    } else {
        frm = document.forms[0];
    }

   i  = frm['inn_ym'].selectedIndex;
   cd = frm['inn_ym'].options[i].value;

   frm_name = 'inn_d';

   var sYear   = cd.substr(0, 4);
   var sMonth  = cd.substr(4, 2);
   var sDay    = "01";
   todays      = new Date(sYear + "/" + sMonth + "/" + sDay);
   var end_day = getEndDay(todays);

   frm[frm_name].length = end_day;

   cnt = 0;
   for (i = 1; i < end_day + 1; i++)
   {
      if (i < 10)
      {
         disp_d = "0" + i;
      }
      else
      {
         disp_d = i;
      }

      frm[frm_name].options[cnt].value = i;
      frm[frm_name].options[cnt].text = disp_d + "日";
      ++cnt;
   }
}

function kickCal()
{
   var selYM = window.document.forms[0].inn_ym.options[window.document.forms[0].inn_ym.selectedIndex].value;
   var url = "calendar.html?selY=" + selYM.substr(0,4) + "&selM=" + selYM.substr(4,2);
   window.open(url,"inputHelpCalendar","width=400,height=280,resizable=yes,status=yes");
}

function dispCalender()
{

    cldr = "";

    var b_link_year = "";
    var b_link_month = "";
    var b_link_yearmonth = "";

    var a_link_year = "";
    var a_link_month = "";
    var a_link_yearmonth = "";

    now_date  = new Date();
    now_year  = now_date.getFullYear();
    now_month = now_date.getMonth() + 1;
    now_day   = now_date.getDate();

    locUrl = window.location.search;

    if (locUrl.match(/[?&]selY=([0-9]+)/)) {
        disp_year = RegExp.$1;
    } else {
        disp_year = now_year();
    }

    if (locUrl.match(/[?&]selM=([0-9]+)/)) {
        disp_month = RegExp.$1;
    } else {
        disp_month = now_month;
    }
    disp_month = parseInt(disp_month,10);

    last_month = parseInt(now_month) + 5;
    if (last_month > 12) {last_month = last_month - 12};

    if (last_month == disp_month) {disp_month = parseInt(disp_month) - 1};

    if (disp_month < 1)
    {
        disp_year  = parseInt(disp_year) - 1;
        disp_month = parseInt(disp_month) + 12;
     }

    if (disp_month != now_month){
        if (disp_month == 1){
            b_link_year  = parseInt(disp_year) - 1;
            b_link_month = 12;
        } else {
            b_link_year  = disp_year;
            b_link_month = parseInt(disp_month) - 1;
        }
        b_link_yearmonth = new Date(b_link_year + "/" + b_link_month + "/1");
    }

    right_disp_month = parseInt(disp_month) + 1;
    if (right_disp_month > 12) {right_disp_month = right_disp_month - 12};
    if (right_disp_month != last_month)
    {
        if (disp_month == 12){
            a_link_year  = parseInt(disp_year) + 1;
            a_link_month = 2;
        } else {
            a_link_year  = disp_year;
            a_link_month = parseInt(disp_month) + 1;
        }
        a_link_yearmonth = new Date(a_link_year + "/" + a_link_month + "/1");
    }

    numdays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    if((disp_year%4 == 0) && (disp_year%100 != 0) || (disp_year%400 == 0)) numdays[1] = 29;

    cldr += "<table>";
    cldr += "<tr>";
    cldr += "<td align=\"left\">";

    if (b_link_yearmonth == ""){
        cldr += "&lt;&lt;前&lt;&lt;</td>";
    } else {
        cldr += "<a href=\"" + "calendar.html\?selY=" + b_link_year + "\&selM=" + b_link_month + "\">&lt;&lt;前&lt;&lt;</a>";
    }
    cldr += "</td>";

    cldr += "<td>&nbsp;</td>";
    cldr += "<td align=\"right\">";
    if (a_link_yearmonth == ""){
        cldr += "&gt;&gt;次&gt;&gt;";
    } else {
        cldr += "<a href=\"" + "calendar.html\?selY=" + a_link_year + "\&selM=" + a_link_month + "\">&gt;&gt;次&gt;&gt;</a>";
    }
    cldr += "</td>";
    cldr += "</tr>";
    cldr += "<tr>";
    cldr += "<td valign=\"top\">";

    day = new Date(disp_year, disp_month-1, 1);
    dtlWrite();

    cldr += "</TABLE>";
    cldr += "</td><td>&nbsp;</td>";
    cldr += "<td valign=top>";

    disp_month = disp_month + 1
    if (disp_month > 12){
        disp_month = 1;
        disp_year = parseInt(disp_year) + 1;
    }

    day = new Date(disp_year, disp_month-1, 1);

    dtlWrite();

    cldr += "</TABLE>";
    cldr += "</td>";
    cldr += "</tr>";
    cldr += "<tr>";
    cldr += "<td align=\"center\" colspan=\"3\"><input type=\"button\" value=\"閉じる\" onclick=\"window.close()\"></td>";
    cldr += "</tr>";
    cldr += "</table>";

    document.write(cldr);
}

function dtlWrite()
{
    if(disp_month == 1){holiday1 = 1; holiday2 = 14-(day.getDay()+5)%7; holiday3 = -1}
    else if(disp_month == 2){holiday1 = 11; holiday2 = -1; holiday3 = -1}
    else if(disp_month == 3){
        ed = 20.8431 + 0.242194 * (disp_year - 1980) - Math.floor((disp_year - 1980)/4);
        holiday1 = Math.floor(ed);
        holiday2 = -1;
        holiday3 = -1;
    }
    else if(disp_month == 4){holiday1 = 29; holiday2 = -1; holiday3 = -1}
    else if(disp_month == 5){holiday1 = 3; holiday2 = 4; holiday3 = 5}
    else if(disp_month == 6){holiday1 = -1; holiday2 = -1; holiday3 = -1}
    else if(disp_month == 7){holiday1 = 21-(day.getDay()+5)%7; holiday2 = -1;holiday3 = -1}
    else if(disp_month == 8){holiday1 = -1; holiday2 = -1; holiday3 = -1}
    else if(disp_month == 9){
        holiday1 = 21-(day.getDay()+5)%7;
        ed = 23.2488 + 0.242194 * (disp_year - 1980) - Math.floor((disp_year - 1980)/4);
        holiday2 = Math.floor(ed);
        holiday3 = -1
    }
    else if(disp_month == 10){holiday1 = 14-(day.getDay()+5)%7;; holiday2 = -1; holiday3 = -1}
    else if(disp_month == 11){holiday1 = 3; holiday2 = 23; holiday3 = -1}
    else if(disp_month == 12){holiday1 = 23; holiday2 = -1; holiday3 = -1}

    cldr += "<table border>";
    cldr += "<tr align=center><th colspan=7>"+ disp_year + "年" + disp_month +"月</th></tr>";
    cldr += "<tr align=center><th><font color=\"#ff0000\">日</a></th><th>月</th><th>火</th><th>水</th><th>木</th><th>金</th><th><font color=\"#0000ff\">土</a></th></tr>";
    for(sunday = 1-day.getDay(); sunday <= numdays[disp_month-1]; sunday +=7){
        cldr += "<TR align=\"center\">";
        for(i = sunday; i < sunday + 7; i++){
            if((i > 0) && (i <= numdays[disp_month-1])){
                if (now_year == disp_year && now_month == disp_month && now_day == i){
                    dtlDay = "<font color=\"#ff0000\"><strong>" + i + "</strong></font>";
                } else {
                    dtlDay = i + "";
                }
                day.setDate(i);
                today = day.getDay();
                if(today == 0){
                    if (now_year == disp_year && now_month == disp_month && now_day > day.getDate()){
                        cldr += "<td bgcolor=\"#FF33FF\">"+ dtlDay +"</td>";
                    } else {
                        cldr += "<td bgcolor=\"#FF33FF\"><a href=\"javaScript:void(0)\" onclick=\"setSelDate("+ disp_year + "," + disp_month + "," + i + ")\">"+ dtlDay +"</a></td>";
                    }
                } else if((i == holiday1)||(i == holiday2)||(i == holiday3)){
                    if (now_year == disp_year && now_month == disp_month && now_day > day.getDate()){
                        cldr += "<td bgcolor=\"#FF33FF\">"+ dtlDay +"</td>";
                    } else {
                        cldr += "<td bgcolor=\"#FF33FF\"><a href=\"javaScript:void(0)\" onclick=\"setSelDate("+ disp_year + "," + disp_month + "," + i + ")\">"+ dtlDay +"</a></td>";
                    }
                } else if((today == 1)&&((i-1 == holiday1)||(i-1 == holiday2)||(i-1 == holiday3))){
                    if (now_year == disp_year && now_month == disp_month && now_day > day.getDate()){
                        cldr += "<td bgcolor=\"#FF33FF\">"+ dtlDay +"</td>";
                    } else {
                        cldr += "<td bgcolor=\"#FF33FF\"><a href=\"javaScript:void(0)\" onclick=\"setSelDate("+ disp_year + "," + disp_month + "," + i + ")\">"+ dtlDay +"</a></td>";
                    }
                } else if(today == 6) {
                    if (now_year == disp_year && now_month == disp_month && now_day > day.getDate()){
                        cldr += "<td bgcolor=\"#99CCCC\">"+ dtlDay +"</td>";
                    } else {
                        cldr += "<td bgcolor=\"#99CCCC\"><a href=\"javaScript:void(0)\" onclick=\"setSelDate("+ disp_year + "," + disp_month + "," + i + ")\">"+ dtlDay +"</a></td>";
                    }
                } else {
                    if (now_year == disp_year && now_month == disp_month && now_day > day.getDate()){
                        cldr += "<td>"+ dtlDay +"</td>";
                    } else {
                        cldr += "<td><a href=\"javaScript:void(0)\" onclick=\"setSelDate("+ disp_year + "," + disp_month + "," + i + ")\">"+ dtlDay +"</a></td>";
                    }
                }
            } else {
                cldr += "<td>&nbsp;</td>";
            }
        }
        cldr += "</TR>";
    }
}

function setSelDate( strYear, strMonth, strDay ) {

   if (strMonth < 10){
      strMonth = "0" + strMonth;
   }

   for( i = 0; i < window.opener.document.forms[0].inn_ym.length; i++ ){
      if( eval(window.opener.document.forms[0].inn_ym.options[i].value) == String(strYear) + String(strMonth) ){
         window.opener.document.forms[0].inn_ym.selectedIndex = i;
         DateChange("calendar");
      }
   }
   for( i = 0; i < window.opener.document.forms[0].inn_d.length; i++ ){
      if( eval(window.opener.document.forms[0].inn_d.options[i].value) == strDay ){
         window.opener.document.forms[0].inn_d.selectedIndex = i;
      }
   }
   window.close();
}

// area.js
var arcd = new Array();

arcd[1] = new prfct("01","北海道",
            new Array(
                 new city("0101","札幌・小樽")
               , new city("0120","登別・洞爺湖")
               , new city("0102","定山渓・ニセコ")
               , new city("0107","千歳・室蘭・苫小牧")
               , new city("0103","道東(十勝川・帯広)")
               , new city("0104","道東(阿寒・知床・網走・釧路)")
               , new city("0105","道央(旭川・富良野・日高・えりも)")
               , new city("0106","道南(函館・湯の川温泉)")
            )
         );

arcd[2] = new prfct("02","青森県",
           new Array(
                new city("0201","青森・浅虫温泉")
              , new city("0202","十和田湖・奥入瀬")
              , new city("0204","弘前・大鰐・五所川原")
              , new city("4","八戸・古牧温泉・馬門温泉")
           )
        );

arcd[3] = new prfct("03","岩手県",
           new Array(
                new city("0309","盛岡・雫石・安比高原")
              , new city("0310","一関・北上・花巻・その他")
              , new city("0320","陸中海岸（釜石・宮古・大船渡）")
           )
        );

arcd[4] = new prfct("04","宮城県",
           new Array(
                new city("0401","仙台市内")
              , new city("0402","松島海岸・気仙沼・石巻")
              , new city("0404","作並・秋保温泉")
              , new city("0403","古川・鳴子・鬼首")
              , new city("0410","白石・蔵王・遠刈田温泉")
           )
        );

arcd[5] = new prfct("05","秋田県",
           new Array(
                new city("0511","能代・大館・十和田湖周辺")
              , new city("0510","秋田・男鹿・その他")
              , new city("0530","田沢湖・八幡平")
           )
        );

arcd[6] = new prfct("06","山形県",
           new Array(
                new city("0611","蔵王・上ノ山温泉")
              , new city("0602","あつみ・湯野浜・鶴岡")
              , new city("0603","山形・天童・新庄")
              , new city("0604","酒田")
              , new city("0606","米沢・白布温泉")
           )
        );

arcd[7] = new prfct("07","福島県",
           new Array(
                new city("0705","福島・郡山・白河")
              , new city("0701","飯坂・岳・土湯温泉")
              , new city("0702","磐梯・猪苗代")
              , new city("0704","会津・東山・芦ノ牧温泉")
              , new city("0710","湯本温泉・いわき・その他")
           )
        );

arcd[8] = new prfct("08","茨城県",
           new Array(
                new city("0811","筑波・土浦・古河")
              , new city("0820","水戸・袋田温泉・日立")
              , new city("0810","大洗・鹿島・潮来・その他")
           )
        );

arcd[9] = new prfct("09","栃木県",
           new Array(
                new city("0921","那須・塩原・矢板")
              , new city("0922","鬼怒川・川治・湯西川温泉")
              , new city("0935","日光・奥日光・中禅寺")
              , new city("0920","宇都宮・真岡・小山・大田原")
           )
        );

arcd[10] = new prfct("10","群馬県",
            new Array(
                 new city("1013","草津・四万温泉")
               , new city("1011","伊香保・磯部・老神温泉")
               , new city("1012","水上・奥利根・尾瀬")
               , new city("1014","万座温泉・嬬恋温泉")
               , new city("1010","前橋・高崎・伊勢崎・藪塚・その他")
            )
         );

arcd[11] = new prfct("11","埼玉県",
          new Array(
               new city("1101","さいたま市・その他")
          )
       );

arcd[12] = new prfct("12","千葉県",
          new Array(
               new city("1201","舞浜（ＴＤＲ）・幕張・市川")
             , new city("1210","千葉・八千代・蘇我")
             , new city("1202","松戸・柏")
             , new city("1203","成田周辺")
             , new city("1206","銚子・九十九里海岸")
             , new city("1204","外房（勝浦・鴨川）")
             , new city("1205","内房（木更津・白浜）")
          )
       );

arcd[13] = new prfct("13","東京都",
          new Array(
               new city("1301","千代田・中央区（東京・銀座・神田）")
             , new city("1310","港区（お台場・赤坂・新橋・浜松町）")
             , new city("1302","品川・大田区（品川・大井・蒲田）")
             , new city("1303","新宿・渋谷・目黒区（新宿・渋谷・青山）")
             , new city("1304","豊島・練馬・板橋・北区（池袋）")
             , new city("1309","文京・台東・荒川区（水道橋・上野・浅草）")
             , new city("1308","墨田・江東・江戸川区（両国・葛西）")
             , new city("1305","中野・杉並・世田谷区（阿佐ヶ谷・玉川）")
             , new city("1306","吉祥寺・国分寺・立川・八王子・多摩地区")
             , new city("1307","伊豆七島（大島・八丈島）")
          )
       );

arcd[14] = new prfct("14","神奈川県",
          new Array(
               new city("1450","川崎・梶ヶ谷")
             , new city("1401","横浜・横須賀")
             , new city("1410","鎌倉・江ノ島・湘南")
             , new city("1404","厚木・相模原・小田原")
             , new city("1405","箱根・強羅・仙石原")
             , new city("1403","湯河原・真鶴・丹沢")
          )
       );

arcd[15] = new prfct("15","新潟県",
          new Array(
               new city("1519","新潟市内")
             , new city("1501","長岡・柏崎")
             , new city("1505","燕・三条・岩室・弥彦・寺泊")
             , new city("1502","越後湯沢・六日町")
             , new city("1503","佐渡（相川・両津）")
             , new city("1504","上越・妙高・赤倉温泉")
             , new city("1510","瀬波・月岡・その他")
          )
       );

arcd[16] = new prfct("16","富山県",
          new Array(
               new city("1601","富山市内")
             , new city("1602","宇奈月・立山・魚津")
             , new city("1610","氷見・高岡・砺波・その他")
          )
       );

arcd[17] = new prfct("17","石川県",
          new Array(
               new city("1701","金沢市内")
             , new city("1702","和倉温泉")
             , new city("1705","輪島・珠洲・奥能登")
             , new city("1703","山中・山代・片山津・粟津")
             , new city("1710","小松・一里野高原")
          )
       );

arcd[18] = new prfct("18","福井県",
          new Array(
               new city("1802","福井市内")
             , new city("1811","鯖江・武生・越前海岸・芦原温泉")
             , new city("1801","敦賀・若狭")
          )
       );

arcd[19] = new prfct("19","山梨県",
          new Array(
               new city("1901","石和温泉")
             , new city("1902","甲府・湯村温泉")
             , new city("1920","河口湖・富士五湖")
             , new city("1910","清里・甲斐・下部温泉・その他")
          )
       );

arcd[20] = new prfct("20","長野県",
          new Array(
               new city("2001","長野市内")
             , new city("2002","松本・浅間温泉・美ヶ原")
             , new city("2010","軽井沢・上田・戸倉・上山田・菅平")
             , new city("2003","野沢・斑尾高原・戸隠")
             , new city("2005","渋・湯田中・志賀高原")
             , new city("2006","白馬・栂池・大町・上高地・安曇野")
             , new city("2008","諏訪・蓼科・白樺湖")
             , new city("2009","南信州・飯田・木曾・昼神温泉")
          )
       );

arcd[21] = new prfct("21","岐阜県",
          new Array(
               new city("2105","飛騨高山")
             , new city("2109","平湯・新平湯・穂高")
             , new city("2103","下呂温泉・郡上高原・恵那峡・可児")
             , new city("2101","岐阜・長良川・大垣・その他")
          )
       );

arcd[22] = new prfct("22","静岡県",
          new Array(
               new city("2202","熱海・網代")
             , new city("2288","伊東・伊豆高原")
             , new city("2206","東伊豆（熱川・河津・北川温泉）")
             , new city("2205","中伊豆（長岡・修善寺・天城）")
             , new city("2203","西伊豆(土肥・堂ヶ島・戸田・三津浜）")
             , new city("2207","南伊豆（下田・下賀茂）")
             , new city("2299","三島・沼津・御殿場・富士")
             , new city("2201","静岡・清水・焼津")
             , new city("2204","浜松・掛川・浜名湖・舘山寺温泉")
          )
       );

arcd[23] = new prfct("23","愛知県",
          new Array(
               new city("2301","名古屋市内")
             , new city("2310","豊橋・岡崎・蒲郡・三河地区")
             , new city("2350","豊田・瀬戸・犬山・小牧")
             , new city("2320","知多半島（半田・日間賀島・篠島）")
          )
       );

arcd[24] = new prfct("24","三重県",
          new Array(
               new city("2401","伊勢・鳥羽・磯部・賢島・熊野")
             , new city("2420","四日市・鈴鹿・津・上野・松坂")
          )
       );

arcd[25] = new prfct("25","滋賀県",
          new Array(
               new city("2501","大津市内・湖西地区（雄琴温泉）")
             , new city("2505","湖東地区（草津・彦根・米原・長浜）")
          )
       );

arcd[26] = new prfct("26","京都府",
          new Array(
               new city("2601","京都駅付近")
             , new city("2602","京都市内中心部（東山・河原町・烏丸）")
             , new city("2603","京都市北部（嵯峨野・北山）")
             , new city("2610","天橋立・舞鶴・福知山・その他")
          )
       );

arcd[27] = new prfct("27","大阪府",
          new Array(
               new city("2701","大阪キタ(大阪駅周辺・中津・天満）")
             , new city("2702","大阪市内中心部（本町・谷町・阿波座）")
             , new city("2710","大阪ミナミ（心斎橋・なんば・天王寺）")
             , new city("2703","大阪北部（新大阪・吹田・その他）")
             , new city("2713","大阪南部（堺・岸和田・関西空港）")
             , new city("2715","大阪東部（東大阪・守口・門真）")
          )
       );

arcd[28] = new prfct("28","兵庫県",
          new Array(
               new city("2801","神戸市内（新神戸・三宮）")
             , new city("2809","阪神地区（伊丹・尼崎・宝塚）")
             , new city("2804","有馬温泉・舞子・西神")
             , new city("2805","淡路島")
             , new city("2803","播磨地区（明石・姫路・赤穂・加古川）")
             , new city("2810","城崎温泉・湯村・但馬・出石")
          )
       );

arcd[29] = new prfct("29","奈良県",
          new Array(
               new city("2901","奈良市内")
             , new city("2902","吉野・山の辺の道")
             , new city("2903","生駒・橿原・十津川・その他")
          )
       );

arcd[30] = new prfct("30","和歌山県",
          new Array(
               new city("3001","紀伊半島（白浜・勝浦・紀伊田辺）")
             , new city("3010","和歌山・新和歌浦")
             , new city("3002","高野山")
          )
       );

arcd[31] = new prfct("31","鳥取県",
          new Array(
               new city("3101","鳥取市内")
             , new city("3110","三朝温泉・羽合")
             , new city("3111","米子・皆生温泉・大山・その他")
          )
       );

arcd[32] = new prfct("32","島根県",
          new Array(
               new city("3201","松江市内・出雲・美保関")
             , new city("3298","玉造温泉")
             , new city("3205","津和野・有福・浜田")
          )
       );

arcd[33] = new prfct("33","岡山県",
          new Array(
               new city("3301","岡山市内")
             , new city("3305","倉敷・瀬戸内")
             , new city("3307","新見・湯原")
             , new city("3306","美作（津山・湯郷・奥津）")
          )
       );

arcd[34] = new prfct("34","広島県",
          new Array(
               new city("3410","広島市内・呉")
             , new city("3411","宮島・宮浜")
             , new city("3420","福山市内・鞆の浦")
             , new city("3415","尾道・西条・三原・その他")
          )
       );

arcd[35] = new prfct("35","山口県",
          new Array(
               new city("3502","小郡・山口市内（山口・湯田温泉）")
             , new city("3503","岩国・徳山・防府")
             , new city("3501","下関・宇部・その他")
             , new city("3520","萩・長門湯本")
          )
       );

arcd[36] = new prfct("36","徳島県",
          new Array(
               new city("3601","徳島市内・鳴門")
             , new city("3605","大歩危・その他")
          )
       );

arcd[37] = new prfct("37","香川県",
          new Array(
               new city("3710","高松市内・屋島・塩江")
             , new city("3712","坂出・丸亀・琴平・その他")
             , new city("3711","小豆島")
          )
       );

arcd[38] = new prfct("38","愛媛県",
          new Array(
               new city("3801","松山・道後温泉")
             , new city("3899","今治・西条・新居浜・純川温泉")
             , new city("3810","宇和島・八幡浜・その他")
          )
       );

arcd[39] = new prfct("39","高知県",
          new Array(
               new city("3901","高知市内")
             , new city("3905","足摺岬・土佐中村・その他")
          )
       );

arcd[40] = new prfct("40","福岡県",
          new Array(
               new city("4001","博多駅周辺")
             , new city("4003","天神・中洲・その他")
             , new city("4010","北九州（小倉・門司）")
             , new city("4005","久留米・柳川温泉・大牟田")
             , new city("4015","筑後川・原鶴温泉")
          )
       );

arcd[41] = new prfct("41","佐賀県",
          new Array(
               new city("4110","嬉野温泉・武雄温泉")
             , new city("4411","佐賀・鳥栖・唐津・呼子")
          )
       );

arcd[42] = new prfct("42","長崎県",
          new Array(
               new city("4201","長崎市内・諫早")
             , new city("4210","佐世保・平戸・西海橋")
             , new city("4211","ハウステンボス")
             , new city("4202","雲仙・小浜・島原")
          )
       );

arcd[43] = new prfct("43","熊本県",
          new Array(
               new city("4310","熊本・水前寺")
             , new city("4399","八代・人吉")
             , new city("4311","菊地温泉・天草")
             , new city("4312","阿蘇・杖立温泉")
          )
       );

arcd[44] = new prfct("44","大分県",
          new Array(
               new city("4401","別府温泉・湯布院")
             , new city("4403","天ヶ瀬・日田温泉・宝泉寺温泉")
             , new city("4402","大分市内")
          )
       );

arcd[45] = new prfct("45","宮崎県",
          new Array(
               new city("4510","宮崎・都城・北郷・日南")
             , new city("4511","延岡・日向")
          )
       );

arcd[46] = new prfct("46","鹿児島県",
          new Array(
               new city("4610","鹿児島市内")
             , new city("4611","霧島・妙見温泉")
             , new city("4699","指宿温泉・枕崎")
             , new city("4688","奄美大島・種子島")
          )
       );

arcd[47] = new prfct("47","沖縄県",
            new Array(
                 new city("4701","那覇市内")
               , new city("4702","沖縄・恩納")
               , new city("4704","名護・その他")
               , new city("4703","石垣・宮古・その他離島")
            )
         );

function city(vl,txt){
  this.vl = vl;
  this.txt = txt;
}

function prfct(vl,txt,ch){
  this.vl = vl;
  this.txt = txt;
  this.ch = ch;
}


//biz.js
var dp = 13;

function getIntValue(_obj){
  var obj = _obj;
  if(obj.type == 'select'){
    return parseInt(obj[obj.selectedIndex].value);
  }else{
    return parseInt(obj.value);
  }
}

function calcTotal(_ac,_rc,_tc){
	var ac = _ac;
	var rc = _rc;
	var tc = _tc;
	var total = getIntValue(ac);
	total *=    getIntValue(rc);
	tc.value = total;
}

function initial(_ps, _cs){
  ps = _ps;
  cs = _cs;

  var chk = 0;
  for (i = 1; i < arcd.length; i++){
    ps.options[i] = new Option(arcd[i].txt, arcd[i].vl, true, true);
    if (this.dp == arcd[i].vl) {
      chk = i;
    }
  }
  ps.selectedIndex = chk;
  changeCity(chk);
}

function changeCity(idx){
  var chk = 0;

  while (true){
    if (ps.options[idx].value == 'NONE'){
      ps.selectedIndex--;
      idx--;
    } else {
      break;
    }
  }
  cs.length = 1;
  if (idx){
    for (i = 0; i < arcd[idx].ch.length; i++){
      cs.options[(i+1)] = new Option(arcd[idx].ch[i].txt, arcd[idx].ch[i].vl, true, true);
    }
  }
  cs.selectedIndex = chk;
}


//biz_check.js
var err_msg = new Array("１部屋あたりの定員対象人数 X 部屋合計で最大20人までです",
                  "ご予算の範囲の指定が不正です",
                  "都道府県を選択してください",
                  "地区を選択してください",
                  "駅名が入力されていません");
var max_room_cnt = 20;

function searchCheck(_form){
   form = _form;

   if(!chkMember(form.total_cnt.value))                        {alert(err_msg[0]);return false;}
                                                                              
   if(!chkMny(form.max_charge.value,form.min_charge.value))    {alert(err_msg[1]);return false;}
                                                                              
   if(!chkDest(form.target_type[0],form.prefecture_cd.value))  {alert(err_msg[2]);return false;}
                                                                              
   if(!chkArea(form.target_type[0],form.city_resort_cd.value)) {alert(err_msg[3]);return false;}
                                                                              
   if(!chkSta(form.target_type[1],form.station_nm.value))      {alert(err_msg[4]);return false;}

   return true;
}

function chkMember(_val){
   var val = _val;
   if(val > this.max_room_cnt){return false;}
   return true;
}
function chkMny(_max,_min){
   var max = _max;
   var min = _min;
   if((max - min) < 0){return false;}
   return true;
}
function chkDest(_chk,_val){
   var val = _val;
   var chk = _chk;
   if(chk.checked){
      if(val == '')
      {
         return false;
      }
   }
   return true;
}
function chkArea(_chk,_val){
   var val = _val;
   var chk = _chk;
   if(chk.checked){
      if(val == '')
      {
         return false;
      }
   }
   return true;
}
function chkSta(_chk,_val){
   var val = _val;
   var chk = _chk;
   if(chk.checked){
      if(val == '')
      {
         return false;
      }
   }
   return true;
}

function getStringLength( str ) {
	var i,cnt = 0;
	for(i=0; i<str.length; i++) {
		if( escape(str.charAt(i)).length >= 4 ) {
			 cnt+=2;
		}
		else {
		 cnt++;
		}
	}
	return cnt;
}

function checkInputNull( inp, nm ){
	var		vl;
	var		i;

	if( inp.type.indexOf("select") == 0 ){	// SELECT タグ判定
		vl = inp.options[0].value;
		for( i=0; i<inp.length; i++ ){
			if( inp.options[i].selected )
				vl = inp.options[i].value;
		}
	}else{
		vl = inp.value;
	}
	if( vl == "" ){
		alert( nm + "が入力されていません。" );
		inp.focus();
		return true;
	}
	return false;
}

function checkInputLength( inp, nm, len ){
	if( getStringLength( inp.value ) > len ){
		alert( nm + "が長すぎます。" );
		inp.focus();
		return true;
	}
	return false;
}

getStringLength("a");

function checkPullNull(obj, title){
  var o = obj;
  if( o.options[o.selectedIndex].value == '' )
  {
    alert( title + 'を選択してください' );
	obj.focus();
    return false;
  }
  return true;
}

function keywordsCheck( obj, limit ){
	var keywords = obj.value;
	if( limit == null ){
		limit = 3; // デフォルト3個
	}

	// 最初と最後のスペース削除
	keywords = keywords.replace(/^[ 　]+/,"");
	keywords = keywords.replace(/[ 　]+$/,"");

	// スペースのみの入力はエラー
	if( keywords.length == 0 ){
		alert( "キーワードを正しく入力してください。");
		obj.focus();
		return false;
	}

	// 全角のスペースを半角スペースに変換
	while( keywords.indexOf("　") != -1 ){
		keywords = keywords.replace("　", " ");
	}

	// 半角スペースで分割
	var keyArray = keywords.split(" ");

	// キーワードが入っている要素をカウント
	var count = 0;
	for( i = 0; i < keyArray.length; i++ ){
		if( keyArray[i] != null && keyArray[i].length != 0 ){
			count++;
		}
	}

	// キーワードが limit より多かったらエラー
	if( count > limit ){
		alert( "キーワードは" + limit + "つ以内で入力してください。");
		obj.focus();
		return false;
	}
	return true;

}

