

/**
 * url 
 * postParameter
 * syncFlag trur=非同期通信, false=同期通信
*/
function getHtml(url,postParameter,syncFlag) {
  var post_parameter = postParameter;
  var xmlhttp = getXmlHttpRequest();
  xmlhttp.open('POST', url, syncFlag);
  xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  xmlhttp.onreadystatechange = function() {}
  xmlhttp.send(post_parameter);
  if (!syncFlag) {
    return getEncodingResponse(xmlhttp.responseText)
  }
}

/**
 * CREATE XMLHttpRequest
 */
function getXmlHttpRequest() {
  var xmlhttp=null;
  try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
    try {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
      xmlhttp = null;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}

/**
 * HTML response dacode
 * Ajax + safari 問題対応
 */
function getEncodingResponse ( req ) {
  var text = req;
  if ( navigator.appVersion.indexOf( "KHTML" ) > -1 ) {
    var esc = escape( text );
    if ( esc.indexOf("%u") < 0 && esc.indexOf("%") > -1 ) {
      text = decodeURIComponent( esc );
    }
  }
  return text;
}

