/** ===================================================================
 * HTML取得処理
 * 2006-08-18 ファイル名変更
 * Created by fwtomo
 * Updated by $Author: fwtomo $
 * $Id: BtcRootConfig.php,v 1.1 2005/07/29 13:02:44 fwtomo Exp $
 * Copyright (C) BT Company Ltd
 * ==================================================================== */

function handleHttpResponse(){
    if( ( asyncHttpObj.readyState == 4 ) && ( asyncHttpObj.status == 200 ) ){
        httpResFunc( asyncHttpObj );
        httpResFunc = null;
    }
}

function getHtml( uri, data, resFunc, isGet, async ){
    var gettype;
    var url;
    var sendData;
    if( isGet ){
       gettype = 'GET'; 
       url = uri + "?" + data;
       sendData = '';
    }else{
       gettype = 'POST'; 
       url = uri;
       sendData = data;
    }
    if( async ){
        var httpObj = asyncHttpObj;
    }else{
        var httpObj = syncHttpObj;
    }
    httpObj.open( gettype, url, async );
    if( !isGet ){
        httpObj.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded; charset=UTF-8" );
    }
    if( async ){
        httpResFunc = resFunc;
        httpObj.onreadystatechange = handleHttpResponse;
        httpObj.send( sendData );
    }else{
        httpObj.send( sendData );
        if( resFunc != null ){
            resFunc( httpObj );
        }
    }
    return httpObj;
}

function getHttpObject(){
    var obj;
    if( this.XMLHttpRequest ){
        obj = new XMLHttpRequest();
    }else if( this.ActiveXObject ){
        try {
            obj = new ActiveXObject( "MSXML2.XMLHTTP" );
        }catch( e ){
            try {
                obj = new ActiveXObject( "Microsoft.XMLHTTP" );
            }catch( e2 ){
                obj = false;
            }
        }
    }
    return obj;
}

var asyncHttpObj = getHttpObject();
var syncHttpObj = getHttpObject();
var httpResFunc;
