  // 各言語の観光情報URLプレフィックス
/*var infoUrl =
  {
    "English" : "http://www.japanican.com/japaninfo/",
    "Korean" : "http://www.japanican.com/korean/jexplorer/",
    "Traditional-Chinese" : "http://www.japanican.com/Traditional-Chinese/jexplorer/scripts/",
    "Simplified-Chinese" : "http://www.japanican.com/Simplified-Chinese/jexplorer/scripts/"
  }*/
  var infoUrl =
  {
    "English" : "http://www.japanican.com/japaninfo/",
    "Korean" : "http://www.japanican.com/korean/jexplorer/",
    "Traditional-Chinese" : "http://www.japanican.com/Traditional-Chinese/jexplorer/scripts/",
    "Simplified-Chinese" : "http://www.japanican.com/Simplified-Chinese/jexplorer/scripts/"
  }
  // 各言語のホテル情報URLプレフィックス
  var hotelUrl = 
  {
    "English" : "http://www.japanican.com/hotels/",
    "Korean" : "http://www.japanican.com/korean/hotels/",
    "Traditional-Chinese" : "http://www.japanican.com/Traditional-Chinese/hotels/",
    "Simplified-Chinese" : "http://www.japanican.com/Simplified-Chinese/hotels/"
  }
  // ホテル画像置き場のパス
  var hotelImgPath = "http://e-htl.jtb.co.jp/photo/M/";

  // ホテル情報を表示するdivタグのid既定値
  var targetDivId = "dispinfo";
  
  var err;
  var max, lang, pref, group, mesh;
  var scb, sbb, sob, inb, rmb, rab, rfb;
  var hotel, ryokan;
  var so, sb;

  function getHotelInfo(id)
  {
    targetDivId = id;
    
//    var style = document.createElement("link");
//	  style.rel = "stylesheet";
//	  style.type = "text/css";
//	  style.href = infoUrl[lang] + "pi/css/RecHotel.css";
//   document.getElementsByTagName("head")[0].appendChild(style);

    
    var scriptTag = document.createElement("script");
		scriptTag.setAttribute("type", "text/javascript");
		scriptTag.setAttribute("charset", "utf-8");
		scriptTag.setAttribute("src", infoUrl[lang] + "pi/HotelInfo.aspx?" + makeSearch());
    document.getElementsByTagName("head")[0].appendChild(scriptTag);
  }
  
  function dispitem(res)
  {
    if (res == null)
      return;
    
    if (res.ErrorInfo != null)
    {
      if (err == "on")
      {
        document.getElementById(targetDivId).innerHTML = res.ErrorInfo;
      }
      return;
    }
    
    if (res.Hotel == null || typeof(res.Hotel) == "undefined")
    {
      if (err == "on")
      {
        document.getElementById(targetDivId).innerHTML = "No match was found for the search conditions.";
      }
      return;
    }
      
    // 宿泊情報
    var src = "";
    src += "<table id='RecHotel'>";
    for (i = 0; i < res.Hotel.length; i++)
    {
      var left = (((i+1) % 2) == 1) ? true : false;
      if (left == true)
      {
        src += "<tr>";
        src += "<td class='RHlc'>";
      }
      else
      {
        src += "<td class='RHrc'>";
      }
      
      // 宿泊施設詳細画面へのURL
      var hotelDetailUrl = hotelUrl[lang] + "ShisetsuDetail.aspx?st=" + res.Hotel[i].id;
      
      src += "<table class='HotelInfo'>";
      src += "<tr>";

      if ("noimage" != res.Hotel[i].img) {
      src += "<td rowspan='2' class='HotelPict'>";
      src += "<p class='hpict'>";
      src += "<a href='" + hotelDetailUrl + "' target='_TOP'>";
      src += "<img src='" + hotelImgPath + res.Hotel[i].img + "' alt='" + res.Hotel[i].title + "' class='hotel' /></a></p></td>";
	  }
		
      src += "<td class='HotelName'><p class='hname'>";
      src += "<a href='" + hotelDetailUrl + "' target='_TOP'>" + res.Hotel[i].title + "</a></p></td>";
      src += "</tr>";
      src += "<tr>";
      src += "<td class='HotelBody'><p class='hbody'><span>" + res.Hotel[i].priceTitle + ": </span><br />" + res.Hotel[i].price + "</p></td>";
      src += "</tr>";
      src += "<tr>";
      src += "<td class='HotelSub'></td>";
      src += "<td class='HotelMore'><p class='hmore'><a href='" + hotelDetailUrl + "' target='_TOP'><img src='" + infoUrl[lang] + "pi/images/moreinfo_" + lang + ".gif' alt='More Info' class='morebtn' /></a></p></td>";
      src += "</tr>";
      src += "</table>";
        
      if (left == true)
      {
        src += "</td>";
      }
      else
      {
        src += "</td>";
        src += "</tr>";
      }
    }
    src += "</table>";
    document.getElementById(targetDivId).innerHTML = src;
  }
  
  function makeSearch()
  {
    var ary = new Array();
    var index = 0;
    
    if (isSetData(max)){  // 表示件数
      ary[index] = "max=" + max;
      index++;
    }
    if (isSetData(lang)){ // 言語タイプ
      ary[index] = "lang=" + lang;
      index++;
    }
    if (isSetData(pref)){ // 都道府県コード
      ary[index] = "pref=" + pref;
      index++;
    }
    if (isSetData(group)){  // サブエリアコード
      ary[index] = "group=" + group;
      index++;
    }
    if (isSetData(mesh)){ // メッシュコード
      ary[index] = "mesh=" + mesh;
      index++;
    }
    if (isSetData(scb)){  // 施設共通ビット
      ary[index] = "scb=" + scb;
      index++;
    }
    if (isSetData(sbb)){  // 施設風呂ビット
      ary[index] = "sbb=" + sbb;
      index++;
    }
    if (isSetData(sob)){  // 施設その他ビット
      ary[index] = "sob=" + sob;
      index++;
    }
    if (isSetData(inb)){  // 施設インバウンド用ビット
      ary[index] = "inb=" + inb;
      index++;
    }
    if (isSetData(rmb)){  // 商品客室関連ビット
      ary[index] = "rmb=" + rmb;
      index++;
    }
    if (isSetData(rab)){  // 商品通年ビット
      ary[index] = "rab=" + rab;
      index++;
    }
    if (isSetData(rfb)){  // 商品季節ビット
      ary[index] = "rfb=" + rfb;
      index++;
    }
    if (isSetData(ryokan)){ // 旅館取得
      ary[index] = "ryokan=" + ryokan;
      index++;
    }
    if (isSetData(hotel)){  // ホテル取得
      ary[index] = "hotel=" + hotel;
      index++;
    }
    if (isSetData(so)){ // ソートモード
      ary[index] = "so=" + so;
      index++; 
    }
    if (isSetData(sb)){ // 施設インバウンド用ビットソート
      ary[index] = "sb=" + sb;
      index++;
    }
    
    // JSONPコールバック関数
    ary[index] = "callback=dispitem";
    
    return ary.join("&");
  }
  
  function isSetData(param)
  {
    if (param == null)
      return false;
    else if (param == "undefined")
      return false;
    else
      return true;
  }
 
