// Ajax 共通変数
var xhrObj; // XMLHttpRequest用オブジェクト
var timer;  // タイムアウト用
////////////////////////////////////////////////////////////////////////////////////////////////////
// Ajax functions
function httpRequest(target_url, method, query){
  try{
    if(window.XMLHttpRequest){
      xhrObj = new XMLHttpRequest();
    }else if(window.ActiveXObject){
      xhrObj = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
//      output('只今システムにエラーが発生しております。');
      return;
    }
  }catch(e){
//    output('只今システムにエラーが発生しております。');
    return;
  }
  // タイマーセット
  timer = setInterval("timeout()",60000); //60秒にセット

  // データを取得する
  xhrObj.onreadystatechange = readData;
  xhrObj.open(method, target_url, true);
  xhrObj.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xhrObj.send(query);
  return;
}
function timeout(){
  clearInterval(timer); // タイマーとめる
  xhrObj.abort();
  output('一定時間内に応答がありませんでした。');
}
function readData(){
  if ( xhrObj.readyState == 4 ){
    if ( xhrObj.status == 200) reprocess(xhrObj.responseText);
    clearInterval(timer); // タイマーとめる
  }
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Ajax データ処理
function output(output_data){
  // obj = document.getElementById("information");
  // obj.innerHTML = output_data;
//  window.alert(output_data);
}
function reprocess(tmp_data){
  tmp_array = tmp_data.split("|");
  if(tmp_array[0]){
    if(tmp_array[0] == "page_open"){
      tmp_obj = document.getElementById("page_count");
      tmp_obj.innerHTML = tmp_array[1];
      tmp_obj = document.getElementById("tel_count");
      tmp_obj.innerHTML = tmp_array[2];
    }else if(tmp_array[0] == "tel_open"){
      tmp_obj = document.getElementById("tel_count");
      tmp_obj.innerHTML = tmp_array[1];
    }
//    window.alert(tmp_data);
  }else{
    // output("商品情報を取得できませんでした。");
  }
}

